web3dlink 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3dlink",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "Web3DLink.es.js",
6
6
  "scripts": {
package/web3dlink.es.js CHANGED
@@ -18974,13 +18974,17 @@ class LoadStream {
18974
18974
  log("数据通道已连通", c);
18975
18975
  }));
18976
18976
  let S = !0;
18977
- return b.on("datachanneltext", (c) => {
18977
+ if (b.on("datachanneltext", (c) => {
18978
18978
  S && (S = !1, u.onSceneInitialized ? u.onSceneInitialized(c) : log("场景初始化加载成功", c)), u.onDatachanneltext ? u.onDatachanneltext(c) : log("接收数据", c);
18979
18979
  }), b.on("error", u.onError || ((c) => {
18980
18980
  console.error(c.message);
18981
18981
  })), b.on("info", u.onInfo || ((c) => {
18982
18982
  log("LarkSRClientEvent info", c);
18983
- })), await b.connect({ appliId: m.appliId }), u.onConnected && u.onConnected(b), A.init(b), b.audioElement && (b.audioElement.volume = 0), A._gameApi;
18983
+ })), await b.connect({ appliId: m.appliId }), u.onConnected && u.onConnected(b), A.init(b), b.audioElement && (b.audioElement.volume = 0), b.params.initResolutionType === 1) {
18984
+ const c = b.screenState.syncClientViewport.width, f = b.screenState.syncClientViewport.height;
18985
+ b == null || b.setCloudAppSize(c, f), console.log("resize", c, f);
18986
+ }
18987
+ return A._gameApi;
18984
18988
  }
18985
18989
  // 初始化插件
18986
18990
  init(m) {
package/web3dlink.umd.js CHANGED
@@ -69,4 +69,4 @@ a=extmap-allow-mixed`)!==-1){const p=s.sdp.split(`
69
69
  void main(void) {
70
70
  gl_FragColor = texture2D(uSampler, vTextureCoord);
71
71
  }
72
- `;class ai{get inited(){return this._inited}get canvas(){return this._canvas}get video(){return this._video}get gl(){return this._gl}get shaderProgram(){return this._shaderProgram}constructor(){this._inited=!1,this._canvas=null,this._video=null,this._gl=null,this._shaderProgram=null,this.vertexPosition=0,this.textureCoord=0,this.uSampler=0,this.buffers=null,this.texture=null,this.drawFrames=0,this.playing=!1,this.timeupdate=!1,this.copyVideo=!1,this.startInternal=!1,this.draw=this.draw.bind(this)}init(n,a){this._inited=!1,this._canvas=n,this._video=a,this._video.addEventListener("playing",()=>{this.playing=!0,this.checkReady()}),this._video.addEventListener("timeupdate",()=>{this.timeupdate=!0,this.checkReady()});const s=n.getContext("webgl");if(s==null)return c.warn("webgl init failed Your browser or machine may not support it",s,n),!1;this._gl=s,s.clearColor(0,0,0,1),s.clear(s.COLOR_BUFFER_BIT);const p=Ie.initShaderProgram(s,Ie.fullscreenVsSource,Ie.fullscreenFsSource);return p?(this._shaderProgram=p,this.vertexPosition=s.getAttribLocation(p,"aVertexPosition"),this.textureCoord=s.getAttribLocation(p,"aTextureCoord"),this.uSampler=s.getUniformLocation(p,"uSampler"),this.buffers=Ie.initfullScreenBuffers(s),this.buffers!=null&&this.buffers.position!=null&&this.buffers.textureCoord&&(Ie.setPositionAttribute(s,this.buffers.position,this.vertexPosition),Ie.setTextureAttribute(s,this.buffers.textureCoord,this.textureCoord),s.bindBuffer(s.ARRAY_BUFFER,this.buffers.position),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.buffers.indices),s.bindBuffer(s.ARRAY_BUFFER,this.buffers.textureCoord),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.buffers.indices),s.bindBuffer(s.ARRAY_BUFFER,null)),this.texture=Ie.initTexture(s),this._inited=!0,!0):(c.warn("initShaderProgram failed",s,Ie.fullscreenVsSource,Ie.fullscreenFsSource),!1)}checkReady(){this.playing&&this.timeupdate&&(this.copyVideo=!0)}startCanvasRender(){this.stopCanvasRender(),this.startInternal=!0,this.draw()}stopCanvasRender(){this.drawFrames!=-1&&(window.cancelAnimationFrame(this.drawFrames),this.drawFrames=-1),this.startInternal=!1}draw(n=0,a=0,s=1920,p=1080){if(!this.inited||this.gl==null||!(this.gl&&this.texture&&this.video&&this.copyVideo))return;Ie.updateTexture(this.gl,this.texture,this.video);let v=this.gl;v.viewport(n,a,s,p),v.clearColor(0,0,0,1),v.disable(v.DEPTH_TEST),v.clear(v.COLOR_BUFFER_BIT),v.useProgram(this.shaderProgram),v.activeTexture(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,this.texture),v.uniform1i(this.uSampler,0);{const R=v.UNSIGNED_SHORT;v.drawElements(v.TRIANGLES,6,R,0)}this.startInternal&&(this.drawFrames=window.requestAnimationFrame(this.draw))}updateVideo(n){this._video=n,this.gl&&this.texture&&Ie.updateTexture(this.gl,this.texture,n)}}function si(o){cn(o,"svelte-1we6aa5",'@charset "UTF-8";.pxy-render.pxy-render-release.svelte-1we6aa5.svelte-1we6aa5{margin:0;padding:0}.pxy-render.pxy-render-release.svelte-1we6aa5 video.svelte-1we6aa5{transition:none}.pxy-render.pxy-render-release.svelte-1we6aa5 .showVideo.svelte-1we6aa5{position:relative;object-fit:fill;width:100%;min-height:100%}.pxy-render.pxy-render-release.svelte-1we6aa5 .hiddenVideo.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px;object-fit:fill}.pxy-render.pxy-render-release.svelte-1we6aa5 .hiddenRenderCanvas.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px}.pxy-render.pxy-render-release.svelte-1we6aa5 .showRenderCanvas.svelte-1we6aa5{position:relative;object-fit:fill}.pxy-render.pxy-render-release.svelte-1we6aa5 .audio.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px}')}function ui(o){let n,a,s,p,v,O,R,L,C,w,V,_,z,B,K,te,$,ke,ge,Ce,Fe,Xe,Ue;return{c(){n=pe("div"),a=pe("video"),O=Ke(),R=pe("canvas"),_=Ke(),z=pe("canvas"),ke=Ke(),ge=pe("audio"),U(a,"class",s=It(o[2]?"hiddenVideo":"showVideo")+" svelte-1we6aa5"),U(a,"width",p=o[0].container.width+"px"),U(a,"height",v=o[0].container.height+"px"),a.autoplay=o[1],a.playsInline=!0,U(a,"webkit-playsinline",!0),U(a,"preload","auto"),U(a,"x5-video-player-type","h5"),U(a,"x5-video-player-fullscreen","true"),U(a,"x5-video-orientation","portrait"),U(R,"class",L=It(o[2]&&o[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5"),U(R,"style",C="width:"+o[0].container.width+"px; height:"+o[0].container.height+"px"),U(R,"width",w=o[10](o[0])+"px"),U(R,"height",V=o[11](o[0])+"px"),U(z,"class",B=It(o[2]&&!o[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5"),U(z,"style",K="width:"+o[0].container.width+"px; height:"+o[0].container.height+"px"),U(z,"width",te=o[10](o[0])+"px"),U(z,"height",$=o[11](o[0])+"px"),U(ge,"class","audio svelte-1we6aa5"),ge.controls=!1,ge.autoplay=!0,U(n,"class","pxy-render pxy-render-release svelte-1we6aa5"),U(n,"width",Ce=o[0].container.width+"px"),U(n,"height",Fe=o[0].container.height+"px")},m(ce,D){Re(ce,n,D),he(n,a),o[30](a),he(n,O),he(n,R),o[31](R),he(n,_),he(n,z),o[32](z),he(n,ke),he(n,ge),o[33](ge),Xe||(Ue=[Mt(a,"loadedmetadata",o[8]),Mt(ge,"loadedmetadata",o[9])],Xe=!0)},p(ce,D){4&D[0]&&s!==(s=It(ce[2]?"hiddenVideo":"showVideo")+" svelte-1we6aa5")&&U(a,"class",s),1&D[0]&&p!==(p=ce[0].container.width+"px")&&U(a,"width",p),1&D[0]&&v!==(v=ce[0].container.height+"px")&&U(a,"height",v),2&D[0]&&(a.autoplay=ce[1]),12&D[0]&&L!==(L=It(ce[2]&&ce[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5")&&U(R,"class",L),1&D[0]&&C!==(C="width:"+ce[0].container.width+"px; height:"+ce[0].container.height+"px")&&U(R,"style",C),1&D[0]&&w!==(w=ce[10](ce[0])+"px")&&U(R,"width",w),1&D[0]&&V!==(V=ce[11](ce[0])+"px")&&U(R,"height",V),12&D[0]&&B!==(B=It(ce[2]&&!ce[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5")&&U(z,"class",B),1&D[0]&&K!==(K="width:"+ce[0].container.width+"px; height:"+ce[0].container.height+"px")&&U(z,"style",K),1&D[0]&&te!==(te=ce[10](ce[0])+"px")&&U(z,"width",te),1&D[0]&&$!==($=ce[11](ce[0])+"px")&&U(z,"height",$),1&D[0]&&Ce!==(Ce=ce[0].container.width+"px")&&U(n,"width",Ce),1&D[0]&&Fe!==(Fe=ce[0].container.height+"px")&&U(n,"height",Fe)},i:tt,o:tt,d(ce){ce&&Oe(n),o[30](null),o[31](null),o[32](null),o[33](null),Xe=!1,St(Ue)}}}const kn="mediaPlayedMute",Gt="mediaPlayedFailed";function ci(o,n,a){__webpack_require__(6131);let s,p,v,O,R,L,{screenState:C}=n,{mutePlayWhenFailed:w}=n,{autoPlay:V=!0}=n,{appState:_}=n,{canvasRender:z=!1}=n,{forceCanvas2d:B=!1}=n,{appParams:K}=n,{forceContinuePlayWhenPause:te=!0}=n,$=!1,ke=0;const ge=Kn();async function Ce(){if(!s)throw c.warn("play video failed. need video element ref"),new Error("no video found");try{c.info("playVideo"),await s.play(),ge("mediaPlayed"),c.info("playVideo success")}catch(H){throw c.info("playVideo failed",H),H}}function Fe(){s?$?(a(5,p.muted=!1,p),p.play().then(()=>{c.info("audio playout success",p.muted)}).catch(H=>{c.info("audio playout failed with user confirm.",H,p.muted)})):a(4,s.muted=!1,s):c.err("no render found")}function Xe(){Fe()}function Ue(){ce(),D()}function ce(){ke!=-1&&(window.clearTimeout(ke),ke=-1)}function D(){if(!B&&L.inited)return L.draw(0,0,Ae(C),Me(C)),void(ke=window.setTimeout(()=>{D()},1e3/K.frameRate));if(!z)return;const H=O;if(!H)return void c.warn("draw call without context");if(!s)return void c.warn("draw call without videoElement");const Je=Ae(C),ut=Me(C);H.clearRect(0,0,Je,ut),H.drawImage(s,0,0,Je,ut),ke=window.setTimeout(()=>{D()},1e3/K.frameRate)}function Ae(H){return I.os==="iOS"&&B?H.container.width:H.appSize.width?H.appSize.width:H.container.width}function Me(H){return I.os==="iOS"?H.container.width:H.appSize.height?H.appSize.height:H.container.height}function We(){te&&(Ce(),Xe())}var ee;return dn(()=>{L=new ai,L.init(R,s),O=v.getContext("2d"),O==null&&c.err("init capture context failed.",O,v),z&&Ue(),a(4,s.playsInline=!0,s),s.addEventListener("pause",We),document.addEventListener("WeixinJSBridgeReady",()=>{c.warn("WeixinJSBridgeReady play video"),V&&Ce().then(()=>{c.info("ios auto play success")}).catch(H=>{c.warn("ios auto play failed",H)})},!1),I.os==="iOS"&&V&&(c.info("on mount ios play video"),Ce().then(()=>{c.info("ios auto play success")}).catch(H=>{c.warn("ios auto play failed",H)}))}),ee=()=>{s.removeEventListener("pause",We),ke!=-1&&(window.clearTimeout(ke),ke=-1),O=null},En().$$.on_destroy.push(ee),o.$$set=H=>{"screenState"in H&&a(0,C=H.screenState),"mutePlayWhenFailed"in H&&a(12,w=H.mutePlayWhenFailed),"autoPlay"in H&&a(1,V=H.autoPlay),"appState"in H&&a(13,_=H.appState),"canvasRender"in H&&a(2,z=H.canvasRender),"forceCanvas2d"in H&&a(3,B=H.forceCanvas2d),"appParams"in H&&a(14,K=H.appParams),"forceContinuePlayWhenPause"in H&&a(15,te=H.forceContinuePlayWhenPause)},[C,V,z,B,s,p,v,R,function(H){c.info("onLoadedmetadata");const Je=s;Je?_>=J.RTC_CLOSED?c.warn("onLoadedmetadata video failed. rtc peerconnection already closed"):(c.info("++++++++++++++onLoadedmetadata+++++++++++++++++"),ge("mediaLoaded"),V?Ce().then(()=>{c.info("play video success")}).catch(ut=>{c.info("play video failed. need user confirm",ut),$?I.isMobile&&(I.isQQ||I.isHuawei||I.isWeChat)?ge(Gt):(Je.muted=!0,Ce().then(()=>{c.info("play video success")}).catch(ht=>{c.err("play video failed.",ht),ge(Gt)})):w?I.isMobile&&(I.isQQ||I.isHuawei||I.isWeChat)?ge(Gt):(Je.muted=!0,Ce().then(()=>{c.info("play video success"),ge(kn)}).catch(ht=>{c.err("play video failed.",ht),ge(Gt)})):ge(Gt)}):c.info("++++++++++++++onLoadedmetadata but not auto play+++++++++++++++++")):c.warn("onLoadedmetadata video failed. need video element ref")},function(){p&&!p.played?p.play().then(()=>{}).catch(H=>{c.info("auto play audio failed",H),ge(kn),a(5,p.muted=!0,p),p.play()}):c.info("audio already played")},Ae,Me,w,_,K,te,function(H){s?(c.info("setVideoSrcObj",H),a(4,s.srcObject=H,s)):c.warn("setup video failed. need video element ref")},function(H){p?(c.info("setAudioSrcObj",H),a(5,p.srcObject=H,p),$=!0,p.play().then(()=>{c.info("auto play audio success.")}).catch(Je=>{c.warn("auto play audio failed. mute play",Je),ge(kn)})):c.warn("setup audio failed. need audio element ref")},function(){return s},function(){return p},function(){return $},function(){return v},function(){return O},Ce,Fe,Xe,function(){s?(s.pause(),$&&p.pause()):c.warn("stop video failed. need video element ref")},function(H,Je=void 0){let ut=C.appSize.width?C.appSize.width:C.container.width,ht=C.appSize.height?C.appSize.height:C.container.height;Je&&Je.width&&(ut=Je.width),Je&&Je.height&&(ht=Je.height);const gn=document.createElement("canvas");gn.width=ut,gn.height=ht;const gr=s,wn=gn.getContext("2d");if(!wn)return void c.warn("draw call without context");wn.clearRect(0,0,ut,ht),gr&&wn.drawImage(gr,0,0,ut,ht);const vr=gn.toDataURL("image/jpeg");return ge("pitcureCaptured",{data:H,base64:vr}),{data:H,base64:vr}},Ue,ce,function(H){at[H?"unshift":"push"](()=>{s=H,a(4,s)})},function(H){at[H?"unshift":"push"](()=>{v=H,a(6,v)})},function(H){at[H?"unshift":"push"](()=>{R=H,a(7,R)})},function(H){at[H?"unshift":"push"](()=>{p=H,a(5,p)})}]}var li=class extends mn{constructor(o){super(),fn(this,o,ci,ui,sn,{screenState:0,mutePlayWhenFailed:12,autoPlay:1,appState:13,canvasRender:2,forceCanvas2d:3,appParams:14,forceContinuePlayWhenPause:15,setVideoSrcObj:16,setAudioSrcObj:17,getVideo:18,getAudio:19,isSeprateAudioTrack:20,getRenderContext2dElement:21,getRenderContext2d:22,playVideo:23,sountPlayout:24,soundPlayout:25,stopVideo:26,captrueFrame:27,startCanvasRender:28,stopCanvasRender:29},si,[-1,-1])}get setVideoSrcObj(){return this.$$.ctx[16]}get setAudioSrcObj(){return this.$$.ctx[17]}get getVideo(){return this.$$.ctx[18]}get getAudio(){return this.$$.ctx[19]}get isSeprateAudioTrack(){return this.$$.ctx[20]}get getRenderContext2dElement(){return this.$$.ctx[21]}get getRenderContext2d(){return this.$$.ctx[22]}get playVideo(){return this.$$.ctx[23]}get sountPlayout(){return this.$$.ctx[24]}get soundPlayout(){return this.$$.ctx[25]}get stopVideo(){return this.$$.ctx[26]}get captrueFrame(){return this.$$.ctx[27]}get startCanvasRender(){return this.$$.ctx[28]}get stopCanvasRender(){return this.$$.ctx[29]}};function di(o){cn(o,"svelte-17ckf92",".cursorContainer.svelte-17ckf92.svelte-17ckf92{pointer-events:none;position:absolute;margin:0;padding:0;display:block;z-index:10;width:24px;height:24px;background-size:contain}.cursorContainer.svelte-17ckf92 img.svelte-17ckf92{width:100%;height:auto}.pointerContainer.svelte-17ckf92.svelte-17ckf92{position:absolute;pointer-events:none;top:0;left:0;z-index:1}.pointerContainer.svelte-17ckf92 .pointer.svelte-17ckf92{width:6px;height:6px;margin-left:-3px;margin-top:-3px;background-color:#32cdcd;border-radius:50%;pointer-events:none}")}function pi(o){let n,a,s;return{c(){n=pe("div"),a=pe("img"),Qe(a.src,s=o[4](o[2].type))||U(a,"src",s),Te(a,"marginLeft",-o[2].hotX+"px"),Te(a,"marginTop",-o[2].hotY+"px"),U(a,"alt",""),U(a,"class","svelte-17ckf92"),U(n,"class","cursorContainer svelte-17ckf92"),U(n,"draggable","false"),Te(n,"left",o[0].x+"px"),Te(n,"top",o[0].y+"px")},m(p,v){Re(p,n,v),he(n,a)},p(p,v){4&v&&!Qe(a.src,s=p[4](p[2].type))&&U(a,"src",s),4&v&&Te(a,"marginLeft",-p[2].hotX+"px"),4&v&&Te(a,"marginTop",-p[2].hotY+"px"),1&v&&Te(n,"left",p[0].x+"px"),1&v&&Te(n,"top",p[0].y+"px")},d(p){p&&Oe(n)}}}function Ai(o){let n,a=o[3]&&nr(o);return{c(){a&&a.c(),n=ln()},m(s,p){a&&a.m(s,p),Re(s,n,p)},p(s,p){s[3]?a?a.p(s,p):(a=nr(s),a.c(),a.m(n.parentNode,n)):a&&(a.d(1),a=null)},d(s){a&&a.d(s),s&&Oe(n)}}}function nr(o){let n,a;return{c(){n=pe("div"),a=pe("div"),U(a,"class","pointer svelte-17ckf92"),U(n,"class","pointerContainer svelte-17ckf92"),Te(n,"left",o[0].x+"px"),Te(n,"top",o[0].y+"px")},m(s,p){Re(s,n,p),he(n,a)},p(s,p){1&p&&Te(n,"left",s[0].x+"px"),1&p&&Te(n,"top",s[0].y+"px")},d(s){s&&Oe(n)}}}function hi(o){let n;function a(v,O){return v[1].isMobile?Ai:pi}let s=a(o),p=s(o);return{c(){p.c(),n=ln()},m(v,O){p.m(v,O),Re(v,n,O)},p(v,[O]){s===(s=a(v))&&p?p.p(v,O):(p.d(1),p=s(v),p&&(p.c(),p.m(n.parentNode,n)))},i:tt,o:tt,d(v){p.d(v),v&&Oe(n)}}}function fi(o,n,a){let{screenState:s}=n,{syncCursorStyle:p}=n,{cursorPosition:v={x:0,y:0}}=n,{touchPonitEnable:O=!0}=n;const R={CURSOR_ARROR:__webpack_require__(1707).A,CURSOR_EW:__webpack_require__(4690).A,CURSOR_LINK:__webpack_require__(6376).A,CURSOR_MOVE:__webpack_require__(4059).A,CURSOR_NESW:__webpack_require__(289).A,CURSOR_NS:__webpack_require__(4145).A,CURSOR_NWSE:__webpack_require__(5957).A,CURSOR_UNAVAIL:__webpack_require__(1696).A,CURSOR_BEAM_RM:__webpack_require__(1008).A,CURSOR_BUSY_RM:__webpack_require__(4106).A,CURSOR_CROSS_RM:__webpack_require__(2971).A,CURSOR_WAIT:__webpack_require__(6293).A};return dn(()=>{a(0,v={x:s.container.width/2,y:s.container.height/2})}),o.$$set=L=>{"screenState"in L&&a(1,s=L.screenState),"syncCursorStyle"in L&&a(2,p=L.syncCursorStyle),"cursorPosition"in L&&a(0,v=L.cursorPosition),"touchPonitEnable"in L&&a(3,O=L.touchPonitEnable)},[v,s,p,O,function(L){switch(c.info("cursor style ",L),L){case Le.ARROW:return R.CURSOR_ARROR;case Le.CROSS:return R.CURSOR_CROSS_RM;case Le.HAND:return R.CURSOR_LINK;case Le.IBEAM:return R.CURSOR_BEAM_RM;case Le.NO:return R.CURSOR_UNAVAIL;case Le.SIZEALL:return R.CURSOR_MOVE;case Le.SIZENESW:return R.CURSOR_NESW;case Le.SIZENS:return R.CURSOR_NS;case Le.SIZENWSE:return R.CURSOR_NWSE;case Le.SIZEWE:return R.CURSOR_EW;case Le.WAIT:return R.CURSOR_WAIT;case Le.CUSTOM:return p.customBase64!=""?p.customBase64:R.CURSOR_ARROR;default:return R.CURSOR_ARROR}}]}var mi=class extends mn{constructor(o){super(),fn(this,o,fi,hi,sn,{screenState:1,syncCursorStyle:2,cursorPosition:0,touchPonitEnable:3},di)}};function yi(o){cn(o,"svelte-98izw4",'@charset "UTF-8";.pxy-view-port.svelte-98izw4.svelte-98izw4{position:absolute;top:0;left:0;padding:0;margin:0;z-index:1;margin:0;padding:0;background-color:rgba(0, 0, 0, 0.05)}.pxy-view-port.svelte-98izw4 .pxy-container.svelte-98izw4{margin:0 auto;box-shadow:0 0 10px rgba(0, 0, 0, 0.4);background-color:rgba(0, 0, 0, 0.05);position:relative;overflow:hidden;margin:0;padding:0}')}function rr(o){let n,a;return n=new mi({props:{screenState:o[0],syncCursorStyle:o[1],cursorPosition:o[9],touchPonitEnable:o[10]}}),{c(){Tn(n.$$.fragment)},m(s,p){An(n,s,p),a=!0},p(s,p){const v={};1&p[0]&&(v.screenState=s[0]),2&p[0]&&(v.syncCursorStyle=s[1]),512&p[0]&&(v.cursorPosition=s[9]),1024&p[0]&&(v.touchPonitEnable=s[10]),n.$set(v)},i(s){a||(it(n.$$.fragment,s),a=!0)},o(s){Et(n.$$.fragment,s),a=!1},d(s){hn(n,s)}}}function ir(o){let n,a;return n=new oi({props:{taskReady:o[6].taskid!="",wsId:o[6].wsId,screenState:o[0],ui:o[2],serverAddress:o[3],appState:o[4],syncApp:o[5],loadingBgUrl:o[7],showLoadingStateBar:o[11],showPlayButton:o[13],tapedPlayButton:o[21],loadingLogoVersion:o[16],loadingStateMsg:o[17]}}),{c(){Tn(n.$$.fragment)},m(s,p){An(n,s,p),a=!0},p(s,p){const v={};64&p[0]&&(v.taskReady=s[6].taskid!=""),64&p[0]&&(v.wsId=s[6].wsId),1&p[0]&&(v.screenState=s[0]),4&p[0]&&(v.ui=s[2]),8&p[0]&&(v.serverAddress=s[3]),16&p[0]&&(v.appState=s[4]),32&p[0]&&(v.syncApp=s[5]),128&p[0]&&(v.loadingBgUrl=s[7]),2048&p[0]&&(v.showLoadingStateBar=s[11]),8192&p[0]&&(v.showPlayButton=s[13]),2097152&p[0]&&(v.tapedPlayButton=s[21]),65536&p[0]&&(v.loadingLogoVersion=s[16]),131072&p[0]&&(v.loadingStateMsg=s[17]),n.$set(v)},i(s){a||(it(n.$$.fragment,s),a=!0)},o(s){Et(n.$$.fragment,s),a=!1},d(s){hn(n,s)}}}function gi(o){let n,a,s,p,v,O,R,L,C,w,V=o[6].appliType!==bt.PIXEL_STREAMING&&(o[0].isMobile||o[0].isLocalRenderMouse)&&rr(o),_={appState:o[4],screenState:o[0],mutePlayWhenFailed:o[8],autoPlay:o[12],canvasRender:o[14],forceCanvas2d:o[15],appParams:o[6]};p=new li({props:_}),o[44](p),p.$on("mediaLoaded",o[45]),p.$on("mediaPlayed",o[46]),p.$on("mediaPlayedMute",o[25]),p.$on("mediaPlayedFailed",o[47]),p.$on("pitcureCaptured",o[48]);let z=(o[4]<=J.MEDIA_LOADED||o[4]>=J.RTC_RETRY)&&ir(o);return{c(){n=pe("div"),a=pe("div"),V&&V.c(),s=Ke(),Tn(p.$$.fragment),O=Ke(),z&&z.c(),U(a,"class","pxy-container svelte-98izw4"),U(a,"style",v=o[0].containerStyle),U(n,"class","pxy-view-port svelte-98izw4"),U(n,"style",R=o[0].viewPortStyle)},m(B,K){Re(B,n,K),he(n,a),V&&V.m(a,null),he(a,s),An(p,a,null),o[49](a),he(n,O),z&&z.m(n,null),o[50](n),L=!0,C||(w=[Mt(a,"mouseup",o[23]),Mt(a,"touchend",o[24],{passive:!0}),Mt(n,"mouseup",o[26]),Mt(n,"touchend",o[26],{passive:!0})],C=!0)},p(B,K){B[6].appliType!==bt.PIXEL_STREAMING&&(B[0].isMobile||B[0].isLocalRenderMouse)?V?(V.p(B,K),65&K[0]&&it(V,1)):(V=rr(B),V.c(),it(V,1),V.m(a,s)):V&&(Yn(),Et(V,1,1,()=>{V=null}),Hn());const te={};16&K[0]&&(te.appState=B[4]),1&K[0]&&(te.screenState=B[0]),256&K[0]&&(te.mutePlayWhenFailed=B[8]),4096&K[0]&&(te.autoPlay=B[12]),16384&K[0]&&(te.canvasRender=B[14]),32768&K[0]&&(te.forceCanvas2d=B[15]),64&K[0]&&(te.appParams=B[6]),p.$set(te),(!L||1&K[0]&&v!==(v=B[0].containerStyle))&&U(a,"style",v),B[4]<=J.MEDIA_LOADED||B[4]>=J.RTC_RETRY?z?(z.p(B,K),16&K[0]&&it(z,1)):(z=ir(B),z.c(),it(z,1),z.m(n,null)):z&&(Yn(),Et(z,1,1,()=>{z=null}),Hn()),(!L||1&K[0]&&R!==(R=B[0].viewPortStyle))&&U(n,"style",R)},i(B){L||(it(V),it(p.$$.fragment,B),it(z),L=!0)},o(B){Et(V),Et(p.$$.fragment,B),Et(z),L=!1},d(B){B&&Oe(n),V&&V.d(),o[44](null),hn(p),o[49](null),z&&z.d(),o[50](null),C=!1,St(w)}}}function vi(o,n,a){let s,p,v,{screenState:O}=n,{syncCursorStyle:R}=n,{ui:L}=n,{serverAddress:C}=n,{appState:w}=n,{syncApp:V}=n,{isMobile:_}=n,{appParams:z}=n,{loadingBgUrl:B}=n,{mutePlayWhenFailed:K}=n,{cursorPosition:te={x:0,y:0}}=n,{touchPonitEnable:$=!0}=n,{showLoadingStateBar:ke=!0}=n,{autoPlay:ge=!0}=n,{showPlayButton:Ce=!0}=n,{canvasRender:Fe=!1}=n,{forceCanvas2d:Xe=!1}=n,{loadingLogoVersion:Ue}=n,{loadingStateMsg:ce=""}=n,D=!1,Ae=!1,Me=!1;const We=Kn();return dn(()=>{We("loaded",p)}),o.$$set=ee=>{"screenState"in ee&&a(0,O=ee.screenState),"syncCursorStyle"in ee&&a(1,R=ee.syncCursorStyle),"ui"in ee&&a(2,L=ee.ui),"serverAddress"in ee&&a(3,C=ee.serverAddress),"appState"in ee&&a(4,w=ee.appState),"syncApp"in ee&&a(5,V=ee.syncApp),"isMobile"in ee&&a(27,_=ee.isMobile),"appParams"in ee&&a(6,z=ee.appParams),"loadingBgUrl"in ee&&a(7,B=ee.loadingBgUrl),"mutePlayWhenFailed"in ee&&a(8,K=ee.mutePlayWhenFailed),"cursorPosition"in ee&&a(9,te=ee.cursorPosition),"touchPonitEnable"in ee&&a(10,$=ee.touchPonitEnable),"showLoadingStateBar"in ee&&a(11,ke=ee.showLoadingStateBar),"autoPlay"in ee&&a(12,ge=ee.autoPlay),"showPlayButton"in ee&&a(13,Ce=ee.showPlayButton),"canvasRender"in ee&&a(14,Fe=ee.canvasRender),"forceCanvas2d"in ee&&a(15,Xe=ee.forceCanvas2d),"loadingLogoVersion"in ee&&a(16,Ue=ee.loadingLogoVersion),"loadingStateMsg"in ee&&a(17,ce=ee.loadingStateMsg)},[O,R,L,C,w,V,z,B,K,te,$,ke,ge,Ce,Fe,Xe,Ue,ce,s,p,v,Me,We,function(){Ae&&(s&&s.sountPlayout(),Ae=!1),z.fullScreenMode==1?D||(We("requestFullScreen"),D=!0):z.fullScreenMode==2&&We("requestFullScreen")},function(){Ae&&(s&&s.sountPlayout(),Ae=!1,_)||(z.mobileFullScreenMode==1?D||(window.setTimeout(()=>{We("requestFullScreen")},100),D=!0):z.mobileFullScreenMode==2&&window.setTimeout(()=>{We("requestFullScreen")},100))},function(){Ae=!0,We("mediaPlayedMute")},function(){w>J.INITED&&w<J.MEDIA_PLAYED&&(s==null||s.playVideo().catch(ee=>{c.warn("play video failed with user click",ee)}),window.setTimeout(()=>{w>J.INITED&&w<J.MEDIA_PLAYED&&a(21,Me=!0)},1e3))},_,function(){return p},function(){return s},function(){return v},function(ee){s==null||s.setVideoSrcObj(ee)},function(){return s==null?void 0:s.getVideo()},async function(){s==null||s.playVideo()},function(){s.sountPlayout()},function(){s.stopVideo()},function(ee){s==null||s.setAudioSrcObj(ee)},function(){return s.getAudio()},function(){return s.startCanvasRender()},function(){return s.stopCanvasRender()},function(){return s.isSeprateAudioTrack()},function(ee,H=void 0){return s.captrueFrame(ee,H)},function(){return s.getRenderContext2dElement()},function(){return s.getRenderContext2d()},function(ee){at[ee?"unshift":"push"](()=>{s=ee,a(18,s)})},()=>We("mediaLoaded"),()=>We("mediaPlayed"),()=>We("mediaPlayedFailed"),ee=>We("pitcureCaptured",ee.detail),function(ee){at[ee?"unshift":"push"](()=>{p=ee,a(19,p)})},function(ee){at[ee?"unshift":"push"](()=>{v=ee,a(20,v)})}]}var bi=class extends mn{constructor(o){super(),fn(this,o,vi,gi,sn,{screenState:0,syncCursorStyle:1,ui:2,serverAddress:3,appState:4,syncApp:5,isMobile:27,appParams:6,loadingBgUrl:7,mutePlayWhenFailed:8,cursorPosition:9,touchPonitEnable:10,showLoadingStateBar:11,autoPlay:12,showPlayButton:13,canvasRender:14,forceCanvas2d:15,loadingLogoVersion:16,loadingStateMsg:17,getContainerComponent:28,getVideoComponent:29,getViewportComponent:30,setVideoSrcObj:31,getVideo:32,playVideo:33,sountPlayout:34,stopVideo:35,setAudioSrcObj:36,getAudio:37,startCanvasRender:38,stopCanvasRender:39,isSeprateAudioTrack:40,captrueFrame:41,getRenderContext2dElement:42,getRenderContext2d:43},yi,[-1,-1])}get screenState(){return this.$$.ctx[0]}set screenState(o){this.$$set({screenState:o}),xe()}get syncCursorStyle(){return this.$$.ctx[1]}set syncCursorStyle(o){this.$$set({syncCursorStyle:o}),xe()}get ui(){return this.$$.ctx[2]}set ui(o){this.$$set({ui:o}),xe()}get serverAddress(){return this.$$.ctx[3]}set serverAddress(o){this.$$set({serverAddress:o}),xe()}get appState(){return this.$$.ctx[4]}set appState(o){this.$$set({appState:o}),xe()}get syncApp(){return this.$$.ctx[5]}set syncApp(o){this.$$set({syncApp:o}),xe()}get isMobile(){return this.$$.ctx[27]}set isMobile(o){this.$$set({isMobile:o}),xe()}get appParams(){return this.$$.ctx[6]}set appParams(o){this.$$set({appParams:o}),xe()}get loadingBgUrl(){return this.$$.ctx[7]}set loadingBgUrl(o){this.$$set({loadingBgUrl:o}),xe()}get mutePlayWhenFailed(){return this.$$.ctx[8]}set mutePlayWhenFailed(o){this.$$set({mutePlayWhenFailed:o}),xe()}get cursorPosition(){return this.$$.ctx[9]}set cursorPosition(o){this.$$set({cursorPosition:o}),xe()}get touchPonitEnable(){return this.$$.ctx[10]}set touchPonitEnable(o){this.$$set({touchPonitEnable:o}),xe()}get showLoadingStateBar(){return this.$$.ctx[11]}set showLoadingStateBar(o){this.$$set({showLoadingStateBar:o}),xe()}get autoPlay(){return this.$$.ctx[12]}set autoPlay(o){this.$$set({autoPlay:o}),xe()}get showPlayButton(){return this.$$.ctx[13]}set showPlayButton(o){this.$$set({showPlayButton:o}),xe()}get canvasRender(){return this.$$.ctx[14]}set canvasRender(o){this.$$set({canvasRender:o}),xe()}get forceCanvas2d(){return this.$$.ctx[15]}set forceCanvas2d(o){this.$$set({forceCanvas2d:o}),xe()}get loadingLogoVersion(){return this.$$.ctx[16]}set loadingLogoVersion(o){this.$$set({loadingLogoVersion:o}),xe()}get loadingStateMsg(){return this.$$.ctx[17]}set loadingStateMsg(o){this.$$set({loadingStateMsg:o}),xe()}get getContainerComponent(){return this.$$.ctx[28]}get getVideoComponent(){return this.$$.ctx[29]}get getViewportComponent(){return this.$$.ctx[30]}get setVideoSrcObj(){return this.$$.ctx[31]}get getVideo(){return this.$$.ctx[32]}get playVideo(){return this.$$.ctx[33]}get sountPlayout(){return this.$$.ctx[34]}get stopVideo(){return this.$$.ctx[35]}get setAudioSrcObj(){return this.$$.ctx[36]}get getAudio(){return this.$$.ctx[37]}get startCanvasRender(){return this.$$.ctx[38]}get stopCanvasRender(){return this.$$.ctx[39]}get isSeprateAudioTrack(){return this.$$.ctx[40]}get captrueFrame(){return this.$$.ctx[41]}get getRenderContext2dElement(){return this.$$.ctx[42]}get getRenderContext2d(){return this.$$.ctx[43]}};const Si=1,Oi=7,Ei=50,Ri=51,or=60,ar=61,Li=62,Ci=70,Ti=71,ki=72,wi=73,Pi=74,Ii=75,Mi=80,Ni=81,xi=82,Vi=90,Di=91,Wi=92,yn=0,sr=1,ur=2,cr=3,lr=4,dr=1,pr=2,Ar=4,hr=8,fr=16,mr=8,_i=16,ji=17,Fi=18,zi=253,Xi=254,qi=255,Zi=0,yr=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame,Ui="GamepadEvent"in window,Bi="WebKitGamepadEvent"in window,st=(document.createEvent("KeyboardEvent").initKeyboardEvent,{});class Gi extends b{get startListen(){return this._startListen}constructor(n){super(),this.playerElementClientRect={x:0,y:0,width:0,height:0,bottom:0,left:0,top:0,right:0,toJSON:()=>JSON.stringify(this)},this.normalizeAndQuantizeUnsigned=(a,s)=>({x:0,y:0,inRange:!1}),this.normalizeAndQuantizeSigned=(a,s)=>({x:0,y:0}),this.unquantizeAndDenormalizeUnsigned=(a,s)=>({x:0,y:0}),this.inputOptions={controlScheme:Zi,suppressBrowserKeys:!0,fakeMouseWithTouches:!1},this._startListen=!1,this.larksr=n,this.updateStatus=this.updateStatus.bind(this),this.gamepadDisconnectHandler=this.gamepadDisconnectHandler.bind(this)}registerInputs(n){this.registerMouseEnterAndLeaveEvents(n),this.registerTouchEvents(n)}setupMouseAndFreezeFrame(n,a){this.playerElementClientRect=n.getBoundingClientRect(),this.setupNormalizeAndQuantize(n,a)}emitUIInteraction(n){return this.emitDescriptor(Ei,n)}emitCommand(n){return this.emitDescriptor(Ri,n)}requestInitialSettings(){this.sendInputData(new Uint8Array([Oi]).buffer)}requestQualityControl(){this.sendInputData(new Uint8Array([Si]).buffer)}emitMouseMove(n,a,s,p){let v=this.normalizeAndQuantizeUnsigned(n,a),O=this.normalizeAndQuantizeSigned(s,p);c.info("emitMouseMove",v,O);let R=new DataView(new ArrayBuffer(9));R.setUint8(0,Pi),R.setUint16(1,v.x,!0),R.setUint16(3,v.y,!0),R.setInt16(5,O.x,!0),R.setInt16(7,O.y,!0),this.sendInputData(R.buffer)}emitMouseDown(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(6));v.setUint8(0,ki),v.setUint8(1,n),v.setUint16(2,p.x,!0),v.setUint16(4,p.y,!0),this.sendInputData(v.buffer)}emitMouseUp(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(6));v.setUint8(0,wi),v.setUint8(1,n),v.setUint16(2,p.x,!0),v.setUint16(4,p.y,!0),this.sendInputData(v.buffer)}emitMouseWheel(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(7));v.setUint8(0,Ii),v.setInt16(1,n,!0),v.setUint16(3,p.x,!0),v.setUint16(5,p.y,!0),this.sendInputData(v.buffer)}releaseMouseButtons(n,a,s){n&dr&&this.emitMouseUp(yn,a,s),n&pr&&this.emitMouseUp(ur,a,s),n&Ar&&this.emitMouseUp(sr,a,s),n&hr&&this.emitMouseUp(cr,a,s),n&fr&&this.emitMouseUp(lr,a,s)}pressMouseButtons(n,a,s){n&dr&&this.emitMouseDown(yn,a,s),n&pr&&this.emitMouseDown(ur,a,s),n&Ar&&this.emitMouseDown(sr,a,s),n&hr&&this.emitMouseDown(cr,a,s),n&fr&&this.emitMouseDown(lr,a,s)}registerMouseEnterAndLeaveEvents(n){let a=this;n.onmouseenter=function(s){c.info("mouse enter");let p=new DataView(new ArrayBuffer(1));p.setUint8(0,Ci),a.sendInputData(p.buffer),n.pressMouseButtons(s.buttons,0,0)},n.onmouseleave=function(s){c.info("mouse leave");let p=new DataView(new ArrayBuffer(1));p.setUint8(0,Ti),a.sendInputData(p.buffer),n.releaseMouseButtons(s.buttons,0,0)}}registerLockedMouseEvents(n){this._startListen=!0;let a=this,s=n.clientWidth/2,p=n.clientHeight/2;function v(){document.pointerLockElement===n||document.mozPointerLockElement===n?(console.log("Pointer locked"),document.addEventListener("mousemove",O,!1)):(console.log("The pointer lock status is now unlocked"),document.removeEventListener("mousemove",O,!1))}function O(R){s+=R.movementX,p+=R.movementY,s>a.larksr.screenState.container.width&&(s-=a.larksr.screenState.container.width),p>a.larksr.screenState.container.height&&(p-=a.larksr.screenState.container.height),s<0&&(s=a.larksr.screenState.container.width+s),p<0&&(p=a.larksr.screenState.container.height-p),a.emitMouseMove(s,p,R.movementX,R.movementY)}n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock,document.exitPointerLock=document.exitPointerLock||n.mozExitPointerLock,n.onclick=function(){a.larksr.isObMode||n.requestPointerLock()},document.addEventListener("pointerlockchange",v,!1),document.addEventListener("mozpointerlockchange",v,!1),n.onmousedown=function(R){a.emitMouseDown(R.button,s,p)},n.onmouseup=function(R){a.emitMouseUp(R.button,s,p)},n.onmousewheel=function(R){a.emitMouseWheel(R.wheelDelta,s,p)},n.pressMouseButtons=function(R){a.pressMouseButtons(R.buttons,s,p)},n.releaseMouseButtons=function(R){a.releaseMouseButtons(R.buttons,s,p)}}registerHoveringMouseEvents(n){let a=this;c.info("registerHoveringMouseEvents",n),n.onmousemove=function(s){a.emitMouseMove(s.offsetX,s.offsetY,s.movementX,s.movementY),c.info("onmousemove",s),s.preventDefault()},n.onmousedown=function(s){a.emitMouseDown(s.button,s.offsetX,s.offsetY),s.preventDefault()},n.onmouseup=function(s){a.emitMouseUp(s.button,s.offsetX,s.offsetY),s.preventDefault()},n.oncontextmenu=function(s){a.emitMouseUp(s.button,s.offsetX,s.offsetY),s.preventDefault()},"onmousewheel"in n?n.onmousewheel=function(s){a.emitMouseWheel(s.wheelDelta,s.offsetX,s.offsetY),s.preventDefault()}:n.addEventListener("DOMMouseScroll",function(s){a.emitMouseWheel(-120*s.detail,s.offsetX,s.offsetY),s.preventDefault()},!1),n.pressMouseButtons=function(s){a.pressMouseButtons(s.buttons,s.offsetX,s.offsetY)},n.releaseMouseButtons=function(s){a.releaseMouseButtons(s.buttons,s.offsetX,s.offsetY)}}registerTouchEvents(n){let a=this,s=[9,8,7,6,5,4,3,2,1,0],p={};function v(R){let L=s.pop();L===void 0&&console.log("exhausted touch indentifiers"),p[R.identifier]=L}function O(R,L){let C=new DataView(new ArrayBuffer(2+7*L.length));C.setUint8(0,R),C.setUint8(1,L.length);let w=2;for(let V=0;V<L.length;V++){let _=L[V];const{screenOrientation:z,viewPort:B}=a.larksr.screenState;let K=_.clientX-n.offsetLeft,te=_.clientY-n.offsetTop;z==="landscape"?(K=_.clientY-n.offsetLeft,te=B.height-_.clientX-n.offsetTop):(K=_.clientX-n.offsetLeft,te=_.clientY-n.offsetTop),c.info(`F${p[_.identifier]}=(${K}, ${te})`);let $=a.normalizeAndQuantizeUnsigned(K,te);C.setUint16(w,$.x,!0),w+=2,C.setUint16(w,$.y,!0),w+=2,C.setUint8(w,p[_.identifier],!0),w+=1,C.setUint8(w,255*_.force,!0),w+=1,C.setUint8(w,$.inRange?1:0,!0),w+=1}a.sendInputData(C.buffer)}if(a.inputOptions.fakeMouseWithTouches){let R;n.ontouchstart=function(L){if(R===void 0){let C=L.changedTouches[0];R={id:C.identifier,x:C.clientX-a.playerElementClientRect.left,y:C.clientY-a.playerElementClientRect.top},n.onmouseenter(L),a.emitMouseDown(yn,R.x,R.y)}L.preventDefault()},n.ontouchend=function(L){for(let C=0;C<L.changedTouches.length;C++){let w=L.changedTouches[C];if(w.identifier===R.id){let V=w.clientX-a.playerElementClientRect.left,_=w.clientY-a.playerElementClientRect.top;a.emitMouseUp(yn,V,_),n.onmouseleave(L),R=void 0;break}}L.preventDefault()},n.ontouchmove=function(L){for(let C=0;C<L.touches.length;C++){let w=L.touches[C];if(w.identifier===R.id){let V=w.clientX-a.playerElementClientRect.left,_=w.clientY-a.playerElementClientRect.top;a.emitMouseMove(V,_,V-R.x,_-R.y),R.x=V,R.y=_;break}}L.preventDefault()}}else n.ontouchstart=function(R){for(let L=0;L<R.changedTouches.length;L++)v(R.changedTouches[L]);c.info("touch start"),O(Mi,R.changedTouches),R.preventDefault()},n.ontouchend=function(R){c.info("touch end"),O(Ni,R.changedTouches);for(let C=0;C<R.changedTouches.length;C++)L=R.changedTouches[C],s.push(p[L.identifier]),delete p[L.identifier];var L;R.preventDefault()},n.ontouchmove=function(R){c.info("touch move"),O(xi,R.touches),R.preventDefault()}}isKeyCodeBrowserKey(n){return n>=112&&n<=123||n===9}getKeyCode(n){return n.keyCode===_i&&n.code==="ShiftRight"?zi:n.keyCode===ji&&n.code==="ControlRight"?Xi:n.keyCode===Fi&&n.code==="AltRight"?qi:n.keyCode}registerKeyboardEvents(){this._startListen=!0;let n=this;document.onkeydown=function(a){c.info(`key down ${a.keyCode}, repeat = ${a.repeat}`),n.sendInputData(new Uint8Array([or,n.getKeyCode(a),a.repeat]).buffer),a.keyCode===mr&&document.onkeypress({charCode:mr}),n.inputOptions.suppressBrowserKeys&&n.isKeyCodeBrowserKey(a.keyCode)&&a.preventDefault()},document.onkeyup=function(a){c.info(`key up ${a.keyCode}`),n.sendInputData(new Uint8Array([ar,n.getKeyCode(a)]).buffer),n.inputOptions.suppressBrowserKeys&&n.isKeyCodeBrowserKey(a.keyCode)&&a.preventDefault()},document.onkeypress=function(a){c.info(`key press ${a.charCode}`);let s=new DataView(new ArrayBuffer(3));s.setUint8(0,Li),s.setUint16(1,a.charCode,!0),n.sendInputData(s.buffer)}}setupHtmlEvents(){this._startListen=!0,Ui?(window.addEventListener("gamepadconnected",this.gamepadConnectHandler),window.addEventListener("gamepaddisconnected",this.gamepadDisconnectHandler)):Bi&&(window.addEventListener("webkitgamepadconnected",this.gamepadConnectHandler),window.addEventListener("webkitgamepaddisconnected",this.gamepadDisconnectHandler))}gamepadConnectHandler(n){c.info("Gamepad connect handler");const a=n.gamepad;st[a.index]={},st[a.index].currentState=a,st[a.index].prevState=a,c.info("gamepad: "+a.id+" connected"),yr(this.updateStatus)}gamepadDisconnectHandler(n){c.warn("Gamepad disconnect handler"),c.warn("gamepad: "+n.gamepad.id+" disconnected"),delete st[n.gamepad.index]}emitControllerAxisMove(n,a,s){const p=new DataView(new ArrayBuffer(11));p.setUint8(0,Wi),p.setUint8(1,n),p.setUint8(2,a),p.setFloat64(3,s,!0),this.sendInputData(p.buffer)}emitControllerButtonPressed(n,a,s){const p=new DataView(new ArrayBuffer(4));p.setUint8(0,Vi),p.setUint8(1,n),p.setUint8(2,a),p.setUint8(3,s),this.sendInputData(p.buffer)}emitControllerButtonReleased(n,a){const s=new DataView(new ArrayBuffer(3));s.setUint8(0,Di),s.setUint8(1,n),s.setUint8(2,a),this.sendInputData(s.buffer)}scanGamepads(){let n=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[];for(let a=0;a<n.length;a++)n[a]&&n[a].index in st&&(st[n[a].index].currentState=n[a])}updateStatus(){this.scanGamepads();for(const n in st){let a=st[n],s=a.currentState,p=a.prevState;for(let v=0;v<s.buttons.length;v++){let O=s.buttons[v],R=p.buttons[v];O.pressed&&!R.pressed?v==6?this.emitControllerAxisMove(n,5,O.value):v==7?this.emitControllerAxisMove(n,6,O.value):this.emitControllerButtonPressed(n,v,0):!O.pressed&&R.pressed?v==6?this.emitControllerAxisMove(n,5,0):v==7?this.emitControllerAxisMove(n,6,0):this.emitControllerButtonReleased(n,v):O.pressed&&R.pressed&&(v==6?this.emitControllerAxisMove(n,5,O.value):v==7?this.emitControllerAxisMove(n,6,O.value):this.emitControllerButtonPressed(n,v,1))}for(let v=0;v<s.axes.length;v+=2){let O=parseFloat(s.axes[v].toFixed(4)),R=-parseFloat(s.axes[v+1].toFixed(4));v===0?(this.emitControllerAxisMove(n,1,O),this.emitControllerAxisMove(n,2,R)):v===2&&(this.emitControllerAxisMove(n,3,O),this.emitControllerAxisMove(n,4,R))}st[n].prevState=s}yr(this.updateStatus)}setupNormalizeAndQuantize(n,a){if(n&&a){let s=n.clientHeight/n.clientWidth,p=a.videoHeight/a.videoWidth;if(s>p){c.info("Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio");let v=s/p;this.normalizeAndQuantizeUnsigned=(O,R)=>{let L=O/n.clientWidth,C=v*(R/n.clientHeight-.5)+.5;return L<0||L>1||C<0||C>1?{inRange:!1,x:65535,y:65535}:{inRange:!0,x:65536*L,y:65536*C}},this.unquantizeAndDenormalizeUnsigned=(O,R)=>{let L=(R/65536-.5)/v+.5;return{x:O/65536*n.clientWidth,y:L*n.clientHeight}},this.normalizeAndQuantizeSigned=(O,R)=>({x:32767*(O/(.5*n.clientWidth)),y:32767*(v*R/(.5*n.clientHeight))})}else{c.info("Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio");let v=p/s;this.normalizeAndQuantizeUnsigned=(O,R)=>{let L=v*(O/n.clientWidth-.5)+.5,C=R/n.clientHeight;return L<0||L>1||C<0||C>1?{inRange:!1,x:65535,y:65535}:{inRange:!0,x:65536*L,y:65536*C}},this.unquantizeAndDenormalizeUnsigned=(O,R)=>{let L=R/65536;return{x:((O/65536-.5)/v+.5)*n.clientWidth,y:L*n.clientHeight}},this.normalizeAndQuantizeSigned=(O,R)=>({x:32767*(v*O/(.5*n.clientWidth)),y:32767*(R/(.5*n.clientHeight))})}}}emitDescriptor(n,a){let s=JSON.stringify(a),p=new DataView(new ArrayBuffer(3+2*s.length)),v=0;p.setUint8(v,n),v++,p.setUint16(v,s.length,!0),v+=2;for(let O=0;O<s.length;O++)p.setUint16(v,s.charCodeAt(O),!0),v+=2;return this.emit({type:0,intpuBuffer:p.buffer,target:this}),p.buffer}sendInputData(n){this.emit({type:0,intpuBuffer:n,target:this})}}var Kt;(function(o){o[o.OPEN=0]="OPEN",o[o.CLOSE=1]="CLOSE",o[o.ERROR=2]="ERROR",o[o.TRY=3]="TRY",o[o.STAUTS=4]="STAUTS"})(Kt||(Kt={}));class Ki extends b{get wsServer(){let n="";if(this.config.appliId&&(n+="appliId="+this.config.appliId+"&"),this.config.groupId&&(n+="groupId="+this.config.groupId+"&"),this.config.targetServerIp&&(n+="targetServerIp="+this.config.targetServerIp+"&"),this.queueId&&(n+="queueId="+this.queueId+"&"),this.config.proxyBasePath)return`${window.location.protocol.indexOf("s")>-1?"wss://":"ws://"}${window.location.host}${this.config.proxyBasePath}/websocket/waitQueue?`+n;{const a=new URL(this.config.serverAddress);return`${a.protocol.indexOf("s")>-1?"wss://":"ws://"}${a.host}/websocket/waitQueue?`+n}}isOpen(){return!!this.connection&&this.connection.readyState===1}constructor(n){super(),this.connection=null,this.keepAliveTimeout=-1,this.queueId="",c.info("初始化 WaitQueue"+JSON.stringify(n)),this.config=n,this.startKeepAlive=this.startKeepAlive.bind(this),this.stopKeepAlive=this.stopKeepAlive.bind(this)}connect(){return new Promise((n,a)=>{c.info("连接 websocket waitqueue 服务器",this.config,this.wsServer),this.config.serverAddress||(c.warn("server uri error:",this.config.serverAddress),a("server uri error:"+this.config.serverAddress));const s=this.wsServer;this.connection=new WebSocket(s),this.connection.binaryType="arraybuffer",this.connection.addEventListener("message",p=>{try{let v=JSON.parse(p.data);switch(v.type){case"020":c.info("on queue try "+p.data),this.emit({type:Kt.TRY}),n(this),this.close();break;case"021":c.info("on queue id "+p.data),v.value&&(this.queueId=v.value);break;case"022":c.info("on status msg "+p.data,v.waitCntBeforeMe),this.emit({type:Kt.STAUTS,waitCount:v.waitCntBeforeMe})}}catch(v){c.err("parse queue msg failed",v,p.data),a()}}),this.connection.addEventListener("open",()=>{c.info("connection open")}),this.connection.addEventListener("error",p=>{c.info("connection error"),a(p)}),this.connection.addEventListener("close",p=>{c.info("websocket connection close",p),a(p)})})}close(){return new Promise((n,a)=>{if(this.connection){const s=this;this.connection.addEventListener("close",p=>{s.connection=null,c.info("CLOSE PROMISE 关闭 websocket 连接"),n()}),this.connection.addEventListener("error",p=>{a(p)}),c.warn("主动关闭 websocket 连接"),this.connection.close()}else c.warn("主动关闭连接,但是当前 websocket 连接为null"),n()})}startKeepAlive(){c.info("proxy startKeepAlive"),this.keepAliveTimeout=window.setTimeout(()=>{this.connection&&this.isOpen()?(this.connection.send("1000"),this.startKeepAlive()):this.stopKeepAlive()},1e4)}stopKeepAlive(){c.info("proxy stopKeepAlive"),this.keepAliveTimeout&&window.clearTimeout(this.keepAliveTimeout)}}var Dt,At,ne;(function(o){o[o.Normal=0]="Normal",o[o.Interactive=1]="Interactive",o[o.MutiPlayer=2]="MutiPlayer"})(Dt||(Dt={})),function(o){o[o.Observer=0]="Observer",o[o.Player=1]="Player"}(At||(At={})),function(o){o.TASK_CREATE_SUCCESS="taskcreatesuccess",o.TASK_CREATE_FAILED="taskcreatefailed",o.RESOURCE_NOT_ENOUGH="resourcenotenough",o.CONNECT="connect",o.LOGIN_SUCCESS="loginsuccess",o.NO_OPERATION_TIMEOUT="operatetimeout",o.CLOSE="close",o.APP_CLOSE="appclose",o.GOT_REMOTE_STREAM="gotremotestream",o.GOT_REMOTE_AUDIO_STREAM="gotremoteaudiostream",o.MEDIA_LOADED="meidaloaded",o.MEDIA_LOADED2="medialoaded",o.MEDIA_PLAY_SUCCESS="mediaplaysuccess",o.MEDIA_PLAY_FAILED="mediaplayfailed",o.MEDIA_PLAY_MUTE="meidaplaymute",o.APPSTATE_CHANGE="appstatechange",o.APP_RESIZE="appresize",o.APP_MOUSE_MODE="appmousemode",o.APP_CURSOR_MODE="appcursormode",o.PLAYER_LIST="playerlist",o.PEERSTATUS_REPORT="peerstatusreport",o.APP_REQUEST_INPUT="apprequestinput",o.APP_REQUEST_GAMEPAD_OUPUT="apprequestgamepadoutput",o.CAPTURE_FRAME="captureframe",o.DATACHANNEL_OPEN="datachannelopen",o.DATACHANNEL_CLOSE="datachannelclose",o.DATACHANNEL_TEXT="datachanneltext",o.DATACHANNEL_BINARY="datachannelbinary",o.LarkEvent="larkevent",o.ERROR="error",o.INFO="info",o.AI_VOICE_STATUS="aivoicestatus",o.AI_VOICE_ASR_RESULT="aivoiceasrresult",o.AI_VOICE_DM_RESULT="aivoicedmresult",o.AI_VOICE_ERROR="aivoiceerror",o.TOUCH_CTR_MAPPING="touchctrmapping",o.RTMP_STREAM_STATE="rtmpstreamstate",o.RTMP_STREAM_ERROR="rtmpstreamerror",o.AERIAL_VIEW_SCREEN="aerialviewscreen",o.START_XR_STREAM_RESPONSE="startxrstreamresponse",o.TOOLTIP_INFO="tooltipinfo",o.OPEN_URL="openurl",o.WAITQUEUE_STATUS="waitqueuestatus"}(ne||(ne={}));var Ji={LarkSR:class extends b{get params(){return this._params}get playerModeType(){return this._params.playerMode}get userType(){return this._params.userType}get isObMode(){return this.playerModeType!=Dt.Normal&&this.userType==At.Observer}get isInteractiveMode(){return this.playerModeType!=Dt.Normal}get isPixelStreaming(){return this.params.appliType===bt.PIXEL_STREAMING}get appState(){return this._app.state}get app(){return this._app}get remoteScreenReady(){return this._remoteScreenReady}set remoteScreenReady(o){this._remoteScreenReady=o}onFirstAppsize(o,n){this.syncClientViewport&&(c.info("remoteScreenReady ",this.screenState.viewPort,this.params,this.screenState.syncClientViewport),this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height)),window.setTimeout(()=>{this.screenState.scrollToCenter()},100)}get screenState(){return this._screenState}set scaleMode(o){this._screenState.scaleMode=o,this.setCanvasMode()}get mouseZoomDirection(){return this.op.mouseZoomDirection}set mouseZoomDirection(o){this.op.mouseZoomDirection=o}get op(){return this._op}get fullScreen(){return this._fullScreen}get lockPointer(){return this._lockPointer}get videoElement(){return this._view.getVideo()}get videoComponent(){return this._view.getVideoComponent()}get audioElement(){return this._view.getAudio()}get isSeprateAudioTrack(){return this._view.isSeprateAudioTrack()}get containerElement(){return this._view.getContainerComponent()}get viewportElement(){return this._view.getViewportComponent()}set isEnableTouchPonit(o){this._view.$set({touchPonitEnable:o})}set isEnableTouchPoint(o){this._view.$set({touchPonitEnable:o})}set enableCanvasRender(o){this._view.canvasRender=o,o?this._view.startCanvasRender():this._view.stopCanvasRender()}get enableCanvasRender(){return this._view.canvasRender}get virtualCursorPosition(){return{x:this._view.cursorPosition.x+this.screenState.container.marginLeft,y:this._view.cursorPosition.y+this.screenState.container.marginTop}}get virtualCursorPositionRaw(){return{x:this._view.cursorPosition.x,y:this._view.cursorPosition.y}}set isEnableLoadingStateBar(o){this._view.$set({showLoadingStateBar:o})}get rootElement(){return this._rootElement}get serverAddress(){return this.config.serverAddress?this.config.serverAddress:""}get serverIp(){return new URL(this.serverAddress).hostname}get config(){return this._config}get uid(){return this._uid}get isPreStart(){return this._isPreStart}isTaskOwner(){return this._isTaskOwner}set initCursorMode(o){this._screenState.initCursorMode=o,this.resetAppMouseLockState(),this.lockPointer.isLockPointer&&this.lockPointer.exitPointerLock()}get initCursorMode(){return this._screenState.initCursorMode}get audioDeviceId(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioDeviceId}get audioTrack(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioTrack}get videoDeviceId(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoDeviceId}get videoTrack(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoTrack}get audioPaused(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioPaused}get videoPaused(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoPaused}getMediaSharePeerConnection(o){var n;return(n=this.app)===null||n===void 0?void 0:n.getMediaSharePeerConnection(o)}get serverFeatures(){var o;return(o=this.app)===null||o===void 0?void 0:o.serverFeatures}get serverStatics(){var o;return(o=this.app)===null||o===void 0?void 0:o.serverStatics}setVideoBitrateKbps(o){var n;(n=this.app)===null||n===void 0||n.sendVideoBitrateKbps(o)}setVideoFps(o){var n;(n=this.app)===null||n===void 0||n.sendVideoFps(o)}setCloudDebugLayout(o){var n;(n=this.app)===null||n===void 0||n.sendShowDebugLayout(o)}restartCloudApp(){var o;(o=this.app)===null||o===void 0||o.sendReStartApplication(),this._remoteScreenReady=!1}setCloudAppSize(o,n){var a;(a=this.app)===null||a===void 0||a.sendApplicationSize(o,n)}get currentAppSize(){var o;return(o=this.app)===null||o===void 0?void 0:o.currentAppSize}startAerialview(o,n=100,a,s){var p;(p=this.app)===null||p===void 0||p.startAerialview(o,n,a,s)}updateAerialview(o){var n;(n=this.app)===null||n===void 0||n.updateAerialview(o)}stopAerialview(){var o;(o=this.app)===null||o===void 0||o.stopAerialview()}get syncClientViewport(){return this.params.initResolutionType!==0}set syncClientViewport(o){o?(this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height),this.params.initResolutionType=1):this.params.initResolutionType=0}constructor(o){super(),this._remoteScreenReady=!1,this.loadingTimeout=0,this._uid=0,this._isPreStart=!1,this._isTaskOwner=!0,this.waitQueue=null,this.onAppStateChange=this.onAppStateChange.bind(this),this.onRTCRetrySuccess=this.onRTCRetrySuccess.bind(this),this.onGotRemoteStream=this.onGotRemoteStream.bind(this),this.onOperationTimeout=this.onOperationTimeout.bind(this),this.onOperationInput=this.onOperationInput.bind(this),this.onAppResize=this.onAppResize.bind(this),this.onAppMouseMode=this.onAppMouseMode.bind(this),this.onAppPlayerList=this.onAppPlayerList.bind(this),this.onAppRequestText=this.onAppRequestText.bind(this),this.onDataChannelText=this.onDataChannelText.bind(this),this.onDataChannelBinary=this.onDataChannelBinary.bind(this),this.onDataChannelOpen=this.onDataChannelOpen.bind(this),this.onDataChannelClose=this.onDataChannelClose.bind(this),this.onCursorStyle=this.onCursorStyle.bind(this),this.onMediaPlayed=this.onMediaPlayed.bind(this),o.handelRootElementSize==null||o.handelRootElementSize==null||o.handleRootElementSize!=null&&o.handleRootElementSize!=null||(o.handleRootElementSize=o.handelRootElementSize),o.useWebCodec!==void 0&&o.useWebCodec!==null&&o.useWebCodec&&(o.forceCanvas2d=!0),this._config=o,this._config.playTimeout!=null&&this._config.playTimeout!=null||(this._config.playTimeout=20),this._params=dt.setUpWithSDKConfig(dt.copyAndCreate(),o),c.logLevel=this._params.logLevel,c.info("create larksr ",o),this._rootElement=o.rootElement,t.init(this._params.language),this._screenState=new Ir(o.rootElement,this._params,this,o.handleRootElementSize,o.onlyHandleRootElementTransform),this._app=new Tr(this),this.iframeHandler=new Pr(this),this.iframeHandler.listenParent(),this._fullScreen=new qn,this._fullScreen.on(0,()=>{window.setTimeout(()=>{c.info("full screen state change. resize"),this._screenState.resize(this._screenState.baseElementScale)},500)}),this._lockPointer=new Zn(document.documentElement),this._lockPointer.on(2,n=>{c.warn("lock point not support on this platform switch to unlock mode"),this.initCursorMode=2,this.$emitInfo(t.ui.LOCK_POINTER_FAILED)}),this._lockPointer.on(3,n=>{c.warn("lock point not support on this platform switch to unlock mode. please check https."),this.initCursorMode=2,this.$emitInfo(t.ui.LOCK_POINTER_FAILED_SECURITY_ERROR)}),o.handleRootElementSize!=null&&o.handleRootElementSize!=1||function(){const n=document.getElementsByTagName("html")[0];n&&n.style&&(n.style.margin="0",n.style.padding="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%");const a=document.body;a&&a.style&&(a.style.margin="0",a.style.padding="0",a.style.overflow="hidden",a.style.width="100%",a.style.height="100%")}(),this._view=new bi({target:o.rootElement,props:{screenState:this.screenState,syncCursorStyle:this.screenState.cursorStyle,ui:t.ui,serverAddress:o.serverAddress?o.serverAddress:"",syncApp:!1,appState:this.appState,isMobile:I.isMobile,appParams:this._params,loadingBgUrl:o.loadingBgUrl?o.loadingBgUrl:"",mutePlayWhenFailed:o.mutePlayWhenFailed==null||o.mutePlayWhenFailed,touchPonitEnable:!0,autoPlay:o.autoPlay==null||o.autoPlay,showPlayButton:o.showPlayButton==null||o.showPlayButton,canvasRender:o.enableCanvasRender!=null&&o.enableCanvasRender!=null&&o.enableCanvasRender,forceCanvas2d:o.forceCanvas2d!=null&&o.forceCanvas2d!=null&&o.forceCanvas2d,loadingLogoVersion:o.loadingLogoVersion==null?"":o.loadingLogoVersion}}),this.app.webcodecDecoder.setCanvas(this._view.getRenderContext2dElement(),this._view.getRenderContext2d()),this._screenState.on(0,n=>{c.info("on resize",n),this._view.$set({screenState:this._screenState}),this.isPixelStreaming&&this.pixelInput.setupMouseAndFreezeFrame(this.containerElement,this.videoElement)}),this._screenState.on(1,n=>{c.info("on ContainerResize",n,this.screenState.syncClientViewport),this.syncClientViewport&&this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height)}),this._op=new Xn(this._view.getContainerComponent(),this),this.pixelInput=new Gi(this),this.setupListener(),this.setCanvasMode()}updateServerAddress(o){this._config.serverAddress=o,this._view.$set({serverAddress:this._config.serverAddress})}initSDKAuthCode(o){return this._config.authCode=o,new Promise((n,a)=>{n()})}async connectWithPxyHost(o){const n=await se.HostAppliGetUrl(o);this._config.serverAddress=n.origin,this._view.$set({serverAddress:this._config.serverAddress}),await this.connect(Object.assign(Object.assign({},o),n.params))}async connect(o){if(!this._config.authCode)throw c.err("sdk 授权校验失败. 请通过 new LarkSR({authCode: id}) 或 initSDKAuthCode 设置"),new Error("sdk 授权校验失败. 请通过 new LarkSR({authCode: id}) 或 initSDKAuthCode 设置");if(!this._config.serverAddress&&!this._config.proxyBasePath)throw new Error("服务器地址未设置");try{const n=await se.GetStartInfo(se.GetUrl(this._config),Object.assign({sdkId:this._config.authCode},o));this.waitQueue&&this._view.loadingStateMsg&&this._view.$set({loadingStateMsg:""}),this.setAppliParams(Dn(n)),this.emit({type:ne.TASK_CREATE_SUCCESS,data:Object.assign({},this.params)}),this.$emit(r.LK_TASK_CREATE_SUCCESS,Object.assign({},this.params)),await this.start()}catch(n){if(c.warn("enter app failed",n),n.type===0){n.eventType=ne.RESOURCE_NOT_ENOUGH;let a=!1;this.config.disableWaitQueue!==null&&this.config.disableWaitQueue!==void 0&&(a=this.config.disableWaitQueue);const s=await se.IsEnableWaitQueue(se.GetUrl(this._config),{});if(a||!s.enableWaitQueue||n.code===820&&this.waitQueue===null)this.emit({type:ne.RESOURCE_NOT_ENOUGH,data:n}),this.$emit(r.LK_RESOURCE_NOT_ENOUGH,n,"RESOURCE NOT ENOUGH");else{c.info("enable wait queue"),this.waitQueue===null&&(this.waitQueue=new Ki({serverAddress:this.config.serverAddress?this.config.serverAddress:"",proxyBasePath:this.config.proxyWsBasePath,appliId:o.appliId,groupId:o.groupId,targetServerIp:o.targetServerIp}),this.waitQueue.on(Kt.STAUTS,p=>{c.info("on wait queue status update",p),this._view.$set({loadingStateMsg:t.message.WAIT_QUEUE_COUNT+p.waitCount}),this.emit({type:ne.WAITQUEUE_STATUS,data:p})}));try{return await this.waitQueue.connect(),this.connect(o)}catch(p){c.err("enable wait queue but has error",p),this.emit({type:ne.RESOURCE_NOT_ENOUGH,data:p}),this.$emit(r.LK_RESOURCE_NOT_ENOUGH,p,"RESOURCE NOT ENOUGH"+JSON.stringify(p))}}}else n.eventType=ne.TASK_CREATE_FAILED,this.emit({type:ne.TASK_CREATE_FAILED,data:n}),this.$emit(r.LK_TASK_CREATE_FAILED,n,"TASK CREATE FAILED");throw n}}setNickname(o){this._params.nickname=o}setAppliParams(o){this._params=dt.setUpWithSDKConfig(dt.copyAndCreate(o),this.config),this.screenState.reset(this._params),t.init(this._params.language),this._view.$set({appParams:this._params}),c.logLevel=this._params.logLevel,this.op.mouseZoomDirection=this._params.mouseZoomDirection,this.setCanvasMode()}start(){return new Promise((o,n)=>this.params.taskid?this.params.appServer?this.params.appPort?(se.ClientInfo(this.config,this.params),(this.config.serverAddress||this.config.proxyBasePath)&&se.GetTouchCtrMapping(se.GetUrl(this._config),this.params.appliId).then(a=>{this.emit({type:ne.TOUCH_CTR_MAPPING,data:a,code:0})}).catch(a=>{c.warn(a)}),this.params.debugTask?this.startProcess():this.taskProcess(),void o()):(c.err("启动流程失败,渲染服务器的端口号为空"),void n("启动流程失败,渲染服务器的端口号为空。请确保正确调用接口获取到参数")):(c.err("启动流程失败,渲染服务器的IP地址为空"),void n("启动流程失败,渲染服务器的IP地址为空。请确保正确调用接口获取到参数")):(c.err("启动流程失败,taskID为空"),void n("启动流程失败,taskID为空。请确保正确调用接口获取到参数")))}sendKeepAlive(){var o;(o=this._app)===null||o===void 0||o.sendKeepAlive()}restart(){this._app.restart(),this.remoteScreenReady=!1}restartApp(){this._app.restartApp()}close(){this._app.disConnect()}destroy(){this.close(),this._view.$destroy()}setMobileForceLandScape(o){this.params.mobileForceLandscape=o,this.screenState.setMobileForceLandScape(o)}changeOperater(o){var n;(n=this._app)===null||n===void 0||n.changeOperater(o)}inputText(o){var n;this._op.updateOperation(),(n=this._app)===null||n===void 0||n.inputText(o)}aiDmTextInput(o){var n;return this._op.updateOperation(),(n=this._app)===null||n===void 0?void 0:n.aiDmTextInput(o)}startAiDmVoiceInput(){var o;return this._op.updateOperation(),(o=this._app)===null||o===void 0?void 0:o.startAiDmVoiceInput()}stopAiDmVoiceInput(){var o;return(o=this._app)===null||o===void 0?void 0:o.stopAiDmVoiceInput()}sendTextToDataChannel(o){var n;this._op.updateOperation(),(n=this._app)===null||n===void 0||n.sendTextToDataChannel(o)}sendBinaryToDataChannel(o){this._op.updateOperation(),this._app.sendBinaryToDataChannel(o)}closeDataChannel(){var o;(o=this._app)===null||o===void 0||o.closeDataChannel()}postMsg(o,n="",a=""){k.IsIframe()&&parent!=null&&parent.postMessage({prex:Wn,type:o,data:n,message:a==""?E.GetEventMessageByType(o):a},"*")}quit(){if(k.IsIframe())return c.warn("cant quit in iframe"),window.opener=null,window.open("","_self"),window.close(),void this.postMsg(r.LK_USER_REQUEST_QUIT);const o=window.WeixinJSBridge;o?o.call("closeWindow"):window.history&&window.history.length>1?window.history.back():(window.opener=null,window.open("","_self"),window.close())}resetAppMouseLockState(){this.op.resetAppMouseLockState()}captrueFrame(o,n=void 0){return this._view.captrueFrame(o,n)}sendInput(o){var n;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(n=this._op)===null||n===void 0||n.$emitInputEvent(o)}mouseMove(o,n,a,s){this.moseMove(o,n,a,s)}moseMove(o,n,a,s){var p;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(p=this._op)===null||p===void 0||p.$emitMoseMove(o,n,a,s)}mouseTap(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseTap(o,n,a)}mouseDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseDown(o,n,a)}mouseUp(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseUp(o,n,a)}mouseWheel(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseWheel(o,n,a)}keyDown(o,n){const a=Zt[o];a&&(this.isPixelStreaming?this.app.sendInputBuffer(new Uint8Array([or,a.vkey,n]).buffer):this._op.$emitKeyDown(a.vkey,n))}keyUp(o){const n=Zt[o];n&&(this.isPixelStreaming?this.app.sendInputBuffer(new Uint8Array([ar,n.vkey]).buffer):this._op.$emitKeyUp(n.vkey))}gamepadButtonDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitGamepadButtonDown(o,n,a)}gamepadButtonUp(o,n){var a;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(a=this._op)===null||a===void 0||a.$emitGamepadButtonUp(o,n)}gamepadTrigger(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitGamepadTrigger(o,n,a)}joystick(o,n,a,s,p){var v;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(v=this._op)===null||v===void 0||v.$emitJoystick(o,n,a,s,p)}touchDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchDown(o,n,a)}touchMove(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchMove(o,n,a)}touchUp(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchUp(o,n,a)}getMouseButtonType(o){switch(o){case"left":return h.CloudLark.MouseKey.LEFT;case"mid":return h.CloudLark.MouseKey.MIDDLE;case"right":return h.CloudLark.MouseKey.RIGHT}}setAudioEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setAudioEnable(o)}setVideoEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setVideoEnable(o)}setShareEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setShareEnable(o)}stopLocalAudio(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalAudio()}stopLocalVideo(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalVideo()}stopLocalShare(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalShare()}pauseAudioSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.pauseAudioSending()}resumeAudioSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.resumeAudioSending()}pauseVideoSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.pauseVideoSending()}resumeVideoSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.resumeVideoSending()}closeAudio(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeAudio()}closeVideo(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeVideo()}closeShare(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeShare()}closeMediaChannel(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeSharePc()}async openAudio(o=""){var n;return await((n=this.app)===null||n===void 0?void 0:n.openAudio(o))}async openVideo(o=!1,n="",a=0,s=0,p){var v;return await((v=this.app)===null||v===void 0?void 0:v.openVideo(o,n,a,s,p))}async openDefaultMedia(o=!0,n=!0){var a;return await((a=this.app)===null||a===void 0?void 0:a.openDefaultMedia(o,n))}async openShareMediaDevice(){var o;return await((o=this.app)===null||o===void 0?void 0:o.openShareMediaDevice())}async getConnectedAudioinputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedAudioinputDevices())}async getConnectedAudioOutputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedAudioOutputDevices())}async getConnectedVideoinputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedVideoinputDevices())}async getConnectedDevices(o){var n;return await((n=this.app)===null||n===void 0?void 0:n.getConnectedDevices(o))}async openAudioDevice(o,n="audioinput"){var a;return await((a=this.app)===null||a===void 0?void 0:a.openAudioDevice(o,n))}async openCamera(o,n=0,a=0,s=!0,p){var v;return await((v=this.app)===null||v===void 0?void 0:v.openCamera(o,n,a,s,p))}async openUserMedia(o,n=!1){return await this.openUserMeida(o,n)}async openUserMeida(o,n=!1){var a;return await((a=this.app)===null||a===void 0?void 0:a.openUserMeida(o,n))}addMediaTrack(o,...n){var a;return(a=this.app)===null||a===void 0?void 0:a.addMediaTrack(o,...n)}removeMediaTrack(o){var n;return(n=this.app)===null||n===void 0?void 0:n.removeMediaTrack(o)}requestUserMediaPermission(o){var n;return(n=this.app)===null||n===void 0?void 0:n.requestUserMediaPermission(o)}StartCloudLiveStreaming(o){var n;return(n=this.app)===null||n===void 0?void 0:n.StartCloudLiveStreaming(o)}StopLiveStreaming(){var o;return(o=this.app)===null||o===void 0?void 0:o.StopLiveStreaming()}async getTouchCtrMapping(o=""){if(!this.config.serverAddress)throw new Error("serverAddress not set");return await se.GetTouchCtrMapping(se.GetUrl(this._config),o||this.params.appliId)}$emit(o,n="",a=""){for(const s of wr)if(s==o){se.LogError(o,a+" "+E.GetEventMessageByType(o),"appliId="+this.params.appliId+"&taskId="+this.params.taskid,this.config);break}this.emit(this.createEvent(o,n,a)),this.postMsg(o,n,a)}$emitError(o="",n=0){this.emit({target:this,type:ne.ERROR,message:o,code:n})}$emitInfo(o="",n=0){this.emit({target:this,type:ne.INFO,message:o,code:n})}createEvent(o,n="",a=""){return{type:ne.LarkEvent,target:this,data:n,message:a,larkevent:o}}setupListener(){this.app.on(Y.LOGIN,o=>{this._uid=o.data.uid,this._isPreStart=o.data.isPrestart,c.info("login success ",o.data,this.uid,this.isPreStart),this.emit({type:ne.LOGIN_SUCCESS,data:o.data})},this),this.app.on(Y.ERROR,o=>{this.emit({type:ne.ERROR,message:o.data.message,code:o.data.code})},this),this.app.on(Y.INFO,o=>{this.emit({type:ne.INFO,message:o.data.message,code:o.data.code})},this),this.app.on(Y.APP_CLOSE,o=>{this.emit({type:ne.APP_CLOSE,data:o.data,message:o.data})},this),this.app.on(Y.REMOTE_STREAM,this.onGotRemoteStream,this),this.app.on(Y.REMOTE_AUDIO_STREAM,this.onGotRemoteAudioStream,this),this.app.on(Y.APP_STATE_CHANGE,this.onAppStateChange,this),this.app.on(Y.RTC_RETRY_SUCCESS,this.onRTCRetrySuccess,this),this.app.on(Y.SYNC_CURSORSTYLE,this.onCursorStyle,this),this.app.on(Y.LK_APP_RESIZE,this.onAppResize,this),this.app.on(Y.LK_APP_MOUSE_MODE,this.onAppMouseMode,this),this.app.on(Y.LK_APP_PLAER_LIST,this.onAppPlayerList,this),this.app.on(Y.LK_APP_REQUEST_TEXT,this.onAppRequestText,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_TEXT_MESSAGE,this.onDataChannelText,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_BINARY_MESSAGE,this.onDataChannelBinary,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_OPEN,this.onDataChannelOpen,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_CLOSE,this.onDataChannelClose,this),this.app.on(Y.NET_STATE,o=>{this.emit({type:ne.PEERSTATUS_REPORT,data:o.data})}),this.app.on(Y.AI_VOICE_STATUS,o=>{this.emit({type:ne.AI_VOICE_STATUS,data:o.data})}),this.app.on(Y.AI_VOICE_ASR_RESULT,o=>{this.emit({type:ne.AI_VOICE_ASR_RESULT,data:o.data})}),this.app.on(Y.AI_VOICE_DM_RESULT,o=>{this.emit({type:ne.AI_VOICE_DM_RESULT,data:o.data})}),this.app.on(Y.AI_VOICE_ERROR,o=>{this.emit({type:ne.AI_VOICE_ERROR,data:o.data})}),this.app.on(Y.RTMP_STREAM_STATE,o=>{this.emit({type:ne.RTMP_STREAM_STATE,data:o.data})}),this.app.on(Y.RTMP_STREAM_ERROR,o=>{this.emit({type:ne.RTMP_STREAM_ERROR,data:o.data})}),this.app.on(Y.AerialViewStatus,o=>{this.op.aerialviewStatus=o.data}),this.app.on(Y.AerialViewScreen,o=>{this.emit({type:ne.AERIAL_VIEW_SCREEN,data:o.data})}),this.app.on(Y.TooltipInfo,o=>{this.emit({type:ne.TOOLTIP_INFO,data:o.data})}),this.app.on(Y.OPEN_URL,o=>{this.emit({type:ne.OPEN_URL,data:o.data})}),this.app.on(Y.START_XR_STREAM_RESPONSE,o=>{c.info("START_XR_STREAM_RESPONSE",o,o.data);try{this.emit({type:ne.START_XR_STREAM_RESPONSE,data:o.data})}catch(n){c.info("emit failed",n)}}),this.app.webcodecDecoder.on(an.PLAYED,o=>{this.app.appStateChange(J.MEDIA_LOADED),this.emit({type:ne.MEDIA_LOADED,target:this}),this.emit({type:ne.MEDIA_LOADED2,target:this}),this.$emit(r.LK_VIDEO_LOADED),this.onMediaPlayed()}),this.op.on(1,this.onOperationTimeout,this),this.op.on(2,o=>{var n;o.data&&((n=this._app)===null||n===void 0||n.inputText(o.data))},this),this.op.on(3,o=>{(I.isMobile||o.cursorPoint&&this.lockPointer.isLockPointer)&&this._view.$set({cursorPosition:o.cursorPoint})}),this._view.$on("pitcureCaptured",o=>{c.info("on capture ",o.detail),this.emit({type:ne.CAPTURE_FRAME,target:this,data:o.detail}),o.detail.data?this.$emit(r.LK_USER_CAPTURE_FRAME_WITH_EXTRA_DATA,o.detail):this.$emit(r.LK_USER_CAPTURE_FRAME,o.detail.base64)}),this._view.$on("mediaLoaded",()=>{this.app.peerConnectionCreated?(this.app.state=J.MEDIA_LOADED,this.emit({type:ne.MEDIA_LOADED,target:this}),this.emit({type:ne.MEDIA_LOADED2,target:this}),this.$emit(r.LK_VIDEO_LOADED),window.clearTimeout(this.loadingTimeout)):c.warn("peerConnectionCreated already released")}),this._view.$on("mediaPlayed",this.onMediaPlayed),this._view.$on("mediaPlayedMute",()=>{c.info("video play success"),this.emit({type:ne.MEDIA_PLAY_MUTE,target:this})}),this._view.$on("mediaPlayedFailed",()=>{this.$emit(r.LK_VIDEO_PLAY_FAILED),this.emit({type:ne.MEDIA_PLAY_FAILED,target:this})}),this._view.$on("requestFullScreen",()=>{I.os!="iOS"&&this.fullScreen.launchFullScreen()})}async taskProcess(){try{const o=await se.GetTask(this.config,this.params.taskid);if(o.status!=0){if(c.info("task 获取成功",o),this._view.$set({syncApp:!1}),o.shareUrl!==null&&o.shareUrl!==void 0&&(this._params.shareUrl=q.getBoolOption(o.shareUrl)),o.textInputEventPrompt!==null&&o.shareUrl!==void 0&&(this._params.textInputEventPrompt=q.getNumberBoolOption(o.textInputEventPrompt,!0)),o.audioInput!==null&&o.audioInput!==void 0&&(this._params.audioInput=q.getNumberBoolOption(o.audioInput,!1)),o.audioInputAutoStart!==null&&o.audioInputAutoStart!==void 0){const n=q.getNumberBoolOption(o.audioInputAutoStart,!1),a=this._config.audioInputAutoStart==null?n:this._config.audioInputAutoStart;this._params.audioInputAutoStart=this._params.audioInput&&a}if(o.videoInput!==null&&o.videoInput!==void 0&&(this._params.videoInput=q.getNumberBoolOption(o.videoInput,!1)),o.videoInputAutoStart!==null&&o.videoInputAutoStart!==void 0){const n=q.getNumberBoolOption(o.videoInputAutoStart,!1),a=this._config.videoInputAutoStart==null?n:this._config.videoInputAutoStart;this._params.videoInputAutoStart=this._params.videoInput&&a}o.liveStreaming!==null&&o.liveStreaming!==void 0&&(this._params.liveStreaming=q.getNumberBoolOption(o.liveStreaming,!1)),o.mobileKeyboardType!==null&&o.mobileKeyboardType!==void 0&&(this._params.mobileKeyboardType=o.mobileKeyboardType!=null?o.mobileKeyboardType:0),o.imeFirstNotice!==null&&o.imeFirstNotice!==void 0&&(this._params.imeFirstNotice=o.imeFirstNotice!=null?o.imeFirstNotice:1),this.startProcess()}else c.info("task 同步中,重新获取",o.status),this._view.$set({syncApp:!0}),window.setTimeout(()=>{this.taskProcess()},1500)}catch(o){this._view.$set({syncApp:!1}),this.$emitError("获取Task信息失败 "+JSON.stringify(o))}}startProcess(){this.app.init(),this.loadingTimeout=window.setTimeout(()=>{this.appState<J.MEDIA_LOADED&&(c.warn("LOADING TIMEOUT!",this.params.loadingTimeout),this.app.disConnect(),this.$emitError(t.message.LK_LOADING_TIMEOUT,r.LK_LOADING_TIMEOUT),this.$emit(r.LK_LOADING_TIMEOUT))},1e3*this.params.loadingTimeout),se.PortMappingList(this.config).then(o=>{const n=o;if(this.config.publicPortMapping)for(let a in n)this.config.publicPortMapping.hasOwnProperty(a)||(this.config.publicPortMapping[a]=n[a]);else this.config.publicPortMapping=n;c.info("update public port mapping ",this.config.publicPortMapping)}).catch(o=>{c.warn("get port mapping failed ",o)}).finally(()=>{this.app.start()})}onAppStateChange(o){o.state==J.MEDIA_LOADED?(c.info("app state change to media ready"),this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),(this.config.handlInput==null||this.config.handlInput)&&(c.info("media ready ",this.params),this.isPixelStreaming?(this.screenState.appSize={width:this.videoElement.videoWidth,height:this.videoElement.videoHeight},this.emit({type:ne.APP_RESIZE,data:this.screenState.appSize}),this.pixelInput.setupMouseAndFreezeFrame(this.containerElement,this.videoElement),this.pixelInput.startListen||(this.params.initCursorMode?this.pixelInput.registerLockedMouseEvents(this.containerElement):this.pixelInput.registerHoveringMouseEvents(this.containerElement),this.pixelInput.registerInputs(this.containerElement),this.pixelInput.registerKeyboardEvents(),this.pixelInput.setupHtmlEvents(),this.pixelInput.on(0,n=>{this.isObMode?c.info("skip operation when use mousemode"):n.intpuBuffer&&this.app.sendInputBuffer(n.intpuBuffer)}))):this.op.startListen||(this.op.on(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.startListening()))):o.state>=J.RTC_RETRY&&(c.info("app state change to before destory"),(this.config.handlInput==null||this.config.handlInput)&&(this.op.off(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.stopListenling())),o.state==J.WEBSOCKET_CHANNEL_OPEN&&this.emit({type:ne.CONNECT}),o.state!=J.RTC_CLOSED&&o.state!=J.WEBSOCKET_CLOSED||this.emit({type:ne.CLOSE}),this._view.appState=o.state,this.emit({type:ne.APPSTATE_CHANGE,data:o.state}),c.info("on appstate change",o.state)}onRTCRetrySuccess(o){c.info("onRTCRetrySuccess",o),this.op.startListen||(this.op.on(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.startListening())}onGotRemoteStream(o){c.info("onGotRemoteStream",o,o.data.getVideoTracks(),this._view),this._view.setVideoSrcObj(o.data),this.emit({target:this,type:ne.GOT_REMOTE_STREAM,data:o}),I.os==="iOS"&&I.isWeChat&&k.IsIframe()&&this.appState<=J.MEDIA_PLAYED&&(this._view.playVideo(),this.emit({target:this,type:ne.MEDIA_PLAY_FAILED}),this.$emit(r.LK_VIDEO_PLAY_FAILED))}onGotRemoteAudioStream(o){c.info("onGotAudioRemoteStream",o,o.data.getVideoTracks(),this._view),this._view.setAudioSrcObj(o.data),this.emit({target:this,type:ne.GOT_REMOTE_AUDIO_STREAM,data:o})}onMediaPlayed(){if(this.app.peerConnectionCreated){this.app.state>J.LOGIN_SUCCESS&&this.app.state<J.BEFORE_DESTORY&&se.TaskInfoClientStarted(this.config,this.params),this.app.state=J.MEDIA_PLAYED,this.$emit(r.LK_VIDEO_PLAY_SUCCSS),this.emit({type:ne.MEDIA_PLAY_SUCCESS,target:this});try{this.params.audioInput&&this.params.audioInputAutoStart&&!this.audioTrack&&this.params.videoInput&&this.params.videoInputAutoStart&&!this.videoTrack?this.openDefaultMedia(!0,!0):(this.params.audioInput&&this.params.audioInputAutoStart&&!this.audioTrack&&this.openAudio(),this.params.videoInput&&this.params.videoInputAutoStart&&!this.videoTrack&&this.openVideo())}catch(o){this.$emitInfo(JSON.stringify(o))}}else c.warn("peerConnectionCreated already released")}onCursorStyle(o){this.emit({type:ne.APP_CURSOR_MODE,data:o.data}),this.screenState.cursorStyle=o.data,this._view.syncCursorStyle=this.screenState.cursorStyle,this._view.screenState=this.screenState,c.info("onCursorStyle",this.screenState.cursorStyle)}onAppResize(o){this.screenState.appSize=o.data,c.info("onAppResize ",o),this.emit({type:ne.APP_RESIZE,data:o.data})}onAppMouseMode(o){this.screenState.appMouseMode=o.data,this.op.setAppMouseMode(o.data),this.emit({type:ne.APP_MOUSE_MODE,data:o.data})}onAppPlayerList(o){let n=o.data,a=[];for(let s of n){let p={isCurrent:s.id===this.uid,userId:s.id?s.id:0,nickName:s.nickName?s.nickName:"",isTaskOwner:!!s.taskOwner,userType:s.controller?At.Player:At.Observer};if(p.isCurrent){if(this.userType!=p.userType){let v=p.userType==At.Player?"您已获得操作权限":"您已失去操作权限";this.$emitInfo(v),this.lockPointer.isLockPointer&&p.userType!=At.Player&&this.lockPointer.exitPointerLock()}this.params.userType=p.userType,this._uid=p.userId,this._isTaskOwner=p.isTaskOwner,this._op.resetAppMouseLockState(),this._view.$set({appParams:this._params}),this.screenState.resize(),c.info("upate current player ",p,this.userType,this.params.userType)}a.push(p)}this.emit({type:ne.PLAYER_LIST,data:a})}onAppRequestText(o){this.params.textInputEventPrompt?this.emit({type:ne.APP_REQUEST_INPUT,data:o.data}):c.warn("app set skip textinput event.")}onDataChannelText(o){this.emit({type:ne.DATACHANNEL_TEXT,data:o.data.string,rawData:o.data.rawString})}onDataChannelBinary(o){this.emit({type:ne.DATACHANNEL_BINARY,data:o.data})}onDataChannelOpen(o){this.emit({type:ne.DATACHANNEL_OPEN,data:o.data})}onDataChannelClose(o){this.emit({type:ne.DATACHANNEL_CLOSE,data:o.data})}onOperationTimeout(){this.isObMode||(c.warn("onOperationTimeout"),this.app&&this.app.disConnect(),this.emit({type:ne.NO_OPERATION_TIMEOUT}),this.emit({type:ne.ERROR,message:t.message.noOperationTimeout}))}onOperationInput(o){this.isObMode?c.info("skip operation when use mousemode"):(c.info("onOperationInput",JSON.stringify(o.input)),this.app&&o.input&&this.app.sendInput(o.input,!0))}async setCanvasMode(){I.os==="iOS"&&(this.screenState.scaleMode!==M.FILL_STRETCH&&this.screenState.scaleMode!==M.FILL_CLIP||(this.syncClientViewport=!0)),(this.config.useWebCodec||this.params.useWebCodec)&&(this._view.stopCanvasRender(),this._view.canvasRender=!0,this._view.forceCanvas2d=!0)}},API:se,AppliParams:dt,LoadAppliParamsFromUrl:function(){let o=q.getStringOption(k.queryString("touchOperateMode"),"mouse");return o=o==="touch"||o==="touchScreen"?"touchScreen":o==="mix"?"mix":"mouse",{appServer:k.queryString("renderServerIp"),appPort:k.queryString("renderServerPort"),renderSSLServerPort:q.getStringOption(k.queryString("renderSSLServerPort"),""),taskid:k.queryString("taskId"),taskId:k.queryString("taskId"),appliType:q.getIntOption(k.queryString("appliType"),bt.SHARED),appliName:decodeURI(k.queryString("appliName")),codeRate:q.getIntOption(k.queryString("codeRate"),N.CodeRate),audioCodeRate:q.getIntOption(k.queryString("audioCodeRate"),128),frameRate:q.getIntOption(k.queryString("frameRate"),N.FrameRate),width:q.getIntOption(k.queryString("width"),N.OriginW),height:q.getIntOption(k.queryString("height"),N.OriginH),scaleMode:q.getScaleMode(parseInt(k.queryString("initWinSize"),10)),network:q.getNetwork(parseInt(k.queryString("network"),10)),preferPubOutIp:q.getStringOption(k.queryString("preferPublicIp"),""),logLevel:q.getLogLevel(k.queryString("logLevel")),noOperationTimeout:q.getIntOption(k.queryString("noOperationTimeout"),0),waterMark:q.getBoolOption(k.queryString("wm"),!1),rttLimit:q.getIntOption(k.queryString("rttLimit"),60),packetLostLimit:q.getIntOption(k.queryString("packetLostLimit"),20),debugTask:q.getBoolOption(k.queryString("debugTask")),wsProxy:q.getNumberBoolOption(k.queryString("wsProxy")),debugWebServer:k.queryString("debugWebServer"),rttLimitInterval:q.getIntOption(k.queryString("rttLimitInterval"),20),initCursorMode:q.getIntOption(k.queryString("initCursorMode"),0),bgColor:q.getBgColor(k.queryString("bgColor")),fullScreenMode:q.getIntOption(k.queryString("fullScreenMode"),0),mobileFullScreenMode:q.getIntOption(k.queryString("mobileFullScreenMode"),1),playerMode:q.getIntOption(k.queryString("playerMode"),0),userType:q.getIntOption(k.queryString("userType"),1),nickname:q.getStringOption(k.queryString("nickname")),authCode:q.getStringOption(k.queryString("authCode"),""),loadingTimeout:q.getIntOption(k.queryString("loadingTimeout"),300),mobileForceLandscape:!!q.getIntOption(k.queryString("mobileForceLandscape"),1),mobileVirtualJoystick:!!q.getIntOption(k.queryString("mobileVirtualJoystick"),1),mouseZoomDirection:q.getIntOption(k.queryString("mouseZoomDirection"),0),showPlayerList:q.getNumberBoolOption(k.queryString("playerListToggle"),!0),preferDecoder:q.getStringOption(k.queryString("preferDecoder"),"h264"),touchOperateMode:o,appliId:q.getStringOption(k.queryString("appliId"),""),syncLocalToCloudClipboard:q.getBoolOption(k.queryString("syncLocalToCloudClipboard"),!0),enableRttIcon:q.getBoolOption(k.queryString("enableRttIcon"),!0),enableSoundRequire:q.getBoolOption(k.queryString("enableSoundRequire"),!0),toastLevel:q.getIntOption(k.queryString("toastLevel"),0),language:k.queryString("language"),wsId:q.getStringOption(k.queryString("wsId"),""),groupId:q.getStringOption(k.queryString("groupId"),""),audioInputAutoStart:q.getBoolOption(k.queryString("audioInputAutoStart"),!1),videoInputAutoStart:q.getBoolOption(k.queryString("videoInputAutoStart"),!1),initResolutionType:q.getIntOption(k.queryString("initResolutionType"),0),shareUrl:q.getBoolOption(k.queryString("audioInput"),!1),textInputEventPrompt:q.getBoolOption(k.queryString("textInputEventPrompt"),!0),audioInput:q.getBoolOption(k.queryString("audioInput"),!1),videoInput:q.getBoolOption(k.queryString("videoInput"),!1),liveStreaming:q.getBoolOption(k.queryString("liveStreaming"),!1),useSeparateMediaSharePeer:!0,mobileKeyboardType:q.getIntOption(k.queryString("mobileKeyboardType"),0),useWebCodec:q.getNumberBoolOption(k.queryString("useWebCodec"),!1),mobileWebMenuType:q.getIntOption(k.queryString("mobileWebMenuType"),0),showWebMenu:q.getIntOption(k.queryString("showWebMenu"),1),forceResolution:q.getBoolOption(k.queryString("forceResolution"),!1),ignoreCloudDesktopResolution:q.getBoolOption(k.queryString("ignoreCloudDesktopResolution"),!0),ignoreScreenOrientation:q.getBoolOption(k.queryString("ignoreScreenOrientation"),!0),imeFirstNotice:q.getIntOption(k.queryString("imeFirstNotice"),0)}},AppliParamsUtils:q,LoadAppliParamsStartAppInfo:Dn,EventBase:b,ScaleMode:M,Capabilities:I,CloudLark:h.CloudLark,FullScreen:qn,LockPointer:Zn,Operation:Xn,LarkSRClientEvent:ne,LarkEventType:r,GESTURE_TYPE:re,KEYMAP:Zt}}(),__webpack_exports__=__webpack_exports__.default,__webpack_exports__}()})})(larksrWebSdk_min);var larksrWebSdk_minExports=larksrWebSdk_min.exports;class LoadStream{constructor(){this._gameApi=null,this._larksr=null}static async createAndInitLarkSR(m,u={}){if(typeof larksrWebSdk_minExports.LarkSR!="function")throw new Error("LarkSR 构造函数未找到,请确保已正确引入 larksr_websdk");setUELogEnabled((m==null?void 0:m.UELogLevel)??!0);const A=loadStream,b=new larksrWebSdk_minExports.LarkSR(m);A._larksr=b,b.on("datachannelopen",u.onDataChannelOpen||(c=>{log("数据通道已连通",c)}));let S=!0;return b.on("datachanneltext",c=>{S&&(S=!1,u.onSceneInitialized?u.onSceneInitialized(c):log("场景初始化加载成功",c)),u.onDatachanneltext?u.onDatachanneltext(c):log("接收数据",c)}),b.on("error",u.onError||(c=>{console.error(c.message)})),b.on("info",u.onInfo||(c=>{log("LarkSRClientEvent info",c)})),await b.connect({appliId:m.appliId}),u.onConnected&&u.onConnected(b),A.init(b),b.audioElement&&(b.audioElement.volume=0),A._gameApi}init(m){try{const u=new CommandManager(m);return this._gameApi=new GameAPI(u),console.log("插件初始化成功"),this._gameApi}catch(u){throw console.error("插件初始化失败",u),u}}async close(){if(this._larksr&&typeof this._larksr.close=="function")try{await this._larksr.close(),console.log("连接关闭成功")}catch(m){console.error("连接关闭失败:",m)}this._gameApi=null,this._larksr=null}}const loadStream=new LoadStream,createAndInitLarkSR=loadStream.constructor.createAndInitLarkSR;function closeGameApi(){return loadStream.close()}exports.closeGameApi=closeGameApi,exports.createAndInitLarkSR=createAndInitLarkSR,exports.default=loadStream,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
72
+ `;class ai{get inited(){return this._inited}get canvas(){return this._canvas}get video(){return this._video}get gl(){return this._gl}get shaderProgram(){return this._shaderProgram}constructor(){this._inited=!1,this._canvas=null,this._video=null,this._gl=null,this._shaderProgram=null,this.vertexPosition=0,this.textureCoord=0,this.uSampler=0,this.buffers=null,this.texture=null,this.drawFrames=0,this.playing=!1,this.timeupdate=!1,this.copyVideo=!1,this.startInternal=!1,this.draw=this.draw.bind(this)}init(n,a){this._inited=!1,this._canvas=n,this._video=a,this._video.addEventListener("playing",()=>{this.playing=!0,this.checkReady()}),this._video.addEventListener("timeupdate",()=>{this.timeupdate=!0,this.checkReady()});const s=n.getContext("webgl");if(s==null)return c.warn("webgl init failed Your browser or machine may not support it",s,n),!1;this._gl=s,s.clearColor(0,0,0,1),s.clear(s.COLOR_BUFFER_BIT);const p=Ie.initShaderProgram(s,Ie.fullscreenVsSource,Ie.fullscreenFsSource);return p?(this._shaderProgram=p,this.vertexPosition=s.getAttribLocation(p,"aVertexPosition"),this.textureCoord=s.getAttribLocation(p,"aTextureCoord"),this.uSampler=s.getUniformLocation(p,"uSampler"),this.buffers=Ie.initfullScreenBuffers(s),this.buffers!=null&&this.buffers.position!=null&&this.buffers.textureCoord&&(Ie.setPositionAttribute(s,this.buffers.position,this.vertexPosition),Ie.setTextureAttribute(s,this.buffers.textureCoord,this.textureCoord),s.bindBuffer(s.ARRAY_BUFFER,this.buffers.position),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.buffers.indices),s.bindBuffer(s.ARRAY_BUFFER,this.buffers.textureCoord),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.buffers.indices),s.bindBuffer(s.ARRAY_BUFFER,null)),this.texture=Ie.initTexture(s),this._inited=!0,!0):(c.warn("initShaderProgram failed",s,Ie.fullscreenVsSource,Ie.fullscreenFsSource),!1)}checkReady(){this.playing&&this.timeupdate&&(this.copyVideo=!0)}startCanvasRender(){this.stopCanvasRender(),this.startInternal=!0,this.draw()}stopCanvasRender(){this.drawFrames!=-1&&(window.cancelAnimationFrame(this.drawFrames),this.drawFrames=-1),this.startInternal=!1}draw(n=0,a=0,s=1920,p=1080){if(!this.inited||this.gl==null||!(this.gl&&this.texture&&this.video&&this.copyVideo))return;Ie.updateTexture(this.gl,this.texture,this.video);let v=this.gl;v.viewport(n,a,s,p),v.clearColor(0,0,0,1),v.disable(v.DEPTH_TEST),v.clear(v.COLOR_BUFFER_BIT),v.useProgram(this.shaderProgram),v.activeTexture(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,this.texture),v.uniform1i(this.uSampler,0);{const R=v.UNSIGNED_SHORT;v.drawElements(v.TRIANGLES,6,R,0)}this.startInternal&&(this.drawFrames=window.requestAnimationFrame(this.draw))}updateVideo(n){this._video=n,this.gl&&this.texture&&Ie.updateTexture(this.gl,this.texture,n)}}function si(o){cn(o,"svelte-1we6aa5",'@charset "UTF-8";.pxy-render.pxy-render-release.svelte-1we6aa5.svelte-1we6aa5{margin:0;padding:0}.pxy-render.pxy-render-release.svelte-1we6aa5 video.svelte-1we6aa5{transition:none}.pxy-render.pxy-render-release.svelte-1we6aa5 .showVideo.svelte-1we6aa5{position:relative;object-fit:fill;width:100%;min-height:100%}.pxy-render.pxy-render-release.svelte-1we6aa5 .hiddenVideo.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px;object-fit:fill}.pxy-render.pxy-render-release.svelte-1we6aa5 .hiddenRenderCanvas.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px}.pxy-render.pxy-render-release.svelte-1we6aa5 .showRenderCanvas.svelte-1we6aa5{position:relative;object-fit:fill}.pxy-render.pxy-render-release.svelte-1we6aa5 .audio.svelte-1we6aa5{position:absolute;z-index:-9999;top:-9999px;left:-9999px}')}function ui(o){let n,a,s,p,v,O,R,L,C,w,V,_,z,B,K,te,$,ke,ge,Ce,Fe,Xe,Ue;return{c(){n=pe("div"),a=pe("video"),O=Ke(),R=pe("canvas"),_=Ke(),z=pe("canvas"),ke=Ke(),ge=pe("audio"),U(a,"class",s=It(o[2]?"hiddenVideo":"showVideo")+" svelte-1we6aa5"),U(a,"width",p=o[0].container.width+"px"),U(a,"height",v=o[0].container.height+"px"),a.autoplay=o[1],a.playsInline=!0,U(a,"webkit-playsinline",!0),U(a,"preload","auto"),U(a,"x5-video-player-type","h5"),U(a,"x5-video-player-fullscreen","true"),U(a,"x5-video-orientation","portrait"),U(R,"class",L=It(o[2]&&o[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5"),U(R,"style",C="width:"+o[0].container.width+"px; height:"+o[0].container.height+"px"),U(R,"width",w=o[10](o[0])+"px"),U(R,"height",V=o[11](o[0])+"px"),U(z,"class",B=It(o[2]&&!o[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5"),U(z,"style",K="width:"+o[0].container.width+"px; height:"+o[0].container.height+"px"),U(z,"width",te=o[10](o[0])+"px"),U(z,"height",$=o[11](o[0])+"px"),U(ge,"class","audio svelte-1we6aa5"),ge.controls=!1,ge.autoplay=!0,U(n,"class","pxy-render pxy-render-release svelte-1we6aa5"),U(n,"width",Ce=o[0].container.width+"px"),U(n,"height",Fe=o[0].container.height+"px")},m(ce,D){Re(ce,n,D),he(n,a),o[30](a),he(n,O),he(n,R),o[31](R),he(n,_),he(n,z),o[32](z),he(n,ke),he(n,ge),o[33](ge),Xe||(Ue=[Mt(a,"loadedmetadata",o[8]),Mt(ge,"loadedmetadata",o[9])],Xe=!0)},p(ce,D){4&D[0]&&s!==(s=It(ce[2]?"hiddenVideo":"showVideo")+" svelte-1we6aa5")&&U(a,"class",s),1&D[0]&&p!==(p=ce[0].container.width+"px")&&U(a,"width",p),1&D[0]&&v!==(v=ce[0].container.height+"px")&&U(a,"height",v),2&D[0]&&(a.autoplay=ce[1]),12&D[0]&&L!==(L=It(ce[2]&&ce[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5")&&U(R,"class",L),1&D[0]&&C!==(C="width:"+ce[0].container.width+"px; height:"+ce[0].container.height+"px")&&U(R,"style",C),1&D[0]&&w!==(w=ce[10](ce[0])+"px")&&U(R,"width",w),1&D[0]&&V!==(V=ce[11](ce[0])+"px")&&U(R,"height",V),12&D[0]&&B!==(B=It(ce[2]&&!ce[3]?"showRenderCanvas":"hiddenRenderCanvas")+" svelte-1we6aa5")&&U(z,"class",B),1&D[0]&&K!==(K="width:"+ce[0].container.width+"px; height:"+ce[0].container.height+"px")&&U(z,"style",K),1&D[0]&&te!==(te=ce[10](ce[0])+"px")&&U(z,"width",te),1&D[0]&&$!==($=ce[11](ce[0])+"px")&&U(z,"height",$),1&D[0]&&Ce!==(Ce=ce[0].container.width+"px")&&U(n,"width",Ce),1&D[0]&&Fe!==(Fe=ce[0].container.height+"px")&&U(n,"height",Fe)},i:tt,o:tt,d(ce){ce&&Oe(n),o[30](null),o[31](null),o[32](null),o[33](null),Xe=!1,St(Ue)}}}const kn="mediaPlayedMute",Gt="mediaPlayedFailed";function ci(o,n,a){__webpack_require__(6131);let s,p,v,O,R,L,{screenState:C}=n,{mutePlayWhenFailed:w}=n,{autoPlay:V=!0}=n,{appState:_}=n,{canvasRender:z=!1}=n,{forceCanvas2d:B=!1}=n,{appParams:K}=n,{forceContinuePlayWhenPause:te=!0}=n,$=!1,ke=0;const ge=Kn();async function Ce(){if(!s)throw c.warn("play video failed. need video element ref"),new Error("no video found");try{c.info("playVideo"),await s.play(),ge("mediaPlayed"),c.info("playVideo success")}catch(H){throw c.info("playVideo failed",H),H}}function Fe(){s?$?(a(5,p.muted=!1,p),p.play().then(()=>{c.info("audio playout success",p.muted)}).catch(H=>{c.info("audio playout failed with user confirm.",H,p.muted)})):a(4,s.muted=!1,s):c.err("no render found")}function Xe(){Fe()}function Ue(){ce(),D()}function ce(){ke!=-1&&(window.clearTimeout(ke),ke=-1)}function D(){if(!B&&L.inited)return L.draw(0,0,Ae(C),Me(C)),void(ke=window.setTimeout(()=>{D()},1e3/K.frameRate));if(!z)return;const H=O;if(!H)return void c.warn("draw call without context");if(!s)return void c.warn("draw call without videoElement");const Je=Ae(C),ut=Me(C);H.clearRect(0,0,Je,ut),H.drawImage(s,0,0,Je,ut),ke=window.setTimeout(()=>{D()},1e3/K.frameRate)}function Ae(H){return I.os==="iOS"&&B?H.container.width:H.appSize.width?H.appSize.width:H.container.width}function Me(H){return I.os==="iOS"?H.container.width:H.appSize.height?H.appSize.height:H.container.height}function We(){te&&(Ce(),Xe())}var ee;return dn(()=>{L=new ai,L.init(R,s),O=v.getContext("2d"),O==null&&c.err("init capture context failed.",O,v),z&&Ue(),a(4,s.playsInline=!0,s),s.addEventListener("pause",We),document.addEventListener("WeixinJSBridgeReady",()=>{c.warn("WeixinJSBridgeReady play video"),V&&Ce().then(()=>{c.info("ios auto play success")}).catch(H=>{c.warn("ios auto play failed",H)})},!1),I.os==="iOS"&&V&&(c.info("on mount ios play video"),Ce().then(()=>{c.info("ios auto play success")}).catch(H=>{c.warn("ios auto play failed",H)}))}),ee=()=>{s.removeEventListener("pause",We),ke!=-1&&(window.clearTimeout(ke),ke=-1),O=null},En().$$.on_destroy.push(ee),o.$$set=H=>{"screenState"in H&&a(0,C=H.screenState),"mutePlayWhenFailed"in H&&a(12,w=H.mutePlayWhenFailed),"autoPlay"in H&&a(1,V=H.autoPlay),"appState"in H&&a(13,_=H.appState),"canvasRender"in H&&a(2,z=H.canvasRender),"forceCanvas2d"in H&&a(3,B=H.forceCanvas2d),"appParams"in H&&a(14,K=H.appParams),"forceContinuePlayWhenPause"in H&&a(15,te=H.forceContinuePlayWhenPause)},[C,V,z,B,s,p,v,R,function(H){c.info("onLoadedmetadata");const Je=s;Je?_>=J.RTC_CLOSED?c.warn("onLoadedmetadata video failed. rtc peerconnection already closed"):(c.info("++++++++++++++onLoadedmetadata+++++++++++++++++"),ge("mediaLoaded"),V?Ce().then(()=>{c.info("play video success")}).catch(ut=>{c.info("play video failed. need user confirm",ut),$?I.isMobile&&(I.isQQ||I.isHuawei||I.isWeChat)?ge(Gt):(Je.muted=!0,Ce().then(()=>{c.info("play video success")}).catch(ht=>{c.err("play video failed.",ht),ge(Gt)})):w?I.isMobile&&(I.isQQ||I.isHuawei||I.isWeChat)?ge(Gt):(Je.muted=!0,Ce().then(()=>{c.info("play video success"),ge(kn)}).catch(ht=>{c.err("play video failed.",ht),ge(Gt)})):ge(Gt)}):c.info("++++++++++++++onLoadedmetadata but not auto play+++++++++++++++++")):c.warn("onLoadedmetadata video failed. need video element ref")},function(){p&&!p.played?p.play().then(()=>{}).catch(H=>{c.info("auto play audio failed",H),ge(kn),a(5,p.muted=!0,p),p.play()}):c.info("audio already played")},Ae,Me,w,_,K,te,function(H){s?(c.info("setVideoSrcObj",H),a(4,s.srcObject=H,s)):c.warn("setup video failed. need video element ref")},function(H){p?(c.info("setAudioSrcObj",H),a(5,p.srcObject=H,p),$=!0,p.play().then(()=>{c.info("auto play audio success.")}).catch(Je=>{c.warn("auto play audio failed. mute play",Je),ge(kn)})):c.warn("setup audio failed. need audio element ref")},function(){return s},function(){return p},function(){return $},function(){return v},function(){return O},Ce,Fe,Xe,function(){s?(s.pause(),$&&p.pause()):c.warn("stop video failed. need video element ref")},function(H,Je=void 0){let ut=C.appSize.width?C.appSize.width:C.container.width,ht=C.appSize.height?C.appSize.height:C.container.height;Je&&Je.width&&(ut=Je.width),Je&&Je.height&&(ht=Je.height);const gn=document.createElement("canvas");gn.width=ut,gn.height=ht;const gr=s,wn=gn.getContext("2d");if(!wn)return void c.warn("draw call without context");wn.clearRect(0,0,ut,ht),gr&&wn.drawImage(gr,0,0,ut,ht);const vr=gn.toDataURL("image/jpeg");return ge("pitcureCaptured",{data:H,base64:vr}),{data:H,base64:vr}},Ue,ce,function(H){at[H?"unshift":"push"](()=>{s=H,a(4,s)})},function(H){at[H?"unshift":"push"](()=>{v=H,a(6,v)})},function(H){at[H?"unshift":"push"](()=>{R=H,a(7,R)})},function(H){at[H?"unshift":"push"](()=>{p=H,a(5,p)})}]}var li=class extends mn{constructor(o){super(),fn(this,o,ci,ui,sn,{screenState:0,mutePlayWhenFailed:12,autoPlay:1,appState:13,canvasRender:2,forceCanvas2d:3,appParams:14,forceContinuePlayWhenPause:15,setVideoSrcObj:16,setAudioSrcObj:17,getVideo:18,getAudio:19,isSeprateAudioTrack:20,getRenderContext2dElement:21,getRenderContext2d:22,playVideo:23,sountPlayout:24,soundPlayout:25,stopVideo:26,captrueFrame:27,startCanvasRender:28,stopCanvasRender:29},si,[-1,-1])}get setVideoSrcObj(){return this.$$.ctx[16]}get setAudioSrcObj(){return this.$$.ctx[17]}get getVideo(){return this.$$.ctx[18]}get getAudio(){return this.$$.ctx[19]}get isSeprateAudioTrack(){return this.$$.ctx[20]}get getRenderContext2dElement(){return this.$$.ctx[21]}get getRenderContext2d(){return this.$$.ctx[22]}get playVideo(){return this.$$.ctx[23]}get sountPlayout(){return this.$$.ctx[24]}get soundPlayout(){return this.$$.ctx[25]}get stopVideo(){return this.$$.ctx[26]}get captrueFrame(){return this.$$.ctx[27]}get startCanvasRender(){return this.$$.ctx[28]}get stopCanvasRender(){return this.$$.ctx[29]}};function di(o){cn(o,"svelte-17ckf92",".cursorContainer.svelte-17ckf92.svelte-17ckf92{pointer-events:none;position:absolute;margin:0;padding:0;display:block;z-index:10;width:24px;height:24px;background-size:contain}.cursorContainer.svelte-17ckf92 img.svelte-17ckf92{width:100%;height:auto}.pointerContainer.svelte-17ckf92.svelte-17ckf92{position:absolute;pointer-events:none;top:0;left:0;z-index:1}.pointerContainer.svelte-17ckf92 .pointer.svelte-17ckf92{width:6px;height:6px;margin-left:-3px;margin-top:-3px;background-color:#32cdcd;border-radius:50%;pointer-events:none}")}function pi(o){let n,a,s;return{c(){n=pe("div"),a=pe("img"),Qe(a.src,s=o[4](o[2].type))||U(a,"src",s),Te(a,"marginLeft",-o[2].hotX+"px"),Te(a,"marginTop",-o[2].hotY+"px"),U(a,"alt",""),U(a,"class","svelte-17ckf92"),U(n,"class","cursorContainer svelte-17ckf92"),U(n,"draggable","false"),Te(n,"left",o[0].x+"px"),Te(n,"top",o[0].y+"px")},m(p,v){Re(p,n,v),he(n,a)},p(p,v){4&v&&!Qe(a.src,s=p[4](p[2].type))&&U(a,"src",s),4&v&&Te(a,"marginLeft",-p[2].hotX+"px"),4&v&&Te(a,"marginTop",-p[2].hotY+"px"),1&v&&Te(n,"left",p[0].x+"px"),1&v&&Te(n,"top",p[0].y+"px")},d(p){p&&Oe(n)}}}function Ai(o){let n,a=o[3]&&nr(o);return{c(){a&&a.c(),n=ln()},m(s,p){a&&a.m(s,p),Re(s,n,p)},p(s,p){s[3]?a?a.p(s,p):(a=nr(s),a.c(),a.m(n.parentNode,n)):a&&(a.d(1),a=null)},d(s){a&&a.d(s),s&&Oe(n)}}}function nr(o){let n,a;return{c(){n=pe("div"),a=pe("div"),U(a,"class","pointer svelte-17ckf92"),U(n,"class","pointerContainer svelte-17ckf92"),Te(n,"left",o[0].x+"px"),Te(n,"top",o[0].y+"px")},m(s,p){Re(s,n,p),he(n,a)},p(s,p){1&p&&Te(n,"left",s[0].x+"px"),1&p&&Te(n,"top",s[0].y+"px")},d(s){s&&Oe(n)}}}function hi(o){let n;function a(v,O){return v[1].isMobile?Ai:pi}let s=a(o),p=s(o);return{c(){p.c(),n=ln()},m(v,O){p.m(v,O),Re(v,n,O)},p(v,[O]){s===(s=a(v))&&p?p.p(v,O):(p.d(1),p=s(v),p&&(p.c(),p.m(n.parentNode,n)))},i:tt,o:tt,d(v){p.d(v),v&&Oe(n)}}}function fi(o,n,a){let{screenState:s}=n,{syncCursorStyle:p}=n,{cursorPosition:v={x:0,y:0}}=n,{touchPonitEnable:O=!0}=n;const R={CURSOR_ARROR:__webpack_require__(1707).A,CURSOR_EW:__webpack_require__(4690).A,CURSOR_LINK:__webpack_require__(6376).A,CURSOR_MOVE:__webpack_require__(4059).A,CURSOR_NESW:__webpack_require__(289).A,CURSOR_NS:__webpack_require__(4145).A,CURSOR_NWSE:__webpack_require__(5957).A,CURSOR_UNAVAIL:__webpack_require__(1696).A,CURSOR_BEAM_RM:__webpack_require__(1008).A,CURSOR_BUSY_RM:__webpack_require__(4106).A,CURSOR_CROSS_RM:__webpack_require__(2971).A,CURSOR_WAIT:__webpack_require__(6293).A};return dn(()=>{a(0,v={x:s.container.width/2,y:s.container.height/2})}),o.$$set=L=>{"screenState"in L&&a(1,s=L.screenState),"syncCursorStyle"in L&&a(2,p=L.syncCursorStyle),"cursorPosition"in L&&a(0,v=L.cursorPosition),"touchPonitEnable"in L&&a(3,O=L.touchPonitEnable)},[v,s,p,O,function(L){switch(c.info("cursor style ",L),L){case Le.ARROW:return R.CURSOR_ARROR;case Le.CROSS:return R.CURSOR_CROSS_RM;case Le.HAND:return R.CURSOR_LINK;case Le.IBEAM:return R.CURSOR_BEAM_RM;case Le.NO:return R.CURSOR_UNAVAIL;case Le.SIZEALL:return R.CURSOR_MOVE;case Le.SIZENESW:return R.CURSOR_NESW;case Le.SIZENS:return R.CURSOR_NS;case Le.SIZENWSE:return R.CURSOR_NWSE;case Le.SIZEWE:return R.CURSOR_EW;case Le.WAIT:return R.CURSOR_WAIT;case Le.CUSTOM:return p.customBase64!=""?p.customBase64:R.CURSOR_ARROR;default:return R.CURSOR_ARROR}}]}var mi=class extends mn{constructor(o){super(),fn(this,o,fi,hi,sn,{screenState:1,syncCursorStyle:2,cursorPosition:0,touchPonitEnable:3},di)}};function yi(o){cn(o,"svelte-98izw4",'@charset "UTF-8";.pxy-view-port.svelte-98izw4.svelte-98izw4{position:absolute;top:0;left:0;padding:0;margin:0;z-index:1;margin:0;padding:0;background-color:rgba(0, 0, 0, 0.05)}.pxy-view-port.svelte-98izw4 .pxy-container.svelte-98izw4{margin:0 auto;box-shadow:0 0 10px rgba(0, 0, 0, 0.4);background-color:rgba(0, 0, 0, 0.05);position:relative;overflow:hidden;margin:0;padding:0}')}function rr(o){let n,a;return n=new mi({props:{screenState:o[0],syncCursorStyle:o[1],cursorPosition:o[9],touchPonitEnable:o[10]}}),{c(){Tn(n.$$.fragment)},m(s,p){An(n,s,p),a=!0},p(s,p){const v={};1&p[0]&&(v.screenState=s[0]),2&p[0]&&(v.syncCursorStyle=s[1]),512&p[0]&&(v.cursorPosition=s[9]),1024&p[0]&&(v.touchPonitEnable=s[10]),n.$set(v)},i(s){a||(it(n.$$.fragment,s),a=!0)},o(s){Et(n.$$.fragment,s),a=!1},d(s){hn(n,s)}}}function ir(o){let n,a;return n=new oi({props:{taskReady:o[6].taskid!="",wsId:o[6].wsId,screenState:o[0],ui:o[2],serverAddress:o[3],appState:o[4],syncApp:o[5],loadingBgUrl:o[7],showLoadingStateBar:o[11],showPlayButton:o[13],tapedPlayButton:o[21],loadingLogoVersion:o[16],loadingStateMsg:o[17]}}),{c(){Tn(n.$$.fragment)},m(s,p){An(n,s,p),a=!0},p(s,p){const v={};64&p[0]&&(v.taskReady=s[6].taskid!=""),64&p[0]&&(v.wsId=s[6].wsId),1&p[0]&&(v.screenState=s[0]),4&p[0]&&(v.ui=s[2]),8&p[0]&&(v.serverAddress=s[3]),16&p[0]&&(v.appState=s[4]),32&p[0]&&(v.syncApp=s[5]),128&p[0]&&(v.loadingBgUrl=s[7]),2048&p[0]&&(v.showLoadingStateBar=s[11]),8192&p[0]&&(v.showPlayButton=s[13]),2097152&p[0]&&(v.tapedPlayButton=s[21]),65536&p[0]&&(v.loadingLogoVersion=s[16]),131072&p[0]&&(v.loadingStateMsg=s[17]),n.$set(v)},i(s){a||(it(n.$$.fragment,s),a=!0)},o(s){Et(n.$$.fragment,s),a=!1},d(s){hn(n,s)}}}function gi(o){let n,a,s,p,v,O,R,L,C,w,V=o[6].appliType!==bt.PIXEL_STREAMING&&(o[0].isMobile||o[0].isLocalRenderMouse)&&rr(o),_={appState:o[4],screenState:o[0],mutePlayWhenFailed:o[8],autoPlay:o[12],canvasRender:o[14],forceCanvas2d:o[15],appParams:o[6]};p=new li({props:_}),o[44](p),p.$on("mediaLoaded",o[45]),p.$on("mediaPlayed",o[46]),p.$on("mediaPlayedMute",o[25]),p.$on("mediaPlayedFailed",o[47]),p.$on("pitcureCaptured",o[48]);let z=(o[4]<=J.MEDIA_LOADED||o[4]>=J.RTC_RETRY)&&ir(o);return{c(){n=pe("div"),a=pe("div"),V&&V.c(),s=Ke(),Tn(p.$$.fragment),O=Ke(),z&&z.c(),U(a,"class","pxy-container svelte-98izw4"),U(a,"style",v=o[0].containerStyle),U(n,"class","pxy-view-port svelte-98izw4"),U(n,"style",R=o[0].viewPortStyle)},m(B,K){Re(B,n,K),he(n,a),V&&V.m(a,null),he(a,s),An(p,a,null),o[49](a),he(n,O),z&&z.m(n,null),o[50](n),L=!0,C||(w=[Mt(a,"mouseup",o[23]),Mt(a,"touchend",o[24],{passive:!0}),Mt(n,"mouseup",o[26]),Mt(n,"touchend",o[26],{passive:!0})],C=!0)},p(B,K){B[6].appliType!==bt.PIXEL_STREAMING&&(B[0].isMobile||B[0].isLocalRenderMouse)?V?(V.p(B,K),65&K[0]&&it(V,1)):(V=rr(B),V.c(),it(V,1),V.m(a,s)):V&&(Yn(),Et(V,1,1,()=>{V=null}),Hn());const te={};16&K[0]&&(te.appState=B[4]),1&K[0]&&(te.screenState=B[0]),256&K[0]&&(te.mutePlayWhenFailed=B[8]),4096&K[0]&&(te.autoPlay=B[12]),16384&K[0]&&(te.canvasRender=B[14]),32768&K[0]&&(te.forceCanvas2d=B[15]),64&K[0]&&(te.appParams=B[6]),p.$set(te),(!L||1&K[0]&&v!==(v=B[0].containerStyle))&&U(a,"style",v),B[4]<=J.MEDIA_LOADED||B[4]>=J.RTC_RETRY?z?(z.p(B,K),16&K[0]&&it(z,1)):(z=ir(B),z.c(),it(z,1),z.m(n,null)):z&&(Yn(),Et(z,1,1,()=>{z=null}),Hn()),(!L||1&K[0]&&R!==(R=B[0].viewPortStyle))&&U(n,"style",R)},i(B){L||(it(V),it(p.$$.fragment,B),it(z),L=!0)},o(B){Et(V),Et(p.$$.fragment,B),Et(z),L=!1},d(B){B&&Oe(n),V&&V.d(),o[44](null),hn(p),o[49](null),z&&z.d(),o[50](null),C=!1,St(w)}}}function vi(o,n,a){let s,p,v,{screenState:O}=n,{syncCursorStyle:R}=n,{ui:L}=n,{serverAddress:C}=n,{appState:w}=n,{syncApp:V}=n,{isMobile:_}=n,{appParams:z}=n,{loadingBgUrl:B}=n,{mutePlayWhenFailed:K}=n,{cursorPosition:te={x:0,y:0}}=n,{touchPonitEnable:$=!0}=n,{showLoadingStateBar:ke=!0}=n,{autoPlay:ge=!0}=n,{showPlayButton:Ce=!0}=n,{canvasRender:Fe=!1}=n,{forceCanvas2d:Xe=!1}=n,{loadingLogoVersion:Ue}=n,{loadingStateMsg:ce=""}=n,D=!1,Ae=!1,Me=!1;const We=Kn();return dn(()=>{We("loaded",p)}),o.$$set=ee=>{"screenState"in ee&&a(0,O=ee.screenState),"syncCursorStyle"in ee&&a(1,R=ee.syncCursorStyle),"ui"in ee&&a(2,L=ee.ui),"serverAddress"in ee&&a(3,C=ee.serverAddress),"appState"in ee&&a(4,w=ee.appState),"syncApp"in ee&&a(5,V=ee.syncApp),"isMobile"in ee&&a(27,_=ee.isMobile),"appParams"in ee&&a(6,z=ee.appParams),"loadingBgUrl"in ee&&a(7,B=ee.loadingBgUrl),"mutePlayWhenFailed"in ee&&a(8,K=ee.mutePlayWhenFailed),"cursorPosition"in ee&&a(9,te=ee.cursorPosition),"touchPonitEnable"in ee&&a(10,$=ee.touchPonitEnable),"showLoadingStateBar"in ee&&a(11,ke=ee.showLoadingStateBar),"autoPlay"in ee&&a(12,ge=ee.autoPlay),"showPlayButton"in ee&&a(13,Ce=ee.showPlayButton),"canvasRender"in ee&&a(14,Fe=ee.canvasRender),"forceCanvas2d"in ee&&a(15,Xe=ee.forceCanvas2d),"loadingLogoVersion"in ee&&a(16,Ue=ee.loadingLogoVersion),"loadingStateMsg"in ee&&a(17,ce=ee.loadingStateMsg)},[O,R,L,C,w,V,z,B,K,te,$,ke,ge,Ce,Fe,Xe,Ue,ce,s,p,v,Me,We,function(){Ae&&(s&&s.sountPlayout(),Ae=!1),z.fullScreenMode==1?D||(We("requestFullScreen"),D=!0):z.fullScreenMode==2&&We("requestFullScreen")},function(){Ae&&(s&&s.sountPlayout(),Ae=!1,_)||(z.mobileFullScreenMode==1?D||(window.setTimeout(()=>{We("requestFullScreen")},100),D=!0):z.mobileFullScreenMode==2&&window.setTimeout(()=>{We("requestFullScreen")},100))},function(){Ae=!0,We("mediaPlayedMute")},function(){w>J.INITED&&w<J.MEDIA_PLAYED&&(s==null||s.playVideo().catch(ee=>{c.warn("play video failed with user click",ee)}),window.setTimeout(()=>{w>J.INITED&&w<J.MEDIA_PLAYED&&a(21,Me=!0)},1e3))},_,function(){return p},function(){return s},function(){return v},function(ee){s==null||s.setVideoSrcObj(ee)},function(){return s==null?void 0:s.getVideo()},async function(){s==null||s.playVideo()},function(){s.sountPlayout()},function(){s.stopVideo()},function(ee){s==null||s.setAudioSrcObj(ee)},function(){return s.getAudio()},function(){return s.startCanvasRender()},function(){return s.stopCanvasRender()},function(){return s.isSeprateAudioTrack()},function(ee,H=void 0){return s.captrueFrame(ee,H)},function(){return s.getRenderContext2dElement()},function(){return s.getRenderContext2d()},function(ee){at[ee?"unshift":"push"](()=>{s=ee,a(18,s)})},()=>We("mediaLoaded"),()=>We("mediaPlayed"),()=>We("mediaPlayedFailed"),ee=>We("pitcureCaptured",ee.detail),function(ee){at[ee?"unshift":"push"](()=>{p=ee,a(19,p)})},function(ee){at[ee?"unshift":"push"](()=>{v=ee,a(20,v)})}]}var bi=class extends mn{constructor(o){super(),fn(this,o,vi,gi,sn,{screenState:0,syncCursorStyle:1,ui:2,serverAddress:3,appState:4,syncApp:5,isMobile:27,appParams:6,loadingBgUrl:7,mutePlayWhenFailed:8,cursorPosition:9,touchPonitEnable:10,showLoadingStateBar:11,autoPlay:12,showPlayButton:13,canvasRender:14,forceCanvas2d:15,loadingLogoVersion:16,loadingStateMsg:17,getContainerComponent:28,getVideoComponent:29,getViewportComponent:30,setVideoSrcObj:31,getVideo:32,playVideo:33,sountPlayout:34,stopVideo:35,setAudioSrcObj:36,getAudio:37,startCanvasRender:38,stopCanvasRender:39,isSeprateAudioTrack:40,captrueFrame:41,getRenderContext2dElement:42,getRenderContext2d:43},yi,[-1,-1])}get screenState(){return this.$$.ctx[0]}set screenState(o){this.$$set({screenState:o}),xe()}get syncCursorStyle(){return this.$$.ctx[1]}set syncCursorStyle(o){this.$$set({syncCursorStyle:o}),xe()}get ui(){return this.$$.ctx[2]}set ui(o){this.$$set({ui:o}),xe()}get serverAddress(){return this.$$.ctx[3]}set serverAddress(o){this.$$set({serverAddress:o}),xe()}get appState(){return this.$$.ctx[4]}set appState(o){this.$$set({appState:o}),xe()}get syncApp(){return this.$$.ctx[5]}set syncApp(o){this.$$set({syncApp:o}),xe()}get isMobile(){return this.$$.ctx[27]}set isMobile(o){this.$$set({isMobile:o}),xe()}get appParams(){return this.$$.ctx[6]}set appParams(o){this.$$set({appParams:o}),xe()}get loadingBgUrl(){return this.$$.ctx[7]}set loadingBgUrl(o){this.$$set({loadingBgUrl:o}),xe()}get mutePlayWhenFailed(){return this.$$.ctx[8]}set mutePlayWhenFailed(o){this.$$set({mutePlayWhenFailed:o}),xe()}get cursorPosition(){return this.$$.ctx[9]}set cursorPosition(o){this.$$set({cursorPosition:o}),xe()}get touchPonitEnable(){return this.$$.ctx[10]}set touchPonitEnable(o){this.$$set({touchPonitEnable:o}),xe()}get showLoadingStateBar(){return this.$$.ctx[11]}set showLoadingStateBar(o){this.$$set({showLoadingStateBar:o}),xe()}get autoPlay(){return this.$$.ctx[12]}set autoPlay(o){this.$$set({autoPlay:o}),xe()}get showPlayButton(){return this.$$.ctx[13]}set showPlayButton(o){this.$$set({showPlayButton:o}),xe()}get canvasRender(){return this.$$.ctx[14]}set canvasRender(o){this.$$set({canvasRender:o}),xe()}get forceCanvas2d(){return this.$$.ctx[15]}set forceCanvas2d(o){this.$$set({forceCanvas2d:o}),xe()}get loadingLogoVersion(){return this.$$.ctx[16]}set loadingLogoVersion(o){this.$$set({loadingLogoVersion:o}),xe()}get loadingStateMsg(){return this.$$.ctx[17]}set loadingStateMsg(o){this.$$set({loadingStateMsg:o}),xe()}get getContainerComponent(){return this.$$.ctx[28]}get getVideoComponent(){return this.$$.ctx[29]}get getViewportComponent(){return this.$$.ctx[30]}get setVideoSrcObj(){return this.$$.ctx[31]}get getVideo(){return this.$$.ctx[32]}get playVideo(){return this.$$.ctx[33]}get sountPlayout(){return this.$$.ctx[34]}get stopVideo(){return this.$$.ctx[35]}get setAudioSrcObj(){return this.$$.ctx[36]}get getAudio(){return this.$$.ctx[37]}get startCanvasRender(){return this.$$.ctx[38]}get stopCanvasRender(){return this.$$.ctx[39]}get isSeprateAudioTrack(){return this.$$.ctx[40]}get captrueFrame(){return this.$$.ctx[41]}get getRenderContext2dElement(){return this.$$.ctx[42]}get getRenderContext2d(){return this.$$.ctx[43]}};const Si=1,Oi=7,Ei=50,Ri=51,or=60,ar=61,Li=62,Ci=70,Ti=71,ki=72,wi=73,Pi=74,Ii=75,Mi=80,Ni=81,xi=82,Vi=90,Di=91,Wi=92,yn=0,sr=1,ur=2,cr=3,lr=4,dr=1,pr=2,Ar=4,hr=8,fr=16,mr=8,_i=16,ji=17,Fi=18,zi=253,Xi=254,qi=255,Zi=0,yr=window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame,Ui="GamepadEvent"in window,Bi="WebKitGamepadEvent"in window,st=(document.createEvent("KeyboardEvent").initKeyboardEvent,{});class Gi extends b{get startListen(){return this._startListen}constructor(n){super(),this.playerElementClientRect={x:0,y:0,width:0,height:0,bottom:0,left:0,top:0,right:0,toJSON:()=>JSON.stringify(this)},this.normalizeAndQuantizeUnsigned=(a,s)=>({x:0,y:0,inRange:!1}),this.normalizeAndQuantizeSigned=(a,s)=>({x:0,y:0}),this.unquantizeAndDenormalizeUnsigned=(a,s)=>({x:0,y:0}),this.inputOptions={controlScheme:Zi,suppressBrowserKeys:!0,fakeMouseWithTouches:!1},this._startListen=!1,this.larksr=n,this.updateStatus=this.updateStatus.bind(this),this.gamepadDisconnectHandler=this.gamepadDisconnectHandler.bind(this)}registerInputs(n){this.registerMouseEnterAndLeaveEvents(n),this.registerTouchEvents(n)}setupMouseAndFreezeFrame(n,a){this.playerElementClientRect=n.getBoundingClientRect(),this.setupNormalizeAndQuantize(n,a)}emitUIInteraction(n){return this.emitDescriptor(Ei,n)}emitCommand(n){return this.emitDescriptor(Ri,n)}requestInitialSettings(){this.sendInputData(new Uint8Array([Oi]).buffer)}requestQualityControl(){this.sendInputData(new Uint8Array([Si]).buffer)}emitMouseMove(n,a,s,p){let v=this.normalizeAndQuantizeUnsigned(n,a),O=this.normalizeAndQuantizeSigned(s,p);c.info("emitMouseMove",v,O);let R=new DataView(new ArrayBuffer(9));R.setUint8(0,Pi),R.setUint16(1,v.x,!0),R.setUint16(3,v.y,!0),R.setInt16(5,O.x,!0),R.setInt16(7,O.y,!0),this.sendInputData(R.buffer)}emitMouseDown(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(6));v.setUint8(0,ki),v.setUint8(1,n),v.setUint16(2,p.x,!0),v.setUint16(4,p.y,!0),this.sendInputData(v.buffer)}emitMouseUp(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(6));v.setUint8(0,wi),v.setUint8(1,n),v.setUint16(2,p.x,!0),v.setUint16(4,p.y,!0),this.sendInputData(v.buffer)}emitMouseWheel(n,a,s){let p=this.normalizeAndQuantizeUnsigned(a,s),v=new DataView(new ArrayBuffer(7));v.setUint8(0,Ii),v.setInt16(1,n,!0),v.setUint16(3,p.x,!0),v.setUint16(5,p.y,!0),this.sendInputData(v.buffer)}releaseMouseButtons(n,a,s){n&dr&&this.emitMouseUp(yn,a,s),n&pr&&this.emitMouseUp(ur,a,s),n&Ar&&this.emitMouseUp(sr,a,s),n&hr&&this.emitMouseUp(cr,a,s),n&fr&&this.emitMouseUp(lr,a,s)}pressMouseButtons(n,a,s){n&dr&&this.emitMouseDown(yn,a,s),n&pr&&this.emitMouseDown(ur,a,s),n&Ar&&this.emitMouseDown(sr,a,s),n&hr&&this.emitMouseDown(cr,a,s),n&fr&&this.emitMouseDown(lr,a,s)}registerMouseEnterAndLeaveEvents(n){let a=this;n.onmouseenter=function(s){c.info("mouse enter");let p=new DataView(new ArrayBuffer(1));p.setUint8(0,Ci),a.sendInputData(p.buffer),n.pressMouseButtons(s.buttons,0,0)},n.onmouseleave=function(s){c.info("mouse leave");let p=new DataView(new ArrayBuffer(1));p.setUint8(0,Ti),a.sendInputData(p.buffer),n.releaseMouseButtons(s.buttons,0,0)}}registerLockedMouseEvents(n){this._startListen=!0;let a=this,s=n.clientWidth/2,p=n.clientHeight/2;function v(){document.pointerLockElement===n||document.mozPointerLockElement===n?(console.log("Pointer locked"),document.addEventListener("mousemove",O,!1)):(console.log("The pointer lock status is now unlocked"),document.removeEventListener("mousemove",O,!1))}function O(R){s+=R.movementX,p+=R.movementY,s>a.larksr.screenState.container.width&&(s-=a.larksr.screenState.container.width),p>a.larksr.screenState.container.height&&(p-=a.larksr.screenState.container.height),s<0&&(s=a.larksr.screenState.container.width+s),p<0&&(p=a.larksr.screenState.container.height-p),a.emitMouseMove(s,p,R.movementX,R.movementY)}n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock,document.exitPointerLock=document.exitPointerLock||n.mozExitPointerLock,n.onclick=function(){a.larksr.isObMode||n.requestPointerLock()},document.addEventListener("pointerlockchange",v,!1),document.addEventListener("mozpointerlockchange",v,!1),n.onmousedown=function(R){a.emitMouseDown(R.button,s,p)},n.onmouseup=function(R){a.emitMouseUp(R.button,s,p)},n.onmousewheel=function(R){a.emitMouseWheel(R.wheelDelta,s,p)},n.pressMouseButtons=function(R){a.pressMouseButtons(R.buttons,s,p)},n.releaseMouseButtons=function(R){a.releaseMouseButtons(R.buttons,s,p)}}registerHoveringMouseEvents(n){let a=this;c.info("registerHoveringMouseEvents",n),n.onmousemove=function(s){a.emitMouseMove(s.offsetX,s.offsetY,s.movementX,s.movementY),c.info("onmousemove",s),s.preventDefault()},n.onmousedown=function(s){a.emitMouseDown(s.button,s.offsetX,s.offsetY),s.preventDefault()},n.onmouseup=function(s){a.emitMouseUp(s.button,s.offsetX,s.offsetY),s.preventDefault()},n.oncontextmenu=function(s){a.emitMouseUp(s.button,s.offsetX,s.offsetY),s.preventDefault()},"onmousewheel"in n?n.onmousewheel=function(s){a.emitMouseWheel(s.wheelDelta,s.offsetX,s.offsetY),s.preventDefault()}:n.addEventListener("DOMMouseScroll",function(s){a.emitMouseWheel(-120*s.detail,s.offsetX,s.offsetY),s.preventDefault()},!1),n.pressMouseButtons=function(s){a.pressMouseButtons(s.buttons,s.offsetX,s.offsetY)},n.releaseMouseButtons=function(s){a.releaseMouseButtons(s.buttons,s.offsetX,s.offsetY)}}registerTouchEvents(n){let a=this,s=[9,8,7,6,5,4,3,2,1,0],p={};function v(R){let L=s.pop();L===void 0&&console.log("exhausted touch indentifiers"),p[R.identifier]=L}function O(R,L){let C=new DataView(new ArrayBuffer(2+7*L.length));C.setUint8(0,R),C.setUint8(1,L.length);let w=2;for(let V=0;V<L.length;V++){let _=L[V];const{screenOrientation:z,viewPort:B}=a.larksr.screenState;let K=_.clientX-n.offsetLeft,te=_.clientY-n.offsetTop;z==="landscape"?(K=_.clientY-n.offsetLeft,te=B.height-_.clientX-n.offsetTop):(K=_.clientX-n.offsetLeft,te=_.clientY-n.offsetTop),c.info(`F${p[_.identifier]}=(${K}, ${te})`);let $=a.normalizeAndQuantizeUnsigned(K,te);C.setUint16(w,$.x,!0),w+=2,C.setUint16(w,$.y,!0),w+=2,C.setUint8(w,p[_.identifier],!0),w+=1,C.setUint8(w,255*_.force,!0),w+=1,C.setUint8(w,$.inRange?1:0,!0),w+=1}a.sendInputData(C.buffer)}if(a.inputOptions.fakeMouseWithTouches){let R;n.ontouchstart=function(L){if(R===void 0){let C=L.changedTouches[0];R={id:C.identifier,x:C.clientX-a.playerElementClientRect.left,y:C.clientY-a.playerElementClientRect.top},n.onmouseenter(L),a.emitMouseDown(yn,R.x,R.y)}L.preventDefault()},n.ontouchend=function(L){for(let C=0;C<L.changedTouches.length;C++){let w=L.changedTouches[C];if(w.identifier===R.id){let V=w.clientX-a.playerElementClientRect.left,_=w.clientY-a.playerElementClientRect.top;a.emitMouseUp(yn,V,_),n.onmouseleave(L),R=void 0;break}}L.preventDefault()},n.ontouchmove=function(L){for(let C=0;C<L.touches.length;C++){let w=L.touches[C];if(w.identifier===R.id){let V=w.clientX-a.playerElementClientRect.left,_=w.clientY-a.playerElementClientRect.top;a.emitMouseMove(V,_,V-R.x,_-R.y),R.x=V,R.y=_;break}}L.preventDefault()}}else n.ontouchstart=function(R){for(let L=0;L<R.changedTouches.length;L++)v(R.changedTouches[L]);c.info("touch start"),O(Mi,R.changedTouches),R.preventDefault()},n.ontouchend=function(R){c.info("touch end"),O(Ni,R.changedTouches);for(let C=0;C<R.changedTouches.length;C++)L=R.changedTouches[C],s.push(p[L.identifier]),delete p[L.identifier];var L;R.preventDefault()},n.ontouchmove=function(R){c.info("touch move"),O(xi,R.touches),R.preventDefault()}}isKeyCodeBrowserKey(n){return n>=112&&n<=123||n===9}getKeyCode(n){return n.keyCode===_i&&n.code==="ShiftRight"?zi:n.keyCode===ji&&n.code==="ControlRight"?Xi:n.keyCode===Fi&&n.code==="AltRight"?qi:n.keyCode}registerKeyboardEvents(){this._startListen=!0;let n=this;document.onkeydown=function(a){c.info(`key down ${a.keyCode}, repeat = ${a.repeat}`),n.sendInputData(new Uint8Array([or,n.getKeyCode(a),a.repeat]).buffer),a.keyCode===mr&&document.onkeypress({charCode:mr}),n.inputOptions.suppressBrowserKeys&&n.isKeyCodeBrowserKey(a.keyCode)&&a.preventDefault()},document.onkeyup=function(a){c.info(`key up ${a.keyCode}`),n.sendInputData(new Uint8Array([ar,n.getKeyCode(a)]).buffer),n.inputOptions.suppressBrowserKeys&&n.isKeyCodeBrowserKey(a.keyCode)&&a.preventDefault()},document.onkeypress=function(a){c.info(`key press ${a.charCode}`);let s=new DataView(new ArrayBuffer(3));s.setUint8(0,Li),s.setUint16(1,a.charCode,!0),n.sendInputData(s.buffer)}}setupHtmlEvents(){this._startListen=!0,Ui?(window.addEventListener("gamepadconnected",this.gamepadConnectHandler),window.addEventListener("gamepaddisconnected",this.gamepadDisconnectHandler)):Bi&&(window.addEventListener("webkitgamepadconnected",this.gamepadConnectHandler),window.addEventListener("webkitgamepaddisconnected",this.gamepadDisconnectHandler))}gamepadConnectHandler(n){c.info("Gamepad connect handler");const a=n.gamepad;st[a.index]={},st[a.index].currentState=a,st[a.index].prevState=a,c.info("gamepad: "+a.id+" connected"),yr(this.updateStatus)}gamepadDisconnectHandler(n){c.warn("Gamepad disconnect handler"),c.warn("gamepad: "+n.gamepad.id+" disconnected"),delete st[n.gamepad.index]}emitControllerAxisMove(n,a,s){const p=new DataView(new ArrayBuffer(11));p.setUint8(0,Wi),p.setUint8(1,n),p.setUint8(2,a),p.setFloat64(3,s,!0),this.sendInputData(p.buffer)}emitControllerButtonPressed(n,a,s){const p=new DataView(new ArrayBuffer(4));p.setUint8(0,Vi),p.setUint8(1,n),p.setUint8(2,a),p.setUint8(3,s),this.sendInputData(p.buffer)}emitControllerButtonReleased(n,a){const s=new DataView(new ArrayBuffer(3));s.setUint8(0,Di),s.setUint8(1,n),s.setUint8(2,a),this.sendInputData(s.buffer)}scanGamepads(){let n=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[];for(let a=0;a<n.length;a++)n[a]&&n[a].index in st&&(st[n[a].index].currentState=n[a])}updateStatus(){this.scanGamepads();for(const n in st){let a=st[n],s=a.currentState,p=a.prevState;for(let v=0;v<s.buttons.length;v++){let O=s.buttons[v],R=p.buttons[v];O.pressed&&!R.pressed?v==6?this.emitControllerAxisMove(n,5,O.value):v==7?this.emitControllerAxisMove(n,6,O.value):this.emitControllerButtonPressed(n,v,0):!O.pressed&&R.pressed?v==6?this.emitControllerAxisMove(n,5,0):v==7?this.emitControllerAxisMove(n,6,0):this.emitControllerButtonReleased(n,v):O.pressed&&R.pressed&&(v==6?this.emitControllerAxisMove(n,5,O.value):v==7?this.emitControllerAxisMove(n,6,O.value):this.emitControllerButtonPressed(n,v,1))}for(let v=0;v<s.axes.length;v+=2){let O=parseFloat(s.axes[v].toFixed(4)),R=-parseFloat(s.axes[v+1].toFixed(4));v===0?(this.emitControllerAxisMove(n,1,O),this.emitControllerAxisMove(n,2,R)):v===2&&(this.emitControllerAxisMove(n,3,O),this.emitControllerAxisMove(n,4,R))}st[n].prevState=s}yr(this.updateStatus)}setupNormalizeAndQuantize(n,a){if(n&&a){let s=n.clientHeight/n.clientWidth,p=a.videoHeight/a.videoWidth;if(s>p){c.info("Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio");let v=s/p;this.normalizeAndQuantizeUnsigned=(O,R)=>{let L=O/n.clientWidth,C=v*(R/n.clientHeight-.5)+.5;return L<0||L>1||C<0||C>1?{inRange:!1,x:65535,y:65535}:{inRange:!0,x:65536*L,y:65536*C}},this.unquantizeAndDenormalizeUnsigned=(O,R)=>{let L=(R/65536-.5)/v+.5;return{x:O/65536*n.clientWidth,y:L*n.clientHeight}},this.normalizeAndQuantizeSigned=(O,R)=>({x:32767*(O/(.5*n.clientWidth)),y:32767*(v*R/(.5*n.clientHeight))})}else{c.info("Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio");let v=p/s;this.normalizeAndQuantizeUnsigned=(O,R)=>{let L=v*(O/n.clientWidth-.5)+.5,C=R/n.clientHeight;return L<0||L>1||C<0||C>1?{inRange:!1,x:65535,y:65535}:{inRange:!0,x:65536*L,y:65536*C}},this.unquantizeAndDenormalizeUnsigned=(O,R)=>{let L=R/65536;return{x:((O/65536-.5)/v+.5)*n.clientWidth,y:L*n.clientHeight}},this.normalizeAndQuantizeSigned=(O,R)=>({x:32767*(v*O/(.5*n.clientWidth)),y:32767*(R/(.5*n.clientHeight))})}}}emitDescriptor(n,a){let s=JSON.stringify(a),p=new DataView(new ArrayBuffer(3+2*s.length)),v=0;p.setUint8(v,n),v++,p.setUint16(v,s.length,!0),v+=2;for(let O=0;O<s.length;O++)p.setUint16(v,s.charCodeAt(O),!0),v+=2;return this.emit({type:0,intpuBuffer:p.buffer,target:this}),p.buffer}sendInputData(n){this.emit({type:0,intpuBuffer:n,target:this})}}var Kt;(function(o){o[o.OPEN=0]="OPEN",o[o.CLOSE=1]="CLOSE",o[o.ERROR=2]="ERROR",o[o.TRY=3]="TRY",o[o.STAUTS=4]="STAUTS"})(Kt||(Kt={}));class Ki extends b{get wsServer(){let n="";if(this.config.appliId&&(n+="appliId="+this.config.appliId+"&"),this.config.groupId&&(n+="groupId="+this.config.groupId+"&"),this.config.targetServerIp&&(n+="targetServerIp="+this.config.targetServerIp+"&"),this.queueId&&(n+="queueId="+this.queueId+"&"),this.config.proxyBasePath)return`${window.location.protocol.indexOf("s")>-1?"wss://":"ws://"}${window.location.host}${this.config.proxyBasePath}/websocket/waitQueue?`+n;{const a=new URL(this.config.serverAddress);return`${a.protocol.indexOf("s")>-1?"wss://":"ws://"}${a.host}/websocket/waitQueue?`+n}}isOpen(){return!!this.connection&&this.connection.readyState===1}constructor(n){super(),this.connection=null,this.keepAliveTimeout=-1,this.queueId="",c.info("初始化 WaitQueue"+JSON.stringify(n)),this.config=n,this.startKeepAlive=this.startKeepAlive.bind(this),this.stopKeepAlive=this.stopKeepAlive.bind(this)}connect(){return new Promise((n,a)=>{c.info("连接 websocket waitqueue 服务器",this.config,this.wsServer),this.config.serverAddress||(c.warn("server uri error:",this.config.serverAddress),a("server uri error:"+this.config.serverAddress));const s=this.wsServer;this.connection=new WebSocket(s),this.connection.binaryType="arraybuffer",this.connection.addEventListener("message",p=>{try{let v=JSON.parse(p.data);switch(v.type){case"020":c.info("on queue try "+p.data),this.emit({type:Kt.TRY}),n(this),this.close();break;case"021":c.info("on queue id "+p.data),v.value&&(this.queueId=v.value);break;case"022":c.info("on status msg "+p.data,v.waitCntBeforeMe),this.emit({type:Kt.STAUTS,waitCount:v.waitCntBeforeMe})}}catch(v){c.err("parse queue msg failed",v,p.data),a()}}),this.connection.addEventListener("open",()=>{c.info("connection open")}),this.connection.addEventListener("error",p=>{c.info("connection error"),a(p)}),this.connection.addEventListener("close",p=>{c.info("websocket connection close",p),a(p)})})}close(){return new Promise((n,a)=>{if(this.connection){const s=this;this.connection.addEventListener("close",p=>{s.connection=null,c.info("CLOSE PROMISE 关闭 websocket 连接"),n()}),this.connection.addEventListener("error",p=>{a(p)}),c.warn("主动关闭 websocket 连接"),this.connection.close()}else c.warn("主动关闭连接,但是当前 websocket 连接为null"),n()})}startKeepAlive(){c.info("proxy startKeepAlive"),this.keepAliveTimeout=window.setTimeout(()=>{this.connection&&this.isOpen()?(this.connection.send("1000"),this.startKeepAlive()):this.stopKeepAlive()},1e4)}stopKeepAlive(){c.info("proxy stopKeepAlive"),this.keepAliveTimeout&&window.clearTimeout(this.keepAliveTimeout)}}var Dt,At,ne;(function(o){o[o.Normal=0]="Normal",o[o.Interactive=1]="Interactive",o[o.MutiPlayer=2]="MutiPlayer"})(Dt||(Dt={})),function(o){o[o.Observer=0]="Observer",o[o.Player=1]="Player"}(At||(At={})),function(o){o.TASK_CREATE_SUCCESS="taskcreatesuccess",o.TASK_CREATE_FAILED="taskcreatefailed",o.RESOURCE_NOT_ENOUGH="resourcenotenough",o.CONNECT="connect",o.LOGIN_SUCCESS="loginsuccess",o.NO_OPERATION_TIMEOUT="operatetimeout",o.CLOSE="close",o.APP_CLOSE="appclose",o.GOT_REMOTE_STREAM="gotremotestream",o.GOT_REMOTE_AUDIO_STREAM="gotremoteaudiostream",o.MEDIA_LOADED="meidaloaded",o.MEDIA_LOADED2="medialoaded",o.MEDIA_PLAY_SUCCESS="mediaplaysuccess",o.MEDIA_PLAY_FAILED="mediaplayfailed",o.MEDIA_PLAY_MUTE="meidaplaymute",o.APPSTATE_CHANGE="appstatechange",o.APP_RESIZE="appresize",o.APP_MOUSE_MODE="appmousemode",o.APP_CURSOR_MODE="appcursormode",o.PLAYER_LIST="playerlist",o.PEERSTATUS_REPORT="peerstatusreport",o.APP_REQUEST_INPUT="apprequestinput",o.APP_REQUEST_GAMEPAD_OUPUT="apprequestgamepadoutput",o.CAPTURE_FRAME="captureframe",o.DATACHANNEL_OPEN="datachannelopen",o.DATACHANNEL_CLOSE="datachannelclose",o.DATACHANNEL_TEXT="datachanneltext",o.DATACHANNEL_BINARY="datachannelbinary",o.LarkEvent="larkevent",o.ERROR="error",o.INFO="info",o.AI_VOICE_STATUS="aivoicestatus",o.AI_VOICE_ASR_RESULT="aivoiceasrresult",o.AI_VOICE_DM_RESULT="aivoicedmresult",o.AI_VOICE_ERROR="aivoiceerror",o.TOUCH_CTR_MAPPING="touchctrmapping",o.RTMP_STREAM_STATE="rtmpstreamstate",o.RTMP_STREAM_ERROR="rtmpstreamerror",o.AERIAL_VIEW_SCREEN="aerialviewscreen",o.START_XR_STREAM_RESPONSE="startxrstreamresponse",o.TOOLTIP_INFO="tooltipinfo",o.OPEN_URL="openurl",o.WAITQUEUE_STATUS="waitqueuestatus"}(ne||(ne={}));var Ji={LarkSR:class extends b{get params(){return this._params}get playerModeType(){return this._params.playerMode}get userType(){return this._params.userType}get isObMode(){return this.playerModeType!=Dt.Normal&&this.userType==At.Observer}get isInteractiveMode(){return this.playerModeType!=Dt.Normal}get isPixelStreaming(){return this.params.appliType===bt.PIXEL_STREAMING}get appState(){return this._app.state}get app(){return this._app}get remoteScreenReady(){return this._remoteScreenReady}set remoteScreenReady(o){this._remoteScreenReady=o}onFirstAppsize(o,n){this.syncClientViewport&&(c.info("remoteScreenReady ",this.screenState.viewPort,this.params,this.screenState.syncClientViewport),this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height)),window.setTimeout(()=>{this.screenState.scrollToCenter()},100)}get screenState(){return this._screenState}set scaleMode(o){this._screenState.scaleMode=o,this.setCanvasMode()}get mouseZoomDirection(){return this.op.mouseZoomDirection}set mouseZoomDirection(o){this.op.mouseZoomDirection=o}get op(){return this._op}get fullScreen(){return this._fullScreen}get lockPointer(){return this._lockPointer}get videoElement(){return this._view.getVideo()}get videoComponent(){return this._view.getVideoComponent()}get audioElement(){return this._view.getAudio()}get isSeprateAudioTrack(){return this._view.isSeprateAudioTrack()}get containerElement(){return this._view.getContainerComponent()}get viewportElement(){return this._view.getViewportComponent()}set isEnableTouchPonit(o){this._view.$set({touchPonitEnable:o})}set isEnableTouchPoint(o){this._view.$set({touchPonitEnable:o})}set enableCanvasRender(o){this._view.canvasRender=o,o?this._view.startCanvasRender():this._view.stopCanvasRender()}get enableCanvasRender(){return this._view.canvasRender}get virtualCursorPosition(){return{x:this._view.cursorPosition.x+this.screenState.container.marginLeft,y:this._view.cursorPosition.y+this.screenState.container.marginTop}}get virtualCursorPositionRaw(){return{x:this._view.cursorPosition.x,y:this._view.cursorPosition.y}}set isEnableLoadingStateBar(o){this._view.$set({showLoadingStateBar:o})}get rootElement(){return this._rootElement}get serverAddress(){return this.config.serverAddress?this.config.serverAddress:""}get serverIp(){return new URL(this.serverAddress).hostname}get config(){return this._config}get uid(){return this._uid}get isPreStart(){return this._isPreStart}isTaskOwner(){return this._isTaskOwner}set initCursorMode(o){this._screenState.initCursorMode=o,this.resetAppMouseLockState(),this.lockPointer.isLockPointer&&this.lockPointer.exitPointerLock()}get initCursorMode(){return this._screenState.initCursorMode}get audioDeviceId(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioDeviceId}get audioTrack(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioTrack}get videoDeviceId(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoDeviceId}get videoTrack(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoTrack}get audioPaused(){var o;return(o=this.app)===null||o===void 0?void 0:o.audioPaused}get videoPaused(){var o;return(o=this.app)===null||o===void 0?void 0:o.videoPaused}getMediaSharePeerConnection(o){var n;return(n=this.app)===null||n===void 0?void 0:n.getMediaSharePeerConnection(o)}get serverFeatures(){var o;return(o=this.app)===null||o===void 0?void 0:o.serverFeatures}get serverStatics(){var o;return(o=this.app)===null||o===void 0?void 0:o.serverStatics}setVideoBitrateKbps(o){var n;(n=this.app)===null||n===void 0||n.sendVideoBitrateKbps(o)}setVideoFps(o){var n;(n=this.app)===null||n===void 0||n.sendVideoFps(o)}setCloudDebugLayout(o){var n;(n=this.app)===null||n===void 0||n.sendShowDebugLayout(o)}restartCloudApp(){var o;(o=this.app)===null||o===void 0||o.sendReStartApplication(),this._remoteScreenReady=!1}setCloudAppSize(o,n){var a;(a=this.app)===null||a===void 0||a.sendApplicationSize(o,n)}get currentAppSize(){var o;return(o=this.app)===null||o===void 0?void 0:o.currentAppSize}startAerialview(o,n=100,a,s){var p;(p=this.app)===null||p===void 0||p.startAerialview(o,n,a,s)}updateAerialview(o){var n;(n=this.app)===null||n===void 0||n.updateAerialview(o)}stopAerialview(){var o;(o=this.app)===null||o===void 0||o.stopAerialview()}get syncClientViewport(){return this.params.initResolutionType!==0}set syncClientViewport(o){o?(this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height),this.params.initResolutionType=1):this.params.initResolutionType=0}constructor(o){super(),this._remoteScreenReady=!1,this.loadingTimeout=0,this._uid=0,this._isPreStart=!1,this._isTaskOwner=!0,this.waitQueue=null,this.onAppStateChange=this.onAppStateChange.bind(this),this.onRTCRetrySuccess=this.onRTCRetrySuccess.bind(this),this.onGotRemoteStream=this.onGotRemoteStream.bind(this),this.onOperationTimeout=this.onOperationTimeout.bind(this),this.onOperationInput=this.onOperationInput.bind(this),this.onAppResize=this.onAppResize.bind(this),this.onAppMouseMode=this.onAppMouseMode.bind(this),this.onAppPlayerList=this.onAppPlayerList.bind(this),this.onAppRequestText=this.onAppRequestText.bind(this),this.onDataChannelText=this.onDataChannelText.bind(this),this.onDataChannelBinary=this.onDataChannelBinary.bind(this),this.onDataChannelOpen=this.onDataChannelOpen.bind(this),this.onDataChannelClose=this.onDataChannelClose.bind(this),this.onCursorStyle=this.onCursorStyle.bind(this),this.onMediaPlayed=this.onMediaPlayed.bind(this),o.handelRootElementSize==null||o.handelRootElementSize==null||o.handleRootElementSize!=null&&o.handleRootElementSize!=null||(o.handleRootElementSize=o.handelRootElementSize),o.useWebCodec!==void 0&&o.useWebCodec!==null&&o.useWebCodec&&(o.forceCanvas2d=!0),this._config=o,this._config.playTimeout!=null&&this._config.playTimeout!=null||(this._config.playTimeout=20),this._params=dt.setUpWithSDKConfig(dt.copyAndCreate(),o),c.logLevel=this._params.logLevel,c.info("create larksr ",o),this._rootElement=o.rootElement,t.init(this._params.language),this._screenState=new Ir(o.rootElement,this._params,this,o.handleRootElementSize,o.onlyHandleRootElementTransform),this._app=new Tr(this),this.iframeHandler=new Pr(this),this.iframeHandler.listenParent(),this._fullScreen=new qn,this._fullScreen.on(0,()=>{window.setTimeout(()=>{c.info("full screen state change. resize"),this._screenState.resize(this._screenState.baseElementScale)},500)}),this._lockPointer=new Zn(document.documentElement),this._lockPointer.on(2,n=>{c.warn("lock point not support on this platform switch to unlock mode"),this.initCursorMode=2,this.$emitInfo(t.ui.LOCK_POINTER_FAILED)}),this._lockPointer.on(3,n=>{c.warn("lock point not support on this platform switch to unlock mode. please check https."),this.initCursorMode=2,this.$emitInfo(t.ui.LOCK_POINTER_FAILED_SECURITY_ERROR)}),o.handleRootElementSize!=null&&o.handleRootElementSize!=1||function(){const n=document.getElementsByTagName("html")[0];n&&n.style&&(n.style.margin="0",n.style.padding="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%");const a=document.body;a&&a.style&&(a.style.margin="0",a.style.padding="0",a.style.overflow="hidden",a.style.width="100%",a.style.height="100%")}(),this._view=new bi({target:o.rootElement,props:{screenState:this.screenState,syncCursorStyle:this.screenState.cursorStyle,ui:t.ui,serverAddress:o.serverAddress?o.serverAddress:"",syncApp:!1,appState:this.appState,isMobile:I.isMobile,appParams:this._params,loadingBgUrl:o.loadingBgUrl?o.loadingBgUrl:"",mutePlayWhenFailed:o.mutePlayWhenFailed==null||o.mutePlayWhenFailed,touchPonitEnable:!0,autoPlay:o.autoPlay==null||o.autoPlay,showPlayButton:o.showPlayButton==null||o.showPlayButton,canvasRender:o.enableCanvasRender!=null&&o.enableCanvasRender!=null&&o.enableCanvasRender,forceCanvas2d:o.forceCanvas2d!=null&&o.forceCanvas2d!=null&&o.forceCanvas2d,loadingLogoVersion:o.loadingLogoVersion==null?"":o.loadingLogoVersion}}),this.app.webcodecDecoder.setCanvas(this._view.getRenderContext2dElement(),this._view.getRenderContext2d()),this._screenState.on(0,n=>{c.info("on resize",n),this._view.$set({screenState:this._screenState}),this.isPixelStreaming&&this.pixelInput.setupMouseAndFreezeFrame(this.containerElement,this.videoElement)}),this._screenState.on(1,n=>{c.info("on ContainerResize",n,this.screenState.syncClientViewport),this.syncClientViewport&&this.setCloudAppSize(this.screenState.syncClientViewport.width,this.screenState.syncClientViewport.height)}),this._op=new Xn(this._view.getContainerComponent(),this),this.pixelInput=new Gi(this),this.setupListener(),this.setCanvasMode()}updateServerAddress(o){this._config.serverAddress=o,this._view.$set({serverAddress:this._config.serverAddress})}initSDKAuthCode(o){return this._config.authCode=o,new Promise((n,a)=>{n()})}async connectWithPxyHost(o){const n=await se.HostAppliGetUrl(o);this._config.serverAddress=n.origin,this._view.$set({serverAddress:this._config.serverAddress}),await this.connect(Object.assign(Object.assign({},o),n.params))}async connect(o){if(!this._config.authCode)throw c.err("sdk 授权校验失败. 请通过 new LarkSR({authCode: id}) 或 initSDKAuthCode 设置"),new Error("sdk 授权校验失败. 请通过 new LarkSR({authCode: id}) 或 initSDKAuthCode 设置");if(!this._config.serverAddress&&!this._config.proxyBasePath)throw new Error("服务器地址未设置");try{const n=await se.GetStartInfo(se.GetUrl(this._config),Object.assign({sdkId:this._config.authCode},o));this.waitQueue&&this._view.loadingStateMsg&&this._view.$set({loadingStateMsg:""}),this.setAppliParams(Dn(n)),this.emit({type:ne.TASK_CREATE_SUCCESS,data:Object.assign({},this.params)}),this.$emit(r.LK_TASK_CREATE_SUCCESS,Object.assign({},this.params)),await this.start()}catch(n){if(c.warn("enter app failed",n),n.type===0){n.eventType=ne.RESOURCE_NOT_ENOUGH;let a=!1;this.config.disableWaitQueue!==null&&this.config.disableWaitQueue!==void 0&&(a=this.config.disableWaitQueue);const s=await se.IsEnableWaitQueue(se.GetUrl(this._config),{});if(a||!s.enableWaitQueue||n.code===820&&this.waitQueue===null)this.emit({type:ne.RESOURCE_NOT_ENOUGH,data:n}),this.$emit(r.LK_RESOURCE_NOT_ENOUGH,n,"RESOURCE NOT ENOUGH");else{c.info("enable wait queue"),this.waitQueue===null&&(this.waitQueue=new Ki({serverAddress:this.config.serverAddress?this.config.serverAddress:"",proxyBasePath:this.config.proxyWsBasePath,appliId:o.appliId,groupId:o.groupId,targetServerIp:o.targetServerIp}),this.waitQueue.on(Kt.STAUTS,p=>{c.info("on wait queue status update",p),this._view.$set({loadingStateMsg:t.message.WAIT_QUEUE_COUNT+p.waitCount}),this.emit({type:ne.WAITQUEUE_STATUS,data:p})}));try{return await this.waitQueue.connect(),this.connect(o)}catch(p){c.err("enable wait queue but has error",p),this.emit({type:ne.RESOURCE_NOT_ENOUGH,data:p}),this.$emit(r.LK_RESOURCE_NOT_ENOUGH,p,"RESOURCE NOT ENOUGH"+JSON.stringify(p))}}}else n.eventType=ne.TASK_CREATE_FAILED,this.emit({type:ne.TASK_CREATE_FAILED,data:n}),this.$emit(r.LK_TASK_CREATE_FAILED,n,"TASK CREATE FAILED");throw n}}setNickname(o){this._params.nickname=o}setAppliParams(o){this._params=dt.setUpWithSDKConfig(dt.copyAndCreate(o),this.config),this.screenState.reset(this._params),t.init(this._params.language),this._view.$set({appParams:this._params}),c.logLevel=this._params.logLevel,this.op.mouseZoomDirection=this._params.mouseZoomDirection,this.setCanvasMode()}start(){return new Promise((o,n)=>this.params.taskid?this.params.appServer?this.params.appPort?(se.ClientInfo(this.config,this.params),(this.config.serverAddress||this.config.proxyBasePath)&&se.GetTouchCtrMapping(se.GetUrl(this._config),this.params.appliId).then(a=>{this.emit({type:ne.TOUCH_CTR_MAPPING,data:a,code:0})}).catch(a=>{c.warn(a)}),this.params.debugTask?this.startProcess():this.taskProcess(),void o()):(c.err("启动流程失败,渲染服务器的端口号为空"),void n("启动流程失败,渲染服务器的端口号为空。请确保正确调用接口获取到参数")):(c.err("启动流程失败,渲染服务器的IP地址为空"),void n("启动流程失败,渲染服务器的IP地址为空。请确保正确调用接口获取到参数")):(c.err("启动流程失败,taskID为空"),void n("启动流程失败,taskID为空。请确保正确调用接口获取到参数")))}sendKeepAlive(){var o;(o=this._app)===null||o===void 0||o.sendKeepAlive()}restart(){this._app.restart(),this.remoteScreenReady=!1}restartApp(){this._app.restartApp()}close(){this._app.disConnect()}destroy(){this.close(),this._view.$destroy()}setMobileForceLandScape(o){this.params.mobileForceLandscape=o,this.screenState.setMobileForceLandScape(o)}changeOperater(o){var n;(n=this._app)===null||n===void 0||n.changeOperater(o)}inputText(o){var n;this._op.updateOperation(),(n=this._app)===null||n===void 0||n.inputText(o)}aiDmTextInput(o){var n;return this._op.updateOperation(),(n=this._app)===null||n===void 0?void 0:n.aiDmTextInput(o)}startAiDmVoiceInput(){var o;return this._op.updateOperation(),(o=this._app)===null||o===void 0?void 0:o.startAiDmVoiceInput()}stopAiDmVoiceInput(){var o;return(o=this._app)===null||o===void 0?void 0:o.stopAiDmVoiceInput()}sendTextToDataChannel(o){var n;this._op.updateOperation(),(n=this._app)===null||n===void 0||n.sendTextToDataChannel(o)}sendBinaryToDataChannel(o){this._op.updateOperation(),this._app.sendBinaryToDataChannel(o)}closeDataChannel(){var o;(o=this._app)===null||o===void 0||o.closeDataChannel()}postMsg(o,n="",a=""){k.IsIframe()&&parent!=null&&parent.postMessage({prex:Wn,type:o,data:n,message:a==""?E.GetEventMessageByType(o):a},"*")}quit(){if(k.IsIframe())return c.warn("cant quit in iframe"),window.opener=null,window.open("","_self"),window.close(),void this.postMsg(r.LK_USER_REQUEST_QUIT);const o=window.WeixinJSBridge;o?o.call("closeWindow"):window.history&&window.history.length>1?window.history.back():(window.opener=null,window.open("","_self"),window.close())}resetAppMouseLockState(){this.op.resetAppMouseLockState()}captrueFrame(o,n=void 0){return this._view.captrueFrame(o,n)}sendInput(o){var n;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(n=this._op)===null||n===void 0||n.$emitInputEvent(o)}mouseMove(o,n,a,s){this.moseMove(o,n,a,s)}moseMove(o,n,a,s){var p;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(p=this._op)===null||p===void 0||p.$emitMoseMove(o,n,a,s)}mouseTap(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseTap(o,n,a)}mouseDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseDown(o,n,a)}mouseUp(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseUp(o,n,a)}mouseWheel(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitMouseWheel(o,n,a)}keyDown(o,n){const a=Zt[o];a&&(this.isPixelStreaming?this.app.sendInputBuffer(new Uint8Array([or,a.vkey,n]).buffer):this._op.$emitKeyDown(a.vkey,n))}keyUp(o){const n=Zt[o];n&&(this.isPixelStreaming?this.app.sendInputBuffer(new Uint8Array([ar,n.vkey]).buffer):this._op.$emitKeyUp(n.vkey))}gamepadButtonDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitGamepadButtonDown(o,n,a)}gamepadButtonUp(o,n){var a;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(a=this._op)===null||a===void 0||a.$emitGamepadButtonUp(o,n)}gamepadTrigger(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitGamepadTrigger(o,n,a)}joystick(o,n,a,s,p){var v;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(v=this._op)===null||v===void 0||v.$emitJoystick(o,n,a,s,p)}touchDown(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchDown(o,n,a)}touchMove(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchMove(o,n,a)}touchUp(o,n,a){var s;this.isPixelStreaming?c.warn("pixel streaming not support extern input yet."):(s=this._op)===null||s===void 0||s.$emitTouchUp(o,n,a)}getMouseButtonType(o){switch(o){case"left":return h.CloudLark.MouseKey.LEFT;case"mid":return h.CloudLark.MouseKey.MIDDLE;case"right":return h.CloudLark.MouseKey.RIGHT}}setAudioEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setAudioEnable(o)}setVideoEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setVideoEnable(o)}setShareEnable(o){var n;return(n=this.app)===null||n===void 0?void 0:n.setShareEnable(o)}stopLocalAudio(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalAudio()}stopLocalVideo(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalVideo()}stopLocalShare(){var o;return(o=this.app)===null||o===void 0?void 0:o.stopLocalShare()}pauseAudioSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.pauseAudioSending()}resumeAudioSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.resumeAudioSending()}pauseVideoSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.pauseVideoSending()}resumeVideoSending(){var o;return(o=this.app)===null||o===void 0?void 0:o.resumeVideoSending()}closeAudio(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeAudio()}closeVideo(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeVideo()}closeShare(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeShare()}closeMediaChannel(){var o;return(o=this.app)===null||o===void 0?void 0:o.closeSharePc()}async openAudio(o=""){var n;return await((n=this.app)===null||n===void 0?void 0:n.openAudio(o))}async openVideo(o=!1,n="",a=0,s=0,p){var v;return await((v=this.app)===null||v===void 0?void 0:v.openVideo(o,n,a,s,p))}async openDefaultMedia(o=!0,n=!0){var a;return await((a=this.app)===null||a===void 0?void 0:a.openDefaultMedia(o,n))}async openShareMediaDevice(){var o;return await((o=this.app)===null||o===void 0?void 0:o.openShareMediaDevice())}async getConnectedAudioinputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedAudioinputDevices())}async getConnectedAudioOutputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedAudioOutputDevices())}async getConnectedVideoinputDevices(){var o;return await((o=this.app)===null||o===void 0?void 0:o.getConnectedVideoinputDevices())}async getConnectedDevices(o){var n;return await((n=this.app)===null||n===void 0?void 0:n.getConnectedDevices(o))}async openAudioDevice(o,n="audioinput"){var a;return await((a=this.app)===null||a===void 0?void 0:a.openAudioDevice(o,n))}async openCamera(o,n=0,a=0,s=!0,p){var v;return await((v=this.app)===null||v===void 0?void 0:v.openCamera(o,n,a,s,p))}async openUserMedia(o,n=!1){return await this.openUserMeida(o,n)}async openUserMeida(o,n=!1){var a;return await((a=this.app)===null||a===void 0?void 0:a.openUserMeida(o,n))}addMediaTrack(o,...n){var a;return(a=this.app)===null||a===void 0?void 0:a.addMediaTrack(o,...n)}removeMediaTrack(o){var n;return(n=this.app)===null||n===void 0?void 0:n.removeMediaTrack(o)}requestUserMediaPermission(o){var n;return(n=this.app)===null||n===void 0?void 0:n.requestUserMediaPermission(o)}StartCloudLiveStreaming(o){var n;return(n=this.app)===null||n===void 0?void 0:n.StartCloudLiveStreaming(o)}StopLiveStreaming(){var o;return(o=this.app)===null||o===void 0?void 0:o.StopLiveStreaming()}async getTouchCtrMapping(o=""){if(!this.config.serverAddress)throw new Error("serverAddress not set");return await se.GetTouchCtrMapping(se.GetUrl(this._config),o||this.params.appliId)}$emit(o,n="",a=""){for(const s of wr)if(s==o){se.LogError(o,a+" "+E.GetEventMessageByType(o),"appliId="+this.params.appliId+"&taskId="+this.params.taskid,this.config);break}this.emit(this.createEvent(o,n,a)),this.postMsg(o,n,a)}$emitError(o="",n=0){this.emit({target:this,type:ne.ERROR,message:o,code:n})}$emitInfo(o="",n=0){this.emit({target:this,type:ne.INFO,message:o,code:n})}createEvent(o,n="",a=""){return{type:ne.LarkEvent,target:this,data:n,message:a,larkevent:o}}setupListener(){this.app.on(Y.LOGIN,o=>{this._uid=o.data.uid,this._isPreStart=o.data.isPrestart,c.info("login success ",o.data,this.uid,this.isPreStart),this.emit({type:ne.LOGIN_SUCCESS,data:o.data})},this),this.app.on(Y.ERROR,o=>{this.emit({type:ne.ERROR,message:o.data.message,code:o.data.code})},this),this.app.on(Y.INFO,o=>{this.emit({type:ne.INFO,message:o.data.message,code:o.data.code})},this),this.app.on(Y.APP_CLOSE,o=>{this.emit({type:ne.APP_CLOSE,data:o.data,message:o.data})},this),this.app.on(Y.REMOTE_STREAM,this.onGotRemoteStream,this),this.app.on(Y.REMOTE_AUDIO_STREAM,this.onGotRemoteAudioStream,this),this.app.on(Y.APP_STATE_CHANGE,this.onAppStateChange,this),this.app.on(Y.RTC_RETRY_SUCCESS,this.onRTCRetrySuccess,this),this.app.on(Y.SYNC_CURSORSTYLE,this.onCursorStyle,this),this.app.on(Y.LK_APP_RESIZE,this.onAppResize,this),this.app.on(Y.LK_APP_MOUSE_MODE,this.onAppMouseMode,this),this.app.on(Y.LK_APP_PLAER_LIST,this.onAppPlayerList,this),this.app.on(Y.LK_APP_REQUEST_TEXT,this.onAppRequestText,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_TEXT_MESSAGE,this.onDataChannelText,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_BINARY_MESSAGE,this.onDataChannelBinary,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_OPEN,this.onDataChannelOpen,this),this.app.on(Y.LK_DATA_CHANNEL_RENDERSERVER_CLOSE,this.onDataChannelClose,this),this.app.on(Y.NET_STATE,o=>{this.emit({type:ne.PEERSTATUS_REPORT,data:o.data})}),this.app.on(Y.AI_VOICE_STATUS,o=>{this.emit({type:ne.AI_VOICE_STATUS,data:o.data})}),this.app.on(Y.AI_VOICE_ASR_RESULT,o=>{this.emit({type:ne.AI_VOICE_ASR_RESULT,data:o.data})}),this.app.on(Y.AI_VOICE_DM_RESULT,o=>{this.emit({type:ne.AI_VOICE_DM_RESULT,data:o.data})}),this.app.on(Y.AI_VOICE_ERROR,o=>{this.emit({type:ne.AI_VOICE_ERROR,data:o.data})}),this.app.on(Y.RTMP_STREAM_STATE,o=>{this.emit({type:ne.RTMP_STREAM_STATE,data:o.data})}),this.app.on(Y.RTMP_STREAM_ERROR,o=>{this.emit({type:ne.RTMP_STREAM_ERROR,data:o.data})}),this.app.on(Y.AerialViewStatus,o=>{this.op.aerialviewStatus=o.data}),this.app.on(Y.AerialViewScreen,o=>{this.emit({type:ne.AERIAL_VIEW_SCREEN,data:o.data})}),this.app.on(Y.TooltipInfo,o=>{this.emit({type:ne.TOOLTIP_INFO,data:o.data})}),this.app.on(Y.OPEN_URL,o=>{this.emit({type:ne.OPEN_URL,data:o.data})}),this.app.on(Y.START_XR_STREAM_RESPONSE,o=>{c.info("START_XR_STREAM_RESPONSE",o,o.data);try{this.emit({type:ne.START_XR_STREAM_RESPONSE,data:o.data})}catch(n){c.info("emit failed",n)}}),this.app.webcodecDecoder.on(an.PLAYED,o=>{this.app.appStateChange(J.MEDIA_LOADED),this.emit({type:ne.MEDIA_LOADED,target:this}),this.emit({type:ne.MEDIA_LOADED2,target:this}),this.$emit(r.LK_VIDEO_LOADED),this.onMediaPlayed()}),this.op.on(1,this.onOperationTimeout,this),this.op.on(2,o=>{var n;o.data&&((n=this._app)===null||n===void 0||n.inputText(o.data))},this),this.op.on(3,o=>{(I.isMobile||o.cursorPoint&&this.lockPointer.isLockPointer)&&this._view.$set({cursorPosition:o.cursorPoint})}),this._view.$on("pitcureCaptured",o=>{c.info("on capture ",o.detail),this.emit({type:ne.CAPTURE_FRAME,target:this,data:o.detail}),o.detail.data?this.$emit(r.LK_USER_CAPTURE_FRAME_WITH_EXTRA_DATA,o.detail):this.$emit(r.LK_USER_CAPTURE_FRAME,o.detail.base64)}),this._view.$on("mediaLoaded",()=>{this.app.peerConnectionCreated?(this.app.state=J.MEDIA_LOADED,this.emit({type:ne.MEDIA_LOADED,target:this}),this.emit({type:ne.MEDIA_LOADED2,target:this}),this.$emit(r.LK_VIDEO_LOADED),window.clearTimeout(this.loadingTimeout)):c.warn("peerConnectionCreated already released")}),this._view.$on("mediaPlayed",this.onMediaPlayed),this._view.$on("mediaPlayedMute",()=>{c.info("video play success"),this.emit({type:ne.MEDIA_PLAY_MUTE,target:this})}),this._view.$on("mediaPlayedFailed",()=>{this.$emit(r.LK_VIDEO_PLAY_FAILED),this.emit({type:ne.MEDIA_PLAY_FAILED,target:this})}),this._view.$on("requestFullScreen",()=>{I.os!="iOS"&&this.fullScreen.launchFullScreen()})}async taskProcess(){try{const o=await se.GetTask(this.config,this.params.taskid);if(o.status!=0){if(c.info("task 获取成功",o),this._view.$set({syncApp:!1}),o.shareUrl!==null&&o.shareUrl!==void 0&&(this._params.shareUrl=q.getBoolOption(o.shareUrl)),o.textInputEventPrompt!==null&&o.shareUrl!==void 0&&(this._params.textInputEventPrompt=q.getNumberBoolOption(o.textInputEventPrompt,!0)),o.audioInput!==null&&o.audioInput!==void 0&&(this._params.audioInput=q.getNumberBoolOption(o.audioInput,!1)),o.audioInputAutoStart!==null&&o.audioInputAutoStart!==void 0){const n=q.getNumberBoolOption(o.audioInputAutoStart,!1),a=this._config.audioInputAutoStart==null?n:this._config.audioInputAutoStart;this._params.audioInputAutoStart=this._params.audioInput&&a}if(o.videoInput!==null&&o.videoInput!==void 0&&(this._params.videoInput=q.getNumberBoolOption(o.videoInput,!1)),o.videoInputAutoStart!==null&&o.videoInputAutoStart!==void 0){const n=q.getNumberBoolOption(o.videoInputAutoStart,!1),a=this._config.videoInputAutoStart==null?n:this._config.videoInputAutoStart;this._params.videoInputAutoStart=this._params.videoInput&&a}o.liveStreaming!==null&&o.liveStreaming!==void 0&&(this._params.liveStreaming=q.getNumberBoolOption(o.liveStreaming,!1)),o.mobileKeyboardType!==null&&o.mobileKeyboardType!==void 0&&(this._params.mobileKeyboardType=o.mobileKeyboardType!=null?o.mobileKeyboardType:0),o.imeFirstNotice!==null&&o.imeFirstNotice!==void 0&&(this._params.imeFirstNotice=o.imeFirstNotice!=null?o.imeFirstNotice:1),this.startProcess()}else c.info("task 同步中,重新获取",o.status),this._view.$set({syncApp:!0}),window.setTimeout(()=>{this.taskProcess()},1500)}catch(o){this._view.$set({syncApp:!1}),this.$emitError("获取Task信息失败 "+JSON.stringify(o))}}startProcess(){this.app.init(),this.loadingTimeout=window.setTimeout(()=>{this.appState<J.MEDIA_LOADED&&(c.warn("LOADING TIMEOUT!",this.params.loadingTimeout),this.app.disConnect(),this.$emitError(t.message.LK_LOADING_TIMEOUT,r.LK_LOADING_TIMEOUT),this.$emit(r.LK_LOADING_TIMEOUT))},1e3*this.params.loadingTimeout),se.PortMappingList(this.config).then(o=>{const n=o;if(this.config.publicPortMapping)for(let a in n)this.config.publicPortMapping.hasOwnProperty(a)||(this.config.publicPortMapping[a]=n[a]);else this.config.publicPortMapping=n;c.info("update public port mapping ",this.config.publicPortMapping)}).catch(o=>{c.warn("get port mapping failed ",o)}).finally(()=>{this.app.start()})}onAppStateChange(o){o.state==J.MEDIA_LOADED?(c.info("app state change to media ready"),this.loadingTimeout&&window.clearTimeout(this.loadingTimeout),(this.config.handlInput==null||this.config.handlInput)&&(c.info("media ready ",this.params),this.isPixelStreaming?(this.screenState.appSize={width:this.videoElement.videoWidth,height:this.videoElement.videoHeight},this.emit({type:ne.APP_RESIZE,data:this.screenState.appSize}),this.pixelInput.setupMouseAndFreezeFrame(this.containerElement,this.videoElement),this.pixelInput.startListen||(this.params.initCursorMode?this.pixelInput.registerLockedMouseEvents(this.containerElement):this.pixelInput.registerHoveringMouseEvents(this.containerElement),this.pixelInput.registerInputs(this.containerElement),this.pixelInput.registerKeyboardEvents(),this.pixelInput.setupHtmlEvents(),this.pixelInput.on(0,n=>{this.isObMode?c.info("skip operation when use mousemode"):n.intpuBuffer&&this.app.sendInputBuffer(n.intpuBuffer)}))):this.op.startListen||(this.op.on(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.startListening()))):o.state>=J.RTC_RETRY&&(c.info("app state change to before destory"),(this.config.handlInput==null||this.config.handlInput)&&(this.op.off(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.stopListenling())),o.state==J.WEBSOCKET_CHANNEL_OPEN&&this.emit({type:ne.CONNECT}),o.state!=J.RTC_CLOSED&&o.state!=J.WEBSOCKET_CLOSED||this.emit({type:ne.CLOSE}),this._view.appState=o.state,this.emit({type:ne.APPSTATE_CHANGE,data:o.state}),c.info("on appstate change",o.state)}onRTCRetrySuccess(o){c.info("onRTCRetrySuccess",o),this.op.startListen||(this.op.on(0,this.onOperationInput,this),this.op.resetLocalRendreMousePosition(),this.op.startListening())}onGotRemoteStream(o){c.info("onGotRemoteStream",o,o.data.getVideoTracks(),this._view),this._view.setVideoSrcObj(o.data),this.emit({target:this,type:ne.GOT_REMOTE_STREAM,data:o}),I.os==="iOS"&&I.isWeChat&&k.IsIframe()&&this.appState<=J.MEDIA_PLAYED&&(this._view.playVideo(),this.emit({target:this,type:ne.MEDIA_PLAY_FAILED}),this.$emit(r.LK_VIDEO_PLAY_FAILED))}onGotRemoteAudioStream(o){c.info("onGotAudioRemoteStream",o,o.data.getVideoTracks(),this._view),this._view.setAudioSrcObj(o.data),this.emit({target:this,type:ne.GOT_REMOTE_AUDIO_STREAM,data:o})}onMediaPlayed(){if(this.app.peerConnectionCreated){this.app.state>J.LOGIN_SUCCESS&&this.app.state<J.BEFORE_DESTORY&&se.TaskInfoClientStarted(this.config,this.params),this.app.state=J.MEDIA_PLAYED,this.$emit(r.LK_VIDEO_PLAY_SUCCSS),this.emit({type:ne.MEDIA_PLAY_SUCCESS,target:this});try{this.params.audioInput&&this.params.audioInputAutoStart&&!this.audioTrack&&this.params.videoInput&&this.params.videoInputAutoStart&&!this.videoTrack?this.openDefaultMedia(!0,!0):(this.params.audioInput&&this.params.audioInputAutoStart&&!this.audioTrack&&this.openAudio(),this.params.videoInput&&this.params.videoInputAutoStart&&!this.videoTrack&&this.openVideo())}catch(o){this.$emitInfo(JSON.stringify(o))}}else c.warn("peerConnectionCreated already released")}onCursorStyle(o){this.emit({type:ne.APP_CURSOR_MODE,data:o.data}),this.screenState.cursorStyle=o.data,this._view.syncCursorStyle=this.screenState.cursorStyle,this._view.screenState=this.screenState,c.info("onCursorStyle",this.screenState.cursorStyle)}onAppResize(o){this.screenState.appSize=o.data,c.info("onAppResize ",o),this.emit({type:ne.APP_RESIZE,data:o.data})}onAppMouseMode(o){this.screenState.appMouseMode=o.data,this.op.setAppMouseMode(o.data),this.emit({type:ne.APP_MOUSE_MODE,data:o.data})}onAppPlayerList(o){let n=o.data,a=[];for(let s of n){let p={isCurrent:s.id===this.uid,userId:s.id?s.id:0,nickName:s.nickName?s.nickName:"",isTaskOwner:!!s.taskOwner,userType:s.controller?At.Player:At.Observer};if(p.isCurrent){if(this.userType!=p.userType){let v=p.userType==At.Player?"您已获得操作权限":"您已失去操作权限";this.$emitInfo(v),this.lockPointer.isLockPointer&&p.userType!=At.Player&&this.lockPointer.exitPointerLock()}this.params.userType=p.userType,this._uid=p.userId,this._isTaskOwner=p.isTaskOwner,this._op.resetAppMouseLockState(),this._view.$set({appParams:this._params}),this.screenState.resize(),c.info("upate current player ",p,this.userType,this.params.userType)}a.push(p)}this.emit({type:ne.PLAYER_LIST,data:a})}onAppRequestText(o){this.params.textInputEventPrompt?this.emit({type:ne.APP_REQUEST_INPUT,data:o.data}):c.warn("app set skip textinput event.")}onDataChannelText(o){this.emit({type:ne.DATACHANNEL_TEXT,data:o.data.string,rawData:o.data.rawString})}onDataChannelBinary(o){this.emit({type:ne.DATACHANNEL_BINARY,data:o.data})}onDataChannelOpen(o){this.emit({type:ne.DATACHANNEL_OPEN,data:o.data})}onDataChannelClose(o){this.emit({type:ne.DATACHANNEL_CLOSE,data:o.data})}onOperationTimeout(){this.isObMode||(c.warn("onOperationTimeout"),this.app&&this.app.disConnect(),this.emit({type:ne.NO_OPERATION_TIMEOUT}),this.emit({type:ne.ERROR,message:t.message.noOperationTimeout}))}onOperationInput(o){this.isObMode?c.info("skip operation when use mousemode"):(c.info("onOperationInput",JSON.stringify(o.input)),this.app&&o.input&&this.app.sendInput(o.input,!0))}async setCanvasMode(){I.os==="iOS"&&(this.screenState.scaleMode!==M.FILL_STRETCH&&this.screenState.scaleMode!==M.FILL_CLIP||(this.syncClientViewport=!0)),(this.config.useWebCodec||this.params.useWebCodec)&&(this._view.stopCanvasRender(),this._view.canvasRender=!0,this._view.forceCanvas2d=!0)}},API:se,AppliParams:dt,LoadAppliParamsFromUrl:function(){let o=q.getStringOption(k.queryString("touchOperateMode"),"mouse");return o=o==="touch"||o==="touchScreen"?"touchScreen":o==="mix"?"mix":"mouse",{appServer:k.queryString("renderServerIp"),appPort:k.queryString("renderServerPort"),renderSSLServerPort:q.getStringOption(k.queryString("renderSSLServerPort"),""),taskid:k.queryString("taskId"),taskId:k.queryString("taskId"),appliType:q.getIntOption(k.queryString("appliType"),bt.SHARED),appliName:decodeURI(k.queryString("appliName")),codeRate:q.getIntOption(k.queryString("codeRate"),N.CodeRate),audioCodeRate:q.getIntOption(k.queryString("audioCodeRate"),128),frameRate:q.getIntOption(k.queryString("frameRate"),N.FrameRate),width:q.getIntOption(k.queryString("width"),N.OriginW),height:q.getIntOption(k.queryString("height"),N.OriginH),scaleMode:q.getScaleMode(parseInt(k.queryString("initWinSize"),10)),network:q.getNetwork(parseInt(k.queryString("network"),10)),preferPubOutIp:q.getStringOption(k.queryString("preferPublicIp"),""),logLevel:q.getLogLevel(k.queryString("logLevel")),noOperationTimeout:q.getIntOption(k.queryString("noOperationTimeout"),0),waterMark:q.getBoolOption(k.queryString("wm"),!1),rttLimit:q.getIntOption(k.queryString("rttLimit"),60),packetLostLimit:q.getIntOption(k.queryString("packetLostLimit"),20),debugTask:q.getBoolOption(k.queryString("debugTask")),wsProxy:q.getNumberBoolOption(k.queryString("wsProxy")),debugWebServer:k.queryString("debugWebServer"),rttLimitInterval:q.getIntOption(k.queryString("rttLimitInterval"),20),initCursorMode:q.getIntOption(k.queryString("initCursorMode"),0),bgColor:q.getBgColor(k.queryString("bgColor")),fullScreenMode:q.getIntOption(k.queryString("fullScreenMode"),0),mobileFullScreenMode:q.getIntOption(k.queryString("mobileFullScreenMode"),1),playerMode:q.getIntOption(k.queryString("playerMode"),0),userType:q.getIntOption(k.queryString("userType"),1),nickname:q.getStringOption(k.queryString("nickname")),authCode:q.getStringOption(k.queryString("authCode"),""),loadingTimeout:q.getIntOption(k.queryString("loadingTimeout"),300),mobileForceLandscape:!!q.getIntOption(k.queryString("mobileForceLandscape"),1),mobileVirtualJoystick:!!q.getIntOption(k.queryString("mobileVirtualJoystick"),1),mouseZoomDirection:q.getIntOption(k.queryString("mouseZoomDirection"),0),showPlayerList:q.getNumberBoolOption(k.queryString("playerListToggle"),!0),preferDecoder:q.getStringOption(k.queryString("preferDecoder"),"h264"),touchOperateMode:o,appliId:q.getStringOption(k.queryString("appliId"),""),syncLocalToCloudClipboard:q.getBoolOption(k.queryString("syncLocalToCloudClipboard"),!0),enableRttIcon:q.getBoolOption(k.queryString("enableRttIcon"),!0),enableSoundRequire:q.getBoolOption(k.queryString("enableSoundRequire"),!0),toastLevel:q.getIntOption(k.queryString("toastLevel"),0),language:k.queryString("language"),wsId:q.getStringOption(k.queryString("wsId"),""),groupId:q.getStringOption(k.queryString("groupId"),""),audioInputAutoStart:q.getBoolOption(k.queryString("audioInputAutoStart"),!1),videoInputAutoStart:q.getBoolOption(k.queryString("videoInputAutoStart"),!1),initResolutionType:q.getIntOption(k.queryString("initResolutionType"),0),shareUrl:q.getBoolOption(k.queryString("audioInput"),!1),textInputEventPrompt:q.getBoolOption(k.queryString("textInputEventPrompt"),!0),audioInput:q.getBoolOption(k.queryString("audioInput"),!1),videoInput:q.getBoolOption(k.queryString("videoInput"),!1),liveStreaming:q.getBoolOption(k.queryString("liveStreaming"),!1),useSeparateMediaSharePeer:!0,mobileKeyboardType:q.getIntOption(k.queryString("mobileKeyboardType"),0),useWebCodec:q.getNumberBoolOption(k.queryString("useWebCodec"),!1),mobileWebMenuType:q.getIntOption(k.queryString("mobileWebMenuType"),0),showWebMenu:q.getIntOption(k.queryString("showWebMenu"),1),forceResolution:q.getBoolOption(k.queryString("forceResolution"),!1),ignoreCloudDesktopResolution:q.getBoolOption(k.queryString("ignoreCloudDesktopResolution"),!0),ignoreScreenOrientation:q.getBoolOption(k.queryString("ignoreScreenOrientation"),!0),imeFirstNotice:q.getIntOption(k.queryString("imeFirstNotice"),0)}},AppliParamsUtils:q,LoadAppliParamsStartAppInfo:Dn,EventBase:b,ScaleMode:M,Capabilities:I,CloudLark:h.CloudLark,FullScreen:qn,LockPointer:Zn,Operation:Xn,LarkSRClientEvent:ne,LarkEventType:r,GESTURE_TYPE:re,KEYMAP:Zt}}(),__webpack_exports__=__webpack_exports__.default,__webpack_exports__}()})})(larksrWebSdk_min);var larksrWebSdk_minExports=larksrWebSdk_min.exports;class LoadStream{constructor(){this._gameApi=null,this._larksr=null}static async createAndInitLarkSR(m,u={}){if(typeof larksrWebSdk_minExports.LarkSR!="function")throw new Error("LarkSR 构造函数未找到,请确保已正确引入 larksr_websdk");setUELogEnabled((m==null?void 0:m.UELogLevel)??!0);const A=loadStream,b=new larksrWebSdk_minExports.LarkSR(m);A._larksr=b,b.on("datachannelopen",u.onDataChannelOpen||(c=>{log("数据通道已连通",c)}));let S=!0;if(b.on("datachanneltext",c=>{S&&(S=!1,u.onSceneInitialized?u.onSceneInitialized(c):log("场景初始化加载成功",c)),u.onDatachanneltext?u.onDatachanneltext(c):log("接收数据",c)}),b.on("error",u.onError||(c=>{console.error(c.message)})),b.on("info",u.onInfo||(c=>{log("LarkSRClientEvent info",c)})),await b.connect({appliId:m.appliId}),u.onConnected&&u.onConnected(b),A.init(b),b.audioElement&&(b.audioElement.volume=0),b.params.initResolutionType===1){const c=b.screenState.syncClientViewport.width,f=b.screenState.syncClientViewport.height;b==null||b.setCloudAppSize(c,f),console.log("resize",c,f)}return A._gameApi}init(m){try{const u=new CommandManager(m);return this._gameApi=new GameAPI(u),console.log("插件初始化成功"),this._gameApi}catch(u){throw console.error("插件初始化失败",u),u}}async close(){if(this._larksr&&typeof this._larksr.close=="function")try{await this._larksr.close(),console.log("连接关闭成功")}catch(m){console.error("连接关闭失败:",m)}this._gameApi=null,this._larksr=null}}const loadStream=new LoadStream,createAndInitLarkSR=loadStream.constructor.createAndInitLarkSR;function closeGameApi(){return loadStream.close()}exports.closeGameApi=closeGameApi,exports.createAndInitLarkSR=createAndInitLarkSR,exports.default=loadStream,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});