Module 277192

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