Build 571251stable
Module 966532
3,209 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>E});var i=n(439372),r=n(952818),s=n(287809),a=n(977997),o=n(572164),l=n(430795),u=n(274372),c=n(974293),d=n(458977),_=n(526233),h=n(270962),f=n(876474);class p extends i.A{registrations=new Map;activeHandlers=new Map;initialized=!1;terminatedCount=0;actions={RUNNING_GAMES_CHANGE:()=>this.updateActiveHandlers(),CLIPS_SETTINGS_UPDATE:()=>this.updateActiveHandlers(),VOICE_CHANNEL_SELECT:()=>this.updateActiveHandlers(),VOICE_STATE_UPDATES:()=>this.updateActiveHandlers()};ensureInitialized(){if(!this.initialized)for(let e of(this.initialized=!0,[{type:"voiceChannel",name:"ml-audio-classification",isEnabled:()=>(0,c.$i)("Clip signal handler registration")&&u.Ay.getEnableAutoclipping(),importHandler:()=>n.e("53725").then(n.bind(n,691148))},{type:"voiceChannel",name:"distributed-clipping",isEnabled:()=>u.Ay.getEnableAutoclipping()&&d.A.getConfig({location:"Clip signal handler registration"}).enableDistributedClips,importHandler:()=>n.e("78045").then(n.bind(n,359788))},{type:"application",name:"steam-timeline",isEnabled:()=>u.Ay.getEnableAutoclipping()&&h.A.getConfig({location:"Clip signal handler registration"}).enableSteamTimeline,importHandler:()=>n.e("97097").then(n.bind(n,891920))},{type:"application",name:"league-of-legends",applicationId:f.m,isEnabled:()=>u.Ay.getEnableAutoclipping()&&_.A.getConfig({location:"Clip signal handler registration"}).enableLeagueEvents,importHandler:()=>n.e("18549").then(n.bind(n,877588))}]))switch(e.type){case"voiceChannel":this.registerVoiceChannel(e.name,e.importHandler,e.isEnabled);break;case"application":this.registerApplication(e.name,e.applicationId,e.importHandler,e.isEnabled)}}registerApplication(e,t,n,i){this.registrations.set(e,{type:"application",name:e,applicationId:t,isEnabled:i,importHandler:n})}registerVoiceChannel(e,t,n){this.registrations.set(e,{type:"voiceChannel",name:e,isEnabled:n,importHandler:t})}isUserInVoiceChannel(){let e=s.default.getCurrentUser();if(null==e)return!1;let t=a.A.getVoiceStateForUser(e.id);return t?.channelId!=null}async updateActiveHandlers(){if(this.ensureInitialized(),!(0,o.TD)())return void this.stopAllHandlers();let e=this.terminatedCount;for(let[t,n]of this.registrations){let i=()=>{if(!(0,o.TD)()||null!=n.isEnabled&&!n.isEnabled())return!1;switch(n.type){case"application":{let e=new Set(r.Ay.getRunningGames().map(e=>e.id));if(null==n.applicationId)return e.size>0;return e.has(n.applicationId)}case"voiceChannel":return this.isUserInVoiceChannel();default:return!1}},s=()=>this.activeHandlers.has(t),a=i(),l=s();if(a&&!l){let r=(await n.importHandler()).default;if(this.terminatedCount!==e)return;i()&&!s()&&this.startHandler(t,n,r)}else!a&&l&&this.stopHandler(t)}}startHandler(e,t,n){let i=n(l.Ts);i.start(),this.activeHandlers.set(e,{handler:i,registration:t})}stopHandler(e){let t=this.activeHandlers.get(e);null!=t&&(t.handler.stop(),this.activeHandlers.delete(e))}stopAllHandlers(){for(let e of Array.from(this.activeHandlers.keys()))this.stopHandler(e)}getHandlerState(e){let t=this.activeHandlers.get(e);return t?.handler.getState?.()}_initialize(){this.ensureInitialized()}_terminate(){this.terminatedCount++,this.stopAllHandlers()}}let E=new p}