Build 542549stable
Module 334348
26,693 characters · in a89852156aeda889.jsDependencies
Lazily required by (0)none
Requires (91)
21817689179282723230146647007139389366102597111159139286147472147925151271174459182922191023192308209932212245240864287809289873305866307301319993321073349288350535375708400669407698414872442433464651468689473145503698523006531685532624534514537652554146562708565645576705594061602034627968652215688810695366698279702841723702724511735438763827775602788868789645793574796774802019805143805945807348813564826673834730837381850992885386890856892547904054909536915089927578931991935208939249942381945810959249962125977997980504983851990078
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>tr});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(983851),v=n(442433),N=n(537652),_=n(212245),T=n(139286),j=n(915089),b=n(724511),R=n(850992),O=n(464651),M=n(735438),L=n(962125),w=n(927578),k=n(240864),P=n(711548);let D=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,w.Em)(e.categoryInfo)?{isNitroLocked:e.categoryInfo.isNitroLocked}:{isNitroLocked:!1}),[n]),T=(0,O.Fk)({activeCategoryIndex:N,isScrolling:y,listRef:S,onActiveCategoryIndexChange:s.setActiveCategoryIndex,scrollOffset:20,searchQuery:v}),j=i.useCallback(e=>{T(e),U({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,O.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:P.i,children:[v.length>0&&!r&&null!=p?p():(0,l.jsx)(L.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?.()]})}),U=(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 G=n(942381),V=n(602034),F=n(892547),H=n(387187);let B=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],G.x),f=n.useStore(e=>e.searchPlaceholder),[g,x]=n.useStore(e=>[e.inspectedExpressionPosition,e.hasInteracted],G.x),A=i.useCallback(e=>{n.setActiveCategoryIndex(""===e?0:R.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:H.i,children:(0,l.jsx)(F.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,V.Aq)(a,g.columnIndex,g.rowIndex)}:void 0}})})});var W=n(456908);function K(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:M,renderHeader:L,renderUpsell:w}=e,k=i.useRef(null),P=i.useRef(null),U=i.useRef(null),G=0===t.length,V=(0,d.RQ)(e=>e.searchQuery),F=r.useStore(e=>e.inspectedExpressionPosition),H=(0,O.oV)({gridWrapperRef:k,containerWidth:s,showingEmptyState:G}),{expressionsGrid:K,rowCount:z,rowCountBySection:Z,columnCounts:Y,gutterWidth:q}=(0,O.se)({categories:t,collapsedCategories:n,gridWidth:H,listPaddingRight:T,itemNodeWidth:_,itemNodeMargin:j}),{getItemProps:J,getRowProps:$,gridContainerProps:X,handleGridContainerKeyDown:Q,isUsingKeyboardNavigation:ee}=(0,O.JZ)({columnCounts:Y,expressionsListRef:P,expressionsGrid:K,onSelectItem:a,store:r,gridNavigatorId:R}),et=i.useCallback((e,t)=>f(K[e],$(e),{isUsingKeyboardNavigation:ee.current,gutterWidth:q,rowIndex:e,totalRowCount:z,sectionIndex:t.sectionIndex},t=>J(e,t),t=>r.setInspectedExpressionPosition(t,e)),[K,J,$,q,ee,f,r,z]),en=i.useCallback(e=>x?.(t[e],e),[t,x]),el=i.useCallback(e=>A?.(t[e],e),[t,A]),ei=i.useCallback(()=>C?.(K?.[F.rowIndex]?.[F.columnIndex]),[K,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(()=>{U.current?.focus()},[]);let es=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B,{ref:U,store:r,hasSendableExpressions:!0,onKeyDown:Q,expressionsListRef:P,gridNavigatorId:R,defaultSearchPlaceholder:h,emptySearchPlaceholder:m}),y?.()]});return(0,l.jsxs)(l.Fragment,{children:[null!=L?L(es):(0,l.jsxs)("div",{className:W.wx,children:[" ",es," "]}),G&&null!=p?p(W.p$):(0,l.jsxs)(l.Fragment,{children:[I(P),null!=M&&(0,l.jsx)("div",{className:W.Eb,children:M}),(0,l.jsx)("div",{ref:k,className:W.AD,id:R,...X,children:null!=H?(0,l.jsx)(D,{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:z,rowCountBySection:Z,rowHeight:S,sectionHeaderHeight:v,sectionFooterHeight:N,renderUpsell:w,onScroll:c}):null})]})]})}var z=n(89366),Z=n(319993),Y=n(959249),q=n(414872),J=n(400669),$=n(2181),X=n(523006),Q=n(885386),ee=n(909536),et=n(763827),en=n(287809),el=n(977997),ei=n(147925),es=n(174459);let er=(0,n(945810).mj)({name:"2026-03-soundboard-default-reordering",kind:"user",defaultConfig:{alwaysPinned:!1,reorderDefaultSounds:!1,buttonVariant:"expressive"},variations:{1:{alwaysPinned:!1,reorderDefaultSounds:!1,buttonVariant:"primary"},2:{alwaysPinned:!0,reorderDefaultSounds:!0,buttonVariant:"primary"},3:{alwaysPinned:!1,reorderDefaultSounds:!0,buttonVariant:"primary"},4:{alwaysPinned:!0,reorderDefaultSounds:!1,buttonVariant:"primary"}}});var ea=n(807348),eo=n(813564),ec=n(102597),eu=n(904054),ed=n(147472);n(321073);var eh=n(931991),em=n(71393),ep=n(576705),ef=n(473145),eg=n(805143),ex=n(935208);function eA(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=[...e].sort((e,t)=>ex.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),eE=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 ey(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),ev=n(990078),eN=n(802019),e_=n(407698),eT=n(652215),ej=n(698279),eb=n(375708),eR=n(917419);let eO=[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()(eR.Yl,{[eR.wH]:n}),children:(0,l.jsx)(t,{className:eR.xi,color:"currentColor"})})}function eL(e,t,n,i,s){switch(e.categoryInfo.type){case ea.Cx.FAVORITES:return(0,l.jsx)(eM,{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)(b.A,{guild:e.categoryInfo.guild,isSelected:n,isLocked:s})},e.key);case ea.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,eS.rm)(`soundboard_guild_${n}`);return t.categoryInfo.type===ea.Cx.GUILD?(0,l.jsx)(e_.Q,{guild:t.categoryInfo.guild,children:eL(t,i,s,a,r)}):(0,l.jsx)(ev.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:eL(t,i,s,a,r)})}function ek(e){let{soundboardListRef:t,categories:n,shouldUpsellLockedCategories:s,listPadding:a=eO,guildId:o,inExpressionPicker:c,showPinnedDefaultsShortcut:u=!1,defaultsSectionIndex:d=-1}=e,h=i.useRef(null),m=(0,x.bG)([en.default],()=>en.default.getCurrentUser()),p=(0,w.TW)(m,eE.PremiumTypes.TIER_2),f=i.useCallback(e=>{d>=0&&(e(d),t.current?.scrollToSectionTop(d))},[d,t]),g=i.useCallback(e=>50*!!u,[u]),A=i.useCallback((e,t,n,i)=>{let r=s&&tt(e.categoryInfo,p,o);return(0,l.jsx)(ew,{category:e,categoryIndex:t,onClick:()=>{es.default.track(eT.HAw.EXPRESSION_PICKER_CATEGORY_SELECTED,{location:{page:eT.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,p]);return u&&((a=[...a])[2]=50),(0,l.jsx)(eN.A,{className:r()(c?eR.HZ:eR.jv),categoryListRef:h,expressionsListRef:t,store:R.LW,categories:n,listPadding:a,renderCategoryListItem:A,rowCount:n.length,categoryHeight:40,getScrollOffsetForIndex:g,children:e=>u&&(0,l.jsx)(I.D,{"aria-label":eb.intl.string(eb.t.Rtvk9X),className:eR.xe,onClick:()=>f(e),children:(0,l.jsx)(C.p,{size:"custom",width:24,height:24,color:"currentColor"})})})}var eP=n(554146),eD=n(191023),eU=n(192308),eG=n(349288),eV=n(695366),eF=n(834730),eH=n(789645),eB=n(565645),eW=n(775602),eK=n(826673),ez=n(182922),eZ=n(532624),eY=n(531685),eq=n(723702),eJ=n(350535),e$=n(319518);function eX(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)([em.A],()=>em.A.getGuild(t?.guildId)),o=(0,h.bG)([eW.A],()=>eW.A.useReducedMotion,[]),c=(0,h.bG)([eY.A],()=>eY.A.isFocused()),u=(0,h.bG)([eZ.Ay],()=>eZ.Ay.getKeybindForAction(eT.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)(eB.A,{emojiId:t.emojiId,emojiName:t.emojiName,className:e$.Zg}):(0,l.jsx)(eD.x,{size:"md",color:"currentColor",className:e$.Zg}),graphicSecondary:null!=a?(0,l.jsx)(b.A,{guild:a,shouldAnimate:!o&&c}):null,titlePrimary:t.name,titleSecondary:a?.name,isFavorite:r});let m=()=>{i(),(0,eU.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,eK.k8)(eP.M.SOUNDBOARD_KEYBIND_TIP),g=null!=u&&(0,eq.isWindows)()&&!p?eb.intl.format(eb.t.udMTth,{keybind:(0,eJ.dI)(u.shortcut,!0),openSettingsHook:(e,t)=>(0,l.jsx)(eG.Anchor,{onClick:m,children:e},t)}):null;return null==g?null:(0,l.jsxs)("div",{className:e$.g,children:[(0,l.jsx)(eV.E,{size:"custom",width:20,height:20,color:"currentColor",className:e$.QW}),(0,l.jsx)(eF.E,{variant:"text-sm/medium",color:"text-default",className:e$.L5,children:g}),(0,l.jsx)(I.D,{className:e$.b,onClick:()=>(0,eK.Dr)(eP.M.SOUNDBOARD_KEYBIND_TIP),children:(0,l.jsx)(eH.P,{size:"xs",color:"currentColor"})})]})}var eQ=n(805945),e0=n(890856),e1=n(307301),e2=n(468689);function e6(e){e2.A.open(e,eT.BEX.SOUNDBOARD),(0,eU.openModalLazy)(async()=>{let{default:t}=await Promise.all([n.e("77122"),n.e("55567"),n.e("60909"),n.e("31870"),n.e("27681"),n.e("8555"),n.e("20287"),n.e("83952"),n.e("66580"),n.e("8979"),n.e("20643"),n.e("98913"),n.e("80559"),n.e("74049"),n.e("12811"),n.e("69006")]).then(n.bind(n,191110));return n=>(0,l.jsx)(t,{...n,guildId:e})})}var e3=n(757718),e7=n(508387);function e4(e){let{guild:t,focused:n,onSelectItem:i,...s}=e,{canCreateExpressions:a}=(0,eh.nr)(t);return(0,l.jsx)(ev.m,{text:eb.intl.string(eb.t["fHo+z1"]),shouldShow:!a,children:(0,l.jsx)("li",{className:e3.H,children:(0,l.jsxs)(e0.s,{...s,"aria-label":eb.intl.formatToPlainString(eb.t.c1qVYh,{guildName:t.name}),className:r()(e7.n4,{[e7.in]:n,[e7.r9]:!a}),onClick:()=>null!=i?i():e6(t.id),children:[(0,l.jsx)(e1.j,{size:"sm",color:"currentColor"}),(0,l.jsx)(eF.E,{variant:"text-xs/semibold",color:a?"currentColor":"text-muted",children:eb.intl.string(eb.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=R.LW.useStore(e=>e.inspectedExpressionPosition),g=`${l}-${s}`,x=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:x,onMouseEnter:()=>u(s),onSelectItem:e=>c(t,e),enableSecondaryActions:!0,buttonOverlay:d,inNitroLockedSection:h,showLockForDisabledSound:m,isSoundmoji:!0===p});case ea.uq.ADD_SOUND:return(0,i.createElement)(e4,{...o(s),key:g,guild:t.item.guild,focused:x,onSelectItem:()=>c(t)})}}var e8=n(965238);let e9=32+q.kg-8,te={[ea.Cx.SEARCH]:c.A.SOUNDBOARD_SEARCH_RESULTS_SECTION,[ea.Cx.DEFAULTS]:c.A.SOUNDBOARD_DEFAULT_SOUNDS_SECTION,[ea.Cx.GUILD]:c.A.SOUNDBOARD_GUILD_SOUNDS_SECTION,[ea.Cx.FAVORITES]:c.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)(q.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,"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)(b.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)(E.$,{size:"md",color:"currentColor",className:e8.nr})}}(),(0,l.jsx)(y.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)(ei.A,{className:e8.nr,direction:n?ei.A.Directions.RIGHT:ei.A.Directions.DOWN})]})})})]})}function tl(){return(0,l.jsx)(N.A,{message:eb.intl.string(eb.t.bgDdNK)})}function ti(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:N,defaultSoundsOnly:b=!1,inExpressionPicker:O,analyticsSource:M}=e,{audioRef:L}=i.useContext(X.A),{analyticsLocations:k}=(0,u.Ay)(),{analyticsLocations:P}=(0,u.Ay)(c.A.PREMIUM_UPSELL),{location:D}=(0,_.p)(),U=i.useMemo(()=>({...D,section:eT.JJy.SOUNDBOARD_SOUND_PICKER}),[D]),[G,V]=i.useState(null),[F,H]=i.useState(null),B=(0,x.bG)([en.default],()=>en.default.getCurrentUser()),W=(0,w.TW)(B,eE.PremiumTypes.TIER_2),q=(0,x.bG)([el.A],()=>el.A.getVoiceState(t,B?.id??eT.dJq)),ei=q?.selfDeaf||q?.mute||q?.suppress,ex=(0,d.RQ)(e=>e.searchQuery),eS=null!=ex&&""!==ex,ev=(0,j.GV)(),eN=er.useConfig({location:"SoundboardSoundGrid"}),e_=(0,ee.St)("soundboard_floating_upsell"),{categories:eR,availableSounds:eO,soundCounts:eM}=function(e){let{filterOutEmptyCurrentGuild:t=!1,moveDefaultsToBottom:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=(0,x.bG)([en.default],()=>en.default.getCurrentUser()),r=w.Ay.isPremium(s,eE.PremiumTypes.TIER_2),[a,o,c]=(0,x.yK)([f.A],()=>[f.A.getSounds(),f.A.getFavorites(),f.A.isFetching()]),u=(0,eg.Y)(e,!1),d=(0,x.yK)([em.A],()=>{let e=[];return u.forEach(t=>{let n=em.A.getGuild(t);null!=n&&e.push(n)}),e}),h=w.Ay.canUseSoundboardEverywhere(s),m=(0,x.bG)([em.A],()=>em.A.getGuild(e?.guild_id)),p=(0,x.bG)([ep.A],()=>{let{canCreateExpressions:e}=(0,eh.ie)(m);return e},[m]);return i.useMemo(()=>{let e=0,i=0,s=[];return l?(ey(s,a),{categories:s,availableSounds:a.get("0")??eC.pD,isFetching:c,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=eI(o,r);c.length>0&&t.push({key:s,categoryInfo:{type:s},items:c})}({sections:s,guildIds:u,allSounds:a,potentialSoundIdsForSection:Array.from(o),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),c=a.length<(0,ef.fA)(t)&&l,u=0===o.length;(c||u)&&!s&&o.push({type:ea.uq.ADD_SOUND,guild:t}),s&&u||e.push({categoryInfo:{type:ea.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:o})}(s,m,{currentGuildHasAddPermissions:p,allSounds:a,filterOutEmptyCurrentGuild:t,sortSoundsFn:eA}),n||h||ey(s,a),!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:s,guilds:d,currentGuildId:m?.id,allSounds:a,hasNitro:r,sortSoundsFn:eA}),(n||h)&&ey(s,a),s.forEach(t=>{t.categoryInfo.type===ea.Cx.GUILD&&(t.categoryInfo.isNitroLocked?i+=t.items.length:e+=t.items.length)}),{categories:s,availableSounds:Array.from(a.values()).flat(),isFetching:c,soundCounts:{favoriteSoundCount:o.size,unlockedCustomSoundCount:e,lockedCustomSoundCount:i}})},[u,a,o,m,p,t,n,h,d,l,c,r,eA])}(s,{moveDefaultsToBottom:eN.reorderDefaultSounds},b),[eL,ew]=i.useState([]),eP=i.useMemo(()=>ex.length>0?[{key:ea.Cx.SEARCH,categoryInfo:{type:ea.Cx.SEARCH},items:eI(eL)}]:eR,[eR,ex.length,eL]),eD=(0,d.RQ)(e=>e.isNitroLockedSectionVisible),eU=i.useMemo(()=>eP.filter(e=>e.items.length>0),[eP]),eG=i.useMemo(()=>eU.findLastIndex(e=>!!(0,w.Em)(e.categoryInfo)&&e.categoryInfo.isNitroLocked),[eU]),eV=!W&&A&&-1!==eG,eF=!W&&A&&-1!==eG,eH=!W&&eN.reorderDefaultSounds&&eR.length>6,eB=Q.b0.useSetting(),eW=i.useMemo(()=>new Set(eB),[eB]),eK=null==s,ez=w.Ay.canUseCustomCallSounds(B),eZ=i.useCallback(e=>{eW.has(e)?eW.delete(e):eW.add(e),Q.b0.updateSetting(Array.from(eW))},[eW]),eY=i.useCallback((e,t,n,l)=>{if(null!=h&&!m)return h(e,n);let i=(0,eo.Ir)(B,e,s,!1);if(null!=h&&m&&i)h(e,n);else if(!p&&i&&(0,eo.Au)(s))(0,eo.Ak)(e,s?.id??eT.dJq,t,l),eS&&es.default.track(eT.HAw.SEARCH_RESULT_SELECTED,{search_type:eT.I4_.SOUNDBOARD,channel_id:s?.id,query:ex,location_stack:t});else{if((0,eo.Ir)(B,e,s))return;A&&V(e)}},[p,B,s,A,eS,ex,h,m]),eq=i.useCallback((e,t)=>{switch(e.item.type){case ea.uq.SOUND:let n=te[e?.category]??null,l=e?.item.index;return eY(e.item.sound,null==n?k:[...k,n],t?.shiftKey!==!0,l);case ea.uq.ADD_SOUND:return o(),e6(e.item.guild.id)}},[k,eY,o]),eJ=i.useCallback((e,n,i,a,o)=>{let c=eU[i.sectionIndex],u=A&&tt(c.categoryInfo,W,t)&&eV,d=t=>{o(t);let n=e[t];W||n?.item.type!==ea.uq.SOUND||(0,eo.Ir)(B,n.item.sound,s,!1)?H(null):H(n.item.sound)};return(0,l.jsx)("ul",{...n,onMouseLeave:()=>{H(null)},className:r()(e8.a,{[e8.uL]:u}),children:e.map((e,t)=>(0,l.jsx)(e5,{descriptor:e,soundButtonProps:{channel:s,interactive:eK?ez:!ei,forceSecondaryActions:!0,analyticsLocations:k},rowIndex:i.rowIndex,columnIndex:t,isUsingKeyboardNavigation:i.isUsingKeyboardNavigation,suppressPlaySound:p,getItemProps:a,onSelectItem:eq,onItemMouseEnter:d,buttonOverlay:E,isNitroLocked:u,showLockForDisabledSound:A,inExpressionPicker:O},t))},`row-${n["aria-rowindex"]}`)},[eU,A,W,t,B,p,eq,s,eK,ez,ei,k,E,eV,O]),e$=i.useCallback((e,t)=>{if(e<=0||!A)return!1;let n=eU[e],l=eU[e-1],i=tt(n.categoryInfo,W,t),s=tt(l.categoryInfo,W,t);return i&&!s},[eU,A,W]),eQ=i.useCallback(()=>{let e=f.A.getSoundById("3");null!=e&&V(e)},[]),e0=i.useCallback(()=>{let e=(0,w.Dd)(eE.PremiumTypes.TIER_2);return eb.intl.format(eb.t["tw/SSq"],{nitroTierName:e,onClick:eQ})},[eQ]),e1=i.useCallback(e=>e$(e,t)?e9:32,[t,e$]),e2=i.useCallback(e=>{let t=e===eU.length-1;return eF&&t?70:eV&&e===eG?20:0},[eU.length,eV,eF,eG]),e3=i.useCallback((e,t)=>(0,l.jsx)("div",{children:t},e),[]),e7=i.useCallback((e,n)=>{let i=`${e.key}`,s=A&&tt(e.categoryInfo,W,t),r=e$(n,t),a=eW.has(i);return(0,l.jsx)(tn,{categoryInfo:e.categoryInfo,toggleCollapsed:()=>{es.default.track(eT.HAw.EXPRESSION_PICKER_CATEGORY_COLLAPSE_TOGGLED,{location:{page:eT.liQ.SOUNDBOARD_POPOUT},tab:ej.kx.SOUNDBOARD,guild_id:t??null,collapsed:!a,sticker_pack_id:null,num_expressions:e.items.length}),eZ(i)},collapsed:a,isSectionNitroLocked:s&&eV,showNitroDivider:r&&eV},`header-${i}`)},[eW,eZ,t,e$,A,W,eV]),e4=i.useCallback((e,t)=>{let n=t===eU.length-1,i=t===eG;return eF&&n?(0,l.jsx)("div",{className:r()(e8.Lk,{[e8.Ns]:i})}):eV&&t===eG?(0,l.jsx)("div",{className:r()(e8.a3,{[e8.Ns]:i})}):null},[eG,eV,eF,eU.length]),ti=i.useCallback(e=>ew((0,ed.lG)(e,eO,B,s,k)),[s,B,eO,k]),ts=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:k,...t})})},[k]),tr=i.useCallback(()=>O?(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)(S.H,{size:"md",color:"currentColor",className:e8.By})}):(0,l.jsx)(I.D,{tabIndex:0,className:e8.Jm,onClick:ts,"aria-label":eb.intl.string(eb.t.kbFsAD),children:(0,l.jsx)(S.H,{size:"md",color:"currentColor",className:e8.By})}),[O,ts]),ta=i.useCallback(e=>{let n=eR.filter(e=>!eH||e.categoryInfo.type!==ea.Cx.DEFAULTS),i=eU.findIndex(e=>e.categoryInfo.type===ea.Cx.DEFAULTS);return(0,l.jsx)(ek,{soundboardListRef:e,categories:n,shouldUpsellLockedCategories:eV,listPadding:y,guildId:t,inExpressionPicker:O,showPinnedDefaultsShortcut:eH,defaultsSectionIndex:i})},[eR,eU,y,eV,t,O,eH]),to=i.useCallback(()=>{let e=(0,z.qD)();return(0,w.LE)(e,eE.pe.TIER_2)??eb.intl.string(eb.t.pj0XBN)},[]),tc=i.useCallback(()=>{if(eF){let e=eD;return eN.alwaysPinned&&(e=!0),(0,l.jsx)(Y.d,{showUpsell:e,text:e0(),button:to(),buttonAnalyticsObject:{section:eT.JJy.SOUND_PICKER_FLOATING_UPSELL},hoveredNitroLockedSound:F,subscribeButtonVariantOverride:eN.buttonVariant,leadingAction:e_?(0,l.jsx)(J.l,{size:"sm",className:e8.ij,location:c.A.PREMIUM_WISHLIST_SOUNDBOARD_UPSELL,forceDarkTheme:!0}):void 0})}return null},[e0,to,eF,eN.alwaysPinned,eN.buttonVariant,e_,eD,F]),tu=i.useCallback(e=>e?.item.type===ea.uq.SOUND?(0,l.jsx)(eX,{closePicker:o,soundboardSound:e?.item.sound??null}):null,[o]),td=i.useCallback(()=>{let e=f.A.getSoundById("3"),t=new Audio((0,ec.A)("3"));null!=L.current&&L.current.pause(),L.current=t,t.currentTime=0,t.volume=(0,eu.A)(e?.volume??1),t.play()},[L]),th=(0,x.bG)([et.A],()=>et.A.getMediaSessionId());return(0,T.A)({type:g.ImpressionTypes.POPOUT,name:g.ImpressionNames.SOUNDBOARD_POPOUT,properties:{source:M,guild_id:t,media_session_id:th,available_custom_sounds_count:eM.unlockedCustomSoundCount,unavailable_custom_sounds_count:eM.lockedCustomSoundCount,favorite_sounds_count:eM.favoriteSoundCount}}),(0,l.jsxs)(l.Fragment,{children:[null!=G?(0,l.jsx)($.A,{title:eb.intl.string(O?eb.t.rZEEvU:eb.t.jGDYF0),description:eb.intl.string(O?eb.t.ZPNG5A:eb.t["grL/hg"]),analyticsLocationSection:eT.JJy.SOUNDBOARD_SOUND_PICKER_UPSELL,upsellViewedTrackingData:{type:eE.e.SOUND_PICKER_SOUND_CLICKED,is_external:!0,location:{...U,object:eT.ZSU.SOUNDBOARD_SOUND},location_stack:P,sku_id:w.Ay.getSkuIdForPremiumType(eE.PremiumTypes.TIER_2)},onClose:()=>V(null),onUpsellClicked:o,onDisplay:td}):void 0,(0,l.jsx)(K,{categories:eU,collapsedCategories:eW,containerWidth:a,store:R.LW,onSelectItem:eq,onSearchExpressions:ti,hasSearchResults:eL.length>0,defaultSearchPlaceholder:eb.intl.string(eb.t.sKt3xS),renderRow:eJ,renderSectionHeader:e7,renderSectionFooter:e4,renderSection:e3,renderCategoryList:ta,renderHeaderAccessories:tr,rowHeight:48,sectionHeaderHeight:e1,sectionFooterHeight:e2,itemNodeWidth:150,gridNavigatorId:ev,renderEmptySearchState:tl,renderInspector:tu,gridNotice:C,renderHeader:N,renderUpsell:tc})]})}var ts=n(367720);function tr(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()(ts.Nz,{[ts.Bg]:j,[ts.yV]:S}),children:j?(0,l.jsx)(o.y,{}):(0,l.jsx)(ti,{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})})})}}