Loading
function(e,t,n){"use strict";n.d(t,{A:()=>ta});var l=n(627968),i=n(64700),s=n(503698),r=n.n(s),a=n(305866),o=n(289873),u=n(793574),c=n(688810),d=n(151271),m=n(702841),h=n(594061),p=n(796774),f=n(209932);n(30146);var g=n(562708),E=n(17928),A=n(27232),C=n(111159),x=n(7689),I=n(939249),_=n(534514),S=n(358618),y=n(983851),v=n(442433),T=n(537652),N=n(212245),j=n(139286),b=n(915089),R=n(724511),P=n(850992),L=n(464651),M=n(735438),O=n(962125),w=n(428262),k=n(240864),D=n(711548);let U=i.forwardRef(function(e,t){let{categories:n,store:s,hasSearchResults:r,listPadding:a,renderRow:o,renderSection:u,renderSectionHeader:c,renderSectionFooter:m,renderInspector:h,renderEmptySearchState:p,rowCount:f,rowCountBySection:g,rowHeight:E,sectionHeaderHeight:A,sectionFooterHeight:C,renderUpsell:x,onScroll:I}=e,_=i.useRef(!1),S=i.useRef(null),y=(0,d.RQ)(e=>e.searchQuery),v=s.useStore(e=>e.activeCategoryIndex),T=i.useMemo(()=>n.map(e=>(0,w.Em)(e.categoryInfo)?{isNitroLocked:e.categoryInfo.isNitroLocked}:{isNitroLocked:!1}),[n]),N=(0,L.Fk)({activeCategoryIndex:v,isScrolling:_,listRef:S,onActiveCategoryIndexChange:s.setActiveCategoryIndex,scrollOffset:20,searchQuery:y}),j=i.useCallback(e=>{N(e),G({listRef:S,searchQuery:y,nitroLockedSectionStates:T,scrollTop:e,sectionHeaderHeight:A,sectionFooterHeight:C}),I?.(e)},[N,y,T,A,C,I]);return i.useEffect(()=>{null!=S.current&&j(S.current.getScrollerNode()?.scrollTop??0)},[j,S]),(0,L.FV)({searchQuery:y,activeCategoryIndex:v,listRef:S}),i.useImperativeHandle(t,()=>({scrollTo:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.scrollTo(...t)},getRowDescriptors:()=>S.current?.getRowDescriptors()??[],getSectionDescriptors:()=>S.current?.getSectionDescriptors()??[],scrollToSectionTop:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.scrollToSectionTop(...t)},scrollRowIntoView:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.scrollRowIntoView(...t)},getScrollerNode:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.getScrollerNode(...t)},scrollIntoViewNode:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.scrollIntoViewNode(...t)},getListDimensions:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return S.current?.getListDimensions(...t)??{height:-1,totalHeight:-1}}}),[]),(0,l.jsxs)("div",{className:D.i,children:[y.length>0&&!r&&null!=p?p():(0,l.jsx)(O.A,{role:"none presentation",listPadding:a,onScroll:j,renderRow:o,renderSection:u,renderSectionHeader:c,renderSectionFooter:m,rowCount:f,rowCountBySection:g,rowHeight:E,sectionHeaderHeight:A,sectionFooterHeight:C,stickyHeaders:!0,ref:S}),x?.(),h?.()]})}),G=(0,M.throttle)(function(e){let{listRef:t,searchQuery:n,nitroLockedSectionStates:l,scrollTop:i,sectionHeaderHeight:s,sectionFooterHeight:r}=e;if(null==t.current)return;let a=(0,k.s)({listRef:t,searchQuery:n,nitroLockedSectionStates:l,scrollTop:i,sectionHeaderHeight:s,sectionFooterHeight:r});d.RQ.setState({isNitroLockedSectionVisible:a.isNitroLockedSectionVisible,areOnlyNitroLockedSectionsVisible:a.areOnlyNitroLockedSectionsVisible})},300,{leading:!1,trailing:!0});var F=n(942381),V=n(602034),B=n(892547),H=n(387187);let W=i.forwardRef(function(e,t){let{store:n,hasSendableExpressions:s,onKeyDown:r,gridNavigatorId:a,expressionsListRef:o,defaultSearchPlaceholder:u,emptySearchPlaceholder:c}=e,m=i.useRef(null),[h,p]=(0,d.RQ)(e=>[e.searchQuery,e.isSearchSuggestion],F.x),f=n.useStore(e=>e.searchPlaceholder),[g,E]=n.useStore(e=>[e.inspectedExpressionPosition,e.hasInteracted],F.x),A=i.useCallback(e=>{n.setActiveCategoryIndex(""===e?0:P.Uk),n.setInspectedExpressionPosition(0,0),n.setSearchPlaceholder(null),(0,d.Ri)(e),o.current?.scrollTo(0)},[o,n]),C=i.useCallback(()=>{A("")},[A]);return i.useImperativeHandle(t,()=>({focus:()=>m.current?.focus()})),i.useLayoutEffect(()=>{p&&m.current?.focus()},[p]),(0,l.jsx)("div",{className:H.i,children:(0,l.jsx)(B.I,{autoFocus:s,disabled:!s,query:h,ref:m,placeholder:null!=f?f:s||null==c?u:c,onClear:C,onKeyDown:r,onChange:A,inputProps:{"aria-haspopup":"grid","aria-controls":a,"aria-expanded":!0,...E?{"aria-activedescendant":(0,V.Aq)(a,g.columnIndex,g.rowIndex)}:void 0}})})});var K=n(456908);function Y(e){let{categories:t,collapsedCategories:n,containerWidth:s,store:r,onSelectItem:a,onSearchExpressions:o,onScroll:u,hasSearchResults:c,defaultSearchPlaceholder:m,emptySearchPlaceholder:h,renderEmptyState:p,renderRow:f,renderSection:g,renderSectionHeader:E,renderSectionFooter:A,renderInspector:C,renderEmptySearchState:x,renderCategoryList:I,renderHeaderAccessories:_,rowHeight:S,sectionHeaderHeight:y,sectionFooterHeight:v,itemNodeWidth:T,listPaddingRight:N,itemNodeMargin:j,listPadding:b,gridNavigatorId:R,gridNotice:P,renderHeader:M,renderUpsell:O}=e,w=i.useRef(null),k=i.useRef(null),D=i.useRef(null),G=0===t.length,F=(0,d.RQ)(e=>e.searchQuery),V=r.useStore(e=>e.inspectedExpressionPosition),B=(0,L.oV)({gridWrapperRef:w,containerWidth:s,showingEmptyState:G}),{expressionsGrid:H,rowCount:Y,rowCountBySection:z,columnCounts:Z,gutterWidth:q}=(0,L.se)({categories:t,collapsedCategories:n,gridWidth:B,listPaddingRight:N,itemNodeWidth:T,itemNodeMargin:j}),{getItemProps:$,getRowProps:J,gridContainerProps:X,handleGridContainerKeyDown:Q,isUsingKeyboardNavigation:ee}=(0,L.JZ)({columnCounts:Z,expressionsListRef:k,expressionsGrid:H,onSelectItem:a,store:r,gridNavigatorId:R}),et=i.useCallback((e,t)=>f(H[e],J(e),{isUsingKeyboardNavigation:ee.current,gutterWidth:q,rowIndex:e,totalRowCount:Y,sectionIndex:t.sectionIndex},t=>$(e,t),t=>r.setInspectedExpressionPosition(t,e)),[H,$,J,q,ee,f,r,Y]),en=i.useCallback(e=>E?.(t[e],e),[t,E]),el=i.useCallback(e=>A?.(t[e],e),[t,A]),ei=i.useCallback(()=>C?.(H?.[V.rowIndex]?.[V.columnIndex]),[H,V.columnIndex,V.rowIndex,C]);i.useEffect(()=>{o(F)},[o,F]),i.useEffect(()=>{r.setBottomPosition(w.current?.getBoundingClientRect().bottom??null)}),i.useEffect(()=>r.resetStoreState,[r.resetStoreState]),i.useLayoutEffect(()=>{D.current?.focus()},[]);let es=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(W,{ref:D,store:r,hasSendableExpressions:!0,onKeyDown:Q,expressionsListRef:k,gridNavigatorId:R,defaultSearchPlaceholder:m,emptySearchPlaceholder:h}),_?.()]});return(0,l.jsxs)(l.Fragment,{children:[null!=M?M(es):(0,l.jsxs)("div",{className:K.wx,children:[" ",es," "]}),G&&null!=p?p(K.p$):(0,l.jsxs)(l.Fragment,{children:[I(k),null!=P&&(0,l.jsx)("div",{className:K.Eb,children:P}),(0,l.jsx)("div",{ref:w,className:K.AD,id:R,...X,children:null!=B?(0,l.jsx)(U,{categories:t,ref:k,store:r,hasSearchResults:c,listPadding:b,renderRow:et,renderSection:g,renderSectionHeader:null!=E?en:void 0,renderSectionFooter:null!=A?el:void 0,renderInspector:null!=C?ei:void 0,renderEmptySearchState:x,rowCount:Y,rowCountBySection:z,rowHeight:S,sectionHeaderHeight:y,sectionFooterHeight:v,renderUpsell:O,onScroll:u}):null})]})]})}var z=n(89366),Z=n(319993),q=n(202639),$=n(414872),J=n(400669),X=n(2181),Q=n(523006),ee=n(885386),et=n(909536),en=n(763827),el=n(287809),ei=n(977997),es=n(147925),er=n(174459),ea=n(807348),eo=n(813564),eu=n(102597),ec=n(904054),ed=n(147472);n(321073);var em=n(931991),eh=n(71393),ep=n(576705),ef=n(473145),eg=n(805143),eE=n(935208);function eA(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=[...e].sort((e,t)=>eE.default.compare(e.soundId,t.soundId));return t?[...n].sort((e,t)=>e.available&&!t.available?-1:!e.available&&t.available?1:0):n}var eC=n(980504),ex=n(788868);function eI(e,t){return null!=t&&(e=t(e)),e.map((e,t)=>({type:ea.uq.SOUND,sound:e,index:t}))}function e_(e,t){let n=t.get("0")??eC.pD;e.push({key:ea.Cx.DEFAULTS,categoryInfo:{type:ea.Cx.DEFAULTS},items:eI(n,eA)})}var eS=n(837381),ey=n(990078),ev=n(802019),eT=n(407698),eN=n(652215),ej=n(698279),eb=n(375708),eR=n(917419);let eP=[8,8,8,8];function eL(e){let{icon:t,isSelected:n,onClick:i,listItemProps:s}=e;return(0,l.jsx)(I.D,{...s,onClick:i,className:r()(eR.Yl,{[eR.wH]:n}),children:(0,l.jsx)(t,{className:eR.xi,color:"currentColor"})})}function eM(e,t,n,i,s){switch(e.categoryInfo.type){case ea.Cx.FAVORITES:return(0,l.jsx)(eL,{icon:A.G,onClick:t,isSelected:n,listItemProps:i},e.key);case ea.Cx.GUILD:return(0,l.jsx)(I.D,{...i,className:eR.L1,onClick:t,children:(0,l.jsx)(R.A,{guild:e.categoryInfo.guild,isSelected:n,isLocked:s})},e.key);case ea.Cx.DEFAULTS:return(0,l.jsx)(eL,{icon:C.p,onClick:t,isSelected:n,listItemProps:i},e.key);default:return null}}function eO(e){let{category:t,categoryIndex:n,onClick:i,isSelected:s,isNitroLocked:r}=e,a=(0,eS.rm)(`soundboard_guild_${n}`);return t.categoryInfo.type===ea.Cx.GUILD?(0,l.jsx)(eT.Q,{guild:t.categoryInfo.guild,children:eM(t,i,s,a,r)}):(0,l.jsx)(ey.m,{text:function(e){switch(e.categoryInfo.type){case ea.Cx.FAVORITES:return eb.intl.string(eb.t.k8fFjp);case ea.Cx.GUILD:return e.categoryInfo.guild.name;case ea.Cx.DEFAULTS:return eb.intl.string(eb.t.Rtvk9X)}}(t),position:"right",align:"center",children:eM(t,i,s,a,r)})}function ew(e){let{soundboardListRef:t,categories:n,shouldUpsellLockedCategories:s,listPadding:a=eP,guildId:o,inExpressionPicker:u}=e,c=i.useRef(null),d=(0,E.bG)([el.default],()=>el.default.getCurrentUser()),m=(0,w.TW)(d,ex.PremiumTypes.TIER_2),h=i.useCallback((e,t,n,i)=>{let r=s&&tt(e.categoryInfo,m,o);return(0,l.jsx)(eO,{category:e,categoryIndex:t,onClick:()=>{er.default.track(eN.HAw.EXPRESSION_PICKER_CATEGORY_SELECTED,{location:{page:eN.liQ.SOUNDBOARD_POPOUT},guild_id:o??null,num_expressions:e.items.length,tab:ej.kx.SOUNDBOARD,sticker_pack_id:null,pack_id:null}),n()},isSelected:i,isNitroLocked:r})},[o,s,m]);return(0,l.jsx)(ev.A,{className:r()(u?eR.HZ:eR.jv),categoryListRef:c,expressionsListRef:t,store:P.LW,categories:n,listPadding:a,renderCategoryListItem:h,rowCount:n.length,categoryHeight:40})}var ek=n(554146),eD=n(191023),eU=n(192308),eG=n(349288),eF=n(695366),eV=n(834730),eB=n(789645),eH=n(565645),eW=n(775602),eK=n(826673),eY=n(182922),ez=n(532624),eZ=n(531685),eq=n(723702),e$=n(350535),eJ=n(319518);function eX(e){let{soundboardSound:t,closePicker:i}=e,s=(0,d.RQ)(e=>e.searchQuery),r=(0,m.bG)([f.A],()=>null!=t&&f.A.isFavoriteSound(t.soundId)),a=(0,m.bG)([eh.A],()=>eh.A.getGuild(t?.guildId)),o=(0,m.bG)([eW.Ay],()=>eW.Ay.useReducedMotion,[]),u=(0,m.bG)([eZ.A],()=>eZ.A.isFocused()),c=(0,m.bG)([ez.Ay],()=>ez.Ay.getKeybindForAction(eN.hCu.SOUNDBOARD_HOLD));if(null!=t&&s.length>0)return(0,l.jsx)(eY.A,{graphicPrimary:null!=t.emojiId||null!=t.emojiName?(0,l.jsx)(eH.A,{emojiId:t.emojiId,emojiName:t.emojiName,className:eJ.Zg}):(0,l.jsx)(eD.x,{size:"md",color:"currentColor",className:eJ.Zg}),graphicSecondary:null!=a?(0,l.jsx)(R.A,{guild:a,shouldAnimate:!o&&u}):null,titlePrimary:t.name,titleSecondary:a?.name,isFavorite:r});let h=()=>{i(),(0,eU.openModalLazy)(async()=>{let{default:e}=await Promise.all([n.e("14144"),n.e("72425"),n.e("46327"),n.e("12618")]).then(n.bind(n,29681));return t=>(0,l.jsx)(e,{...t})})},p=(0,eK.k8)(ek.M.SOUNDBOARD_KEYBIND_TIP),g=null!=c&&(0,eq.isWindows)()&&!p?eb.intl.format(eb.t.udMTth,{keybind:(0,e$.dI)(c.shortcut,!0),openSettingsHook:(e,t)=>(0,l.jsx)(eG.Anchor,{onClick:h,children:e},t)}):null;return null==g?null:(0,l.jsxs)("div",{className:eJ.g,children:[(0,l.jsx)(eF.E,{size:"custom",width:20,height:20,color:"currentColor",className:eJ.QW}),(0,l.jsx)(eV.E,{variant:"text-sm/medium",color:"text-default",className:eJ.L5,children:g}),(0,l.jsx)(I.D,{className:eJ.b,onClick:()=>(0,eK.Dr)(ek.M.SOUNDBOARD_KEYBIND_TIP),children:(0,l.jsx)(eB.P,{size:"xs",color:"currentColor"})})]})}var eQ=n(805945),e0=n(890856),e1=n(307301),e2=n(468689);function e3(e){e2.A.open(e,eN.BEX.SOUNDBOARD),(0,eU.openModalLazy)(async()=>{let{default:t}=await Promise.all([n.e("16227"),n.e("26543"),n.e("82546"),n.e("76846"),n.e("33973"),n.e("7792"),n.e("8555"),n.e("20287"),n.e("83952"),n.e("66580"),n.e("8979"),n.e("20643"),n.e("69006"),n.e("98913"),n.e("74049"),n.e("80559"),n.e("12811")]).then(n.bind(n,191110));return n=>(0,l.jsx)(t,{...n,guildId:e})})}var e4=n(757718),e6=n(508387);function e5(e){let{guild:t,focused:n,onSelectItem:i,...s}=e,{canCreateExpressions:a}=(0,em.nr)(t);return(0,l.jsx)(ey.m,{text:eb.intl.string(eb.t["fHo+z1"]),shouldShow:!a,children:(0,l.jsx)("li",{className:e4.H,children:(0,l.jsxs)(e0.s,{...s,"aria-label":eb.intl.formatToPlainString(eb.t.c1qVYh,{guildName:t.name}),className:r()(e6.n4,{[e6.in]:n,[e6.r9]:!a}),onClick:()=>null!=i?i():e3(t.id),children:[(0,l.jsx)(e1.j,{size:"sm",color:"currentColor"}),(0,l.jsx)(eV.E,{variant:"text-xs/semibold",color:a?"currentColor":"text-muted",children:eb.intl.string(eb.t["8Fu/S7"])})]})})})}function e7(e){let{descriptor:t,soundButtonProps:n,rowIndex:l,columnIndex:s,isUsingKeyboardNavigation:r,suppressPlaySound:a,getItemProps:o,onSelectItem:u,onItemMouseEnter:c,buttonOverlay:d,isNitroLocked:m,showLockForDisabledSound:h,inExpressionPicker:p}=e,f=P.LW.useStore(e=>e.inspectedExpressionPosition),g=`${l}-${s}`,E=r&&f.rowIndex===l&&f.columnIndex===s;switch(t.item.type){case ea.uq.SOUND:return(0,i.createElement)(eQ.Ay,{...o(s),...n,key:g,sound:t.item.sound,suppressPlaySound:a,focused:E,onMouseEnter:()=>c(s),onSelectItem:e=>u(t,e),enableSecondaryActions:!0,buttonOverlay:d,inNitroLockedSection:m,showLockForDisabledSound:h,isSoundmoji:!0===p});case ea.uq.ADD_SOUND:return(0,i.createElement)(e5,{...o(s),key:g,guild:t.item.guild,focused:E,onSelectItem:()=>u(t)})}}var e8=n(965238);let e9=32+$.kg-8,te={[ea.Cx.SEARCH]:u.A.SOUNDBOARD_SEARCH_RESULTS_SECTION,[ea.Cx.DEFAULTS]:u.A.SOUNDBOARD_DEFAULT_SOUNDS_SECTION,[ea.Cx.GUILD]:u.A.SOUNDBOARD_GUILD_SOUNDS_SECTION,[ea.Cx.FAVORITES]:u.A.SOUNDBOARD_FAVORITES_SECTION};function tt(e,t,n){return null==n&&e.type===ea.Cx.GUILD&&!t||e.type===ea.Cx.GUILD&&e.guild.id!==n&&!t}function tn(e){let{categoryInfo:t,collapsed:n,toggleCollapsed:i,isSectionNitroLocked:s,showNitroDivider:a}=e;return(0,l.jsxs)(l.Fragment,{children:[a&&(0,l.jsx)($.Ay,{className:e8.yH}),(0,l.jsx)("div",{className:r()(e8.hd,{[e8.Jb]:s,[e8.VD]:s}),children:(0,l.jsx)(I.D,{className:e8.bV,onClick:i,onKeyDown:e=>e.stopPropagation(),"aria-expanded":!n,children:(0,l.jsxs)("div",{className:e8.M2,children:[function(){switch(t.type){case ea.Cx.FAVORITES:return(0,l.jsx)(A.G,{size:"xs",color:"currentColor",className:e8.nr});case ea.Cx.GUILD:return(0,l.jsx)(R.A,{guild:t.guild,height:16,width:16});case ea.Cx.DEFAULTS:return(0,l.jsx)(C.p,{size:"custom",width:28,height:28,color:"currentColor",className:e8.nr});case ea.Cx.SEARCH:return(0,l.jsx)(x.$,{size:"md",color:"currentColor",className:e8.nr})}}(),(0,l.jsx)(_.D,{variant:"text-sm/semibold",color:"none",className:e8.Gf,children:function(){switch(t.type){case ea.Cx.FAVORITES:return eb.intl.string(eb.t.k8fFjp);case ea.Cx.GUILD:return t.guild.name;case ea.Cx.DEFAULTS:return eb.intl.string(eb.t.Rtvk9X);case ea.Cx.SEARCH:return eb.intl.string(eb.t["zkoeq/"])}}()}),(0,l.jsx)(es.A,{className:e8.nr,direction:n?es.A.Directions.RIGHT:es.A.Directions.DOWN})]})})})]})}function tl(){return(0,l.jsx)(T.A,{message:eb.intl.string(eb.t.bgDdNK)})}function ti(e){let{className:t}=e,n=(0,E.bG)([f.A],()=>f.A.isSoundboardVolumeMuted())?S._:y.H;return(0,l.jsx)(n,{size:"md",color:"currentColor",className:t})}function ts(e){let{guildId:t,channel:s,containerWidth:a,onClose:o,onSelect:m,shouldValidateSelectedSound:h=!1,suppressPlaySound:p=!1,shouldShowLockedSounds:A=!0,gridNotice:C,soundButtonOverlay:x,listPadding:_,renderHeader:S,defaultSoundsOnly:T=!1,inExpressionPicker:R,analyticsSource:L}=e,{audioRef:M}=i.useContext(Q.A),{analyticsLocations:O}=(0,c.Ay)(),{analyticsLocations:k}=(0,c.Ay)(u.A.PREMIUM_UPSELL),{location:D}=(0,N.p)(),U=i.useMemo(()=>({...D,section:eN.JJy.SOUNDBOARD_SOUND_PICKER}),[D]),[G,F]=i.useState(null),V=(0,E.bG)([el.default],()=>el.default.getCurrentUser()),B=(0,w.TW)(V,ex.PremiumTypes.TIER_2),H=(0,E.bG)([ei.A],()=>ei.A.getVoiceState(t,V?.id??eN.dJq)),W=H?.selfDeaf||H?.mute||H?.suppress,K=(0,d.RQ)(e=>e.searchQuery),$=null!=K&&""!==K,es=(0,b.GV)(),eE=(0,et.St)("soundboard_floating_upsell"),{categories:eS,availableSounds:ey,soundCounts:ev}=function(e){let{filterOutEmptyCurrentGuild:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=(0,E.bG)([el.default],()=>el.default.getCurrentUser()),s=w.Ay.isPremium(l,ex.PremiumTypes.TIER_2),[r,a,o]=(0,E.yK)([f.A],()=>[f.A.getSounds(),f.A.getFavorites(),f.A.isFetching()]),u=(0,eg.Y)(e,!1),c=(0,E.yK)([eh.A],()=>{let e=[];return u.forEach(t=>{let n=eh.A.getGuild(t);null!=n&&e.push(n)}),e}),d=w.Ay.canUseSoundboardEverywhere(l),m=(0,E.bG)([eh.A],()=>eh.A.getGuild(e?.guild_id)),h=(0,E.bG)([ep.A],()=>{let{canCreateExpressions:e}=(0,em.ie)(m);return e},[m]);return i.useMemo(()=>{let e=0,l=0,i=[];return n?(e_(i,r),{categories:i,availableSounds:r.get("0")??eC.pD,isFetching:o,soundCounts:{favoriteSoundCount:0,unlockedCustomSoundCount:0,lockedCustomSoundCount:0}}):(!function(e){let{sections:t,guildIds:n,allSounds:l,potentialSoundIdsForSection:i,sectionType:s,sortSoundsFn:r}=e,a={};for(let e of[...n,"0"])for(let t of l.get(e)??[])null!=i.find(e=>e===t.soundId)&&(a[t.soundId]=t);let o=[];for(let e of i){let t=a[e];null!=t&&o.push(t)}let u=eI(o,r);u.length>0&&t.push({key:s,categoryInfo:{type:s},items:u})}({sections:i,guildIds:u,allSounds:r,potentialSoundIdsForSection:Array.from(a),sectionType:ea.Cx.FAVORITES,sortSoundsFn:eA}),void 0!==m&&function(e,t,n){let{currentGuildHasAddPermissions:l,allSounds:i,filterOutEmptyCurrentGuild:s,sortSoundsFn:r}=n,a=i.get(t.id)??[],o=eI(a,r),u=a.length<(0,ef.fA)(t)&&l,c=0===o.length;(u||c)&&!s&&o.push({type:ea.uq.ADD_SOUND,guild:t}),s&&c||e.push({categoryInfo:{type:ea.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:o})}(i,m,{currentGuildHasAddPermissions:h,allSounds:r,filterOutEmptyCurrentGuild:t,sortSoundsFn:eA}),d||e_(i,r),!function(e){let{sections:t,guilds:n,currentGuildId:l,allSounds:i,hasNitro:s,sortSoundsFn:r}=e;for(let e of n){if(e.id===l)continue;let n=eI(i.get(e.id)??[],r);n.length>0&&t.push({categoryInfo:{type:ea.Cx.GUILD,guild:e,isNitroLocked:!s},key:e.id,items:n})}}({sections:i,guilds:c,currentGuildId:m?.id,allSounds:r,hasNitro:s,sortSoundsFn:eA}),d&&e_(i,r),i.forEach(t=>{t.categoryInfo.type===ea.Cx.GUILD&&(t.categoryInfo.isNitroLocked?l+=t.items.length:e+=t.items.length)}),{categories:i,availableSounds:Array.from(r.values()).flat(),isFetching:o,soundCounts:{favoriteSoundCount:a.size,unlockedCustomSoundCount:e,lockedCustomSoundCount:l}})},[u,r,a,m,h,t,d,c,n,o,s,eA])}(s,void 0,T),[eT,eR]=i.useState([]),eP=i.useMemo(()=>K.length>0?[{key:ea.Cx.SEARCH,categoryInfo:{type:ea.Cx.SEARCH},items:eI(eT)}]:eS,[eS,K.length,eT]),eL=(0,d.RQ)(e=>e.isNitroLockedSectionVisible),eM=i.useMemo(()=>eP.filter(e=>e.items.length>0),[eP]),eO=i.useMemo(()=>eM.findLastIndex(e=>!!(0,w.Em)(e.categoryInfo)&&e.categoryInfo.isNitroLocked),[eM]),ek=!B&&A&&-1!==eO,eD=!B&&A&&-1!==eO,eU=ee.b0.useSetting(),eG=i.useMemo(()=>new Set(eU),[eU]),eF=null==s,eV=w.Ay.canUseCustomCallSounds(V),eB=i.useCallback(e=>{eG.has(e)?eG.delete(e):eG.add(e),ee.b0.updateSetting(Array.from(eG))},[eG]),eH=i.useCallback((e,t,n,l)=>{if(null!=m&&!h)return m(e,n);let i=(0,eo.Ir)(V,e,s,!1);if(null!=m&&h&&i)m(e,n);else if(!p&&i&&(0,eo.Au)(s))(0,eo.Ak)(e,s?.id??eN.dJq,t,l),$&&er.default.track(eN.HAw.SEARCH_RESULT_SELECTED,{search_type:eN.I4_.SOUNDBOARD,channel_id:s?.id,query:K,location_stack:t});else{if((0,eo.Ir)(V,e,s))return;A&&F(e)}},[p,V,s,A,$,K,m,h]),eW=i.useCallback((e,t)=>{switch(e.item.type){case ea.uq.SOUND:let n=te[e?.category]??null,l=e?.item.index;return eH(e.item.sound,null==n?O:[...O,n],t?.shiftKey!==!0,l);case ea.uq.ADD_SOUND:return o(),e3(e.item.guild.id)}},[O,eH,o]),eK=i.useCallback((e,n,i,a,o)=>{let u=eM[i.sectionIndex],c=A&&tt(u.categoryInfo,B,t)&&ek;return(0,l.jsx)("ul",{...n,className:r()(e8.a,{[e8.uL]:c}),children:e.map((e,t)=>(0,l.jsx)(e7,{descriptor:e,soundButtonProps:{channel:s,interactive:eF?eV:!W,forceSecondaryActions:!0,analyticsLocations:O},rowIndex:i.rowIndex,columnIndex:t,isUsingKeyboardNavigation:i.isUsingKeyboardNavigation,suppressPlaySound:p,getItemProps:a,onSelectItem:eW,onItemMouseEnter:o,buttonOverlay:x,isNitroLocked:c,showLockForDisabledSound:A,inExpressionPicker:R},t))},`row-${n["aria-rowindex"]}`)},[eM,A,B,t,p,eW,s,eF,eV,W,O,x,ek,R]),eY=i.useCallback((e,t)=>{if(e<=0||!A)return!1;let n=eM[e],l=eM[e-1],i=tt(n.categoryInfo,B,t),s=tt(l.categoryInfo,B,t);return i&&!s},[eM,A,B]),ez=i.useCallback(()=>{let e=f.A.getSoundById("3");null!=e&&F(e)},[]),eZ=i.useCallback(()=>{let e=(0,w.Dd)(ex.PremiumTypes.TIER_2);return eb.intl.format(eb.t["tw/SSq"],{nitroTierName:e,onClick:ez})},[ez]),eq=i.useCallback(e=>eY(e,t)?e9:32,[t,eY]),e$=i.useCallback(e=>{let t=e===eM.length-1;return eD&&t?70:ek&&e===eO?20:0},[eM.length,ek,eD,eO]),eJ=i.useCallback((e,t)=>(0,l.jsx)("div",{children:t},e),[]),eQ=i.useCallback((e,n)=>{let i=`${e.key}`,s=A&&tt(e.categoryInfo,B,t),r=eY(n,t),a=eG.has(i);return(0,l.jsx)(tn,{categoryInfo:e.categoryInfo,toggleCollapsed:()=>{er.default.track(eN.HAw.EXPRESSION_PICKER_CATEGORY_COLLAPSE_TOGGLED,{location:{page:eN.liQ.SOUNDBOARD_POPOUT},tab:ej.kx.SOUNDBOARD,guild_id:t??null,collapsed:!a,sticker_pack_id:null,num_expressions:e.items.length}),eB(i)},collapsed:a,isSectionNitroLocked:s&&ek,showNitroDivider:r&&ek},`header-${i}`)},[eG,eB,t,eY,A,B,ek]),e0=i.useCallback((e,t)=>{let n=t===eM.length-1,i=t===eO;return eD&&n?(0,l.jsx)("div",{className:r()(e8.Lk,{[e8.Ns]:i})}):ek&&t===eO?(0,l.jsx)("div",{className:r()(e8.a3,{[e8.Ns]:i})}):null},[eO,ek,eD,eM.length]),e1=i.useCallback(e=>eR((0,ed.lG)(e,ey,V,s,O)),[s,V,ey,O]),e2=i.useCallback(e=>{(0,v.L3)(e,async()=>{let{default:e}=await n.e("11562").then(n.bind(n,666801));return t=>(0,l.jsx)(e,{sourceAnalyticsLocations:O,...t})})},[O]),e4=i.useCallback(()=>R?(0,l.jsx)(Z.Gq,{renderPopout:()=>(0,l.jsx)(Z.qn,{}),tooltipText:eb.intl.string(eb.t["19lt24"]),position:"top",clickableClassName:r()(e8.Jm,e8.Zz),children:(0,l.jsx)(y.H,{size:"md",color:"currentColor",className:e8.By})}):(0,l.jsx)(I.D,{tabIndex:0,className:e8.Jm,onClick:e2,"aria-label":eb.intl.string(eb.t.kbFsAD),children:(0,l.jsx)(ti,{className:e8.By})}),[R,e2]),e6=i.useCallback(e=>(0,l.jsx)(ew,{soundboardListRef:e,categories:eS,shouldUpsellLockedCategories:ek,listPadding:_,guildId:t,inExpressionPicker:R}),[eS,_,ek,t,R]),e5=i.useCallback(()=>{let e=(0,z.qD)();return(0,w.LE)(e,ex.pe.TIER_2)??eb.intl.string(eb.t.pj0XBN)},[]),ts=i.useCallback(()=>eD?(0,l.jsx)(q.d,{showUpsell:eL,text:eZ(),button:e5(),buttonAnalyticsObject:{section:eN.JJy.SOUND_PICKER_FLOATING_UPSELL},leadingAction:eE?(0,l.jsx)(J.l,{size:"sm",className:e8.ij,location:u.A.PREMIUM_WISHLIST_SOUNDBOARD_UPSELL,forceDarkTheme:!0}):void 0}):null,[eZ,e5,eD,eE,eL]),tr=i.useCallback(e=>e?.item.type===ea.uq.SOUND?(0,l.jsx)(eX,{closePicker:o,soundboardSound:e?.item.sound??null}):null,[o]),ta=i.useCallback(()=>{let e=f.A.getSoundById("3"),t=new Audio((0,eu.A)("3"));null!=M.current&&M.current.pause(),M.current=t,t.currentTime=0,t.volume=(0,ec.A)(e?.volume??1),t.play()},[M]),to=(0,E.bG)([en.A],()=>en.A.getMediaSessionId());return(0,j.A)({type:g.ImpressionTypes.POPOUT,name:g.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:L,guild_id:t,media_session_id:to,available_custom_sounds_count:ev.unlockedCustomSoundCount,unavailable_custom_sounds_count:ev.lockedCustomSoundCount,favorite_sounds_count:ev.favoriteSoundCount}}),(0,l.jsxs)(l.Fragment,{children:[null!=G?(0,l.jsx)(X.A,{title:eb.intl.string(R?eb.t.rZEEvU:eb.t.jGDYF0),description:eb.intl.string(R?eb.t.ZPNG5A:eb.t["grL/hg"]),analyticsLocationSection:eN.JJy.SOUNDBOARD_SOUND_PICKER_UPSELL,upsellViewedTrackingData:{type:ex.e.SOUND_PICKER_SOUND_CLICKED,is_external:!0,location:{...U,object:eN.ZSU.SOUNDBOARD_SOUND},location_stack:k,sku_id:w.Ay.getSkuIdForPremiumType(ex.PremiumTypes.TIER_2)},onClose:()=>F(null),onUpsellClicked:o,onDisplay:ta}):void 0,(0,l.jsx)(Y,{categories:eM,collapsedCategories:eG,containerWidth:a,store:P.LW,onSelectItem:eW,onSearchExpressions:e1,hasSearchResults:eT.length>0,defaultSearchPlaceholder:eb.intl.string(eb.t.sKt3xS),renderRow:eK,renderSectionHeader:eQ,renderSectionFooter:e0,renderSection:eJ,renderCategoryList:e6,renderHeaderAccessories:e4,rowHeight:48,sectionHeaderHeight:eq,sectionFooterHeight:e$,itemNodeWidth:150,gridNavigatorId:es,renderEmptySearchState:tl,renderInspector:tr,gridNotice:C,renderHeader:S,renderUpsell:ts})]})}var tr=n(367720);function ta(e){let{guildId:t,channel:n,containerWidth:s,onClose:g,onSelect:E,analyticsSource:A,suppressPlaySound:C,shouldValidateSelectedSound:x,shouldShowLockedSounds:I=!0,gridNotice:_,inExpressionPicker:S,soundButtonOverlay:y,listPadding:v,renderHeader:T,defaultSoundsOnly:N}=e,{fetching:j,maybeFetchData:b}={fetching:(0,m.bG)([f.A],()=>f.A.isFetchingAnySounds()),maybeFetchData:i.useCallback(()=>{p.E7(),h.bW.loadIfNecessary()},[])},{analyticsLocations:R}=(0,c.Ay)(u.A.SOUNDBOARD_POPOUT);return i.useEffect(()=>{b()},[b]),i.useEffect(()=>{S||(0,d.Ri)("")},[S]),(0,l.jsx)(c.f5,{value:R,children:(0,l.jsx)(a.l,{className:r()(tr.Nz,{[tr.Bg]:j,[tr.yV]:S}),children:j?(0,l.jsx)(o.y,{}):(0,l.jsx)(ts,{guildId:t,channel:n,onClose:g,onSelect:E,shouldValidateSelectedSound:x,containerWidth:s,suppressPlaySound:C,shouldShowLockedSounds:I,gridNotice:_,soundButtonOverlay:y,listPadding:v,renderHeader:T,defaultSoundsOnly:N,inExpressionPicker:S,analyticsSource:A})})})}}