Build 555975stable
Module 174768
5,803 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";let i;n.d(t,{A:()=>z}),n(321073),n(667532);var r=n(735438),s=n.n(r),a=n(17928),o=n(506774),l=n(228366),u=n(115718),c=n(280157),d=n(455234),_=n(695633),h=n(363195),f=n(495544),p=n(734057),E=n(31717),m=n(808728),g=n(696451),A=n(71393),I=n(576705),T=n(222823),S=n(309010),y=n(967198),N=n(543465),v=n(768038),C=n(403362),R=n(652215),O=n(375708);let b="seenQSTutorial",D=[u.rD.USER,u.rD.GROUP_DM,u.rD.TEXT_CHANNEL,u.rD.GUILD,u.rD.APPLICATION,u.rD.LINK,u.rD.IN_APP_NAVIGATION],L=0,w=!1,M=!1,P=null,x=[],k=null,U=0,G=[],F=[],V=null;function B(){M=A.A.getGuildCount()>=3||s().size(p.A.getMutablePrivateChannels())>=20,G=[]}function H(e){let t=(0,c.A)(e);return null==t||null!=P&&P!==t.type?null:t}function j(e){let{query:t,queryMode:n}=e,r=t.trim(),s=y.A.getGuildId()??void 0,a=new Set([`user:${f.default.getId()}`]);null!=s&&a.add(`guild:${s}`),V=Date.now(),i=i??new u.Ay(Y,D,null!=n?100:5,{frecencyBoosters:!0,blacklist:a,allowSnowflake:!0},100),k=null,U=r.length,P=n,i.search(r)}function Y(e,t){if(!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.record.id!==r.record.id)return!1}return!0}(e=""===(t=t.trim()).trim()?function(){var e;let t,n=y.A.getGuildId()??void 0,i=S.A.getChannelId()??void 0;switch(P){case u.rD.USER:{let e=f.default.getId();return v.Ay.getRecentlyTalked(i,100).filter(t=>{let{record:n}=t;return n.id!==e})}case u.rD.APPLICATION:return v.Ay.queryApplications({query:"",limit:100,fuzzy:!0});case u.rD.GUILD:return v.Ay.queryGuilds({query:"",limit:100,fuzzy:!0});case u.rD.TEXT_CHANNEL:return v.Ay.queryChannels({query:"",guildId:y.A.getGuildId(),limit:100,fuzzy:!0,allowEmptyQueries:!0});case u.rD.VOICE_CHANNEL:return v.Ay.queryChannels({query:"",guildId:y.A.getGuildId(),limit:100,fuzzy:!0,filter:()=>!0,type:m.vM,allowEmptyQueries:!0})}let r=[],s=new Set,a=[];for(let e=1;e<F.length;e+=1){let t=H(F[e]);null!=t&&(t.type!==u.rD.TEXT_CHANNEL&&t.type!==u.rD.VOICE_CHANNEL||I.A.can(R.xBc.VIEW_CHANNEL,t.record))&&(a.push(t),s.size<3&&s.add(F[e]))}let o=(e=e=>e===i||s.has(e),t=[],E.A.getRecentlyEditedDrafts(E.C.ChannelMessage).forEach(n=>{let{channelId:i}=n;if(e(i))return;let r=H(i);null!=r&&t.push({record:r,channelId:i})}),t);if(o.length>0)for(let e of(r.push((0,u.jF)(O.intl.string(O.t["4B63jZ"]))),o))s.add(e.channelId),r.push(e.record);let l=T.Ay.getMentionChannelIds().filter(e=>e!==i&&!s.has(e)),c=[];for(let e=l.length-1;e>=0;e--){let t=l[e];if(null==t)continue;let n=H(t);null!=n&&c.push({channelId:t,result:n})}if(c.length>0)for(let{channelId:e,result:t}of(r.push((0,u.jF)(O.intl.string(O.t["61Df13"]))),c))s.add(t.record.id),s.add(e),r.push(t);if(null!=n){let e=m.Ay.getSelectableChannelIds(n).filter(e=>{let t=p.A.getChannel(e);return!(null==t||e===i||s.has(e)||N.Ay.isChannelMuted(t.guild_id,e)||null!=t.parent_id&&N.Ay.isChannelMuted(t.guild_id,t.parent_id))&&(0,d.Y)(t)}).map(e=>H(e)).filter(C.Vq);Object.values(_.A.getActiveJoinedUnreadThreadsForGuild(n)).forEach(t=>{for(let n in t){let t=H(n);null==t||s.has(t.record.id)||e.push(t)}}),e.length>0&&(r.push((0,u.jF)(O.intl.string(O.t.ieCAhD))),r=r.concat(e))}let h=r.length>0?3:7;return a.length>h&&a.splice(h),a.length>0&&(r=[(0,u.jF)(O.intl.string(O.t["80lOZ1"])),...a,...r]),r}():e,G)){G=e;var n=e,i=t;switch(P){case u.rD.USER:{let e=A.A.getGuild(y.A.getGuildId());n.unshift((0,u.jF)(null!=e?O.intl.formatToPlainString(O.t.FREzQs,{name:e.name}):O.intl.string(O.t.XFYW1o))),x=n;break}case u.rD.TEXT_CHANNEL:n.unshift((0,u.jF)(O.intl.string(O.t.W26k4V))),x=n;break;case u.rD.VOICE_CHANNEL:n.unshift((0,u.jF)(O.intl.string(O.t.zUoI5C))),x=n;break;case u.rD.GUILD:n.unshift((0,u.jF)(O.intl.string(O.t.olADPs))),x=n;break;case u.rD.APPLICATION:n.unshift((0,u.jF)(O.intl.string(O.t.VwK1ld))),x=n;break;default:x=n}if(i!==k)k=i,U=Math.max(i.length,U),L=(0,u.Vv)(u.vB.DOWN,-1,x);else{let e=x[L];null!=e&&e.type===u.rD.HEADER&&(L=(0,u.Vv)(u.vB.DOWN,L,x))}$.emitChange()}}function W(){k=null,U=0,G=[],null!=i&&(i.destroy(),i=null)}class K extends a.Ay.PersistedStore{static displayName="QuickSwitcherStore";static persistKey="QuickSwitcherStore";initialize(e){this.waitFor(_.A,f.default,p.A,E.A,m.Ay,g.Ay,A.A,I.A,T.Ay,S.A,y.A,h.A,N.Ay),this.syncWith([h.A],()=>!0),w=o.w.get(b)||!1,F=e?.channelHistory??[]}getState(){return{channelHistory:F}}isOpen(){return null!=i}getResultTotals(e){return null==i?0:null==e?i.results.reduce((e,t)=>t.type!==u.rD.HEADER?e+1:e,0):i.results.reduce((t,n)=>n.type===e?t+1:t,0)}channelNoticePredicate(e,t){let n=Date.now()-t>=R.D2K;return M&&n}getFrequentGuilds(){return null!=i?i.queryGuilds("",100):null}getFrequentGuildsLength(){return null!=i?i.queryGuilds("",100).length:0}getChannelHistory(){return F}getLastShowTimestamp(){return V}getProps(){return{theme:h.A.theme,query:null!=i?i.query:"",queryMode:P,results:x,selectedIndex:L,seenTutorial:w,maxQueryLength:U}}}let $=new K(l.h,{CONNECTION_OPEN:B,CONNECTION_OPEN_SUPPLEMENTAL:B,QUICKSWITCHER_SHOW:j,SHOW_ACTION_SHEET_QUICK_SWITCHER:j,QUICKSWITCHER_HIDE:W,OVERLAY_SET_INPUT_LOCKED:W,HIDE_ACTION_SHEET_QUICK_SWITCHER:W,QUICKSWITCHER_SEARCH:function(e){let{query:t,queryMode:n}=e,r=t.trim();if(null==i)return!1;if(P!==n){i.setResultTypes(null!=n?[n]:D),i.setLimit(null!=n?100:5);let e=y.A.getGuildId()??void 0;n===u.rD.USER&&null!=e?i.setOptions({userFilters:{guild:e,friends:!0}},!0):n===u.rD.VOICE_CHANNEL?i.setOptions({voiceChannelGuildFilter:null},!0):i.setOptions({userFilters:null,voiceChannelGuildFilter:void 0},!0)}if((P=n)===u.rD.USER){let e=y.A.getGuildId()??null;i.search(r,e)}else i.search(r,void 0)},QUICKSWITCHER_SELECT:function(e){L=e.selectedIndex},QUICKSWITCHER_SWITCH_TO:function(){if(w)return!1;w=!0,o.w.set(b,!0)},CHANNEL_SELECT:function(e){let{channelId:t}=e;if(null==t)return!1;(F=F.filter(e=>e!==t)).unshift(t),F.length>8&&(F.length=8)}}),z=$}