UNPKG

@zoom/meetingsdk

Version:
1 lines 34.9 kB
"use strict";(self.webpackChunk_zoom_webclientjs=self.webpackChunk_zoom_webclientjs||[]).push([[6649,7740,9030],{69138:(e,o,n)=>{n.d(o,{X:()=>i});class i{constructor(e={}){this._onError="function"===typeof e.onError?e.onError:null,this._pending=[],this._pumping=!1}enqueue(e){return"function"!==typeof e?Promise.reject(new TypeError("AsyncSerialTaskQueue.enqueue expects a function")):new Promise((o,n)=>{this._pending.push({run:e,res:o,rej:n}),this._pump()})}clear(){const e=this._pending.splice(0);for(const o of e)o.res()}getDepth(){return this._pending.length}_pump(){this._pumping||(this._pumping=!0,(()=>{return e=this,o=null,n=function*(){for(;this._pending.length;){const{run:n,res:i,rej:t}=this._pending.shift();try{yield n(),i()}catch(e){if(this._onError)try{this._onError(e)}catch(o){}t(e)}}this._pumping=!1},new Promise((i,t)=>{var r=e=>{try{s(n.next(e))}catch(o){t(o)}},c=e=>{try{s(n.throw(e))}catch(o){t(o)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(r,c);s((n=n.apply(e,o)).next())});var e,o,n})())}}},21527:(e,o,n)=>{n.d(o,{k:()=>c});const i=["lifecycleId","lifeCycleID","parentLifecycleId"];const t=["background: #4a4a52","color: #f3f4f6","font-weight: 600","padding: 5px 10px","border-left: 4px solid #9ca3af","border-radius: 3px"].join("; ");function r(e){if("(none)"===e)return t;const o=function(e){let o=2166136261;for(let n=0;n<e.length;n++)o^=e.charCodeAt(n),o=Math.imul(o,16777619);return Math.abs(o)%360}(e);return[`background: linear-gradient(90deg, hsl(${o}, 52%, 30%) 0%, hsl(${o}, 38%, 20%) 100%)`,"color: #f8fafc","font-weight: 700","padding: 5px 10px",`border-left: 4px solid hsl(${o}, 88%, 58%)`,"border-radius: 3px"].join("; ")}function c(e,o,n){const t=console[e]||console.log;if(void 0===n)return void t(o);const c=function(e){if(!e||"object"!==typeof e)return null;for(let o=0;o<i.length;o++){const n=i[o];if(Object.prototype.hasOwnProperty.call(e,n)){const o=e[n];if(null!=o&&""!==o)return String(o)}}return null}(n);if(null==c)return void t(o,n);t(`%c${`${o} | ${c}`}`,r(c),n)}},45226:(e,o,n)=>{n.d(o,{T:()=>t,Y:()=>i});const i="luna://com.webos.service.hccmanager",t="Remote Controller"},57740:(e,o,n)=>{n.r(o),n.d(o,{cancelMicButtonSubscription:()=>F,cancelRecordVoiceSubscription:()=>H,clearLgMicAudioQueue:()=>D,enqueueLgMicAudioTask:()=>g,ensureMicButtonSubscription:()=>X,flushLgMicAudioQueue:()=>h,getInRecordVoiceSession:()=>_,getMicRemoteActionBusy:()=>G,isRecordVoiceStartupInFlight:()=>z,markDeferredJoinEdgeCancel:()=>x,resetMicButtonSubscriberState:()=>Q,setInRecordVoiceSession:()=>N,setLgStore:()=>T,setMicRemoteActionBusy:()=>V,startRecordVoiceDefaultThenGum:()=>W,startRecordVoiceSubscription:()=>Y,subscribeMicButtonPressed:()=>ee});var i=n(23422),t=n(29392),r=n(60780),c=n(33585),s=n(45226),l=n(50498),u=n(97502),a=n(18306),d=n(69138),p=n(21527),m=(e,o,n)=>new Promise((i,t)=>{var r=e=>{try{s(n.next(e))}catch(o){t(o)}},c=e=>{try{s(n.throw(e))}catch(o){t(o)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(r,c);s((n=n.apply(e,o)).next())});const E="luna://com.webos.service.voiceconductor",v="recordVoice",f="key/isMicButtonPressed",S=500;let A=null;const I=new d.X({onError:e=>{console.warn("[LG-mic] lgMicAudioQueue task failed",{error:String(e)})}});function g(e){return I.enqueue(e)}function D(){I.clear()}function h(){return g(()=>{})}function T(e){A=e,e||D()}let R=null,b=null,w=!1;const _=()=>w,N=e=>{w=e};let U=0,y=null;function C(e){y&&((0,p.k)("warn","[LG-mic] recordVoice lifecycle cleared",{lifecycleId:y,reason:e}),y=null)}let P=null,M=null,O=!1;const G=()=>O,V=e=>{const o=document.querySelector("button.join-audio-container__btn");o&&(o.disabled=e),O=e};let k=0,L=!1,B=!1;function z(){return L}function x(){B=!0}function j(){var e,o;const n=null==(o=null==(e=null==window?void 0:window.webOS)?void 0:e.service)?void 0:o.request;return"function"===typeof n?n:null}function F(){if(P&&"function"===typeof P.cancel)try{P.cancel(),console.warn("[LG-mic] cancelMicButtonSubscription \u2014 subscription cancelled")}catch(e){console.error("[LG-mic] cancelMicButtonSubscription \u2014 cancel threw",e)}P=null}function Q(){}function q(e){var o,n,i,t,r;const c=null!=e?e:null==(o=null==A?void 0:A.getState)?void 0:o.call(A),l=null==(n=null==c?void 0:c.audio)?void 0:n.activeMicrophone,u=null==(i=null==c?void 0:c.audio)?void 0:i.microphoneDevicesList;if(!l||!Array.isArray(u))return!1;const a=u.find(e=>e.deviceId===l);return null!=(r=null==(t=null==a?void 0:a.label)?void 0:t.includes(s.T))&&r}function $(e){const o={};return e&&(o.voiceTicket=e),o}function J(e){return m(this,null,function*(){console.warn("[LG-mic] requestStopRecordingVoice \u2014 called",{voiceTicket:e||"(none)",webOSAvailable:!!j()});const o=j();if(o)return new Promise(function(n,i){try{o(E,{method:"stopRecordingVoice",parameters:$(e),subscribe:!1,onSuccess:function(o){console.warn("confcall-api-success",{serviceUri:"luna://com.webos.service.voiceconductor",method:"stopRecordingVoice",voiceTicket:e||"",payload:o}),n(o)},onFailure:function(e){console.error("confcall-api-failure",{method:"stopRecordingVoice",error:e}),i(e)}})}catch(t){console.error("confcall-api-exception",{method:"stopRecordingVoice",error:String(t)}),i(t)}});console.error("confcall-api-failure",{method:"stopRecordingVoice",error:"webOS service unavailable"})})}function H(){if((0,p.k)("warn","[LG-mic] cancelRecordVoiceSubscription \u2014 called",{lifecycleId:y||"(none)",hasSubscription:!!R,hasCancelFn:"function"===typeof(null==R?void 0:R.cancel),currentVoiceTicket:b||"(none)"}),R&&"function"===typeof R.cancel)try{R.cancel(),console.warn("[LG-mic] cancelRecordVoiceSubscription \u2014 subscription cancelled successfully")}catch(e){console.error("Failed to cancel LG voice conductor subscription | recordVoice",e)}else console.warn("[LG-mic] cancelRecordVoiceSubscription \u2014 no active subscription to cancel");R=null,b=null,N(!1)}function Y(e){return m(this,null,function*(){const o=j();if((0,p.k)("warn","[LG-mic] startRecordVoiceSubscription \u2014 called",{lifecycleId:y||"(none)",params:e,webOSAvailable:!!o,currentVoiceTicket:b||"(none)",inRecordVoiceSession:_(),hasExistingSubscription:!!R}),!o)return console.error("[LG-mic] startRecordVoiceSubscription \u2014 aborted: webOS service unavailable"),!1;if(_()&&R&&b)return(0,p.k)("warn","[LG-mic] startRecordVoiceSubscription \u2014 skipped: session already active",{lifecycleId:y||"(none)",currentVoiceTicket:b}),!0;U+=1,y=`${"recordVoice"}-${Date.now().toString(36)}-${U.toString(36)}`,L=!0;try{return(0,p.k)("log","[LG-mic] startRecordVoiceSubscription \u2014 running stopRecordingVoiceFlow first",{lifecycleId:y}),yield function(){return m(this,null,function*(){const e=b;(0,p.k)("warn","[LG-mic] stopRecordingVoiceFlow \u2014 start",{lifecycleId:y||"(none)",voiceTicket:e||"(none)",inRecordVoiceSession:_(),hasSubscription:!!R});try{yield J(e),console.warn("[LG-mic] stopRecordingVoiceFlow \u2014 requestStopRecordingVoice resolved")}catch(o){(0,p.k)("error","[LG-mic] stopRecordingVoiceFlow \u2014 requestStopRecordingVoice threw",{lifecycleId:y||"(none)",error:String(o)})}finally{H(),(0,p.k)("warn","[LG-mic] stopRecordingVoiceFlow \u2014 complete, voiceTicket cleared",{lifecycleId:y||"(none)"})}})}(),(0,p.k)("warn","[LG-mic] startRecordVoiceSubscription \u2014 stop flow complete, subscribing now",{lifecycleId:y}),yield new Promise(function(n,i){let r=!1;const c=function(e){r||(r=!0,e||C("startup-finish-false"),n(e))};try{(0,p.k)("warn","[LG-mic] startRecordVoiceSubscription \u2014 calling window.webOS.service.request for recordVoice",{lifecycleId:y,params:e}),R=o(E,{method:v,parameters:e,subscribe:!0,onSuccess:function(e){var o,n,i;const s=y||"(none)",a=b;e&&e.voiceTicket&&(b=e.voiceTicket,a!==b&&(0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 voiceTicket updated",{lifecycleId:s,prevTicket:a,newTicket:b})),function(e){if(!e||"object"!==typeof e)return void console.error("[LG-mic] syncInRecordVoiceSessionFromPayload \u2014 ignored: invalid payload",{payload:e});const o=e.event,n=_();"recordingStart"===o?(N(!0),console.warn("[LG-mic] syncInRecordVoiceSessionFromPayload \u2014 recordingStart",{before:n,after:_()})):"recordingStop"===o?(N(!1),console.warn("[LG-mic] syncInRecordVoiceSessionFromPayload \u2014 recordingStop",{before:n,after:_()})):"failure"===o||e.errorCode?(N(!1),console.error("[LG-mic] syncInRecordVoiceSessionFromPayload \u2014 failure/errorCode",{event:o,errorCode:e.errorCode,before:n,after:_()})):console.log("[LG-mic] syncInRecordVoiceSessionFromPayload \u2014 unhandled event, no state change",{event:o,inRecordVoiceSession:_()})}(e);const d=null!=(o=null==e?void 0:e.event)?o:"unknown";if((0,p.k)("warn","recordvoice-event",{lifecycleId:s,event:d,socketPath:null!=(n=null==e?void 0:e.socketPath)?n:"",voiceTicket:null!=(i=null==e?void 0:e.voiceTicket)?i:"",returnValue:null==e?void 0:e.returnValue,raw:e}),"recordingStop"===d||"recordingStart"===d){const e=s,o=d;g(()=>{var n,i,r;if("recordingStop"===o)if((0,l.C)()){const o=(0,u.e0)();o?((0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 recordingStop in preview, calling mutePreviewAudio",{lifecycleId:e}),o.mute()):(0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 recordingStop in preview but no preview actions registered (preview hook not mounted)",{lifecycleId:e})}else{const o=null==A?void 0:A.dispatch,c=null==(r=null==(i=null==(n=null==A?void 0:A.getState)?void 0:n.call(A))?void 0:i.meeting)?void 0:r.currentUser;"function"===typeof o&&null!=(null==c?void 0:c.userId)?((0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 recordingStop received, dispatching muteAudio",{lifecycleId:e,userId:c.userId}),o((0,t.Mo)(c.userId))):(0,p.k)("error","[LG-mic] recordVoice onSuccess \u2014 recordingStop ignored: store or current user unavailable",{lifecycleId:e,hasDispatch:"function"===typeof o,userId:null==c?void 0:c.userId})}else if("recordingStart"===o)if((0,l.C)()){const o=(0,u.e0)();o?((0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 recordingStart in preview, calling unmutePreviewAudio",{lifecycleId:e}),o.unmute()):(0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 recordingStart in preview but no preview actions registered (preview hook not mounted)",{lifecycleId:e})}else(0,p.k)("log","[LG-mic] recordVoice onSuccess \u2014 recordingStart in meeting, no audio side-effect",{lifecycleId:e})}).catch(()=>{})}else(0,p.k)("log","[LG-mic] recordVoice onSuccess \u2014 event has no audio side-effect",{lifecycleId:s,eventType:d});r?(0,p.k)("log","[LG-mic] recordVoice onSuccess \u2014 promise already settled, ignoring",{lifecycleId:s,eventType:d}):e&&!1===e.returnValue?((0,p.k)("error","[LG-mic] recordVoice onSuccess \u2014 returnValue false, resolving finish(false)",{lifecycleId:s,payload:e}),c(!1)):((0,p.k)("warn","[LG-mic] recordVoice onSuccess \u2014 resolving finish(true)",{lifecycleId:s,eventType:d}),c(!0))},onFailure:function(e){const o=y||"(none)";(0,p.k)("error","recordvoice-event",{lifecycleId:o,event:"failure",error:e}),(0,p.k)("error","[LG-mic] recordVoice onFailure \u2014 subscription failed",{lifecycleId:o,error:e,settled:r}),R=null,b=null,N(!1),C("subscription-onFailure"),r||(r=!0,i(e))}})}catch(s){(0,p.k)("error","[LG-mic] startRecordVoiceSubscription \u2014 exception thrown when calling webOS.service.request",{lifecycleId:y||"(none)",error:String(s)}),r||(r=!0),C("startup-exception"),i(s)}})}finally{!function(){var e;if(!B)return;if(B=!1,!A)return;const o=A.getState();(0,a.V)(o)&&!(null==(e=o.meeting.currentUser)?void 0:e.muted)||H()}(),L=!1,R||C("startup-finally-no-subscription")}})}function W(e){return m(this,null,function*(){var o,n;if((0,p.k)("warn","[LG-mic] startRecordVoiceDefaultThenGum \u2014 called",{parentLifecycleId:null!=e?e:"(none)",inRecordVoiceSession:_(),currentVoiceTicket:b||"(none)"}),_()&&R&&b)return(0,p.k)("warn","[LG-mic] startRecordVoiceDefaultThenGum \u2014 skipped: already in recordVoice session",{parentLifecycleId:null!=e?e:"(none)",currentVoiceTicket:b}),!1;if(!q(null==(o=null==A?void 0:A.getState)?void 0:o.call(A)))return(0,p.k)("warn","[LG-mic] startRecordVoiceDefaultThenGum \u2014 skipped: active mic is not Remote Controller",{parentLifecycleId:null!=e?e:"(none)"}),!1;try{const o=yield Y({subscribe:!0,socketType:"none"});if((0,p.k)("warn","[LG-mic] startRecordVoiceDefaultThenGum \u2014 startRecordVoiceSubscription resolved",{parentLifecycleId:null!=e?e:"(none)",recordOk:o}),!o)return(0,p.k)("error","[LG-mic] startRecordVoiceDefaultThenGum \u2014 recordVoice failed, skipping GUM",{parentLifecycleId:null!=e?e:"(none)"}),!1}catch(a){return(0,p.k)("error","[LG-mic] startRecordVoiceDefaultThenGum \u2014 startRecordVoiceSubscription threw",{parentLifecycleId:null!=e?e:"(none)",error:String(a)}),!1}(0,p.k)("warn","[LG-mic] startRecordVoiceDefaultThenGum \u2014 recordVoice OK, proceeding to getUserMedia",{parentLifecycleId:null!=e?e:"(none)"});const i=null==A?void 0:A.getState(),t=null==(n=null==i?void 0:i.meeting)?void 0:n.currentUser;if(!(null==i?void 0:i.audio)||!(null==t?void 0:t.userId))return(0,p.k)("error","[LG-mic] startRecordVoiceDefaultThenGum \u2014 aborted: store or current user unavailable",{parentLifecycleId:null!=e?e:"(none)",hasStore:!!A,hasState:!!i,hasAudioState:!!(null==i?void 0:i.audio),userId:null==t?void 0:t.userId}),!1;const{activeMicrophone:s,microphoneDevicesList:l=[]}=i.audio,u=l.find(e=>e.deviceId===s);return r.C.avSocket.sendSocket(c.CHANGE_AUDIO_MIC,{ssrc:0,AudioSelectValue:"default"===s?null:s,microphoneLabel:null==u?void 0:u.label,defaultMuted:null==t?void 0:t.muted}),!0})}function Z(e){const o=j();if(console.warn("[LG-mic] subscribeMicButtonPressedCore \u2014 called",{hasActiveSubscription:!!P,webOSRequestAvailable:!!o}),F(),!o)return console.error("[LG-mic] subscribeMicButtonPressedCore \u2014 aborted: webOS.service.request is not a function"),()=>{};const n=o=>{console.log("[LG-mic] core \u2014 raw payload received",{payload:o});const n=function(e){if(console.log("[LG-mic] parseMicButtonPressedState \u2014 raw payload:",e),null==e||"object"!==typeof e)return console.error("[LG-mic] parseMicButtonPressedState \u2014 rejected: payload is null or not an object",{payload:e}),null;if(!1===e.returnValue)return console.error("[LG-mic] parseMicButtonPressedState \u2014 rejected: returnValue is false",{payload:e}),null;if(!Object.prototype.hasOwnProperty.call(e,"pressed"))return console.error('[LG-mic] parseMicButtonPressedState \u2014 rejected: no "pressed" key',{payloadKeys:Object.keys(e)}),null;const o=e.pressed;return console.log("[LG-mic] parseMicButtonPressedState \u2014 pressed value:",o),!0===o||"true"===o||1===o?(console.log("[LG-mic] parseMicButtonPressedState \u2192 true (pressed)",{rawValue:o}),!0):!1===o||"false"===o||0===o?(console.log("[LG-mic] parseMicButtonPressedState \u2192 false (released)",{rawValue:o}),!1):(console.error("[LG-mic] parseMicButtonPressedState \u2014 rejected: unrecognised pressed value",{rawValue:o}),null)}(o);if(console.log("[LG-mic] core \u2014 pressed value:",n),null===n)return void console.error("[LG-mic] core \u2014 ignored: parseMicButtonPressedState returned null");const i=!0===M,t=i&&!1===n,r=M;if(M=n,console.log("[LG-mic] core \u2014 edge detection",{pressed:n,wasPressed:i,isReleaseEdge:t,prevLastHccMicPressed:r,lastHccMicPressed:M}),!t)return void console.log("[LG-mic] core \u2014 not a release edge, no action");const c=Date.now(),s=c-k;if(s<S)console.warn("[LG-mic] core \u2014 debounced (too soon)",{timeSinceLast:s,debounceMs:S});else{k=c;try{e()}catch(l){console.error("[LG-mic] core \u2014 onReleaseEdge threw",{error:String(l)})}}};console.warn("[LG-mic] core \u2014 registering HCC subscription",{serviceUri:s.Y,method:f});try{P=o(s.Y,{method:f,parameters:{subscribe:!0},onSuccess:function(e){console.log("[LG-mic] core \u2014 HCC isMicButtonPressed onSuccess",{payload:e}),n(e)},onFailure:function(e){console.error("[LG-mic] core \u2014 HCC subscription onFailure",{error:e})},subscribe:!0}),console.warn("[LG-mic] core \u2014 HCC subscription registered successfully")}catch(t){return console.error("[LG-mic] core \u2014 exception during HCC subscribe call",{error:String(t)}),()=>{}}const i=P;return function(){P===i&&F()}}function K(){if(G())console.warn("[LG-mic] handleMicButtonReleaseEdge \u2014 release edge skipped: micRemoteActionBusy is true");else{if((0,l.C)()){const e=(0,u.b2)();return void("function"===typeof e?(console.warn("[LG-mic] handleMicButtonReleaseEdge \u2014 isInPreview, calling handleAudioClick"),Y({subscribe:!0,socketType:"none"}),e()):console.warn("[LG-mic] handleMicButtonReleaseEdge \u2014 isInPreview but no handleAudioClick registered (preview hook not mounted)"))}A?(console.warn("[LG-mic] handleMicButtonReleaseEdge \u2014 not in preview, calling toggleMute"),function(e){m(this,null,function*(){const{getState:o,dispatch:n}=e,{meeting:{currentUser:r}}=o();if(console.warn("[LG-mic] toggleMute \u2014 evaluating",{userId:null==r?void 0:r.userId,isJoinAudio:(0,i.lc)(r),muted:null==r?void 0:r.muted,inRecordVoiceSession:_(),micRemoteActionBusy:O}),(null==r?void 0:r.userId)&&(0,i.lc)(r)){V(!0);try{if(r.muted){if(!q(o()))return console.warn("[LG-mic] toggleMute \u2014 active mic is not Remote Controller, dispatching UNMUTE without recordVoice flow"),void(yield n((0,t.pb)(r.userId)));console.warn("[LG-mic] toggleMute \u2014 dispatching UNMUTE + starting recordVoice flow"),yield W().catch(()=>{}).then(()=>n((0,t.pb)(r.userId)))}else{console.warn("[LG-mic] toggleMute \u2014 user is unmuted \u2192 stopping recordVoice (will mute)"),n((0,t.Mo)(null==r?void 0:r.userId));const e=b;H(),J(e).catch(e=>{console.error("[LG-mic] toggleMute \u2014 background stopRecordingVoice failed (state already cleared)",{error:String(e)})})}}finally{V(!1)}}else console.warn("[LG-mic] toggleMute \u2014 skipped: audio not connected",{userId:null==r?void 0:r.userId,isJoinAudio:(0,i.lc)(r)})})}(A)):console.error("[LG-mic] handleMicButtonReleaseEdge \u2014 in-meeting release edge but lgStore is null; cannot toggleMute")}}function X(){return P?(console.log("[LG-mic] ensureMicButtonSubscription \u2014 already active, no-op"),()=>{}):(console.warn("[LG-mic] ensureMicButtonSubscription \u2014 registering default HCC handler"),Z(K))}function ee(e){return console.warn("[LG-mic] subscribeMicButtonPressed \u2014 called",{hasStore:!!e}),T(e),F(),X()}},97502:(e,o,n)=>{n.d(o,{Ay:()=>O,b2:()=>P,e0:()=>M});var i=n(31099),t=n(66765),r=n(85698),c=n(43190),s=n(19813),l=n(88213),u=n(70239),a=n(60780),d=n(2543),p=n(52734),m=n(53252),E=n(39560),v=n(21062),f=n(27523),S=n(39313),A=n(23422),I=n(49924),g=n(81217),D=n(93242),h=n(15225),T=n(50891),R=n(12904),b=(e,o,n)=>new Promise((i,t)=>{var r=e=>{try{s(n.next(e))}catch(o){t(o)}},c=e=>{try{s(n.throw(e))}catch(o){t(o)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(r,c);s((n=n.apply(e,o)).next())});const w=(0,T.rY)(["Preview","Video"]),_=(0,T.rY)(["Preview","Audio"]),N=(0,R.Zr)(["Preview","Video"]),U=(0,R.Zr)(["Preview","Audio"]);let y=null,C=null;function P(){return y}function M(){return C}const O=({isAudioInitSuccess:e=!1,isVideoInitSuccess:o=!1,isVbPreReady:T=!1,cache:R=t.RU.PREVIEW_OPTIONS,canAudioUnmute:P=!0,canVideoUnmute:M=!0,toggleShowAllowPermissionPrompt:O,toggleShowNoPermissionConfirm:G,toggleShowAskPermissionConfirm:V,isOnHold:k})=>{const[L,B]=(0,i.useState)(t.nz.LOADING),[z,x]=(0,i.useState)(t.U_.LOADING),[j,F]=(0,i.useState)((0,c.Hv)(R)),[Q,q]=(0,i.useState)((0,c.og)(R)),[$,J]=(0,i.useState)(!1),[H,Y]=(0,i.useState)(t.q3.NONE),[W,Z]=(0,i.useState)([]),[K,X]=(0,i.useState)([]),[ee,oe]=(0,i.useState)(null),[ne,ie]=(0,i.useState)(null),[te,re]=(0,i.useState)([]),[ce,se]=(0,i.useState)(null),[le,ue]=(0,i.useState)(!1),[ae,de]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),Ee=z===t.U_.OPEN,ve=(0,i.useRef)(null),fe=(0,i.useRef)({audio:e,video:o}),Se=(0,i.useRef)({audio:!1,video:!1});fe.current.audio=e,fe.current.video=o;const[Ae,Ie]=(0,i.useState)(null),ge=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=(0,c.Dw)(Pe);ge.current=e,Ie(e)},[]);const De=(0,i.useRef)(null);De.current={audioStatus:De.current?De.current.audioStatus:L,videoStatus:z,canAudioUnmute:P,canVideoUnmute:M};const he=(0,i.useCallback)(e=>{De.current.audioStatus=e,B(e)},[]),Te=(0,i.useCallback)(e=>{De.current.videoStatus=e,x(e)},[]),Re=(0,i.useCallback)(e=>{re(e),e.length<=0?(Y(t.q3.CAN_NOT_DETECT_CAMERA),Te(t.U_.CAN_NOT_DETECT_CAMERA)):(Y(t.q3.NONE),(0,A.u5)(e)&&r.A.emit(t.od.REAL_CAMERA_LIST_GOT))},[Te]),be=(0,i.useCallback)(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),(0,A.u5)(te)||!(0,f.id)((0,c.Bp)())&&!(0,f.AI)((0,c.Bp)(),!0)?J(!0):(ve.current=setTimeout(()=>{(0,A.u5)(te)||De.current.videoStatus===t.U_.OPEN||J(!0),ve.current=null},5e3),navigator.mediaDevices.getUserMedia({video:!0}).then(e=>{if(e.getTracks().forEach(e=>{e.stop()}),p.A.emit("VIDEO_DEVICE_PERMISSION_GRANT"),(0,A.u5)(te))return ve.current&&(clearTimeout(ve.current),ve.current=null),void J(!0);r.A.on(t.od.REAL_CAMERA_LIST_GOT,()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),J(!0)})}).catch(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),J(!0)}))},[te]),we=(0,i.useCallback)(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),ge.current.stopVideo(),J(!1)},[]),_e=(0,i.useCallback)(()=>{(0,s.x_)("preview user start capture video",[s.NY.user_action,s.NY.video_telemetry]),be(a.C.isVDIConnected),Te(t.U_.CAPTURING),q(t.U_.OPEN),(0,c.w6)(R,t.U_.OPEN)},[R,Te,be]),Ne=(0,i.useCallback)(()=>{const e=(0,c.Hv)(R),{canAudioUnmute:o}=De.current;e===t.nz.UNMUTED&&o?(Ae.unmuteAudio(),he(t.nz.UNMUTED)):o?(Ae.muteAudio(),he(t.nz.MUTED)):(Ae.muteAudio(),he(t.nz.DISABLED)),Y(t.q3.NONE)},[he,Ae,R,De]),Ue=(0,i.useCallback)(()=>{l.Job.start(u.A.PREVIEW_CONNECT_AUDIO,()=>{Ae.leaveAudio(),Ae.connectAudio({captureAudio:!0}),he(t.nz.CAPTURING)}).then(()=>{Ne()})},[Ae,Ne,he]),{handleAskPermissionResolve:ye,handleAskPermissionPEPCButtonInvalid:Ce}=(0,S.C)({setAskPermissionPromptVisible:V,setAllowPermissionPromptVisible:O,setNoPermissionConfirmVisible:G,loading:!1,isPreviewMode:!0,isViewOnly:(0,c.Bp)(),avSocket:Ae,isOnHold:k});(0,i.useEffect)(()=>{if(!Ae)return;const e=e=>{(0,d.has)(e,"microphones")&&Z(e.microphones),(0,d.has)(e,"speakers")&&X(e.speakers),(0,d.has)(e,"cameras")&&Re(e.cameras),(0,d.has)(e,"activeMicrophone")&&(oe(e.activeMicrophone),e.activeMicrophone!==ee&&Ae.changeMicrophone(e.activeMicrophone)),(0,d.has)(e,"activeSpeaker")&&ie(e.activeSpeaker),(0,d.has)(e,"activeCamera")&&(se(e.activeCamera),e.activeCamera!==ce&&Ee&&Ae.changeCamera(e.activeCamera))},o=e=>{(0,d.has)(e,"activeMicrophone")&&(oe(e.activeMicrophone),Ae.changeMicrophone(e.activeMicrophone)),(0,d.has)(e,"activeSpeaker")&&ie(e.activeSpeaker),(0,d.has)(e,"activeCamera")&&(se(e.activeCamera),Ee&&Ae.changeCamera(e.activeCamera))};return p.A.on("DEVICE_CHANGED",e),p.A.on("DEVICE_SELECTED",o),()=>{p.A.off("DEVICE_CHANGED",e),p.A.off("DEVICE_SELECTED",o)}},[Ae,ne,ce,ee,Re,Ee]),(0,i.useEffect)(()=>{p.A.watchInitComplete().then(e=>{Z(e.microphones),X(e.speakers),oe(e.activeMicrophone),ie(e.activeSpeaker),Re(e.cameras),se(e.activeCamera)})},[Re]),(0,i.useEffect)(()=>{b(void 0,null,function*(){const{backgroundIdx:e}=yield(0,h.sA)();$&&Ae&&(le||ae||-1===e||!e)&&Ae.startVideo(a.C.isVDIConnected)})},[$,Ae,ae,le]),(0,i.useEffect)(()=>{const{audioStatus:e}=De.current,o=ge.current;P?P&&e===t.nz.DISABLED&&(he(t.nz.MUTED),(0,c.$Q)(R,t.nz.MUTED)):(e===t.nz.MUTED&&(he(t.nz.DISABLED),(0,c.$Q)(R,t.nz.MUTED)),e===t.nz.UNMUTED&&(o.muteAudio(),he(t.nz.DISABLED),(0,c.$Q)(R,t.nz.MUTED)))},[P]),(0,i.useEffect)(()=>{const{videoStatus:e}=De.current;M?M&&e===t.U_.DISABLED&&(Te(t.U_.CLOSED),(0,c.w6)(R,t.U_.CLOSED)):(e===t.U_.OPEN&&we(),Te(t.U_.DISABLED),(0,c.w6)(R,t.U_.CLOSED))},[M]),(0,i.useEffect)(()=>()=>{var e;ve.current&&(clearTimeout(ve.current),ve.current=null);const{audioStatus:o,videoStatus:n}=De.current;n!==t.U_.OPEN&&n!==t.U_.CAPTURING&&n!==t.U_.FORBIDDEN||(w.log("Stop video before leaving preview page"),N.debug({logTitle:"Stop video before leaving preview page"}),we()),o!==t.nz.MUTED&&o!==t.nz.UNMUTED&&o!==t.nz.CAPTURING&&o!==t.nz.FORBIDDEN||(_.log("Leave audio before leaving preview page"),U.debug({logTitle:"Leave audio before leaving preview page"}),null==(e=ge.current)||e.leaveAudio()),(0,c.YD)()},[we]);const Pe=(0,I.wA)();(0,i.useEffect)(()=>{if(!Ae)return;const e=(0,c.Bp)(),o=(e,o=!0)=>{if(Se.current.audio)return;Se.current.audio=!0;const n=(0,c.Hv)(R)!==t.nz.NOT_CONNECTED,i=!o||[v.xz.GRANTED_AUDIO_VIDEO,v.xz.GRANTED_AUDIO].indexOf(e)>-1;(0,s.x_)(`preview init audio success, need join audio: ${n}, has permission: ${i}`,[s.NY.audio_telemetry]),i?n?l.Job.start(u.A.PREVIEW_CONNECT_AUDIO,()=>{Ae.connectAudio({captureAudio:i}),he(t.nz.CAPTURING)}).then(()=>{Ne()}).catch():he(t.nz.NOT_CONNECTED):(Ae.connectAudio({captureAudio:i}),he(t.nz.FORBIDDEN))},n=(e,o=!0)=>{if(Se.current.video)return;Se.current.video=!0,Ae.mirrorMyVideo();const n=!o||[v.xz.GRANTED_AUDIO_VIDEO,v.xz.GRANTED_VIDEO].indexOf(e)>-1,i=(0,c.og)(R),{videoStatus:r,canVideoUnmute:l}=De.current,u=i===t.U_.OPEN&&l;(0,s.x_)(`preview init video success, has permission: ${n}, should start video: ${u}`,[s.NY.video_telemetry]),n?r!==t.U_.DISABLED&&(u?(be(),r===t.U_.LOADING&&Te(t.U_.CAPTURING)):Te(l?t.U_.CLOSED:t.U_.DISABLED)):Te(t.U_.FORBIDDEN)};return r.A.on(t.od.AUDIO_INIT_SUCCESS,()=>{Pe((0,g.yX)(!0)),(0,f.AI)(e,!0)||(0,f.id)(e)?l.Job.watch(u.A.REQUEST_PERMISSION).then(e=>{o(e)}):o(void 0,!1)}),r.A.on(t.od.AUDIO_CONNECT_SUCCESS,()=>{l.Job.complete(u.A.PREVIEW_CONNECT_AUDIO)}),r.A.on(t.od.AUDIO_LEAVE_SUCCESS,()=>{he(t.nz.NOT_CONNECTED)}),r.A.on(t.od.AUDIO_FORBIDDEN,()=>{he(t.nz.FORBIDDEN),Y(t.q3.AUDIO_FORBIDDEN)}),r.A.on(t.od.VIDEO_INIT_SUCCESS,()=>{Pe((0,g.T1)(!0)),(0,f.AI)(e,!0)||(0,f.id)(e)?l.Job.watch(u.A.REQUEST_PERMISSION).then(e=>{n(e)}):n(void 0,!1)}),r.A.on(t.od.CAMERA_IS_TAKEN,()=>{Te(t.U_.FORBIDDEN),Y(t.q3.CAMERA_TAKEN),J(!1)}),r.A.on(t.od.VIDEO_START_SUCCESS,()=>{Te(t.U_.OPEN),Y(t.q3.NONE)}),r.A.on(t.od.VIDEO_FORBIDDEN,()=>{Te(t.U_.FORBIDDEN),Y(t.q3.VIDEO_FORBIDDEN),J(!1)}),r.A.on(t.od.VIDEO_BACKGROUND_INIT_SUCCESS,()=>{Pe((0,g.m$)(!0)),ue(!0)}),r.A.on(t.od.VIDEO_BACKGROUND_INIT_ERROR,()=>b(void 0,null,function*(){yield(0,h.X6)(),de(!0)})),r.A.on(t.od.VDI_WEBRTC_REDIR_SDK_CONNECTED,e=>{e?(me(!0),a.C.isVDIConnected=!0):(me(!1),a.C.isVDIConnected=!1)}),(0,f.AI)(e,!0)||(0,f.id)(e)?l.Job.watch(u.A.REQUEST_PERMISSION).then(e=>{fe.current.audio&&o(e),fe.current.video&&n(e)}):(fe.current.audio&&o(void 0,!1),fe.current.video&&n(void 0,!1)),()=>{r.A.offAll(Object.values(t.od))}},[Ae]);const Me=e=>{var o;if(!(0,E.DCm)())return;const n=null==(o=a.C)?void 0:o.externalController;if(!(null==n?void 0:n.notifyConnectorZoomMsg))return;const i=e===t.nz.UNMUTED?m.pS.UNMUTE_AUDIO:m.pS.MUTE_AUDIO;n.notifyConnectorZoomMsg(m.$H.UI,i)},Oe=e=>b(void 0,null,function*(){if((0,E.DCm)())try{const{startRecordVoiceSubscription:o,cancelRecordVoiceSubscription:i}=yield n.e(7740).then(n.bind(n,57740));e===t.nz.UNMUTED?o({subscribe:!0,socketType:"none"}):e===t.nz.MUTED&&i()}catch(o){}}),Ge=()=>{const{canAudioUnmute:e}=De.current;switch(L){case t.nz.MUTED:(0,s.x_)("preview user unmute audio",[s.NY.user_action,s.NY.audio_telemetry]),Ae.unmuteAudio(),Me(t.nz.UNMUTED),Oe(t.nz.UNMUTED),(0,c.$Q)(R,t.nz.UNMUTED),he(t.nz.UNMUTED);break;case t.nz.UNMUTED:(0,s.x_)("preview user mute audio",[s.NY.user_action,s.NY.audio_telemetry]),Ae.muteAudio(),Me(t.nz.MUTED),Oe(t.nz.MUTED),(0,c.$Q)(R,t.nz.MUTED),he(t.nz.MUTED);break;case t.nz.NOT_CONNECTED:{const o=(0,c.YZ)(R)&&e;l.Job.start(u.A.PREVIEW_CONNECT_AUDIO,()=>{Ae.connectAudio({isAudioOn:o}),he(t.nz.CAPTURING),o?(F(t.nz.UNMUTED),(0,c.$Q)(R,t.nz.UNMUTED)):(F(t.nz.DISABLED),(0,c.$Q)(R,t.nz.MUTED))}).then(()=>{o?(Ae.unmuteAudio(),Me(t.nz.UNMUTED),Oe(t.nz.UNMUTED),he(t.nz.UNMUTED)):e?(Ae.muteAudio(),Me(t.nz.MUTED),Oe(t.nz.MUTED),he(t.nz.MUTED)):(Ae.muteAudio(),he(t.nz.DISABLED))}).catch();break}case t.nz.FORBIDDEN:(0,f.id)((0,c.Bp)())&&"granted"!==a.C.micPermissionStatus.state?(0,D.A)({permissionType:v.gD.MICROPHONE,onPermissionGranted:()=>{Ue()},onPEPCButtonInvalid:()=>{Ue()}}):Ue();case t.nz.DISABLED:case t.nz.LOADING:case t.nz.CAPTURING:}},Ve=()=>{var e;const o=null==(e=De.current)?void 0:e.audioStatus;o===t.nz.UNMUTED?((0,s.x_)("preview forced mute audio",[s.NY.user_action,s.NY.audio_telemetry]),Ae.muteAudio(),(0,c.$Q)(R,t.nz.MUTED),he(t.nz.MUTED)):_.warn("[preview] mutePreviewAudio \u2014 skipped",{status:o})},ke=()=>{var e;const o=null==(e=De.current)?void 0:e.audioStatus;o===t.nz.MUTED?((0,s.x_)("preview forced unmute audio",[s.NY.user_action,s.NY.audio_telemetry]),Ae.unmuteAudio(),(0,c.$Q)(R,t.nz.UNMUTED),he(t.nz.UNMUTED)):_.warn("[preview] unmutePreviewAudio \u2014 skipped",{status:o})};(0,i.useEffect)(()=>{T&&ue(!0)},[T]);const Le=(0,i.useRef)(Ge);Le.current=Ge,(0,i.useEffect)(()=>{const e=()=>{var e;return null==(e=Le.current)?void 0:e.call(Le)};return y=e,()=>{y===e&&(y=null)}},[]);const Be=(0,i.useRef)({mute:Ve,unmute:ke});return Be.current={mute:Ve,unmute:ke},(0,i.useEffect)(()=>{const e={mute:()=>{var e,o;return null==(o=null==(e=Be.current)?void 0:e.mute)?void 0:o.call(e)},unmute:()=>{var e,o;return null==(o=null==(e=Be.current)?void 0:e.unmute)?void 0:o.call(e)}};return C=e,()=>{C===e&&(C=null)}},[]),{audioStatus:L,videoStatus:z,vbStatus:le,nextAudioStatus:j,nextVideoStatus:Q,willRenderVideo:$,error:H,setError:Y,handleAudioClick:Ge,mutePreviewAudio:Ve,unmutePreviewAudio:ke,handleVideoClick:()=>{switch(z){case t.U_.OPEN:(0,s.x_)("preview user stop capture video",[s.NY.user_action,s.NY.video_telemetry]),we(),Te(t.U_.CLOSED),(0,c.w6)(R,t.U_.CLOSED);break;case t.U_.CLOSED:_e();break;case t.U_.FORBIDDEN:(0,f.id)((0,c.Bp)())&&"granted"!==a.C.cameraPermissionStatus.state?(0,D.A)({permissionType:v.gD.CAMERA,onPermissionGranted:()=>{_e()},onPEPCButtonInvalid:()=>{_e()}}):_e();case t.U_.LOADING:case t.U_.CAPTURING:}},speakers:K,microphones:W,cameras:te,activeSpeaker:ne,activeMicrophone:ee,activeCamera:ce,isVDIConnected:pe,setAudioStatus:he,setVideoStatus:Te,handleAskPermissionResolve:ye,handleAskPermissionPEPCButtonInvalid:Ce}}},8167:(e,o,n)=>{n.d(o,{A:()=>m});var i=n(74848),t=(n(31099),n(2543)),r=n.n(t),c=n(5718),s=n(50030),l=n(17344);const u=(0,n(30235).H)()?l.q0:l.Zx,a=({title:e})=>(0,i.jsxs)("div",{className:"allow-tip-box",children:[(0,i.jsx)("div",{className:"allow-tip-title",children:e}),(0,i.jsx)("div",{className:"allow-tip-desc",children:(0,s.BL)(u)})]}),d="permission_allow_tip",p={};p.show=r().debounce(e=>{const o=!!p[d];let n;o||(n=o||e?(0,i.jsx)(a,{title:s.Fo}):(0,i.jsx)(a,{title:s.vx}),c.A.uniqueToast({name:d,message:n,aliveTime:0,update:!0,className:"permission-allow-tip"}))},100,{leading:!0}),p.close=()=>{delete p[d],c.A.close(d)};const m=p},95381:(e,o,n)=>{n.d(o,{A:()=>d});var i=n(74848),t=(n(31099),n(50030)),r=n(30235),c=n(17344),s=n(5718);const l=(0,r.H)()?c.q0:c.Zx,u="allow-permission-prompt",a={show:()=>{s.A.uniqueToast({name:u,message:(0,i.jsxs)("div",{className:"allow-tip-box",children:[(0,i.jsx)("div",{className:"allow-tip-title",children:t.NJ}),(0,i.jsx)("div",{className:"allow-tip-desc",children:(0,t.DR)(l)})]}),aliveTime:0,className:"permission-allow-tip"})},close:()=>{s.A.close(u)}},d=a},39313:(e,o,n)=>{n.d(o,{C:()=>v});var i=n(31099),t=n(88213),r=n(70239),c=n(60780),s=n(85698),l=n(21062),u=n(27523),a=n(95381),d=n(8167),p=n(39560),m=n(12904);const E=(0,m.Zr)(["media_permissions"]),v=e=>{const{setAskPermissionPromptVisible:o,setAllowPermissionPromptVisible:n,setNoPermissionConfirmVisible:m,loading:v,isPreviewMode:f,isViewOnly:S,avSocket:A,isOnHold:I}=e,g=(0,p.Xbj)()&&!I,D=(0,i.useCallback)(e=>{const n=e.target.permissionStatus,{micPermissionStatus:i,cameraPermissionStatus:s}=c.C,a=n===l.yB.GRANTED&&e.target.type===l.gD.CAMERA_MICROPHONE||"granted"===i.state&&"granted"===s.state,d=n===l.yB.GRANTED&&e.target.type===l.gD.MICROPHONE||"granted"===i.state&&"granted"!==s.state;a?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO_VIDEO):d&&(t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO),(0,u._G)(l.Ap.video,l.nj.DISMISS)),o(!1)},[]),h=(0,i.useCallback)(e=>{"fallback"!==e&&t.Job.start(r.A.REQUEST_PERMISSION)},[]),T=(0,i.useCallback)((e="init")=>{var n,i,s,d;if(!v&&A){if((0,u.id)(S)){const n=["microphone","camera"].map(e=>navigator.permissions.query({name:e}));h(e),Promise.all(n).then(([e,n])=>{!!(0,u.PM)(l.Ap.audio)||!!(0,u.PM)(l.Ap.video)||e.state!==l.yB.PROMPT||n.state!==l.yB.PROMPT?e.state===l.yB.GRANTED&&n.state!==l.yB.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO):e.state!==l.yB.GRANTED&&n.state===l.yB.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_VIDEO):e.state===l.yB.GRANTED&&n.state==l.yB.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO_VIDEO):t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.DENIED):o(!0)})}else if((0,u.AI)(S,f)){const o=(0,u.PM)(l.Ap.video),n=(0,u.PM)(l.Ap.audio),i=!!o||!!n,c=(0,u.EJ)(l.Ap.audio),s=(0,u.EJ)(l.Ap.video);h(e),i?s===l.nj.GRANTED&&c!==l.nj.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_VIDEO):s!==l.nj.GRANTED&&c===l.nj.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO):s===l.nj.GRANTED&&c===l.nj.GRANTED?t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.GRANTED_AUDIO_VIDEO):t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.DENIED):(()=>{if(g){const e=["microphone","camera"].map(e=>navigator.permissions.query({name:e}));Promise.all(e).then(([e,o])=>{e.state===l.yB.PROMPT&&o.state===l.yB.PROMPT?(a.A.show(),setTimeout(()=>{null==A||A.requestPermission()},2e3)):null==A||A.requestPermission()})}else null==A||A.requestPermission()})()}u.EA.log(`Web client media permissions initial value. Microphone: ${null==(n=c.C.micPermissionStatus)?void 0:n.state}, Camera: ${null==(i=c.C.cameraPermissionStatus)?void 0:i.state}`,["meida_permisisons_init"]),E.debug({logTitle:`Web client media permissions initial value. Microphone: ${null==(s=c.C.micPermissionStatus)?void 0:s.state}, Camera: ${null==(d=c.C.cameraPermissionStatus)?void 0:d.state}`},["meida_permisisons_init"])}},[v,A]),R=(0,i.useCallback)(()=>{o(!1),T("fallback")},[T]);return(0,i.useEffect)(()=>{v||T()},[v,T]),(0,i.useEffect)(()=>{s.A.on(l.yU.REQUEST_PERMISSION_RESULT,e=>{if(g&&a.A.close(),e!==l.xz.REQUESTING_AUDIO){if([l.xz.DENIED,l.xz.DISMISS].indexOf(e)>-1)if((0,p.Xbj)()){(0,u.PM)(l.Ap.audio)||(0,u._G)(l.Ap.audio,l.nj.DISMISS);(0,u.PM)(l.Ap.video)||(0,u._G)(l.Ap.video,l.nj.DISMISS),t.Job.complete(r.A.REQUEST_PERMISSION,l.xz.DENIED)}else m(!0);else t.Job.complete(r.A.REQUEST_PERMISSION,e);g&&d.A.close(),n(!1)}else g&&d.A.show(!0)}),s.A.on(l.yU.REQUEST_PERMISSION_POP,()=>{g?(a.A.close(),d.A.show()):(0,u.Q6)(S,I)&&n(!0)})},[]),{handleAskPermissionResolve:D,handleAskPermissionPEPCButtonInvalid:R}}},50498:(e,o,n)=>{n.d(o,{C:()=>t,X:()=>r});var i=n(52270);const t=()=>!!i.Task.getPendingTasks().concat(i.Task.getRunningTasks()).find(e=>e.isPreview),r=()=>i.Task.getPendingTasks().concat(i.Task.getRunningTasks()).filter(e=>e.isPreview||e.isWaitingForHost)}}]);