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),c=n(793574),u=n(688810),d=n(151271),h=n(702841),m=n(594061),p=n(796774),f=n(209932);n(30146);var g=n(562708),x=n(17928),A=n(27232),C=n(111159),E=n(7689),I=n(939249),y=n(534514),S=n(358618),v=n(983851),N=n(228366),_=n(442433),T=n(537652),j=n(212245),b=n(139286),R=n(915089),O=n(724511),M=n(850992),L=n(464651),w=n(735438),k=n(962125),P=n(428262),D=n(240864),U=n(711548);let G=i.forwardRef(function(e,t){let{categories:n,store:s,hasSearchResults:r,listPadding:a,renderRow:o,renderSection:c,renderSectionHeader:u,renderSectionFooter:h,renderInspector:m,renderEmptySearchState:p,rowCount:f,rowCountBySection:g,rowHeight:x,sectionHeaderHeight:A,sectionFooterHeight:C,renderUpsell:E,onScroll:I}=e,y=i.useRef(!1),S=i.useRef(null),v=(0,d.RQ)(e=>e.searchQuery),N=s.useStore(e=>e.activeCategoryIndex),_=i.useMemo(()=>n.map(e=>(0,P.Em)(e.categoryInfo)?{isNitroLocked:e.categoryInfo.isNitroLocked}:{isNitroLocked:!1}),[n]),T=(0,L.Fk)({activeCategoryIndex:N,isScrolling:y,listRef:S,onActiveCategoryIndexChange:s.setActiveCategoryIndex,scrollOffset:20,searchQuery:v}),j=i.useCallback(e=>{T(e),V({listRef:S,searchQuery:v,nitroLockedSectionStates:_,scrollTop:e,sectionHeaderHeight:A,sectionFooterHeight:C}),I?.(e)},[T,v,_,A,C,I]);return i.useEffect(()=>{null!=S.current&&j(S.current.getScrollerNode()?.scrollTop??0)},[j,S]),(0,L.FV)({searchQuery:v,activeCategoryIndex:N,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:U.i,children:[v.length>0&&!r&&null!=p?p():(0,l.jsx)(k.A,{role:"none presentation",listPadding:a,onScroll:j,renderRow:o,renderSection:c,renderSectionHeader:u,renderSectionFooter:h,rowCount:f,rowCountBySection:g,rowHeight:x,sectionHeaderHeight:A,sectionFooterHeight:C,stickyHeaders:!0,ref:S}),E?.(),m?.()]})}),V=(0,w.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,D.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),H=n(602034),B=n(892547),W=n(387187);let K=i.forwardRef(function(e,t){let{store:n,hasSendableExpressions:s,onKeyDown:r,gridNavigatorId:a,expressionsListRef:o,defaultSearchPlaceholder:c,emptySearchPlaceholder:u}=e,h=i.useRef(null),[m,p]=(0,d.RQ)(e=>[e.searchQuery,e.isSearchSuggestion],F.x),f=n.useStore(e=>e.searchPlaceholder),[g,x]=n.useStore(e=>[e.inspectedExpressionPosition,e.hasInteracted],F.x),A=i.useCallback(e=>{n.setActiveCategoryIndex(""===e?0:M.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:()=>h.current?.focus()})),i.useLayoutEffect(()=>{p&&h.current?.focus()},[p]),(0,l.jsx)("div",{className:W.i,children:(0,l.jsx)(B.I,{autoFocus:s,disabled:!s,query:m,ref:h,placeholder:null!=f?f:s||null==u?c:u,onClear:C,onKeyDown:r,onChange:A,inputProps:{"aria-haspopup":"grid","aria-controls":a,"aria-expanded":!0,...x?{"aria-activedescendant":(0,H.Aq)(a,g.columnIndex,g.rowIndex)}:void 0}})})});var z=n(456908);function Z(e){let{categories:t,collapsedCategories:n,containerWidth:s,store:r,onSelectItem:a,onSearchExpressions:o,onScroll:c,hasSearchResults:u,defaultSearchPlaceholder:h,emptySearchPlaceholder:m,renderEmptyState:p,renderRow:f,renderSection:g,renderSectionHeader:x,renderSectionFooter:A,renderInspector:C,renderEmptySearchState:E,renderCategoryList:I,renderHeaderAccessories:y,rowHeight:S,sectionHeaderHeight:v,sectionFooterHeight:N,itemNodeWidth:_,listPaddingRight:T,itemNodeMargin:j,listPadding:b,gridNavigatorId:R,gridNotice:O,renderHeader:M,renderUpsell:w}=e,k=i.useRef(null),P=i.useRef(null),D=i.useRef(null),U=0===t.length,V=(0,d.RQ)(e=>e.searchQuery),F=r.useStore(e=>e.inspectedExpressionPosition),H=(0,L.oV)({gridWrapperRef:k,containerWidth:s,showingEmptyState:U}),{expressionsGrid:B,rowCount:W,rowCountBySection:Z,columnCounts:Y,gutterWidth:q}=(0,L.se)({categories:t,collapsedCategories:n,gridWidth:H,listPaddingRight:T,itemNodeWidth:_,itemNodeMargin:j}),{getItemProps:J,getRowProps:$,gridContainerProps:X,handleGridContainerKeyDown:Q,isUsingKeyboardNavigation:ee}=(0,L.JZ)({columnCounts:Y,expressionsListRef:P,expressionsGrid:B,onSelectItem:a,store:r,gridNavigatorId:R}),et=i.useCallback((e,t)=>f(B[e],$(e),{isUsingKeyboardNavigation:ee.current,gutterWidth:q,rowIndex:e,totalRowCount:W,sectionIndex:t.sectionIndex},t=>J(e,t),t=>r.setInspectedExpressionPosition(t,e)),[B,J,$,q,ee,f,r,W]),en=i.useCallback(e=>x?.(t[e],e),[t,x]),el=i.useCallback(e=>A?.(t[e],e),[t,A]),ei=i.useCallback(()=>C?.(B?.[F.rowIndex]?.[F.columnIndex]),[B,F.columnIndex,F.rowIndex,C]);i.useEffect(()=>{o(V)},[o,V]),i.useEffect(()=>{r.setBottomPosition(k.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)(K,{ref:D,store:r,hasSendableExpressions:!0,onKeyDown:Q,expressionsListRef:P,gridNavigatorId:R,defaultSearchPlaceholder:h,emptySearchPlaceholder:m}),y?.()]});return(0,l.jsxs)(l.Fragment,{children:[null!=M?M(es):(0,l.jsxs)("div",{className:z.wx,children:[" ",es," "]}),U&&null!=p?p(z.p$):(0,l.jsxs)(l.Fragment,{children:[I(P),null!=O&&(0,l.jsx)("div",{className:z.Eb,children:O}),(0,l.jsx)("div",{ref:k,className:z.AD,id:R,...X,children:null!=H?(0,l.jsx)(G,{categories:t,ref:P,store:r,hasSearchResults:u,listPadding:b,renderRow:et,renderSection:g,renderSectionHeader:null!=x?en:void 0,renderSectionFooter:null!=A?el:void 0,renderInspector:null!=C?ei:void 0,renderEmptySearchState:E,rowCount:W,rowCountBySection:Z,rowHeight:S,sectionHeaderHeight:v,sectionFooterHeight:N,renderUpsell:w,onScroll:c}):null})]})]})}var Y=n(89366),q=n(319993),J=n(202639),$=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),ec=n(813564),eu=n(102597),ed=n(904054),eh=n(147472);n(321073);var em=n(931991),ep=n(71393),ef=n(576705),eg=n(473145),ex=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 eE=n(980504),eI=n(788868);function ey(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")??eE.pD;e.push({key:eo.Cx.DEFAULTS,categoryInfo:{type:eo.Cx.DEFAULTS},items:ey(n,eC)})}var ev=n(837381),eN=n(990078),e_=n(802019),eT=n(407698),ej=n(652215),eb=n(698279),eR=n(375708),eO=n(917419);let eM=[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()(eO.Yl,{[eO.wH]:n}),children:(0,l.jsx)(t,{className:eO.xi,color:"currentColor"})})}function ew(e,t,n,i,s){switch(e.categoryInfo.type){case eo.Cx.FAVORITES:return(0,l.jsx)(eL,{icon:A.G,onClick:t,isSelected:n,listItemProps:i},e.key);case eo.Cx.GUILD:return(0,l.jsx)(I.D,{...i,className:eO.L1,onClick:t,children:(0,l.jsx)(O.A,{guild:e.categoryInfo.guild,isSelected:n,isLocked:s})},e.key);case eo.Cx.DEFAULTS:return(0,l.jsx)(eL,{icon:C.p,onClick:t,isSelected:n,listItemProps:i},e.key);default:return null}}function ek(e){let{category:t,categoryIndex:n,onClick:i,isSelected:s,isNitroLocked:r}=e,a=(0,ev.rm)(`soundboard_guild_${n}`);return t.categoryInfo.type===eo.Cx.GUILD?(0,l.jsx)(eT.Q,{guild:t.categoryInfo.guild,children:ew(t,i,s,a,r)}):(0,l.jsx)(eN.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:ew(t,i,s,a,r)})}function eP(e){let{soundboardListRef:t,categories:n,shouldUpsellLockedCategories:s,listPadding:a=eM,guildId:o,inExpressionPicker:c}=e,u=i.useRef(null),d=(0,x.bG)([ei.default],()=>ei.default.getCurrentUser()),h=(0,P.TW)(d,eI.PremiumTypes.TIER_2),m=i.useCallback((e,t,n,i)=>{let r=s&&tn(e.categoryInfo,h,o);return(0,l.jsx)(ek,{category:e,categoryIndex:t,onClick:()=>{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,h]);return(0,l.jsx)(e_.A,{className:r()(c?eO.HZ:eO.jv),categoryListRef:u,expressionsListRef:t,store:M.LW,categories:n,listPadding:a,renderCategoryListItem:m,rowCount:n.length,categoryHeight:40})}var eD=n(554146),eU=n(191023),eG=n(192308),eV=n(349288),eF=n(695366),eH=n(834730),eB=n(789645),eW=n(565645),eK=n(775602),ez=n(826673),eZ=n(182922),eY=n(532624),eq=n(531685),eJ=n(723702),e$=n(350535),eX=n(319518);function eQ(e){let{soundboardSound:t,closePicker:i}=e,s=(0,d.RQ)(e=>e.searchQuery),r=(0,h.bG)([f.A],()=>null!=t&&f.A.isFavoriteSound(t.soundId)),a=(0,h.bG)([ep.A],()=>ep.A.getGuild(t?.guildId)),o=(0,h.bG)([eK.A],()=>eK.A.useReducedMotion,[]),c=(0,h.bG)([eq.A],()=>eq.A.isFocused()),u=(0,h.bG)([eY.Ay],()=>eY.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)(O.A,{guild:a,shouldAnimate:!o&&c}):null,titlePrimary:t.name,titleSecondary:a?.name,isFavorite:r});let m=()=>{i(),(0,eG.openModalLazy)(async()=>{let{default:e}=await Promise.all([n.e("3633"),n.e("72425"),n.e("46327"),n.e("12618")]).then(n.bind(n,29681));return t=>(0,l.jsx)(e,{...t})})},p=(0,ez.k8)(eD.M.SOUNDBOARD_KEYBIND_TIP),g=null!=u&&(0,eJ.isWindows)()&&!p?eR.intl.format(eR.t.udMTth,{keybind:(0,e$.dI)(u.shortcut,!0),openSettingsHook:(e,t)=>(0,l.jsx)(eV.Anchor,{onClick:m,children:e},t)}):null;return null==g?null:(0,l.jsxs)("div",{className:eX.g,children:[(0,l.jsx)(eF.E,{size:"custom",width:20,height:20,color:"currentColor",className:eX.QW}),(0,l.jsx)(eH.E,{variant:"text-sm/medium",color:"text-default",className:eX.L5,children:g}),(0,l.jsx)(I.D,{className:eX.b,onClick:()=>(0,ez.Dr)(eD.M.SOUNDBOARD_KEYBIND_TIP),children:(0,l.jsx)(eB.P,{size:"xs",color:"currentColor"})})]})}var e0=n(805945),e1=n(890856),e2=n(307301),e6=n(468689);function e3(e){e6.A.open(e,ej.BEX.SOUNDBOARD),(0,eG.openModalLazy)(async()=>{let{default:t}=await Promise.all([n.e("57303"),n.e("60909"),n.e("8516"),n.e("76846"),n.e("56927"),n.e("8555"),n.e("20287"),n.e("83952"),n.e("66580"),n.e("8979"),n.e("20643"),n.e("80559"),n.e("98913"),n.e("74049"),n.e("69006"),n.e("12811")]).then(n.bind(n,191110));return n=>(0,l.jsx)(t,{...n,guildId:e})})}var e7=n(757718),e4=n(508387);function e8(e){let{guild:t,focused:n,onSelectItem:i,...s}=e,{canCreateExpressions:a}=(0,em.nr)(t);return(0,l.jsx)(eN.m,{text:eR.intl.string(eR.t["fHo+z1"]),shouldShow:!a,children:(0,l.jsx)("li",{className:e7.H,children:(0,l.jsxs)(e1.s,{...s,"aria-label":eR.intl.formatToPlainString(eR.t.c1qVYh,{guildName:t.name}),className:r()(e4.n4,{[e4.in]:n,[e4.r9]:!a}),onClick:()=>null!=i?i():e3(t.id),children:[(0,l.jsx)(e2.j,{size:"sm",color:"currentColor"}),(0,l.jsx)(eH.E,{variant:"text-xs/semibold",color:a?"currentColor":"text-muted",children:eR.intl.string(eR.t["8Fu/S7"])})]})})})}function e5(e){let{descriptor:t,soundButtonProps:n,rowIndex:l,columnIndex:s,isUsingKeyboardNavigation:r,suppressPlaySound:a,getItemProps:o,onSelectItem:c,onItemMouseEnter:u,buttonOverlay:d,isNitroLocked:h,showLockForDisabledSound:m,inExpressionPicker:p}=e,f=M.LW.useStore(e=>e.inspectedExpressionPosition),g=`${l}-${s}`,x=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:x,onMouseEnter:()=>u(s),onSelectItem:e=>c(t,e),enableSecondaryActions:!0,buttonOverlay:d,inNitroLockedSection:h,showLockForDisabledSound:m,isSoundmoji:!0===p});case eo.uq.ADD_SOUND:return(0,i.createElement)(e8,{...o(s),key:g,guild:t.item.guild,focused:x,onSelectItem:()=>c(t)})}}var e9=n(965238);let te=32+$.kg-8,tt={[eo.Cx.SEARCH]:c.A.SOUNDBOARD_SEARCH_RESULTS_SECTION,[eo.Cx.DEFAULTS]:c.A.SOUNDBOARD_DEFAULT_SOUNDS_SECTION,[eo.Cx.GUILD]:c.A.SOUNDBOARD_GUILD_SOUNDS_SECTION,[eo.Cx.FAVORITES]:c.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)($.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,"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)(O.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)(E.$,{size:"md",color:"currentColor",className:e9.nr})}}(),(0,l.jsx)(y.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,s]=i.useState(()=>et.dG.getSetting()?.volume===0);i.useEffect(()=>{let e=e=>s(0===e.volume);return N.h.subscribe("USER_SOUNDBOARD_SET_VOLUME",e),()=>{N.h.unsubscribe("USER_SOUNDBOARD_SET_VOLUME",e)}},[]);let r=n?S._:v.H;return(0,l.jsx)(r,{size:"md",color:"currentColor",className:t})}function tr(e){let{guildId:t,channel:s,containerWidth:a,onClose:o,onSelect:h,shouldValidateSelectedSound:m=!1,suppressPlaySound:p=!1,shouldShowLockedSounds:A=!0,gridNotice:C,soundButtonOverlay:E,listPadding:y,renderHeader:S,defaultSoundsOnly:N=!1,inExpressionPicker:T,analyticsSource:O}=e,{audioRef:L}=i.useContext(ee.A),{analyticsLocations:w}=(0,u.Ay)(),{analyticsLocations:k}=(0,u.Ay)(c.A.PREMIUM_UPSELL),{location:D}=(0,j.p)(),U=i.useMemo(()=>({...D,section:ej.JJy.SOUNDBOARD_SOUND_PICKER}),[D]),[G,V]=i.useState(null),F=(0,x.bG)([ei.default],()=>ei.default.getCurrentUser()),H=(0,P.TW)(F,eI.PremiumTypes.TIER_2),B=(0,x.bG)([es.A],()=>es.A.getVoiceState(t,F?.id??ej.dJq)),W=B?.selfDeaf||B?.mute||B?.suppress,K=(0,d.RQ)(e=>e.searchQuery),z=null!=K&&""!==K,$=(0,R.GV)(),er=(0,en.St)("soundboard_floating_upsell"),{categories:eA,availableSounds:ev,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,x.bG)([ei.default],()=>ei.default.getCurrentUser()),s=P.Ay.isPremium(l,eI.PremiumTypes.TIER_2),[r,a,o]=(0,x.yK)([f.A],()=>[f.A.getSounds(),f.A.getFavorites(),f.A.isFetching()]),c=(0,ex.Y)(e,!1),u=(0,x.yK)([ep.A],()=>{let e=[];return c.forEach(t=>{let n=ep.A.getGuild(t);null!=n&&e.push(n)}),e}),d=P.Ay.canUseSoundboardEverywhere(l),h=(0,x.bG)([ep.A],()=>ep.A.getGuild(e?.guild_id)),m=(0,x.bG)([ef.A],()=>{let{canCreateExpressions:e}=(0,em.ie)(h);return e},[h]);return i.useMemo(()=>{let e=0,l=0,i=[];return n?(eS(i,r),{categories:i,availableSounds:r.get("0")??eE.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 c=ey(o,r);c.length>0&&t.push({key:s,categoryInfo:{type:s},items:c})}({sections:i,guildIds:c,allSounds:r,potentialSoundIdsForSection:Array.from(a),sectionType:eo.Cx.FAVORITES,sortSoundsFn:eC}),void 0!==h&&function(e,t,n){let{currentGuildHasAddPermissions:l,allSounds:i,filterOutEmptyCurrentGuild:s,sortSoundsFn:r}=n,a=i.get(t.id)??[],o=ey(a,r),c=a.length<(0,eg.fA)(t)&&l,u=0===o.length;(c||u)&&!s&&o.push({type:eo.uq.ADD_SOUND,guild:t}),s&&u||e.push({categoryInfo:{type:eo.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:o})}(i,h,{currentGuildHasAddPermissions:m,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=ey(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:u,currentGuildId:h?.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}})},[c,r,a,h,m,t,d,u,n,o,s,eC])}(s,void 0,N),[e_,eT]=i.useState([]),eO=i.useMemo(()=>K.length>0?[{key:eo.Cx.SEARCH,categoryInfo:{type:eo.Cx.SEARCH},items:ey(e_)}]:eA,[eA,K.length,e_]),eM=(0,d.RQ)(e=>e.isNitroLockedSectionVisible),eL=i.useMemo(()=>eO.filter(e=>e.items.length>0),[eO]),ew=i.useMemo(()=>eL.findLastIndex(e=>!!(0,P.Em)(e.categoryInfo)&&e.categoryInfo.isNitroLocked),[eL]),ek=!H&&A&&-1!==ew,eD=!H&&A&&-1!==ew,eU=et.b0.useSetting(),eG=i.useMemo(()=>new Set(eU),[eU]),eV=null==s,eF=P.Ay.canUseCustomCallSounds(F),eH=i.useCallback(e=>{eG.has(e)?eG.delete(e):eG.add(e),et.b0.updateSetting(Array.from(eG))},[eG]),eB=i.useCallback((e,t,n,l)=>{if(null!=h&&!m)return h(e,n);let i=(0,ec.Ir)(F,e,s,!1);if(null!=h&&m&&i)h(e,n);else if(!p&&i&&(0,ec.Au)(s))(0,ec.Ak)(e,s?.id??ej.dJq,t,l),z&&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,ec.Ir)(F,e,s))return;A&&V(e)}},[p,F,s,A,z,K,h,m]),eW=i.useCallback((e,t)=>{switch(e.item.type){case eo.uq.SOUND:let n=tt[e?.category]??null,l=e?.item.index;return eB(e.item.sound,null==n?w:[...w,n],t?.shiftKey!==!0,l);case eo.uq.ADD_SOUND:return o(),e3(e.item.guild.id)}},[w,eB,o]),eK=i.useCallback((e,n,i,a,o)=>{let c=eL[i.sectionIndex],u=A&&tn(c.categoryInfo,H,t)&&ek;return(0,l.jsx)("ul",{...n,className:r()(e9.a,{[e9.uL]:u}),children:e.map((e,t)=>(0,l.jsx)(e5,{descriptor:e,soundButtonProps:{channel:s,interactive:eV?eF:!W,forceSecondaryActions:!0,analyticsLocations:w},rowIndex:i.rowIndex,columnIndex:t,isUsingKeyboardNavigation:i.isUsingKeyboardNavigation,suppressPlaySound:p,getItemProps:a,onSelectItem:eW,onItemMouseEnter:o,buttonOverlay:E,isNitroLocked:u,showLockForDisabledSound:A,inExpressionPicker:T},t))},`row-${n["aria-rowindex"]}`)},[eL,A,H,t,p,eW,s,eV,eF,W,w,E,ek,T]),ez=i.useCallback((e,t)=>{if(e<=0||!A)return!1;let n=eL[e],l=eL[e-1],i=tn(n.categoryInfo,H,t),s=tn(l.categoryInfo,H,t);return i&&!s},[eL,A,H]),eZ=i.useCallback(()=>{let e=f.A.getSoundById("3");null!=e&&V(e)},[]),eY=i.useCallback(()=>{let e=(0,P.Dd)(eI.PremiumTypes.TIER_2);return eR.intl.format(eR.t["tw/SSq"],{nitroTierName:e,onClick:eZ})},[eZ]),eq=i.useCallback(e=>ez(e,t)?te:32,[t,ez]),eJ=i.useCallback(e=>{let t=e===eL.length-1;return eD&&t?70:ek&&e===ew?20:0},[eL.length,ek,eD,ew]),e$=i.useCallback((e,t)=>(0,l.jsx)("div",{children:t},e),[]),eX=i.useCallback((e,n)=>{let i=`${e.key}`,s=A&&tn(e.categoryInfo,H,t),r=ez(n,t),a=eG.has(i);return(0,l.jsx)(tl,{categoryInfo:e.categoryInfo,toggleCollapsed:()=>{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}),eH(i)},collapsed:a,isSectionNitroLocked:s&&ek,showNitroDivider:r&&ek},`header-${i}`)},[eG,eH,t,ez,A,H,ek]),e0=i.useCallback((e,t)=>{let n=t===eL.length-1,i=t===ew;return eD&&n?(0,l.jsx)("div",{className:r()(e9.Lk,{[e9.Ns]:i})}):ek&&t===ew?(0,l.jsx)("div",{className:r()(e9.a3,{[e9.Ns]:i})}):null},[ew,ek,eD,eL.length]),e1=i.useCallback(e=>eT((0,eh.lG)(e,ev,F,s,w)),[s,F,ev,w]),e2=i.useCallback(e=>{(0,_.L3)(e,async()=>{let{default:e}=await n.e("11562").then(n.bind(n,666801));return t=>(0,l.jsx)(e,{sourceAnalyticsLocations:w,...t})})},[w]),e6=i.useCallback(()=>T?(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)(v.H,{size:"md",color:"currentColor",className:e9.By})}):(0,l.jsx)(I.D,{tabIndex:0,className:e9.Jm,onClick:e2,"aria-label":eR.intl.string(eR.t.kbFsAD),children:(0,l.jsx)(ts,{className:e9.By})}),[T,e2]),e7=i.useCallback(e=>(0,l.jsx)(eP,{soundboardListRef:e,categories:eA,shouldUpsellLockedCategories:ek,listPadding:y,guildId:t,inExpressionPicker:T}),[eA,y,ek,t,T]),e4=i.useCallback(()=>{let e=(0,Y.qD)();return(0,P.LE)(e,eI.pe.TIER_2)??eR.intl.string(eR.t.pj0XBN)},[]),e8=i.useCallback(()=>eD?(0,l.jsx)(J.d,{showUpsell:eM,text:eY(),button:e4(),buttonAnalyticsObject:{section:ej.JJy.SOUND_PICKER_FLOATING_UPSELL},leadingAction:er?(0,l.jsx)(X.l,{size:"sm",className:e9.ij,location:c.A.PREMIUM_WISHLIST_SOUNDBOARD_UPSELL,forceDarkTheme:!0}):void 0}):null,[eY,e4,eD,er,eM]),tr=i.useCallback(e=>e?.item.type===eo.uq.SOUND?(0,l.jsx)(eQ,{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!=L.current&&L.current.pause(),L.current=t,t.currentTime=0,t.volume=(0,ed.A)(e?.volume??1),t.play()},[L]),to=(0,x.bG)([el.A],()=>el.A.getMediaSessionId());return(0,b.A)({type:g.ImpressionTypes.POPOUT,name:g.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:O,guild_id:t,media_session_id:to,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(T?eR.t.rZEEvU:eR.t.jGDYF0),description:eR.intl.string(T?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:P.Ay.getSkuIdForPremiumType(eI.PremiumTypes.TIER_2)},onClose:()=>V(null),onUpsellClicked:o,onDisplay:ta}):void 0,(0,l.jsx)(Z,{categories:eL,collapsedCategories:eG,containerWidth:a,store:M.LW,onSelectItem:eW,onSearchExpressions:e1,hasSearchResults:e_.length>0,defaultSearchPlaceholder:eR.intl.string(eR.t.sKt3xS),renderRow:eK,renderSectionHeader:eX,renderSectionFooter:e0,renderSection:e$,renderCategoryList:e7,renderHeaderAccessories:e6,rowHeight:48,sectionHeaderHeight:eq,sectionFooterHeight:eJ,itemNodeWidth:150,gridNavigatorId:$,renderEmptySearchState:ti,renderInspector:tr,gridNotice:C,renderHeader:S,renderUpsell:e8})]})}var ta=n(367720);function to(e){let{guildId:t,channel:n,containerWidth:s,onClose:g,onSelect:x,analyticsSource:A,suppressPlaySound:C,shouldValidateSelectedSound:E,shouldShowLockedSounds:I=!0,gridNotice:y,inExpressionPicker:S,soundButtonOverlay:v,listPadding:N,renderHeader:_,defaultSoundsOnly:T}=e,{fetching:j,maybeFetchData:b}={fetching:(0,h.bG)([f.A],()=>f.A.isFetchingAnySounds()),maybeFetchData:i.useCallback(()=>{p.E7(),m.bW.loadIfNecessary()},[])},{analyticsLocations:R}=(0,u.Ay)(c.A.SOUNDBOARD_POPOUT);return i.useEffect(()=>{b()},[b]),i.useEffect(()=>{S||(0,d.Ri)("")},[S]),(0,l.jsx)(u.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:x,shouldValidateSelectedSound:E,containerWidth:s,suppressPlaySound:C,shouldShowLockedSounds:I,gridNotice:y,soundButtonOverlay:v,listPadding:N,renderHeader:_,defaultSoundsOnly:T,inExpressionPicker:S,analyticsSource:A})})})}}