UNPKG

@zoom/meetingsdk

Version:
1 lines 73.5 kB
!function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t,r){"use strict";const i=e=>0==(e&e-1);var n=new class{constructor(){this._highFrequencyLogs={},this.fixVersion=""}setInstance(e,t){this._instance=e,this.fixVersion=t}getMessageFromErrorOrEvent(e,t){let r=e;return t instanceof ErrorEvent?(t.filename&&(r+=" File: ".concat(t.filename)),(t.lineno||t.colno)&&(r+=" Line: ".concat(t.lineno,":").concat(t.colno)),t.message&&(r+=" Message: ".concat(t.message)),t.error&&(r+="\nStack: ".concat(t.error.stack))):t instanceof Error?(t.fileName&&(r+=" File: ".concat(t.fileName)),(t.lineNumber||t.columnNumber)&&(r+=" Line: ".concat(t.lineNumber,":").concat(t.columnNumber)),t.message&&(r+=" Message: ".concat(t.message)),t.stack&&(r+=" Stack: ".concat(t.stack)),t.name&&(r+=" Name: ".concat(t.name)),t.constraint&&(r+=" Constraint: ".concat(t.constraint))):t instanceof CloseEvent?(t.code&&(r+=" Code: ".concat(t.code)),t.reason&&(r+=" Reason: ".concat(t.reason)),r+=" wasClean: ".concat(t.wasClean)):t instanceof DOMException?(t.message&&(r+=" Message: ".concat(t.message)),t.name&&(r+=" Name: ".concat(t.name))):r+=t?t.toString():"",r}error(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this.getMessageFromErrorOrEvent(e,t),this._highFrequencyLogs[e]?this._highFrequencyLogs[e]+=1:this._highFrequencyLogs[e]=1;const r=i(this._highFrequencyLogs[e]);this._instance&&r&&this._instance.error(e,[this.fixVersion])}severityerror(e,t){this._instance&&this._instance.error(JSON.stringify(e),t)}directReport(e,t){var r,i;this._instance&&(t||(t=["MEDIASDK_INFO"]),null===(r=(i=this._instance).directReport)||void 0===r||r.call(i,{msg:e},t))}warn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this.getMessageFromErrorOrEvent(e,t),this._instance&&this._instance.warn(e)}log(e){this._instance&&this._instance.log(e)}clearHighFrequencyLogs(){this._highFrequencyLogs={}}};new Error;const a=new Map;function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"|";return e?e.toString().replaceAll(/[,,]/g,t):""}let o=null,u=null;function h(e,t){var r,i;if(!function(e){const t=performance.now();return(!a.has(e)||t-a.get(e)>5e3)&&(a.set(e,t),!0)}(e))return;let h;try{h=s("object"==typeof t?JSON.stringify(t):t)}catch(e){h=s(t)}null===(r=u)||void 0===r||r("NEM-".concat(e,"-").concat(h)),n.error("NotifyUIError,event=".concat(e,",data=").concat(h)),null===(i=o)||void 0===i||i(e,t)}function l(){return self.GROWABLE_HEAP_I8?self.GROWABLE_HEAP_I8():Module.HEAP8}r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return d})),r.d(t,"f",(function(){return f})),r.d(t,"c",(function(){return _})),r.d(t,"d",(function(){return T})),r.d(t,"e",(function(){return p}));const c="function"!=typeof importScripts;function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;c?n.error(e,t):E(e,t)}function E(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;var r,i,n,a;(t instanceof Error||t instanceof ErrorEvent)&&(e+=" Message: "+(null===(r=t)||void 0===r?void 0:r.message)+" Stack: "+(null!==(i=null===(n=t)||void 0===n||null===(n=n.error)||void 0===n?void 0:n.stack)&&void 0!==i?i:null===(a=t)||void 0===a?void 0:a.stack),t=null);postMessage({status:61,errorMessage:e,errorEvent:t})}function f(e){postMessage({status:61,errorMessage:e,level:"low"})}function _(e){postMessage({status:35,data:e})}function T(e){c?h(-51,e):postMessage({status:-27,where:e})}const m=["","MOZ_","OP_","WEBKIT_"];function p(e,t){for(var r=0;r<m.length;++r){var i=m[r]+t,n=e.getExtension(i);if(n)return n}}new Map,new class{constructor(){this.ssrcInfoMap=new Map,this.timer=null}updateSSRCInfo(e,t){this.ssrcInfoMap.has(e)||this.ssrcInfoMap.set(e,{firstTime:0,lastTime:0,frames:0,fps:0}),this._calculateFPS(e,t),this._removeZeroFPS()}_calculateFPS(e,t){const r=this.ssrcInfoMap.get(e);if(0===r.frames?r.firstTime=t:r.lastTime=t,r.frames+=1,r.frames>2&&r.frames%5==0&&r.lastTime-r.firstTime>=1e3){const t=Math.floor(1e3/((r.lastTime-r.firstTime)/(r.frames-1)));r.fps!==t&&(this._notifyFPS(e,t),r.fps=t),r.firstTime=r.lastTime,r.frames=1}}_removeZeroFPS(){let e=Date.now();this.ssrcInfoMap.forEach((t,r)=>{const i=this.ssrcInfoMap.get(r);i&&e-i.lastTime>2e3&&(this.ssrcInfoMap.delete(r),this._notifyFPS(r,0))})}_notifyFPS(e,t){postMessage({status:66.6,data:{ssrc:e,fps:t}})}_checkIfNewFrameComing(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this._removeZeroFPS(),this.timer=null},2500)}}},function(e,t,r){"use strict";r.r(t),r.d(t,"QOS_DEFAULT_POLLING_INTERVAL",(function(){return i})),r.d(t,"VIDEO_MONITOR_LOG_SECOENDS",(function(){return n})),r.d(t,"THREAD_STATE_IDLE",(function(){return a})),r.d(t,"THREAD_STATE_CREATING",(function(){return s})),r.d(t,"THREAD_STATE_CREATED",(function(){return o})),r.d(t,"MEDIA_S2C_KEEPALIVE",(function(){return u})),r.d(t,"MEDIA_AUDIO_DATA",(function(){return h})),r.d(t,"MEDIA_AUDIO_RTCP",(function(){return l})),r.d(t,"MEDIA_AUDIO_FEATURE",(function(){return c})),r.d(t,"MEDIA_VIDEO_DATA",(function(){return d})),r.d(t,"MEDIA_VIDEO_RTCP",(function(){return E})),r.d(t,"MEDIA_NTP_UPDATE",(function(){return f})),r.d(t,"VIDEO_KEYFRAME_REQ",(function(){return _})),r.d(t,"VIDEO_CAPTURER_RESOLUTION_360P",(function(){return T})),r.d(t,"VIDEO_CAPTURER_RESOLUTION_720P",(function(){return m})),r.d(t,"VIDEO_CAPTURER_RESOLUTION_1080P",(function(){return p})),r.d(t,"UPDATE_ENCRYPTION_GCM_MODEL_KEY",(function(){return R})),r.d(t,"MEDIA_AUDIO_QOS_SESS_DATA",(function(){return v})),r.d(t,"INTERPRETATION_ENABLE",(function(){return g})),r.d(t,"INTERPRETATION_SET_LANG",(function(){return A})),r.d(t,"INTERPRETATION_MUTE",(function(){return x})),r.d(t,"INTERPRETATION_SET_INTERPRETER",(function(){return O})),r.d(t,"DATA_DIRECTION_FROM_RECEIVE",(function(){return b})),r.d(t,"DATA_DIRECTION_FROM_SEND",(function(){return I})),r.d(t,"RWG_WCL_PDU_QOS_DATA",(function(){return y})),r.d(t,"RWG_WCL_PDU_QOS_DATA_VIDEO",(function(){return D})),r.d(t,"serverHeartbeatMaxTimeoutSeconds",(function(){return L})),r.d(t,"RQUEST_ANIMATION_MODE",(function(){return M})),r.d(t,"SET_INTERVAL_MODE",(function(){return N})),r.d(t,"VIDEO_INVALID",(function(){return S})),r.d(t,"VIDEO_RGBA",(function(){return w})),r.d(t,"VIDEO_I420",(function(){return C})),r.d(t,"VIDEO_NV12",(function(){return U})),r.d(t,"VIDEO_BGRA",(function(){return B})),r.d(t,"EVENT_ROLLBACK_BUFFER",(function(){return F})),r.d(t,"EVENT_NEEDMORE_DATA",(function(){return P})),r.d(t,"EVENT_CAPTURE_DATA",(function(){return V})),r.d(t,"EVENT_CACHE_SIZE",(function(){return G})),r.d(t,"WEBCODEC_ENCODE_OFF",(function(){return k})),r.d(t,"WEBCODEC_DECODE_OFF",(function(){return W})),r.d(t,"QosSession",(function(){return H})),r.d(t,"QosConnectType",(function(){return Y})),r.d(t,"MAX_VIDEO_CAPTURE_FPS",(function(){return X})),r.d(t,"MIN_VIDEO_CAPTURE_FPS",(function(){return K})),r.d(t,"VIDEO_CAPTURE_FPS",(function(){return j})),r.d(t,"VIDEO_CAPTURE_20FPS",(function(){return q})),r.d(t,"DOWN_VIDEO_CAPTURE_FPS",(function(){return z})),r.d(t,"LOWER_VIDEO_CAPTURE_FPS",(function(){return Q})),r.d(t,"VIDEO_DATA_MAX_SIZE",(function(){return Z})),r.d(t,"VIDEO_FRAME_BUFFER_SIZE",(function(){return J})),r.d(t,"SHARING_NULL",(function(){return $})),r.d(t,"SHARING_NORMAL",(function(){return ee})),r.d(t,"SHARING_VIDEO_MODE",(function(){return te})),r.d(t,"SHARING_VIDEO_MODE_CAPTURED_FPS",(function(){return re})),r.d(t,"SHARING_NORMAL_MODE_CAPTURED_FPS",(function(){return ie})),r.d(t,"VIDEO_RINGBUF_PKG_NUM",(function(){return ne})),r.d(t,"ADDITIONNAL_MULTITHREAD_NUMBER_ENCODE_FOR_360P",(function(){return ae})),r.d(t,"ADDITIONNAL_MULTITHREAD_NUMBER_ENCODE_FOR_720P",(function(){return se})),r.d(t,"ADDITIONNAL_MULTITHREAD_NUMBER_ENCODE_FOR_1080p",(function(){return oe})),r.d(t,"WCL_PLATFORM_TYPE",(function(){return ue})),r.d(t,"AS_CAPTURE_SOURCE",(function(){return he})),r.d(t,"MEDIA_COMMAND",(function(){return le})),r.d(t,"RENDER_UNSET",(function(){return ce})),r.d(t,"RENDER_IN_WORKER",(function(){return de})),r.d(t,"RENDER_IN_MAIN",(function(){return Ee})),r.d(t,"WEBRTC_NO_AUDIO_MODE",(function(){return fe})),r.d(t,"WEBRTC_COMMPUTER_AUDIO_MODE",(function(){return _e})),r.d(t,"WEBRTC_SHARE_AUDIO_MODE",(function(){return Te})),r.d(t,"WEBRTC_MULTI_AUDIO_MODE",(function(){return me})),r.d(t,"VIDEO_FRAME",(function(){return pe})),r.d(t,"SHARING_FRAME",(function(){return Re})),r.d(t,"MAX_RENDER_WITHOUT_SAB",(function(){return ve})),r.d(t,"ACTIVE_SPEAKER_SSRC",(function(){return ge})),r.d(t,"FACE_MODE_UNKNOW",(function(){return Ae})),r.d(t,"FACE_MODE_USER",(function(){return xe})),r.d(t,"FACE_MODE_ENVIRONMENT",(function(){return Oe})),r.d(t,"ORIGINAL_SOUND_OFF",(function(){return be})),r.d(t,"ORIGINAL_SOUND_ON",(function(){return Ie})),r.d(t,"ORIGINAL_SOUND_STEREO",(function(){return ye})),r.d(t,"ORIGINAL_SOUND_HIGHFIDELITY",(function(){return De})),r.d(t,"ORIGINAL_SOUND_HIGHFIDELITY_STEREO",(function(){return Le})),r.d(t,"SHARE_AUDIO",(function(){return Me})),r.d(t,"ORIGINAL_SOUND_OFF_HIGH_BITRATE",(function(){return Ne})),r.d(t,"PUBLISHER_ICEConnectionState_Failed",(function(){return Se})),r.d(t,"SUBSCRIBER_ICEConnectionState_Failed",(function(){return we})),r.d(t,"NO_MESSAGE_FAILOVER",(function(){return Ce})),r.d(t,"WS_ERROR_FAILOVER",(function(){return Ue})),r.d(t,"WS_CLOSE_FAILOVER",(function(){return Be})),r.d(t,"RUNTIME_ERROR_FAILOVER",(function(){return Fe})),r.d(t,"WEBRTC_FALLBACK_TO_WASM",(function(){return Pe})),r.d(t,"VB_CONSTANT",(function(){return Ve})),r.d(t,"AUDIO_ENCODE_WORKER",(function(){return Ge})),r.d(t,"AUDIO_DECODE_WORKER",(function(){return ke})),r.d(t,"AUDIO_WASM_WORKLET",(function(){return We})),r.d(t,"AUDIO_WEBRTC_WORKLET",(function(){return He})),r.d(t,"DATACHANNEL_MONITOR_SEPARATOR",(function(){return Ye})),r.d(t,"LOADEDMETADATAT_IMEOUT",(function(){return Xe})),r.d(t,"MEDIA_SOLUTION_WEBRTC",(function(){return Ke})),r.d(t,"MEDIA_SOLUTION_WASM",(function(){return je})),r.d(t,"AudioProfile",(function(){return qe})),r.d(t,"REPORT_KEY_SHARE",(function(){return ze})),r.d(t,"REPORT_KEY_NORMAL",(function(){return Qe})),r.d(t,"WEBGL_CONTEXT_INVALID_WHEN_START",(function(){return Ze})),r.d(t,"HEALTH_CHECK_TYPE",(function(){return Je})),r.d(t,"HEALTH_CHECK_OPERATOR",(function(){return $e})),r.d(t,"REMINDER_AFTER_MUTED",(function(){return et})),r.d(t,"RECAPTURE_AUDIO_AFTER_MUTED",(function(){return tt})),r.d(t,"NET_QUALITY_LEVEL",(function(){return rt})),r.d(t,"NET_BW_LEVEL",(function(){return it}));const i=1e3,n=5,a=43,s=44,o=45,u=0,h=1,l=6,c=146,d=2,E=7,f=9,_=17,T=10,m=11,p=12,R=102,v=107,g=0,A=1,x=2,O=3,b=0,I=1,y=108,D=104,L=65,M=0,N=1,S=-1,w=0,C=1,U=2,B=3,F=0,P=1,V=2,G=3,k=1,W=2,H={SESSION_TYPE_CONF:0,SESSION_TYPE_AUDIO:1,SESSION_TYPE_DESKSHARE:2,SESSION_TYPE_VIDEO:3,SESSION_TYPE_CHAT:4,SESSION_TYPE_TELEPHONE:5,SESSION_TYPE_ZC_PING:6,SESSION_TYPE_TOTAL_CNT:7},Y={CONNECT_TYPE_UDP:0,CONNECT_TYPE_TCP:1},X=30,K=1,j=24,q=20,z=15,Q=10,Z=8294400,J=5,$=0,ee=1,te=2,re=15,ie=5,ne=400,ae=3,se=7,oe=8,ue={DESKTOP:0,MOBILE:1,ANDROID:2,IPHONE:3},he={DESKTOP_SOURCE:0,UAC_SOURCE:1},le={SHARE_REMOTE_CONTROL_UAC_MOUSE:144,SHARE_REMOTE_CONTROL_UAC_JPEG_FRAME:145},ce=-1,de=0,Ee=1,fe=0,_e=1,Te=2,me=_e+Te,pe=0,Re=1,ve=25,ge=1,Ae=-1,xe=0,Oe=1,be=0,Ie=1,ye=2|Ie,De=4|Ie,Le=ye|De,Me=8,Ne=16,Se=3,we=107,Ce="100",Ue="101",Be="102",Fe="103",Pe="150",Ve="WCL_M,isWebEnabled:1, isLocalEnabled:1, isSmartBkgnd:1, bkgType:2",Ge=0,ke=1,We=2,He=3,Ye="{[WLCCONT]}",Xe=1e4,Ke=1,je=2,qe={[be]:new Map([["useinbandfec",{value:1,operater:"add"}],["maxaveragebitrate",{value:48e3,operater:"add"}],["maxplaybackrate",{value:24e3,operater:"add"}],["sprop-maxcapturerate",{value:24e3,operater:"add"}],["sprop-stereo",{value:1,operater:"sub"}],["stereo",{value:1,operater:"sub"}]]),[Ie]:new Map([["useinbandfec",{value:1,operater:"sub"}],["maxaveragebitrate",{value:96e3,operater:"add"}],["maxplaybackrate",{value:48e3,operater:"add"}],["sprop-maxcapturerate",{value:48e3,operater:"add"}],["sprop-stereo",{value:1,operater:"add"}],["stereo",{value:1,operater:"add"}]]),[ye]:new Map([["useinbandfec",{value:1,operater:"sub"}],["maxaveragebitrate",{value:96e3,operater:"add"}],["maxplaybackrate",{value:48e3,operater:"add"}],["sprop-maxcapturerate",{value:48e3,operater:"add"}],["sprop-stereo",{value:1,operater:"add"}],["stereo",{value:1,operater:"add"}]]),[De]:new Map([["useinbandfec",{value:1,operater:"sub"}],["maxaveragebitrate",{value:128e3,operater:"add"}],["maxplaybackrate",{value:48e3,operater:"add"}],["sprop-maxcapturerate",{value:48e3,operater:"add"}],["sprop-stereo",{value:1,operater:"add"}],["stereo",{value:1,operater:"add"}]]),[Le]:new Map([["useinbandfec",{value:1,operater:"sub"}],["maxaveragebitrate",{value:128e3,operater:"add"}],["maxplaybackrate",{value:48e3,operater:"add"}],["sprop-maxcapturerate",{value:48e3,operater:"add"}],["sprop-stereo",{value:1,operater:"add"}],["stereo",{value:1,operater:"add"}]]),[Me]:new Map([["useinbandfec",{value:1,operater:"sub"}],["maxaveragebitrate",{value:"96000",operater:"add"}],["maxplaybackrate",{value:"48000",operater:"add"}],["sprop-maxcapturerate",{value:"48000",operater:"add"}]]),[Ne]:new Map([["useinbandfec",{value:1,operater:"add"}],["maxaveragebitrate",{value:64e3,operater:"add"}],["maxplaybackrate",{value:24e3,operater:"add"}],["sprop-maxcapturerate",{value:24e3,operater:"add"}],["sprop-stereo",{value:1,operater:"sub"}],["stereo",{value:1,operater:"sub"}]])},ze="SHARE",Qe="NORMAL",Ze="WebGLContextInvalidWhenStart",Je={VIDEO:0,SHARE:1},$e={PAUSE:0,RESUME:1,STOP:2},et=!0,tt=!1,rt={NET_QUALITY_UNKNOWN:-1,NET_QUALITY_VERY_BAD:0,NET_QUALITY_BAD:1,NET_QUALITY_NOT_GOOD:2,NET_QUALITY_NORMAL:3,NET_QUALITY_GOOD:4,NET_QUALITY_EXCELLENT:5},it={NET_BW_LEVEL_UNKNOWN:-1,NET_BW_LEVEL_VERY_LOW:0,NET_BW_LEVEL_LOW:1,NET_BW_LEVEL_NORMAL:2}},function(e,t,r){"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.VB_VIDEOFRAME_COPYTO_ERROR=t.VB_EVENT_TYPE=void 0,function(e){e.VB_INIT_SUCCESS="VB_INIT_SUCCESS",e.VB_INIT_FAILED="VB_INIT_FAILED",e.VB_GENERATED_FRAME="VB_GENERATED_FRAME",e.VB_SEND_FRAME="VB_SEND_FRAME",e.VB_UPDATE_BG="VB_UPDATE_BG",e.VB_PREDICT_DONE="VB_PREDICT_DONE",e.VB_MODEL_READY="VB_MODEL_READY",e.VB_FREE_MEMORY="VB_FREE_MEMORY",e.VB_VIDEO_FORMAT_UNSUPPORTED="VB_VIDEO_FORMAT_UNSUPPORTED",e.VB_WORKER_INIT="VB_WORKER_INIT",e.VB_WORKER_ERROR="VB_WORKER_ERROR",e.VB_RENDER_CANVAS="VB_RENDER_CANVAS",e.VB_RENDER_FRAME="VB_RENDER_FRAME",e.VB_START="VB_START",e.VB_REQUEST_FRAME="VB_REQUEST_FRAME",e.VB_TOGGLE_VB="VB_TOGGLE_VB",e.VB_STOP="VB_STOP",e.VB_MIRROR="VB_MIRROR",e.VB_GENERATE_STREAM="VB_GENERATE_STREAM",e.VB_STOP_STREAM="VB_STOP_STREAM",e.VB_CHANGE_STREAM_CANVAS_SIZE="VB_CHANGE_STREAM_CANVAS_SIZE",e.VB_GENERATE_FIRST_FRAME="VB_GENERATE_FIRST_FRAME",e.VB_UPDATE_STATS="VB_UPDATE_STATS",e.VB_UPDATE_NEED_FRAME="VB_UPDATE_NEED_FRAME",e.VB_UPDATE_FRAME_RATE="VB_UPDATE_FRAME_RATE",e.VB_RESOLUTION_CHANGE="VB_RESOLUTION_CHANGE"}(i||(t.VB_EVENT_TYPE=i={})),t.VB_VIDEOFRAME_COPYTO_ERROR="VB_VIDEOFRAME_COPYTO_ERROR"},function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var i=r(7);e.exports=function(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,a){function s(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}u((i=i.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(2),s=n(r(6)),o=n(r(9));function u(e){self.postMessage({cmd:a.VB_EVENT_TYPE.VB_WORKER_ERROR,payload:e.error||e.reason})}self.wcl_trace_log=function(){},self.addEventListener("error",u),self.addEventListener("unhandledrejection",u);const h=new class{constructor(){this.vbRender=null,this.frameRate=24,this.frameReader=null,this.videoStream=null,this.requestTimer=null,this.isVBEnabled=!0,this.isStreamEnabled=!1,this.vbWritableStream=null,this.vbFrameWriter=null,this.streamRender=null,this.manualFreeMemory=!1,this.isWaitingFirstFrame=!1,this.fps=0,this.statsTimer=null,this.receivingFps=0,this.receivedFrames=0,this.generatedFrames=0,this.width=0,this.height=0,this.handleMessage=this.handleMessage.bind(this),this.requestFrame=this.requestFrame.bind(this),this.updateStats=this.updateStats.bind(this),this.handleUnsupportedFrame=this.handleUnsupportedFrame.bind(this)}updateStats(){this.receivedFrames+=this.receivingFps,this.generatedFrames+=this.fps,this.postMessage({cmd:a.VB_EVENT_TYPE.VB_UPDATE_STATS,payload:{fps:this.fps,receivingFps:this.receivingFps,generatedFrames:this.generatedFrames,receivedFrames:this.receivedFrames,width:this.width,height:this.height}}),this.fps=0,this.receivingFps=0}postMessage(e){self.postMessage(e)}start(){this.statsTimer&&(clearInterval(this.statsTimer),this.fps=0,this.receivingFps=0,this.receivedFrames=0,this.generatedFrames=0),this.requestTimer&&(this.videoStream?clearTimeout(this.requestTimer):clearInterval(this.requestTimer)),this.videoStream&&!this.frameReader&&(this.frameReader=this.videoStream.getReader()),this.requestFrame(),this.statsTimer=setInterval(this.updateStats,1e3)}stop(e){clearInterval(this.statsTimer),this.fps=0,this.receivingFps=0,this.receivedFrames=0,this.generatedFrames=0,this.updateStats(),this.frameReader?(this.frameReader.releaseLock(),this.frameReader=null,clearTimeout(this.requestTimer)):(clearInterval(this.requestTimer),this.requestTimer=null),e&&this.videoStream&&(this.videoStream.cancel(),this.videoStream=null)}requestFrame(){this.frameReader?this.frameReader.read().then(({value:e,done:t})=>{if(t)clearTimeout(this.requestTimer),this.requestTimer=null;else{const{timestamp:t,displayWidth:r,displayHeight:i}=e;this.frameTimestamp=t,this.frameDisplayHeight=i,this.frameDisplayWidth=r,this.sendFrame(e),this.requestTimer=setTimeout(this.requestFrame,1e3/this.frameRate-4)}}).catch(()=>{clearTimeout(this.requestTimer),this.requestTimer=null}):this.requestTimer=setInterval(()=>{this.postMessage({cmd:a.VB_EVENT_TYPE.VB_REQUEST_FRAME})},1e3/this.frameRate-4)}handleUnsupportedFrame(e=""){this.postMessage({cmd:a.VB_EVENT_TYPE.VB_VIDEO_FORMAT_UNSUPPORTED,payload:e})}sendFrame(e){var t;this.receivingFps++,this.isVBEnabled?this.vb.generateVBFrame(e):(null===(t=this.vbRender)||void 0===t||t.render(e),this.writeVBFrameToStream(e))}writeVBFrameToStream(e){if(this.isStreamEnabled)if(this.vbFrameWriter){let t;if("format"in e)t=e;else if("data_ptr"in e){const{format_width:r,format_height:i,valid_x:n,valid_y:a,valid_width:s,valid_height:o,data:u}=e;t=new VideoFrame(u,{format:"I420",timestamp:this.frameTimestamp,codedWidth:r,codedHeight:i,visibleRect:{x:n,y:a,width:s,height:o},displayHeight:this.frameDisplayHeight,displayWidth:this.frameDisplayWidth})}t&&(this.vbFrameWriter.write(t),t.close())}else this.streamRender&&this.streamRender.render(e)}handleMessage(e){var t,r,n;return i(this,void 0,void 0,(function*(){const{cmd:i}=e.data;switch(i){case a.VB_EVENT_TYPE.VB_SEND_FRAME:{const t=e.data.payload;this.sendFrame(t);break}case a.VB_EVENT_TYPE.VB_UPDATE_BG:{const t=e.data.payload;"blur"===t?this.vb.blur():this.vb.setBackgroundImage(t);break}case a.VB_EVENT_TYPE.VB_FREE_MEMORY:this.vb.free(e.data.payload);break;case a.VB_EVENT_TYPE.VB_WORKER_INIT:{const t=e.data.payload;this.manualFreeMemory=t.needFrame||!1,this.vb=new s.default,this.vb.onModelReady=()=>{this.postMessage({cmd:a.VB_EVENT_TYPE.VB_MODEL_READY})},this.vb.onPredictDone=()=>{this.postMessage({cmd:a.VB_EVENT_TYPE.VB_PREDICT_DONE,payload:this.vb.backend})},this.vb.onUnsupportedFrame=this.handleUnsupportedFrame,this.vb.onVBFrame=e=>{this.fps++;const{valid_width:t,valid_height:r}=e;this.writeVBFrameToStream(e),this.vbRender&&this.vbRender.render(e),this.vb.manualFreeMemory&&this.postMessage({cmd:a.VB_EVENT_TYPE.VB_GENERATED_FRAME,payload:e}),this.isWaitingFirstFrame&&(this.isWaitingFirstFrame=!1,this.postMessage({cmd:a.VB_EVENT_TYPE.VB_GENERATE_FIRST_FRAME})),this.width===t&&this.height===r||(this.postMessage({cmd:a.VB_EVENT_TYPE.VB_RESOLUTION_CHANGE,payload:{width:t,height:r}}),this.width=e.valid_width,this.height=e.valid_height)},this.vb.manualFreeMemory=this.manualFreeMemory;try{yield this.vb.initialize(t),self.postMessage({cmd:a.VB_EVENT_TYPE.VB_INIT_SUCCESS})}catch(e){this.postMessage({cmd:a.VB_EVENT_TYPE.VB_INIT_FAILED,payload:e})}break}case a.VB_EVENT_TYPE.VB_RENDER_CANVAS:{const t=e.data.payload;this.vbRender=new o.default(t,"VB_MODULE_CANVAS"),this.vbRender.onUnsupportedFrame=this.handleUnsupportedFrame;break}case a.VB_EVENT_TYPE.VB_RENDER_FRAME:{const r=e.data.payload;null===(t=this.vbRender)||void 0===t||t.render(r);break}case a.VB_EVENT_TYPE.VB_START:{const{videoStream:t,frameRate:r}=e.data.payload||{};this.frameRate=r||this.frameRate,t&&(this.videoStream=t),this.start(),this.isWaitingFirstFrame=!0;break}case a.VB_EVENT_TYPE.VB_TOGGLE_VB:this.isVBEnabled=e.data.payload;break;case a.VB_EVENT_TYPE.VB_STOP:this.stop(e.data.payload),this.isWaitingFirstFrame=!1;break;case a.VB_EVENT_TYPE.VB_MIRROR:null===(r=this.vbRender)||void 0===r||r.setMirror(e.data.payload);break;case a.VB_EVENT_TYPE.VB_GENERATE_STREAM:{const t=e.data.payload;t?"getWriter"in t?(this.vbWritableStream=t,this.vbFrameWriter=this.vbWritableStream.getWriter()):this.streamRender=new o.default(t,"VB_STREAM_CANVAS_IN_WORKER"):this.vb.manualFreeMemory=!0,this.isStreamEnabled=!0;break}case a.VB_EVENT_TYPE.VB_CHANGE_STREAM_CANVAS_SIZE:{const{width:t,height:r}=e.data.payload;null===(n=this.streamRender)||void 0===n||n.updateSize(t,r);break}case a.VB_EVENT_TYPE.VB_STOP_STREAM:this.isStreamEnabled=!1,this.manualFreeMemory||(this.vb.manualFreeMemory=!1);break;case a.VB_EVENT_TYPE.VB_UPDATE_NEED_FRAME:{const{payload:t}=e.data;this.manualFreeMemory=t,(t||!this.isStreamEnabled||this.vbWritableStream||this.streamRender)&&(this.vb.manualFreeMemory=t);break}case a.VB_EVENT_TYPE.VB_UPDATE_FRAME_RATE:this.frameRate=e.data.payload,this.start();break;default:console.warn("unrecognize")}}))}};self.addEventListener("message",h.handleMessage)},function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,a){function s(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}u((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const n=r(2);r(11);self.LimitWebCodecsEncoderTo360_js=()=>!1,self.LimitWebCodecsDecoderTo360_js=()=>!1,self.hardcodecpunumber=()=>navigator.hardwareConcurrency||1,self.IsSupportMultiThread=()=>0,self.js_info_from_wcl_video_data=(e,t,r,i,n,a)=>{Module._free(t)},self.GetLogLevel_js=()=>0;t.default=class{constructor(){this.isSABEnable=!!self.SharedArrayBuffer,this.afnModelArtifacts={},this.afnIOHandle={},this.baseModelArtifacts={},this.baseIOHandle={},this.modelLoadedCount=0,this.manualFreeMemory=!1,this.backend="",this.afnIOHandle.load=()=>this.afnModelArtifacts,this.afnIOHandle.save=()=>{},this.baseIOHandle.load=()=>this.baseModelArtifacts,this.baseIOHandle.save=()=>{},this.vbFrameCallback=this.vbFrameCallback.bind(this),this.executeBase=this.executeBase.bind(this),this.executeAfn=this.executeAfn.bind(this)}GET_HEAP_U8(){return self.GROWABLE_HEAP_U8?self.GROWABLE_HEAP_U8():Module.HEAPU8}GET_HEAD_F32(){return self.GROWABLE_HEAP_F32?self.GROWABLE_HEAP_F32():Module.HEAPF32}vbFrameCallback(e,t,r,i,n,a,s,o,u,h){const l={data:this.GET_HEAP_U8().subarray(t+0,t+r),data_ptr:this.isSABEnable?t:null,len_of_data:r,format_width:i,format_height:n,valid_x:a,valid_y:s,valid_width:o,valid_height:u,yuv_limited:h};this.onVBFrame&&this.onVBFrame(l),this.isSABEnable&&this.manualFreeMemory||Module._free(t)}executeBase(e,t,r,i){return tf.tidy(()=>{var n=new Float32Array(wasmMemory.buffer,e,t),a=tf.tensor4d(n,[1,144,256,3],"float32"),s=this.baseModel.predict(a);1==s[1].size?(this.mask=Float32Array.from(s[0].as1D(36864).arraySync()),this.prob=Float32Array.from(s[1].as1D(1).arraySync())):(this.mask=Float32Array.from(s[1].as1D(36864).arraySync()),this.prob=Float32Array.from(s[0].as1D(1).arraySync()));let o=new Float32Array(wasmMemory.buffer);o.set(this.mask,r>>2),o.set(this.prob,i>>2)}),0}executeAfn(e,t,r,i,n){return tf.tidy(()=>{var a=new Float32Array(wasmMemory.buffer,e,i),s=new Float32Array(wasmMemory.buffer,t,i),o=new Float32Array(wasmMemory.buffer,r,i/3),u=tf.tensor4d(a,[1,144,256,3],"float32"),h=tf.tensor4d(s,[1,144,256,3],"float32"),l=tf.tensor4d(o,[1,144,256,1],"float32"),c=this.afnModel.predict([u,h,l]);this.mask=Float32Array.from(c.as1D(36864).arraySync()),this.GET_HEAD_F32().set(this.mask,n>>2)}),0}getResourceUrl(e){return{tfJsUrl:e+"/vb-resource/tf.min.js",modelUrl:e+"/vb-resource/dualModel.bin",wasmGlueCodeUrl:this.isSABEnable?e+"/video.mtsimd.js":e+"/video.simd.js",wasmUrl:this.isSABEnable?e+"/video.mtsimd.wasm":e+"/video.simd.wasm",wasmBackendUrl:e+"/vb-resource/tf-backend-wasm.min.js"}}decryptData(e,t,r){return self.crypto.subtle.decrypt({name:"AES-GCM",iv:r},t,e)}modelLoadReady(){this.modelLoadedCount++,2===this.modelLoadedCount&&this.onModelReady&&this.onModelReady()}loadWasm(e,t){return self.Module={locateFile:()=>t},importScripts(e),new Promise((e,t)=>{Module.onRuntimeInitialized=()=>{this.create_vb_no_sab_thread=Module.cwrap("_create_vb_no_sab_thread","number",[]),this.signal_vb_thread_bg=Module.cwrap("_signal_vb_thread_bg","number",["number","number","number","number"]),this.signal_vb_thread_blur=Module.cwrap("_signal_vb_thread_blur","number",["number","number"]),this.signal_vb_thread_video_yuv=Module.cwrap("_signal_vb_thread_video_yuv","number",["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"]),this.signal_vb_thread_video_rgba=Module.cwrap("_signal_vb_thread_video_rgba","number",["number","number","number","number","number","number","number","number"]),e()},Module.onAbort=()=>{t("wasm initialize failed")}})}initTF(e,t,r,n,a){return i(this,void 0,void 0,(function*(){let i=!1,s=!1,o=null;importScripts(e);try{i=yield tf.setBackend("webgl")}catch(e){o=e}if(!i&&r){if(!n||!a)return Promise.reject("No webAssembly backend resource provided");importScripts(n),tf.wasm.setWasmPaths(a+"/vb-resource/");try{s=yield tf.setBackend("wasm")}catch(e){o=e}}return i||s?(this.backend=tf.getBackend(),this.initializeAiModel(t)):Promise.reject(o)}))}initializeAiModel(e){return i(this,void 0,void 0,(function*(){if("string"==typeof e){const t=yield fetch(e);if(!t.ok){const{url:e,status:r}=t;throw new Error(`Fetch model file failed. url: ${e}, status: ${r}`)}e=yield t.arrayBuffer()}yield this.DecryptDualModel(e),this.onPredictDone&&this.onPredictDone()}))}initializeAfnModel(e,t){return i(this,void 0,void 0,(function*(){var r=JSON.parse(t);if(this.afnModelArtifacts.modelTopology=r.modelTopology,this.afnModelArtifacts.format=r.format,this.afnModelArtifacts.generatedBy=r.generatedBy,this.afnModelArtifacts.convertedBy=r.convertedBy,r.weightsManifest)for(var i=0;i<r.weightsManifest.length;i++)this.afnModelArtifacts.weightSpecs=r.weightsManifest[i].weights;r.trainingConfig&&(this.afnModelArtifacts.trainingConfig=r.trainingConfig),r.userDefinedMetadata&&(this.afnModelArtifacts.userDefinedMetadata=r.userDefinedMetadata),this.afnModelArtifacts.weightData=e,this.afnModel=yield tf.loadGraphModel(this.afnIOHandle),this.modelLoadReady();var n=new Float32Array(110592),a=new Float32Array(110592),s=new Float32Array(36864),o=tf.tensor4d(n,[1,144,256,3],"float32"),u=tf.tensor4d(a,[1,144,256,3],"float32"),h=tf.tensor4d(s,[1,144,256,1],"float32");this.afnModel.predict([o,u,h])}))}initializeBaseModel(e,t){return i(this,void 0,void 0,(function*(){var r=JSON.parse(t);if(this.baseModelArtifacts.modelTopology=r.modelTopology,this.baseModelArtifacts.format=r.format,this.baseModelArtifacts.generatedBy=r.generatedBy,this.baseModelArtifacts.convertedBy=r.convertedBy,r.weightsManifest)for(var i=0;i<r.weightsManifest.length;i++)this.baseModelArtifacts.weightSpecs=r.weightsManifest[i].weights;r.trainingConfig&&(this.baseModelArtifacts.trainingConfig=r.trainingConfig),r.userDefinedMetadata&&(this.baseModelArtifacts.userDefinedMetadata=r.userDefinedMetadata),this.baseModelArtifacts.weightData=e,this.baseModel=yield tf.loadGraphModel(this.baseIOHandle),this.modelLoadReady();var n=new Float32Array(110592),a=tf.tensor4d(n,[1,144,256,3],"float32");this.baseModel.predict(a)}))}DecryptDualModel(e){return i(this,void 0,void 0,(function*(){let t=new Uint8Array(e,0,12),r=new Uint8Array(e,12,32);const n=yield self.crypto.subtle.importKey("raw",r,"AES-GCM",!0,["encrypt","decrypt"]);let a=t.length+r.length,s=new Uint32Array(e.slice(a,a+4))[0];a+=4;let o=e.slice(a,a+s);a+=s,s=new Uint32Array(e.slice(a,a+4))[0],a+=4;let u=new Uint8Array(e,a,s);a+=s,s=new Uint32Array(e.slice(a,a+4))[0],a+=4;let h=e.slice(a,a+s);a+=s,s=new Uint32Array(e.slice(a,a+4))[0],a+=4;let l=new Uint8Array(e,a,s);yield Promise.all([(()=>i(this,void 0,void 0,(function*(){const e=yield this.decryptData(l,n,t),r=(new TextDecoder).decode(e);yield this.initializeAfnModel(h,r)})))(),(()=>i(this,void 0,void 0,(function*(){const e=yield this.decryptData(u,n,t),r=(new TextDecoder).decode(e);yield this.initializeBaseModel(o,r)})))()])}))}initialize(e){return i(this,void 0,void 0,(function*(){const{cdnPath:t,enableWasm:r=!1,needFrame:i=!1}=e;let n=null;t&&(n=this.getResourceUrl(t));const{tfJsUrl:a=(null==n?void 0:n.tfJsUrl),wasmGlueCodeUrl:s=(null==n?void 0:n.wasmGlueCodeUrl),wasmUrl:o=(null==n?void 0:n.wasmUrl),model:u=(null==n?void 0:n.modelUrl)}=e;if(!(a&&s&&o&&u))return Promise.reject("Wrong parameter");this.manualFreeMemory=i,yield Promise.all([this.initTF(a,u,r,null==n?void 0:n.wasmBackendUrl,t),this.loadWasm(s,o)]),this.create_vb_no_sab_thread(),this.signal_vb_thread_blur(0,0),self.execute_base=this.executeBase,self.execute_afn=this.executeAfn,self.processed_capture_data_callback=this.vbFrameCallback}))}generateVBFrame(e){return i(this,void 0,void 0,(function*(){if("format"in e){const{format:t}=e,{width:r,height:i}=e.visibleRect;let a,s,o,u,h,l,c,d,E,f,_,T,m,p;if(s=r,o=i,f=e.allocationSize(),"NV12"===t||"BGRA"===t||"I420"===t||"I420A"===t){_=Module._malloc(f);const R=this.GET_HEAP_U8().subarray(_,_+f);try{yield e.copyTo(R)}catch(t){throw e.close(),Module._free(_),new Error(n.VB_VIDEOFRAME_COPYTO_ERROR)}try{"NV12"===t?(u=r*i,h=r*i/2,l=r,c=l,d=0,E=0,this.signal_vb_thread_video_yuv(_,0,s,o,_,u,_+u,h,_+u,h,l,c,c,d,E,3)):"BGRA"===t?(l=r,T=i,d=0,E=0,a=4,this.signal_vb_thread_video_rgba(_,f,s,o,4*s,0,0,a)):"I420"!==t&&"I420A"!==t||(l=r,T=i,c=l/2,m=l/2,u=r*i,h=r*i/4,p=r*i/4,d=0,E=0,a=2,this.signal_vb_thread_video_yuv(_,0,s,o,_,u,_+u,h,_+u+h,h,l,c,c,d,E,a))}catch(e){Module._free(_)}}else this.onUnsupportedFrame&&this.onUnsupportedFrame(t||"");e.close()}else{const{width:t,height:r,data:i}=e,n=Module._malloc(t*r*4);let a=this.GET_HEAP_U8().subarray(n,n+i.length);const s=i.length;a.set(i,0),this.signal_vb_thread_video_rgba(n,s,t,r,4*t,0,0,1)}}))}free(e){Module._free(e)}setBackgroundImage(e){const{data:t,width:r,height:i}=e,n=Module._malloc(t.length);let a=new Uint8Array(t);this.GET_HEAP_U8().subarray(n,n+t.length).set(a,0),this.signal_vb_thread_bg(n,a.length,r,i)}blur(){this.signal_vb_thread_blur(0,0)}}},function(e,t,r){var i=r(3).default,n=r(8);e.exports=function(e){var t=n(e,"string");return"symbol"===i(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var i=r(3).default;e.exports=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,a){function s(e){try{u(i.next(e))}catch(e){a(e)}}function o(e){try{u(i.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}u((i=i.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(10)),s=r(1);t.default=class{constructor(e,t){this.isMirror=!1,this.display=new a.default(e,t,0,void 0,{preserveDrawingBuffer:!1},void 0,!1,!1)}renderFrame(e,t,r,i){if(this.display){let n={x:0,y:0,width:this.display.canvasElement.width,height:this.display.canvasElement.height};this.display.updateRemoteVideoTextures(e,t,i,r,0,!0,n,!1),this.display.drawRemoteVideo(n,this.isMirror)}}render(e){return i(this,void 0,void 0,(function*(){let t=s.VIDEO_RGBA;if("data_ptr"in e){const{data:t,format_width:r,format_height:i,valid_x:n,valid_y:a,valid_width:o,valid_height:u}=e;let h={top:a,left:n,width:o,height:u};this.display.setVideoMode(s.VIDEO_I420),this.renderFrame(r,i,t,h)}else if(self.VideoFrame&&e instanceof VideoFrame){const{format:r,visibleRect:i}=e;if(r&&i){if("I420"===r||"I420A"===r)t=s.VIDEO_I420;else if("NV12"===r)t=s.VIDEO_NV12;else{if("BGRA"!==r)return void(this.onUnsupportedFrame&&this.onUnsupportedFrame(r));t=s.VIDEO_BGRA}const{width:n,height:a}=i,o=new Uint8Array(e.allocationSize()),u={top:0,left:0,width:n,height:a};this.display.setVideoMode(t);try{yield e.copyTo(o),this.renderFrame(n,a,o,u)}catch(e){}e.close()}}else if(e instanceof ImageData){const{width:t,height:r}=e,i={top:0,left:0,width:t,height:r};this.display.setVideoMode(s.VIDEO_RGBA),this.renderFrame(t,r,e.data,i)}}))}updateSize(e,t){this.display.canvasElement.width=e,this.display.canvasElement.height=t}setMirror(e){this.isMirror=e}}},function(e,t,r){"use strict";r.r(t);var i=r(1),n=r(0);function a(e,t){const r=Math.pow(10,t);return Math.floor(e*r)/r}function s(e,t){const r=Math.pow(10,t);return Math.ceil(e*r)/r}function o(e,t,r,i){return h(e,t),u(r,"set"),function(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}(e,r,i),i}function u(e,t){if(void 0===e)throw new TypeError("attempted to "+t+" private static field before its declaration")}function h(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}class l{static isEnableCanvasCtxOptionsOpt(){return t=c,h(e=l,l),u(t,"get"),function(e,t){return t.get?t.get.call(e):t.value}(e,t);var e,t}static setIsEnableCanvasCtxOptionsOpt(e){o(l,l,c,e)}}var c={writable:!0,value:!1},d=l;let E=new Map,f=[];function _(e){e.preventDefault()}function T(e,t,r,n,a,s,o){let u=arguments.length>7&&void 0!==arguments[7]&&arguments[7];this.canvasElement=e,this.canvasID=t,this.contextOptions=a,this.textureindex=r||0,this.texturestride=this.textureindex?3:o?4:6,this.initmask=o||!1,this.reuse=!1,this.isEnableCanvasAlphaChannel=u,T.prototype.ROTATION_CLOCK0=0,T.prototype.ROTATION_CLOCK90=1,T.prototype.ROTATION_CLOCK180=2,T.prototype.ROTATION_CLOCK270=3,this.webGLResources=s,s||(this.initContextGL(),this.contextGL&&(this.webGLContextLostProtect(),this.contextGL.isContextLost()&&this.restoreContext())),this.reinit(s);var h=new ArrayBuffer(4);this.dummpyCursor=new Uint8Array(h),this.dummpyWaterMark=new Uint8Array(h),this.cursorWidth=0,this.cursorHeight=0,this.hasCursor=0,this.hasWaterMark=0,this.watermarkOpacity=.15,this.watermarkData=null,this.watermarkWidth=0,this.watermarkHeight=0,this.isMultiView=!1,this.hasWholeFrame=0,this.croppingParams={},this.croppingParams.top=0,this.croppingParams.left=0,this.croppingParams.width=0,this.croppingParams.height=0,this.textureWidth=0,this.textureHeight=0,this.canvasWidth=0,this.canvasHeight=0,this.picRotation=-1,this.bgColor=[0,0,0],this.cx=0,this.cy=0,this.cw=0,this.ch=0,this.colorRange=-1,this.videoMode=i.VIDEO_INVALID,this.rotation=this.ROTATION_CLOCK0,this.fillMode=0,this.fillModeForResolution=0}function m(e,t,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;var a=e.contextGL;let s=a.canvas.width,o=a.canvas.height;n&&(s=n.width,o=n.height);var u,h,l,c,d=i==e.ROTATION_CLOCK90||i==e.ROTATION_CLOCK270?r:t,E=i==e.ROTATION_CLOCK90||i==e.ROTATION_CLOCK270?t:r,f=d/E*o,_=E/d*s;f>s?(u=0,l=1,c=1-(h=(o-_)/2/o)):(h=0,c=1,l=1-(u=(s-f)/2/s)),u=2*u-1,l=2*l-1,h=1-2*h,c=1-2*c;var T=new Float32Array([l,h,u,h,l,c,u,c,l,h,u,h,l,c,u,c]);a.bindBuffer(a.ARRAY_BUFFER,e.vertexPosBuffer),a.bufferData(a.ARRAY_BUFFER,T,a.DYNAMIC_DRAW)}function p(e,t,r,i,n){var a=e.contextGL,s=i.top/r,o=i.left/t,u=s+(i.height-1)/r,h=o+i.width/t,l=[o,s,h,s,h,u,o,u];n==e.ROTATION_CLOCK90&&(l.unshift(l[6],l[7]),l=l.slice(0,8)),n==e.ROTATION_CLOCK180&&(l.unshift(l[4],l[5],l[6],l[7]),l=l.slice(0,8)),n==e.ROTATION_CLOCK270&&(l.push(l[0],l[1]),l=l.slice(2));var c=l[0],d=l[1];l[0]=l[2],l[1]=l[3],l[2]=c,l[3]=d;var E=new Float32Array([...l,1,0,0,0,1,1,0,1]);a.bindBuffer(a.ARRAY_BUFFER,e.texturePosBuffer),a.bufferData(a.ARRAY_BUFFER,E,a.DYNAMIC_DRAW)}T.prototype.reinit=function(e){if(this.webGLResources=e,!this.contextGL||this.contextGL.isContextLost()||this.contextGL.glInitSucceed||this.webGLResources){if(this.webGLResources&&this.webGLResources.contextgl&&!this.webGLResources.contextgl.isContextLost()){this.contextGL=this.webGLResources.contextgl,this.shaderProgram=this.webGLResources.program,this.waterMarkTextureRef=this.webGLResources.waterMarkTextureRef,this.repeatedWaterMarkTextureRef=this.webGLResources.repeatedWaterMarkTextureRef,this.initTextures(!1),this.vertexPosBuffer=this.webGLResources.vBuffer,this.texturePosBuffer=this.webGLResources.tBuffer;let e=this.contextGL.getError();this.contextGL.glInitSucceed=e!=this.contextGL.NO_ERROR&&e!=this.contextGL.CONTEXT_LOST_WEBGL?0:1}}else{this.initProgram(),this.initmask?this.initTextures(!1):this.initTextures(!0),this.initBuffers();let e=this.contextGL.getError();this.contextGL.glInitSucceed=e!=this.contextGL.NO_ERROR&&e!=this.contextGL.CONTEXT_LOST_WEBGL?0:1}},T.prototype.webGLContextLostSimulate=function(){let e="undefined"==typeof window?self:window;e.webGLEXTSimulate=e.webGLEXTSimulate||[],e.webGLEXTSimulate.push(Object(n.e)(this.contextGL,"WEBGL_lose_context"))},T.prototype.restoreContext=function(){if(this.contextGL)try{var e,t;if(null!==(e=this.canvasElement)&&void 0!==e&&e.loseContextExtension&&!this.canvasElement.restoreTimeoutId&&this.contextGL.isContextLost())this.canvasElement.restoreTimeoutId=setTimeout(()=>{Object(n.d)("WebGLRestoreTimeout")},1500),null===(t=this.canvasElement)||void 0===t||t.loseContextExtension.restoreContext()}catch(e){Object(n.b)("webgl restoreContext exception",e)}},T.prototype.webgGLContextLostCallback=function(e){Object(n.f)("webglcontextlost event: canvas listener size=".concat(f.length,", canvas id: ").concat(this.canvasID,", , ids:").concat(f.join())),e.preventDefault(),this.contextGL.glInitSucceed=0,this.contextOptions&&this.contextOptions.webglcontextlostCallback&&this.contextOptions.webglcontextlostCallback(e,this.contextOptions.params)},T.prototype.removeEventListener=function(e,t){if(e&&t){0,e.restoreTimeoutId&&(clearTimeout(e.restoreTimeoutId),e.restoreTimeoutId=void 0),e.removeEventListener("webglcontextlost",t.contextLostHandler),e.removeEventListener("webglcontextrestored",t.contextRestoredHandler);const r=f.indexOf(this.canvasID);f.splice(r,1),E.delete(e)}},T.prototype.webGLContextRestoredCallback=function(e){Object(n.f)("webglcontextrestored event from canvas id: ".concat(this.canvasID)),this.canvasElement.restoreTimeoutId&&(clearTimeout(this.canvasElement.restoreTimeoutId),this.canvasElement.restoreTimeoutId=void 0),this.reinit(),this.contextOptions&&this.contextOptions.webglcontextrestoredCallback&&this.contextOptions.webglcontextrestoredCallback(e,this.contextOptions.params)},T.prototype.webGLContextLostProtect=function(){this.canvasElement&&!this.canvasElement.loseContextExtension&&(this.canvasElement.loseContextExtension=Object(n.e)(this.contextGL,"WEBGL_lose_context"));let e=this.canvasElement,t=E.get(e);t&&this.removeEventListener(e,t),E.set(e,this),this.contextLostHandler=this.webgGLContextLostCallback.bind(this),this.contextRestoredHandler=this.webGLContextRestoredCallback.bind(this),e.addEventListener("webglcontextlost",this.contextLostHandler,{capture:!1}),e.addEventListener("webglcontextrestored",this.contextRestoredHandler,{capture:!1}),-1===f.indexOf(this.canvasID)&&(f.push(this.canvasID),f.length>4&&Object(n.f)("webglcanvas listener size=".concat(f.length,", ids:").concat(f.join())))},T.prototype.isWebGL=function(){return this.contextGL},T.prototype.isAvaiable=function(){return this.contextGL&&!this.contextGL.isContextLost()&&this.contextGL.glInitSucceed},T.prototype.initContextGL=function(){for(var e,t,r,i=this.canvasElement,a=null,s=["webgl","experimental-webgl","moz-webgl","webkit-3d"],o=0;!a&&o<s.length;){var u=s[o];try{if(d.isEnableCanvasCtxOptionsOpt()){let e={depth:!1,stencil:!1,antialias:!1,alpha:this.isEnableCanvasAlphaChannel};if(this.contextOptions){let t={...this.contextOptions,...e};a=i.getContext(u,t)}else a=i.getContext(u,e)}else a=this.contextOptions?i.getContext(u,this.contextOptions):i.getContext(u)}catch(e){a=null}a&&"function"==typeof a.getParameter||(a=null),++o}if(this.contextGL=a,!a||a.isContextLost())return Object(n.b)("Failed when trying to get WebGLContext on canvas(".concat(null===(e=this.canvasElement)||void 0===e?void 0:e.width,",").concat(null===(t=this.canvasElement)||void 0===t?void 0:t.height,"), gl=").concat(a,", lost=").concat(null===(r=a)||void 0===r?void 0:r.isContextLost())),void Object(n.d)("InitWebGLFail");a.glInitSucceed=0},T.prototype.initProgram=function(){var e=this.contextGL;var t=e.createShader(e.VERTEX_SHADER);e.shaderSource(t,"\n attribute vec4 vertexPos;\n attribute vec4 texturePos;\n attribute vec4 masktexturePos;\n varying vec2 textureCoord;\n varying vec2 masktextureCoord;\n\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos.xy;\n masktextureCoord = masktexturePos.xy;\n }\n "),e.compileShader(t),e.getShaderParameter(t,e.COMPILE_STATUS)||e.isContextLost()||Object(n.f)("webgl Vertex shader failed to compile: "+e.getShaderInfoLog(t));var r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,"\n precision highp float;\n varying highp vec2 textureCoord;\n varying highp vec2 masktextureCoord;\n \n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n uniform sampler2D cursorSampler;\n uniform sampler2D waterMarkSampler;\n uniform sampler2D previewVideoSampler;\n uniform sampler2D maskSampler;\n \n uniform vec4 cursorInfo;\n uniform int onlyRGBA;\n uniform int bgraMode;\n uniform int colorRange;\n uniform int waterMarkFlag;\n uniform int cursorFlag;\n uniform int yuvmode;\n \n const int MAX_ELLIPSE_COUNT = 10;\n uniform int maskFlag; // 0: mask disabled; 1: mask enabled;\n uniform int maskMode; // 0: static mask; 1: dynamic mask;\n uniform vec4 uEllipses[MAX_ELLIPSE_COUNT]; // each ellipse contains (cx, cy, rx, ry) 4-coords\n uniform int uEllipseCount; // how many ellipses will draw\n\n const mat4 YUV2RGB_L = mat4(\n 1.1643828125, 0, 1.59602734375, -0.87078515625,\n 1.1643828125, -0.39176171875, -0.81296875, 0.52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1\n );\n\n const mat4 YUV2RGB_F = mat4(\n 1.0, 0, 1.402, -0.701,\n 1.0, -0.34413, -0.71414, 0.529135,\n 1.0, 1.772, 0, -0.886,\n 0, 0, 0, 1\n );\n\n void main(void) {\n vec4 c;\n if (waterMarkFlag != 1) {\n if (onlyRGBA == 0) {\n highp float y = texture2D(ySampler, textureCoord).r;\n highp float u;\n highp float v;\n\n if (yuvmode == 1) {\n u = texture2D(uSampler, textureCoord).r;\n v = texture2D(vSampler, textureCoord).r;\n } else {\n u = texture2D(uSampler, textureCoord).r;\n v = texture2D(uSampler, textureCoord).a;\n }\n\n if (colorRange == 0) {\n c = vec4(y, u, v, 1) * YUV2RGB_L;\n } else {\n c = vec4(y, u, v, 1) * YUV2RGB_F;\n }\n\n if (cursorFlag == 1) {\n if (cursorInfo.z > 0.0 && \n textureCoord.x >= cursorInfo.x && \n textureCoord.y >= cursorInfo.y && \n textureCoord.x < cursorInfo.x + cursorInfo.z && \n textureCoord.y < cursorInfo.y + cursorInfo.w) {\n \n vec2 cursorCoord = textureCoord - cursorInfo.xy;\n cursorCoord /= cursorInfo.zw;\n vec4 cursor = texture2D(cursorSampler, cursorCoord);\n c = c * (1.0 - cursor.a) + cursor * cursor.a;\n }\n }\n } else {\n c = texture2D(previewVideoSampler, textureCoord);\n if (bgraMode == 1) {\n c = vec4(c.b, c.g, c.r, c.a);\n }\n }\n } else {\n c = texture2D(waterMarkSampler, textureCoord);\n if (c.r == 0.0 && c.g == 0.0 && c.b == 0.0) {\n c.a = 0.0;\n }\n }\n\n if (maskFlag == 1 && waterMarkFlag != 1) {\n vec4 mask = texture2D(maskSampler, masktextureCoord);\n if (maskMode == 0) {\n // -- handle static mask --\n if (mask.r != 0.0 || mask.g != 0.0 || mask.b != 0.0) {\n c = mask * mask.a + c * (1.0 - mask.a);\n }\n } else if (maskMode == 1) {\n // -- handle dynamic mask -- \n bool inEllipse = false; // variable for checking whether the pixel to be drawn hits ellipse\n for (int i = 0; i < MAX_ELLIPSE_COUNT; i++) {\n if (i > uEllipseCount) break;\n\n vec2 ellipseCenter = uEllipses[i].xy;\n vec2 ellipseRadii = uEllipses[i].zw;\n vec2 ellipsePos = masktextureCoord - ellipseCenter;\n\n float ellipseEq = (ellipsePos.x * ellipsePos.x) / (ellipseRadii.x * ellipseRadii.x) + \n (ellipsePos.y * ellipsePos.y) / (ellipseRadii.y * ellipseRadii.y);\n if (ellipseEq <= 1.0) {\n // the pixel in the ellipse range\n inEllipse = true;\n break;\n }\n }\n\n if (inEllipse) {\n c = mask * mask.a + c * (1.0 - mask.a);\n }\n }\n }\n\n if (waterMarkFlag != 1) {\n c.a = 1.0;\n }\n\n gl_FragColor = c;\n }\n"),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)||e.isContextLost()||Object(n.f)("webgl Fragment shader failed to compile: "+e.getShaderInfoLog(r));var i=e.createProgram();e.attachShader(i,t),e.attachShader(i,r),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)||e.isContextLost()||Object(n.f)("webgl Program failed to compile: "+e.getProgramInfoLog(i)),e.useProgram(i),this.shaderProgram=i},T.prototype.initBuffers=function(){var e=this.contextGL,t=this.shaderProgram,r=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1]),e.STATIC_DRAW);var i=e.getAttribLocation(t,"vertexPos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.vertexPosBuffer=r;var n=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,n),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1,1,0,0,0,1,1,0,1]),e.STATIC_DRAW);var a=e.getAttribLocation(t,"texturePos");if(e.enableVertexAttribArray(a),e.vertexAttribPointer(a,2,e.FLOAT,!1,0,0),this.initmask&&!this.masktexturePosBuffer){var s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),e.STATIC_DRAW);var o=e.getAttribLocation(t,"masktexturePos");e.enableVertexAttribArray(o),e.vertexAttribPointer(o,2,e.FLOAT,!1,0,0),this.masktexturePosBuffer=s}this.texturePosBuffer=n},T.prototype.initTextures=function(e){var t=this.contextGL,r=this.shaderProgram;t.pixelStorei(t.UNPACK_ALIGNMENT,1);var n=this.initTexture();this.yTextureRef=n,this.oyTextureRef=n;var a=this.initTexture();this.uTextureRef=a,this.ouTextureRef=a;var s=this.initTexture();if(this.vTextureRef=s,this.ovTextureRef=s,e){this.BindTextures(i.VIDEO_I420);var o=this.initTexture(),u=t.getUniformLocation(r,"cursorSampler");t.uniform1i(u,this.textureindex*this.texturestride+3),this.cursorTextureRef=o;var h=this.initTexture(),l=t.getUniformLocation(r,"waterMarkSampler");t.uniform1i(l,4),this.waterMarkTextureRef=h;var c=this.initTexture();this.repeatedWaterMarkTextureRef=c;var d=this.initTexture(),E=t.getUniformLocation(r,"previewVideoSampler");t.uniform1i(E,