Loading
function(e,t,n){"use strict";n.d(t,{A:()=>to});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(754998),q=n(319993),$=n(202639),J=n(414872),X=n(400669),Q=n(2181),ee=n(523006),et=n(885386),en=n(909536),el=n(763827),ei=n(287809),es=n(977997),er=n(147925),ea=n(174459),eo=n(807348),eu=n(813564),ec=n(102597),ed=n(904054),em=n(147472);n(321073);var eh=n(931991),ep=n(71393),ef=n(576705),eg=n(473145),eE=n(805143),eA=n(935208);function eC(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=[...e].sort((e,t)=>eA.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 ex=n(980504),eI=n(788868);function e_(e,t){return null!=t&&(e=t(e)),e.map((e,t)=>({type:eo.uq.SOUND,sound:e,index:t}))}function eS(e,t){let n=t.get("0")??ex.pD;e.push({key:eo.Cx.DEFAULTS,categoryInfo:{type:eo.Cx.DEFAULTS},items:e_(n,eC)})}var ey=n(837381),ev=n(990078),eT=n(802019),eN=n(407698),ej=n(652215),eb=n(698279),eR=n(375708),eP=n(917419);let eL=[8,8,8,8];function eM(e){let{icon:t,isSelected:n,onClick:i,listItemProps:s}=e;return(0,l.jsx)(I.D,{...s,onClick:i,className:r()(eP.Yl,{[eP.wH]:n}),children:(0,l.jsx)(t,{className:eP.xi,color:"currentColor"})})}function eO(e,t,n,i,s){switch(e.categoryInfo.type){case eo.Cx.FAVORITES:return(0,l.jsx)(eM,{icon:A.G,onClick:t,isSelected:n,listItemProps:i},e.key);case eo.Cx.GUILD:return(0,l.jsx)(I.D,{...i,className:eP.L1,onClick:t,children:(0,l.jsx)(R.A,{guild:e.categoryInfo.guild,isSelected:n,isLocked:s})},e.key);case eo.Cx.DEFAULTS:return(0,l.jsx)(eM,{icon:C.p,onClick:t,isSelected:n,listItemProps:i},e.key);default:return null}}function ew(e){let{category:t,categoryIndex:n,onClick:i,isSelected:s,isNitroLocked:r}=e,a=(0,ey.rm)(`soundboard_guild_${n}`);return t.categoryInfo.type===eo.Cx.GUILD?(0,l.jsx)(eN.Q,{guild:t.categoryInfo.guild,children:eO(t,i,s,a,r)}):(0,l.jsx)(ev.m,{text:function(e){switch(e.categoryInfo.type){case eo.Cx.FAVORITES:return eR.intl.string(eR.t.k8fFjp);case eo.Cx.GUILD:return e.categoryInfo.guild.name;case eo.Cx.DEFAULTS:return eR.intl.string(eR.t.Rtvk9X)}}(t),position:"right",align:"center",children:eO(t,i,s,a,r)})}function ek(e){let{soundboardListRef:t,categories:n,shouldUpsellLockedCategories:s,listPadding:a=eL,guildId:o,inExpressionPicker:u}=e,c=i.useRef(null),d=(0,E.bG)([ei.default],()=>ei.default.getCurrentUser()),m=(0,w.TW)(d,eI.PremiumTypes.TIER_2),h=i.useCallback((e,t,n,i)=>{let r=s&&tn(e.categoryInfo,m,o);return(0,l.jsx)(ew,{category:e,categoryIndex:t,onClick:function(){ea.default.track(ej.HAw.EXPRESSION_PICKER_CATEGORY_SELECTED,{location:{page:ej.liQ.SOUNDBOARD_POPOUT},guild_id:o??null,num_expressions:e.items.length,tab:eb.kx.SOUNDBOARD,sticker_pack_id:null,pack_id:null}),n()},isSelected:i,isNitroLocked:r})},[o,s,m]);return(0,l.jsx)(eT.A,{className:r()(u?eP.HZ:eP.jv),categoryListRef:c,expressionsListRef:t,store:P.LW,categories:n,listPadding:a,renderCategoryListItem:h,rowCount:n.length,categoryHeight:40})}var eD=n(554146),eU=n(191023),eG=n(192308),eF=n(349288),eV=n(695366),eB=n(834730),eH=n(789645),eW=n(565645),eK=n(775602),eY=n(826673),ez=n(182922),eZ=n(532624),eq=n(531685),e$=n(723702),eJ=n(350535),eX=n(319518);function eQ(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)([ep.A],()=>ep.A.getGuild(t?.guildId)),o=(0,m.bG)([eK.Ay],()=>eK.Ay.useReducedMotion,[]),u=(0,m.bG)([eq.A],()=>eq.A.isFocused()),c=(0,m.bG)([eZ.Ay],()=>eZ.Ay.getKeybindForAction(ej.hCu.SOUNDBOARD_HOLD));if(null!=t&&s.length>0)return(0,l.jsx)(ez.A,{graphicPrimary:null!=t.emojiId||null!=t.emojiName?(0,l.jsx)(eW.A,{emojiId:t.emojiId,emojiName:t.emojiName,className:eX.Zg}):(0,l.jsx)(eU.x,{size:"md",color:"currentColor",className:eX.Zg}),graphicSecondary:null!=a?(0,l.jsx)(R.A,{guild:a,shouldAnimate:!o&&u}):null,titlePrimary:t.name,titleSecondary:a?.name,isFavorite:r});function h(){i(),(0,eG.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})})}let p=(0,eY.k8)(eD.M.SOUNDBOARD_KEYBIND_TIP),g=null!=c&&(0,e$.isWindows)()&&!p?eR.intl.format(eR.t.udMTth,{keybind:(0,eJ.dI)(c.shortcut,!0),openSettingsHook:(e,t)=>(0,l.jsx)(eF.Anchor,{onClick:h,children:e},t)}):null;return null==g?null:(0,l.jsxs)("div",{className:eX.g,children:[(0,l.jsx)(eV.E,{size:"custom",width:20,height:20,color:"currentColor",className:eX.QW}),(0,l.jsx)(eB.E,{variant:"text-sm/medium",color:"text-default",className:eX.L5,children:g}),(0,l.jsx)(I.D,{className:eX.b,onClick:function(){return(0,eY.Dr)(eD.M.SOUNDBOARD_KEYBIND_TIP)},children:(0,l.jsx)(eH.P,{size:"xs",color:"currentColor"})})]})}var e0=n(805945),e1=n(890856),e2=n(307301),e3=n(468689);function e4(e){e3.A.open(e,ej.BEX.SOUNDBOARD),(0,eG.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("83952"),n.e("20287"),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 e6=n(757718),e5=n(508387);function e7(e){let{guild:t,focused:n,onSelectItem:i,...s}=e,{canCreateExpressions:a}=(0,eh.nr)(t);return(0,l.jsx)(ev.m,{text:eR.intl.string(eR.t["fHo+z1"]),shouldShow:!a,children:(0,l.jsx)("li",{className:e6.H,children:(0,l.jsxs)(e1.s,{...s,"aria-label":eR.intl.formatToPlainString(eR.t.c1qVYh,{guildName:t.name}),className:r()(e5.n4,{[e5.in]:n,[e5.r9]:!a}),onClick:()=>null!=i?i():e4(t.id),children:[(0,l.jsx)(e2.j,{size:"sm",color:"currentColor"}),(0,l.jsx)(eB.E,{variant:"text-xs/semibold",color:a?"currentColor":"text-muted",children:eR.intl.string(eR.t["8Fu/S7"])})]})})})}function e8(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 eo.uq.SOUND:return(0,i.createElement)(e0.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 eo.uq.ADD_SOUND:return(0,i.createElement)(e7,{...o(s),key:g,guild:t.item.guild,focused:E,onSelectItem:()=>u(t)})}}var e9=n(965238);let te=32+J.kg-8,tt={[eo.Cx.SEARCH]:u.A.SOUNDBOARD_SEARCH_RESULTS_SECTION,[eo.Cx.DEFAULTS]:u.A.SOUNDBOARD_DEFAULT_SOUNDS_SECTION,[eo.Cx.GUILD]:u.A.SOUNDBOARD_GUILD_SOUNDS_SECTION,[eo.Cx.FAVORITES]:u.A.SOUNDBOARD_FAVORITES_SECTION};function tn(e,t,n){return null==n&&e.type===eo.Cx.GUILD&&!t||e.type===eo.Cx.GUILD&&e.guild.id!==n&&!t}function tl(e){let{categoryInfo:t,collapsed:n,toggleCollapsed:i,isSectionNitroLocked:s,showNitroDivider:a}=e;return(0,l.jsxs)(l.Fragment,{children:[a&&(0,l.jsx)(J.Ay,{className:e9.yH}),(0,l.jsx)("div",{className:r()(e9.hd,{[e9.Jb]:s,[e9.VD]:s}),children:(0,l.jsx)(I.D,{className:e9.bV,onClick:i,onKeyDown:e=>e.stopPropagation(),"aria-expanded":!n,children:(0,l.jsxs)("div",{className:e9.M2,children:[function(){switch(t.type){case eo.Cx.FAVORITES:return(0,l.jsx)(A.G,{size:"xs",color:"currentColor",className:e9.nr});case eo.Cx.GUILD:return(0,l.jsx)(R.A,{guild:t.guild,height:16,width:16});case eo.Cx.DEFAULTS:return(0,l.jsx)(C.p,{size:"custom",width:28,height:28,color:"currentColor",className:e9.nr});case eo.Cx.SEARCH:return(0,l.jsx)(x.$,{size:"md",color:"currentColor",className:e9.nr})}}(),(0,l.jsx)(_.D,{variant:"text-sm/semibold",color:"none",className:e9.Gf,children:function(){switch(t.type){case eo.Cx.FAVORITES:return eR.intl.string(eR.t.k8fFjp);case eo.Cx.GUILD:return t.guild.name;case eo.Cx.DEFAULTS:return eR.intl.string(eR.t.Rtvk9X);case eo.Cx.SEARCH:return eR.intl.string(eR.t["zkoeq/"])}}()}),(0,l.jsx)(er.A,{className:e9.nr,direction:n?er.A.Directions.RIGHT:er.A.Directions.DOWN})]})})})]})}function ti(){return(0,l.jsx)(T.A,{message:eR.intl.string(eR.t.bgDdNK)})}function ts(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 tr(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(ee.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:ej.JJy.SOUNDBOARD_SOUND_PICKER}),[D]),[G,F]=i.useState(null),V=(0,E.bG)([ei.default],()=>ei.default.getCurrentUser()),B=(0,w.TW)(V,eI.PremiumTypes.TIER_2),H=(0,E.bG)([es.A],()=>es.A.getVoiceState(t,V?.id??ej.dJq)),W=H?.selfDeaf||H?.mute||H?.suppress,K=(0,d.RQ)(e=>e.searchQuery),J=null!=K&&""!==K,er=(0,b.GV)(),eA=(0,en.St)("soundboard_floating_upsell"),ey=(0,Z.$)("soundboard_floating_upsell"),{categories:ev,availableSounds:eT,soundCounts:eN}=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)([ei.default],()=>ei.default.getCurrentUser()),s=w.Ay.isPremium(l,eI.PremiumTypes.TIER_2),[r,a,o]=(0,E.yK)([f.A],()=>[f.A.getSounds(),f.A.getFavorites(),f.A.isFetching()]),u=(0,eE.Y)(e,!1),c=(0,E.yK)([ep.A],()=>{let e=[];return u.forEach(t=>{let n=ep.A.getGuild(t);null!=n&&e.push(n)}),e}),d=w.Ay.canUseSoundboardEverywhere(l),m=(0,E.bG)([ep.A],()=>ep.A.getGuild(e?.guild_id)),h=(0,E.bG)([ef.A],()=>{let{canCreateExpressions:e}=(0,eh.ie)(m);return e},[m]);return i.useMemo(()=>{let e=0,l=0,i=[];return n?(eS(i,r),{categories:i,availableSounds:r.get("0")??ex.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=e_(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:eo.Cx.FAVORITES,sortSoundsFn:eC}),void 0!==m&&function(e,t,n){let{currentGuildHasAddPermissions:l,allSounds:i,filterOutEmptyCurrentGuild:s,sortSoundsFn:r}=n,a=i.get(t.id)??[],o=e_(a,r),u=a.length<(0,eg.fA)(t)&&l,c=0===o.length;(u||c)&&!s&&o.push({type:eo.uq.ADD_SOUND,guild:t}),s&&c||e.push({categoryInfo:{type:eo.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:o})}(i,m,{currentGuildHasAddPermissions:h,allSounds:r,filterOutEmptyCurrentGuild:t,sortSoundsFn:eC}),d||eS(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=e_(i.get(e.id)??[],r);n.length>0&&t.push({categoryInfo:{type:eo.Cx.GUILD,guild:e,isNitroLocked:!s},key:e.id,items:n})}}({sections:i,guilds:c,currentGuildId:m?.id,allSounds:r,hasNitro:s,sortSoundsFn:eC}),d&&eS(i,r),i.forEach(t=>{t.categoryInfo.type===eo.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,eC])}(s,void 0,T),[eP,eL]=i.useState([]),eM=i.useMemo(()=>K.length>0?[{key:eo.Cx.SEARCH,categoryInfo:{type:eo.Cx.SEARCH},items:e_(eP)}]:ev,[ev,K.length,eP]),eO=(0,d.RQ)(e=>e.isNitroLockedSectionVisible),ew=i.useMemo(()=>eM.filter(e=>e.items.length>0),[eM]),eD=i.useMemo(()=>ew.findLastIndex(e=>!!(0,w.Em)(e.categoryInfo)&&e.categoryInfo.isNitroLocked),[ew]),eU=!B&&A&&-1!==eD,eG=!B&&A&&-1!==eD,eF=et.b0.useSetting(),eV=i.useMemo(()=>new Set(eF),[eF]),eB=null==s,eH=w.Ay.canUseCustomCallSounds(V),eW=i.useCallback(e=>{eV.has(e)?eV.delete(e):eV.add(e),et.b0.updateSetting(Array.from(eV))},[eV]),eK=i.useCallback((e,t,n,l)=>{if(null!=m&&!h)return m(e,n);let i=(0,eu.Ir)(V,e,s,!1);if(null!=m&&h&&i)m(e,n);else if(!p&&i&&(0,eu.Au)(s))(0,eu.Ak)(e,s?.id??ej.dJq,t,l),J&&ea.default.track(ej.HAw.SEARCH_RESULT_SELECTED,{search_type:ej.I4_.SOUNDBOARD,channel_id:s?.id,query:K,location_stack:t});else{if((0,eu.Ir)(V,e,s))return;A&&F(e)}},[p,V,s,A,J,K,m,h]),eY=i.useCallback((e,t)=>{switch(e.item.type){case eo.uq.SOUND:let n=tt[e?.category]??null,l=e?.item.index;return eK(e.item.sound,null==n?O:[...O,n],t?.shiftKey!==!0,l);case eo.uq.ADD_SOUND:return o(),e4(e.item.guild.id)}},[O,eK,o]),ez=i.useCallback((e,n,i,a,o)=>{let u=ew[i.sectionIndex],c=A&&tn(u.categoryInfo,B,t)&&eU;return(0,l.jsx)("ul",{...n,className:r()(e9.a,{[e9.uL]:c}),children:e.map((e,t)=>(0,l.jsx)(e8,{descriptor:e,soundButtonProps:{channel:s,interactive:eB?eH:!W,forceSecondaryActions:!0,analyticsLocations:O},rowIndex:i.rowIndex,columnIndex:t,isUsingKeyboardNavigation:i.isUsingKeyboardNavigation,suppressPlaySound:p,getItemProps:a,onSelectItem:eY,onItemMouseEnter:o,buttonOverlay:x,isNitroLocked:c,showLockForDisabledSound:A,inExpressionPicker:R},t))},`row-${n["aria-rowindex"]}`)},[ew,A,B,t,p,eY,s,eB,eH,W,O,x,eU,R]),eZ=i.useCallback((e,t)=>{if(e<=0||!A)return!1;let n=ew[e],l=ew[e-1],i=tn(n.categoryInfo,B,t),s=tn(l.categoryInfo,B,t);return i&&!s},[ew,A,B]),eq=i.useCallback(()=>{let e=f.A.getSoundById("3");null!=e&&F(e)},[]),e$=i.useCallback(()=>{let e=(0,w.Dd)(eI.PremiumTypes.TIER_2);return eR.intl.format(eR.t["tw/SSq"],{nitroTierName:e,onClick:eq})},[eq]),eJ=i.useCallback(e=>eZ(e,t)?te:32,[t,eZ]),eX=i.useCallback(e=>{let t=e===ew.length-1;return eG&&t?70:eU&&e===eD?20:0},[ew.length,eU,eG,eD]),e0=i.useCallback((e,t)=>(0,l.jsx)("div",{children:t},e),[]),e1=i.useCallback((e,n)=>{let i=`${e.key}`,s=A&&tn(e.categoryInfo,B,t),r=eZ(n,t),a=eV.has(i);return(0,l.jsx)(tl,{categoryInfo:e.categoryInfo,toggleCollapsed:function(){ea.default.track(ej.HAw.EXPRESSION_PICKER_CATEGORY_COLLAPSE_TOGGLED,{location:{page:ej.liQ.SOUNDBOARD_POPOUT},tab:eb.kx.SOUNDBOARD,guild_id:t??null,collapsed:!a,sticker_pack_id:null,num_expressions:e.items.length}),eW(i)},collapsed:a,isSectionNitroLocked:s&&eU,showNitroDivider:r&&eU},`header-${i}`)},[eV,eW,t,eZ,A,B,eU]),e2=i.useCallback((e,t)=>{let n=t===ew.length-1,i=t===eD;return eG&&n?(0,l.jsx)("div",{className:r()(e9.Lk,{[e9.Ns]:i})}):eU&&t===eD?(0,l.jsx)("div",{className:r()(e9.a3,{[e9.Ns]:i})}):null},[eD,eU,eG,ew.length]),e3=i.useCallback(e=>eL((0,em.lG)(e,eT,V,s,O)),[s,V,eT,O]),e6=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]),e5=i.useCallback(()=>R?(0,l.jsx)(q.Gq,{renderPopout:()=>(0,l.jsx)(q.qn,{}),tooltipText:eR.intl.string(eR.t["19lt24"]),position:"top",clickableClassName:r()(e9.Jm,e9.Zz),children:(0,l.jsx)(y.H,{size:"md",color:"currentColor",className:e9.By})}):(0,l.jsx)(I.D,{tabIndex:0,className:e9.Jm,onClick:e6,"aria-label":eR.intl.string(eR.t.kbFsAD),children:(0,l.jsx)(ts,{className:e9.By})}),[R,e6]),e7=i.useCallback(e=>(0,l.jsx)(ek,{soundboardListRef:e,categories:ev,shouldUpsellLockedCategories:eU,listPadding:_,guildId:t,inExpressionPicker:R}),[ev,_,eU,t,R]),tr=i.useCallback(()=>{let e=(0,z.qD)();return(0,w.LE)(e,eI.pe.TIER_2)??eR.intl.string(eR.t.pj0XBN)},[]),ta=i.useCallback(()=>eG?(0,l.jsx)($.d,{showUpsell:eO,text:e$(),button:tr(),buttonAnalyticsObject:{section:ej.JJy.SOUND_PICKER_FLOATING_UPSELL},subscribeButtonVariantOverride:ey,leadingAction:eA?(0,l.jsx)(X.l,{size:"sm",className:e9.ij,location:u.A.PREMIUM_WISHLIST_SOUNDBOARD_UPSELL,forceDarkTheme:!0}):void 0}):null,[e$,tr,eG,eA,ey,eO]),to=i.useCallback(e=>e?.item.type===eo.uq.SOUND?(0,l.jsx)(eQ,{closePicker:o,soundboardSound:e?.item.sound??null}):null,[o]),tu=i.useCallback(()=>{let e=f.A.getSoundById("3"),t=new Audio((0,ec.A)("3"));null!=M.current&&M.current.pause(),M.current=t,t.currentTime=0,t.volume=(0,ed.A)(e?.volume??1),t.play()},[M]),tc=(0,E.bG)([el.A],()=>el.A.getMediaSessionId());return(0,j.A)({type:g.ImpressionTypes.POPOUT,name:g.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:L,guild_id:t,media_session_id:tc,available_custom_sounds_count:eN.unlockedCustomSoundCount,unavailable_custom_sounds_count:eN.lockedCustomSoundCount,favorite_sounds_count:eN.favoriteSoundCount}}),(0,l.jsxs)(l.Fragment,{children:[null!=G?(0,l.jsx)(Q.A,{title:eR.intl.string(R?eR.t.rZEEvU:eR.t.jGDYF0),description:eR.intl.string(R?eR.t.ZPNG5A:eR.t["grL/hg"]),analyticsLocationSection:ej.JJy.SOUNDBOARD_SOUND_PICKER_UPSELL,upsellViewedTrackingData:{type:eI.e.SOUND_PICKER_SOUND_CLICKED,is_external:!0,location:{...U,object:ej.ZSU.SOUNDBOARD_SOUND},location_stack:k,sku_id:w.Ay.getSkuIdForPremiumType(eI.PremiumTypes.TIER_2)},onClose:()=>F(null),onUpsellClicked:o,onDisplay:tu}):void 0,(0,l.jsx)(Y,{categories:ew,collapsedCategories:eV,containerWidth:a,store:P.LW,onSelectItem:eY,onSearchExpressions:e3,hasSearchResults:eP.length>0,defaultSearchPlaceholder:eR.intl.string(eR.t.sKt3xS),renderRow:ez,renderSectionHeader:e1,renderSectionFooter:e2,renderSection:e0,renderCategoryList:e7,renderHeaderAccessories:e5,rowHeight:48,sectionHeaderHeight:eJ,sectionFooterHeight:eX,itemNodeWidth:150,gridNavigatorId:er,renderEmptySearchState:ti,renderInspector:to,gridNotice:C,renderHeader:S,renderUpsell:ta})]})}var ta=n(367720);function to(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()(ta.Nz,{[ta.Bg]:j,[ta.yV]:S}),children:j?(0,l.jsx)(o.y,{}):(0,l.jsx)(tr,{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})})})}}