Build 533169stable
Module 918530
3,019 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>S,I:()=>y}),n(321073);var r=n(64700),i=n(311907),s=n(931991),a=n(71393),o=n(576705),l=n(287809),u=n(473145),c=n(927578),d=n(209932),_=n(807348),f=n(805143),p=n(194567),h=n(980504),m=n(788868);function E(e,t){return null!=t&&(e=t(e)),e.map((e,t)=>({type:_.uq.SOUND,sound:e,index:t}))}function g(e){let{sections:t,guildIds:n,allSounds:r,potentialSoundIdsForSection:i,sectionType:s,sortSoundsFn:a}=e,o={};for(let e of[...n,"0"])for(let t of r.get(e)??[])null!=i.find(e=>e===t.soundId)&&(o[t.soundId]=t);let l=[];for(let e of i){let t=o[e];null!=t&&l.push(t)}let u=E(l,a);u.length>0&&t.push({key:s,categoryInfo:{type:s},items:u})}function A(e){let{sections:t,guilds:n,currentGuildId:r,allSounds:i,hasNitro:s,sortSoundsFn:a}=e;for(let e of n){if(e.id===r)continue;let n=E(i.get(e.id)??[],a);n.length>0&&t.push({categoryInfo:{type:_.Cx.GUILD,guild:e,isNitroLocked:!s},key:e.id,items:n})}}function I(e,t,n){let{currentGuildHasAddPermissions:r,allSounds:i,filterOutEmptyCurrentGuild:s,sortSoundsFn:a}=n,o=i.get(t.id)??[],l=E(o,a),c=o.length<(0,u.fA)(t)&&r,d=0===l.length;(c||d)&&!s&&l.push({type:_.uq.ADD_SOUND,guild:t}),s&&d||e.push({categoryInfo:{type:_.Cx.GUILD,guild:t,isNitroLocked:!1},key:t.id,items:l})}function T(e,t){let n=t.get("0")??h.pD;e.push({key:_.Cx.DEFAULTS,categoryInfo:{type:_.Cx.DEFAULTS},items:E(n,p.U)})}function S(e){let{filterOutEmptyCurrentGuild:t=!1,moveDefaultsToBottom:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=arguments.length>2&&void 0!==arguments[2]&&arguments[2],E=(0,i.bG)([l.default],()=>l.default.getCurrentUser()),S=c.Ay.isPremium(E,m.PremiumTypes.TIER_2),[y,v,N]=(0,i.yK)([d.A],()=>[d.A.getSounds(),d.A.getFavorites(),d.A.isFetching()]),C=(0,p.I)(),R=(0,f.Y)(e,!1),O=(0,i.yK)([a.A],()=>{let e=[];return R.forEach(t=>{let n=a.A.getGuild(t);null!=n&&e.push(n)}),e}),b=c.Ay.canUseSoundboardEverywhere(E),D=(0,i.bG)([a.A],()=>a.A.getGuild(e?.guild_id)),L=(0,i.bG)([o.A],()=>{let{canCreateExpressions:e}=(0,s.ie)(D);return e},[D]);return r.useMemo(()=>{let e=0,r=0,i=[];return u?(T(i,y),{categories:i,availableSounds:y.get("0")??h.pD,isFetching:N,soundCounts:{favoriteSoundCount:0,unlockedCustomSoundCount:0,lockedCustomSoundCount:0}}):(g({sections:i,guildIds:R,allSounds:y,potentialSoundIdsForSection:Array.from(v),sectionType:_.Cx.FAVORITES,sortSoundsFn:p.U}),void 0!==D&&I(i,D,{currentGuildHasAddPermissions:L,allSounds:y,filterOutEmptyCurrentGuild:t,sortSoundsFn:C}),n||b||T(i,y),A({sections:i,guilds:O,currentGuildId:D?.id,allSounds:y,hasNitro:S,sortSoundsFn:C}),(n||b)&&T(i,y),i.forEach(t=>{t.categoryInfo.type===_.Cx.GUILD&&(t.categoryInfo.isNitroLocked?r+=t.items.length:e+=t.items.length)}),{categories:i,availableSounds:Array.from(y.values()).flat(),isFetching:N,soundCounts:{favoriteSoundCount:v.size,unlockedCustomSoundCount:e,lockedCustomSoundCount:r}})},[R,y,v,D,L,t,n,b,O,u,N,S,C])}function y(e,t,n){return r.useMemo(()=>n.length>0?[{key:_.Cx.SEARCH,categoryInfo:{type:_.Cx.SEARCH},items:E(t)}]:e,[e,n.length,t])}}