Loading
function(e,t,n){"use strict";n.d(t,{A:()=>q});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(17928),o=n(534514),u=n(892547),c=n(939249),d=n(477155),m=n(228366),h=n(497685),p=n(235986),f=n(151271),g=n(821102),E=n(996566),A=n(291147),C=n(703244),x=n(735438),I=n.n(x),_=n(803805),S=n(661531),y=n(27232),v=n(555704),T=n(92008),N=n(25277),j=n(583613),b=n(327143),R=n(615300),P=n(404605);let L=[S.A.unsafe_rawColors.PREMIUM_TIER_1_PURPLE.css,S.A.unsafe_rawColors.PREMIUM_TIER_1_BLUE.css,"#929AFA"];class M extends i.PureComponent{state={backgroundColor:I().sample(L)};render(){let{props:{height:e},state:{backgroundColor:t}}=this;return(0,l.jsx)("div",{style:{height:e,backgroundColor:t},className:P.nX})}}class O extends i.Component{static defaultProps={direction:-1};constructor(e){super(e);const t=Array(10).fill(null).map(()=>I().random(40,150));this.state={blocks:t,height:2*t.reduce((e,t)=>e+t+12,12),translateY:new R.A.Value(0)}}componentDidMount(){this.animateSlide()}animateSlide=()=>{let{props:{direction:e},state:{translateY:t,height:n}}=this;t.setValue(e>0?0:-n/2+12),R.A.timing(t,{toValue:e>0?-n/2+12:0,duration:800,easing:R.A.Easing.linear}).start(this.animateSlide)};getAnimatedStyle(){let{props:{columns:e},state:{translateY:t}}=this;return{width:`${100/e}%`,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:["0px","1px"]})}]}}render(){let{blocks:e}=this.state;return(0,l.jsxs)(R.A.div,{className:P.fi,style:this.getAnimatedStyle(),children:[e.map((e,t)=>(0,l.jsx)(M,{height:e},t)),e.map((e,t)=>(0,l.jsx)(M,{height:e},`alt${t}`))]})}}function w(e){let{columns:t}=e;return(0,l.jsx)("div",{className:P.fi,style:{width:`${100/t}%`},children:[,,,,].fill(null).map((e,t)=>(0,l.jsx)("div",{className:P.c8},t))})}class k extends i.PureComponent{render(){let{columns:e,renderColumn:t}=this.props;return(0,l.jsx)("div",{className:P.kL,children:Array(e).fill(null).map((n,l)=>t(e,l))})}}var D=n(285961),U=n(652215),G=n(375708),F=n(736212);function V(e,t){return(0,l.jsx)(w,{columns:e},t)}class B extends i.PureComponent{_masonryRef=i.createRef();state={favoritesTile:function(e){let t=I().sample(I().values(e));return{type:U.dD.FAVORITES,name:G.intl.string(G.t.y3LQCG),icon:y.G,src:null!=t?t.src:"https://media.giphy.com/media/1TOSaJsWtnhe0/giphy.gif",format:t?.format??_.TL.IMAGE}}(this.props.favorites),selectedIndex:{column:0,row:0},focusedId:null};componentDidMount(){0===this.props.trendingCategories.length&&(0,h.k8)()}handleFocus=e=>{let{current:t}=this._masonryRef;if(null==t)return;let n=t.getCoordsMap()[e];null!=n&&(t.scrollIntoViewRect({start:n.top-10,end:n.top+n.height+10}),this.setState({focusedId:e}))};handleSelect=e=>{let{onSelectItem:t}=this.props,n=this.getData().find(t=>t.name===e);null!=n&&null!=t&&t(n.type,n.name)};getItemKey=(e,t)=>{if(e>0)return null;let n=this.getData()[t];return null!=n?n.name:null};memoizedData=(0,j.L_)(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n?[...t]:[e,...t]});getData(){return this.memoizedData(this.state.favoritesTile,this.props.trendingCategories,this.props.hideFavoritesTile)}renderCategoryExtras(e){let{name:t,type:n}=e;return(0,l.jsxs)(i.Fragment,{children:[(0,l.jsx)("div",{className:n===U.dD.FAVORITES?F.H7:F.FP}),(0,l.jsxs)("div",{className:F.O1,children:[n===U.dD.TRENDING_GIFS?(0,l.jsx)(v.U,{className:F.Yl,color:"currentColor"}):null,(0,l.jsx)("span",{className:F.yb,children:t})]})]})}renderItem=(e,t,n,i)=>{if(e>0)return null;let s=this.getData()[t];if(null==s)return;let{onSelectItem:r,imagePool:a,videoPool:o}=this.props,{focusedId:u}=this.state;return(0,l.jsx)(D.uG,{format:s.format,color:S.A.unsafe_rawColors.PRIMARY_800.css,src:s.src,item:s,index:t,coords:n,onClick:()=>r(s.type,s.name),renderExtras:this.renderCategoryExtras,focused:s.name===u,imagePool:a,videoPool:o,"aria-label":s.name},i)};renderContent=(e,t,n)=>{let{className:i,trendingCategories:s}=this.props;return 0===s.length?(0,l.jsx)(k,{columns:e,width:t,renderColumn:V}):(0,l.jsx)(T.f,{ref:this._masonryRef,fade:!0,className:r()(F.kL,i),itemGutter:12,getItemKey:this.getItemKey,columns:e,getItemHeight:()=>110,renderItem:this.renderItem,sections:[this.getData().length],chunkSize:50})};getItemGrid=()=>{let{current:e}=this._masonryRef;return null!=e?e.getItemGrid():[]};getCoordsMap=()=>{let{current:e}=this._masonryRef;return null!=e?e.getCoordsMap():{}};render(){return(0,l.jsx)(N.A,{getItemGrid:this.getItemGrid,getCoordsMap:this.getCoordsMap,onFocus:this.handleFocus,onSelect:this.handleSelect,children:(0,l.jsx)(b.A,{desiredItemWidth:200,maxColumns:6,children:this.renderContent})})}}function H(e){let t=(0,a.bG)([g.A],()=>g.A.getTrendingCategories()),n=(0,E.rM)(),i=(0,D.d5)();return(0,l.jsx)(B,{...e,...i,trendingCategories:t,favorites:n})}var W=n(732139),K=n(650583),Y=n(874926);function z(e){return e.stopPropagation()}class Z extends i.PureComponent{state={resultType:null};componentDidMount(){h.V$(),document.addEventListener("keydown",this.backToFrontPage),""!==this.props.query&&this.search(this.props.query,U.dD.SEARCH)}componentDidUpdate(e){""===e.query&&""!==this.props.query&&null==this.state.resultType&&this.search(this.props.query,U.dD.SEARCH)}componentWillUnmount(){m.h.wait(()=>h.Se()),document.removeEventListener("keydown",this.backToFrontPage)}search(e,t,n){h.$P(e,t,n),""===e?this.setState({resultType:null}):this.state.resultType!==U.dD.SEARCH&&this.setState({resultType:U.dD.SEARCH})}backToFrontPage=e=>{let{resultType:t}=this.state;e.key!==K.dh.ESCAPE||null!=t&&(e.stopPropagation(),e.preventDefault(),this.handleClearQuery())};handleChangeQuery=e=>{(0,f.Ri)(e),this.search(e,U.dD.SEARCH)};handleSelectSuggestion=e=>{(0,f.Ri)(""),h.Se(),this.search(e,U.dD.SEARCH_SUGGESTION,!0)};handleClearQuery=()=>{let{current:e}=this.props.searchBarRef;(0,f.Ri)(""),h.Se(),this.setState({resultType:null}),null!=e&&e.focus()};handleSelectGIF=e=>{let{onSelectGIF:t}=this.props;null!=t&&t(e)};handleSelectItem=(e,t)=>{switch(e){case U.dD.TRENDING_CATEGORY:h.$P(t,U.dD.TRENDING_CATEGORY,!0);break;case U.dD.TRENDING_GIFS:h.Z4()}this.setState({resultType:e},()=>{if(e===U.dD.TRENDING_CATEGORY){let{current:e}=this.props.searchBarRef;null!=e&&e.focus()}})};renderHeaderContent(){let{query:e,headingColor:t}=this.props,{resultType:n}=this.state;switch(n){case U.dD.FAVORITES:return(0,l.jsx)(o.D,{variant:"heading-md/semibold",color:t,className:Y.wL,children:G.intl.string(G.t.y3LQCG)});case U.dD.TRENDING_GIFS:return(0,l.jsx)(o.D,{variant:"heading-md/semibold",color:t,className:Y.wL,children:G.intl.string(G.t.H6zNFz)});default:{let t=(0,C.cf)(),n=(0,A.w)(t);return(0,l.jsx)(u.I,{query:e,onChange:this.handleChangeQuery,onClear:this.handleClearQuery,placeholder:n,"aria-label":n,ref:this.props.searchBarRef,autoFocus:!0})}}}renderHeader(){let{resultType:e}=this.state,t=null;return null!=e&&(t=(0,l.jsx)(c.D,{onClick:this.handleClearQuery,className:Y.Gv,"aria-label":G.intl.string(G.t["13/7kX"]),children:(0,l.jsx)(d.r,{size:"md",color:"currentColor"})})),(0,l.jsxs)(p.A,{align:p.A.Align.CENTER,children:[t,this.renderHeaderContent()]})}renderContent(){let{contentClassName:e,resultItems:t,resultQuery:n,query:i,favorites:s,searchOffset:r,searchLimit:a,searchTotalResults:o,suggestions:u,hideFavorites:c}=this.props,{resultType:d}=this.state;return null==d?(0,l.jsx)(H,{className:e,hideFavoritesTile:c,onSelectItem:this.handleSelectItem}):(0,l.jsx)(D.Ay,{className:e,data:d===U.dD.FAVORITES?s:t,onSelectGIF:this.handleSelectGIF,resultType:d,resultQuery:n,query:i,searchOffset:r,searchLimit:a,searchTotalResults:o,suggestions:u,onSelectSuggestion:this.handleSelectSuggestion,selectedGIF:this.props.selectedGIF})}render(){let{className:e,forwardedRef:t}=this.props;return(0,l.jsxs)("div",{id:W.ni,role:"tabpanel","aria-labelledby":W.g9,className:r()(Y.kL,e),onClick:z,ref:t,children:[(0,l.jsx)("div",{className:r()(Y.wx,this.props.headerClassName),children:this.renderHeader()}),(0,l.jsx)("div",{className:Y.Qs,children:this.renderContent()})]})}}let q=i.forwardRef((e,t)=>{i.useEffect(()=>{e.persistSearch||((0,f.Ri)(e.initialQuery??""),h.$P(e.initialQuery??"",U.dD.SEARCH))},[e.persistSearch,e.initialQuery]);let{query:n,resultQuery:s,resultItems:r,suggestions:o}=(0,a.cf)([g.A],()=>({query:g.A.getQuery(),resultQuery:g.A.getResultQuery(),resultItems:g.A.getResultItems(),suggestions:g.A.getSuggestions()})),u=(0,f.RQ)(e=>e.searchQuery),c=(0,E.IE)(),d=i.useRef(null);return(0,l.jsx)(Z,{...e,forwardedRef:t,query:null!=n&&""!==n?n:u,resultQuery:s,resultItems:r,suggestions:o,favorites:c,searchOffset:0,searchTotalResults:g.A.getResultItems().length,searchLimit:null,searchBarRef:d,selectedGIF:e.selectedGIF})})}