Module 503509

2,378 characters · in no known chunk
Dependencies
Required by (2)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";let i;n.d(t,{A:()=>D,c:()=>g});var r=n(17928),s=n(506774),a=n(228366),o=n(313961),l=n(885386),u=n(617617),c=n(164891),d=n(495544),_=n(734057),f=n(461213),h=n(607567),p=n(531685),E=n(652215);let m={width:232,height:315},g={width:400,height:374},A=new Set,I=[],T=new Map,S=new Set,N=!1;function y(e){if(null==e||null==T.get(e))return!1;T.delete(e),(S=new Set(S)).delete(e)}function C(e){let{channelId:t,ongoingRings:n}=e,r="GUILD_RING_START"===e.type;if(r&&!c.A.getCurrentConfig({guildId:e.guildId,location:"IncomingCallCreate"}).enabled)return!1;let s=d.default.getId(),a=s in n&&null!=n[s];if(!S.has(t)&&a){var l;let e,a,u=_.A.getChannel(t);if(null==u)return!1;let d=10*S.size,{x:f,y:E}=(l=r?u:void 0,e=p.A.windowSize(),a=function(e){let{enabled:t}=c.A.getCurrentConfig({guildId:e?.guild_id,location:"IncomingCallStore"});if(e?.guild_id==null||!t)return m;let n=h.Ay.getVoiceStatesForChannel(e).filter(t=>!o.A.getGuildRingingUsers(e.id).has(t.user.id)),i=n.length>2,r=48*Math.min(n.length,2)+22*!!i;return{...g,height:g.height+r}}(l),null!=i&&i.x+a.width<e.width&&i.y+a.height<e.height?i:{x:e.width/2-a.width/2,y:e.height/2-a.height/2});return T.set(t,{channel:u,senderId:n[s],x:f+d,y:E+d}),void(S=new Set(S)).add(t)}return!!S.has(t)&&!a&&y(t)}function v(e){let{channelId:t}=e;return("GUILD_RING_STOP"!==e.type||!!c.A.getCurrentConfig({guildId:e.guildId,location:"IncomingCallDelete"}).enabled&&!!e.ringing.includes(d.default.getId()))&&y(t)}function O(){N=f.A.getStatus()===E.clD.DND||l.NO.getSetting()}function R(){let e=d.default.getId();S.forEach(t=>{null==_.A.getChannel(t)?.guild_id||o.A.getGuildRingingUsers(t).has(e)||y(t)})}class b extends r.Ay.Store{static displayName="IncomingCallStore";initialize(){this.waitFor(d.default,o.A,_.A,f.A,h.Ay,u.A,p.A),this.syncWith([f.A],O),this.syncWith([u.A],O),this.syncWith([o.A],R)}getIncomingCalls(){return N?I:Array.from(T.values())}getIncomingCallChannelIds(){return N?A:S}getFirstIncomingCallId(){return N?null:S.values().next().value}hasIncomingCalls(){return!N&&S.size>0}}let D=new b(a.h,{CALL_CREATE:C,CALL_UPDATE:C,CALL_DELETE:v,GUILD_RING_START:C,GUILD_RING_STOP:v,VOICE_CHANNEL_SELECT:function(e){let{channelId:t}=e;return y(t)},INCOMING_CALL_MOVE:function(e){let{x:t,y:n}=e;return i={x:t,y:n},s.w.set("IncomingCallStore",i),!1},CHANNEL_DELETE:function(e){let{channel:t}=e;return y(t.id)}})}