@illgrenoble/webx-client 1.11.0 → 1.12.1
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/dist/WebXClient.d.ts +1 -2
- package/dist/common/WebXImageBlenderFunc.d.ts +26 -0
- package/dist/{display → common}/WebXSubImage.d.ts +5 -5
- package/dist/common/index.d.ts +3 -0
- package/dist/display/WebXCursor.d.ts +5 -17
- package/dist/display/WebXCursorFactory.d.ts +2 -2
- package/dist/display/WebXDisplay.d.ts +11 -10
- package/dist/display/WebXDisplayOverlay.d.ts +10 -0
- package/dist/display/WebXWindow.d.ts +4 -4
- package/dist/display/WebXWindowImageFactory.d.ts +31 -0
- package/dist/display/index.d.ts +0 -6
- package/dist/index.d.ts +2 -0
- package/dist/message/WebXCursorImageMessage.d.ts +3 -3
- package/dist/message/WebXImageMessage.d.ts +4 -4
- package/dist/message/WebXMessage.d.ts +13 -1
- package/dist/message/WebXShapeMessage.d.ts +3 -3
- package/dist/message/WebXSubImagesMessage.d.ts +1 -1
- package/dist/message/WebXWindowsMessage.d.ts +1 -1
- package/dist/renderer/WebXCanvasRenderer.d.ts +1 -2
- package/dist/renderer/{WebXAlphaStencilBlender.d.ts → WebXImageBlender.d.ts} +1 -1
- package/dist/renderer/WebXImageBlenderWorker.d.ts +1 -0
- package/dist/renderer/WebXWindowCanvas.d.ts +27 -8
- package/dist/renderer/index.d.ts +1 -1
- package/dist/texture/WebXTexture.d.ts +18 -0
- package/dist/texture/WebXTextureFactory.d.ts +23 -0
- package/dist/texture/WebXTextureFunc.d.ts +3 -0
- package/dist/texture/index.d.ts +3 -0
- package/dist/transport/WebXBinarySerializer.d.ts +13 -8
- package/dist/transport/WebXMessageBuffer.d.ts +4 -0
- package/dist/transport/WebXMessageDecoder.d.ts +2 -5
- package/dist/transport/WebXMessageDecoderWorker.d.ts +1 -0
- package/dist/transport/WebXMessageFunc.d.ts +22 -0
- package/dist/transport/index.d.ts +0 -2
- package/dist/tunnel/WebXTunnel.d.ts +5 -2
- package/dist/tunnel/WebXWebSocketTunnel.d.ts +2 -4
- package/dist/webx-client.cjs +1 -0
- package/dist/webx-client.esm.js +1 -0
- package/package.json +12 -9
- package/dist/WebXClient.js +0 -513
- package/dist/WebXClient.js.map +0 -1
- package/dist/WebXConnectionHandler.js +0 -96
- package/dist/WebXConnectionHandler.js.map +0 -1
- package/dist/WebXEngine.js +0 -7
- package/dist/WebXEngine.js.map +0 -1
- package/dist/display/WebXCursor.js +0 -150
- package/dist/display/WebXCursor.js.map +0 -1
- package/dist/display/WebXCursorFactory.js +0 -59
- package/dist/display/WebXCursorFactory.js.map +0 -1
- package/dist/display/WebXDisplay.js +0 -501
- package/dist/display/WebXDisplay.js.map +0 -1
- package/dist/display/WebXMaterial.js +0 -142
- package/dist/display/WebXMaterial.js.map +0 -1
- package/dist/display/WebXSubImage.js +0 -26
- package/dist/display/WebXSubImage.js.map +0 -1
- package/dist/display/WebXTextureFactory.d.ts +0 -54
- package/dist/display/WebXTextureFactory.js +0 -160
- package/dist/display/WebXTextureFactory.js.map +0 -1
- package/dist/display/WebXWindow.js +0 -475
- package/dist/display/WebXWindow.js.map +0 -1
- package/dist/display/WebXWindowProperties.js +0 -25
- package/dist/display/WebXWindowProperties.js.map +0 -1
- package/dist/display/index.js +0 -24
- package/dist/display/index.js.map +0 -1
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/input/GuacamoleKeyboard.js +0 -1551
- package/dist/input/WebXKeyboard.js +0 -44
- package/dist/input/WebXKeyboard.js.map +0 -1
- package/dist/input/WebXMouse.js +0 -231
- package/dist/input/WebXMouse.js.map +0 -1
- package/dist/input/index.js +0 -20
- package/dist/input/index.js.map +0 -1
- package/dist/input/mouse/WebXMouseState.js +0 -217
- package/dist/input/mouse/WebXMouseState.js.map +0 -1
- package/dist/input/mouse/index.js +0 -18
- package/dist/input/mouse/index.js.map +0 -1
- package/dist/instruction/WebXClipboardInstruction.js +0 -23
- package/dist/instruction/WebXClipboardInstruction.js.map +0 -1
- package/dist/instruction/WebXConnectInstruction.js +0 -24
- package/dist/instruction/WebXConnectInstruction.js.map +0 -1
- package/dist/instruction/WebXCursorImageInstruction.js +0 -23
- package/dist/instruction/WebXCursorImageInstruction.js.map +0 -1
- package/dist/instruction/WebXDataAckInstruction.js +0 -26
- package/dist/instruction/WebXDataAckInstruction.js.map +0 -1
- package/dist/instruction/WebXImageInstruction.js +0 -23
- package/dist/instruction/WebXImageInstruction.js.map +0 -1
- package/dist/instruction/WebXInstruction.js +0 -28
- package/dist/instruction/WebXInstruction.js.map +0 -1
- package/dist/instruction/WebXInstructionResponse.js +0 -78
- package/dist/instruction/WebXInstructionResponse.js.map +0 -1
- package/dist/instruction/WebXInstructionType.js +0 -96
- package/dist/instruction/WebXInstructionType.js.map +0 -1
- package/dist/instruction/WebXKeyboardInstruction.js +0 -25
- package/dist/instruction/WebXKeyboardInstruction.js.map +0 -1
- package/dist/instruction/WebXMouseInstruction.js +0 -27
- package/dist/instruction/WebXMouseInstruction.js.map +0 -1
- package/dist/instruction/WebXPongInstruction.js +0 -23
- package/dist/instruction/WebXPongInstruction.js.map +0 -1
- package/dist/instruction/WebXQualityInstruction.js +0 -24
- package/dist/instruction/WebXQualityInstruction.js.map +0 -1
- package/dist/instruction/WebXScreenInstruction.js +0 -20
- package/dist/instruction/WebXScreenInstruction.js.map +0 -1
- package/dist/instruction/WebXShapeInstruction.js +0 -23
- package/dist/instruction/WebXShapeInstruction.js.map +0 -1
- package/dist/instruction/WebXWindowsInstruction.js +0 -21
- package/dist/instruction/WebXWindowsInstruction.js.map +0 -1
- package/dist/instruction/index.js +0 -32
- package/dist/instruction/index.js.map +0 -1
- package/dist/message/WebXClipboardMessage.js +0 -23
- package/dist/message/WebXClipboardMessage.js.map +0 -1
- package/dist/message/WebXConnectionMessage.js +0 -21
- package/dist/message/WebXConnectionMessage.js.map +0 -1
- package/dist/message/WebXCursorImageMessage.js +0 -35
- package/dist/message/WebXCursorImageMessage.js.map +0 -1
- package/dist/message/WebXImageMessage.js +0 -33
- package/dist/message/WebXImageMessage.js.map +0 -1
- package/dist/message/WebXMessage.js +0 -23
- package/dist/message/WebXMessage.js.map +0 -1
- package/dist/message/WebXMessageType.js +0 -64
- package/dist/message/WebXMessageType.js.map +0 -1
- package/dist/message/WebXMouseMessage.js +0 -29
- package/dist/message/WebXMouseMessage.js.map +0 -1
- package/dist/message/WebXNopMessage.js +0 -18
- package/dist/message/WebXNopMessage.js.map +0 -1
- package/dist/message/WebXPingMessage.js +0 -21
- package/dist/message/WebXPingMessage.js.map +0 -1
- package/dist/message/WebXQualityMessage.js +0 -32
- package/dist/message/WebXQualityMessage.js.map +0 -1
- package/dist/message/WebXScreenMessage.js +0 -29
- package/dist/message/WebXScreenMessage.js.map +0 -1
- package/dist/message/WebXShapeMessage.js +0 -29
- package/dist/message/WebXShapeMessage.js.map +0 -1
- package/dist/message/WebXSubImagesMessage.js +0 -29
- package/dist/message/WebXSubImagesMessage.js.map +0 -1
- package/dist/message/WebXWindowsMessage.js +0 -25
- package/dist/message/WebXWindowsMessage.js.map +0 -1
- package/dist/message/index.js +0 -31
- package/dist/message/index.js.map +0 -1
- package/dist/renderer/WebXAlphaStencilBlender.js +0 -136
- package/dist/renderer/WebXAlphaStencilBlender.js.map +0 -1
- package/dist/renderer/WebXBlenderWorker.d.ts +0 -1
- package/dist/renderer/WebXBlenderWorker.js +0 -33
- package/dist/renderer/WebXBlenderWorker.js.map +0 -1
- package/dist/renderer/WebXCanvasRenderer.js +0 -190
- package/dist/renderer/WebXCanvasRenderer.js.map +0 -1
- package/dist/renderer/WebXWindowBlender.d.ts +0 -11
- package/dist/renderer/WebXWindowBlender.js +0 -27
- package/dist/renderer/WebXWindowBlender.js.map +0 -1
- package/dist/renderer/WebXWindowCanvas.js +0 -306
- package/dist/renderer/WebXWindowCanvas.js.map +0 -1
- package/dist/renderer/blender.d.ts +0 -5
- package/dist/renderer/blender.js +0 -201
- package/dist/renderer/blender.js.map +0 -1
- package/dist/renderer/index.js +0 -20
- package/dist/renderer/index.js.map +0 -1
- package/dist/tracer/WebXDebugImageMessageHandler.js +0 -102
- package/dist/tracer/WebXDebugImageMessageHandler.js.map +0 -1
- package/dist/tracer/WebXHandler.js +0 -3
- package/dist/tracer/WebXHandler.js.map +0 -1
- package/dist/tracer/WebXInstructionHandler.js +0 -13
- package/dist/tracer/WebXInstructionHandler.js.map +0 -1
- package/dist/tracer/WebXMessageHandler.js +0 -13
- package/dist/tracer/WebXMessageHandler.js.map +0 -1
- package/dist/tracer/WebXStatsHandler.js +0 -13
- package/dist/tracer/WebXStatsHandler.js.map +0 -1
- package/dist/tracer/index.js +0 -22
- package/dist/tracer/index.js.map +0 -1
- package/dist/transport/WebXBinarySerializer.js +0 -63
- package/dist/transport/WebXBinarySerializer.js.map +0 -1
- package/dist/transport/WebXInstructionBuffer.js +0 -109
- package/dist/transport/WebXInstructionBuffer.js.map +0 -1
- package/dist/transport/WebXInstructionEncoder.js +0 -294
- package/dist/transport/WebXInstructionEncoder.js.map +0 -1
- package/dist/transport/WebXMessageBuffer.js +0 -104
- package/dist/transport/WebXMessageBuffer.js.map +0 -1
- package/dist/transport/WebXMessageDecoder.js +0 -333
- package/dist/transport/WebXMessageDecoder.js.map +0 -1
- package/dist/transport/index.js +0 -22
- package/dist/transport/index.js.map +0 -1
- package/dist/tunnel/WebXTunnel.js +0 -156
- package/dist/tunnel/WebXTunnel.js.map +0 -1
- package/dist/tunnel/WebXWebSocketTunnel.js +0 -88
- package/dist/tunnel/WebXWebSocketTunnel.js.map +0 -1
- package/dist/tunnel/index.js +0 -19
- package/dist/tunnel/index.js.map +0 -1
- package/dist/utils/WebXColorGenerator.js +0 -46
- package/dist/utils/WebXColorGenerator.js.map +0 -1
- package/dist/utils/WebXVersion.js +0 -25
- package/dist/utils/WebXVersion.js.map +0 -1
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- /package/dist/{display → common}/WebXWindowProperties.d.ts +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WebXMessage } from '../message';
|
|
2
|
-
import { WebXTextureFactory } from '../display';
|
|
3
2
|
import { WebXMessageBuffer } from './WebXMessageBuffer';
|
|
4
3
|
/**
|
|
5
4
|
* Decodes binary messages received from the WebX Engine into WebXMessage objects.
|
|
@@ -7,13 +6,11 @@ import { WebXMessageBuffer } from './WebXMessageBuffer';
|
|
|
7
6
|
* WebXMessage implementations.
|
|
8
7
|
*/
|
|
9
8
|
export declare class WebXMessageDecoder {
|
|
10
|
-
private _textureFactory;
|
|
9
|
+
private readonly _textureFactory;
|
|
11
10
|
/**
|
|
12
11
|
* Creates a new instance of WebXMessageDecoder.
|
|
13
|
-
*
|
|
14
|
-
* @param _textureFactory The texture factory used to create textures from image data.
|
|
15
12
|
*/
|
|
16
|
-
constructor(
|
|
13
|
+
constructor();
|
|
17
14
|
/**
|
|
18
15
|
* Decodes a binary message buffer into a WebXMessage object.
|
|
19
16
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WebXMessage } from '../message';
|
|
2
|
+
import { WebXMessageBuffer } from "./WebXMessageBuffer";
|
|
3
|
+
/**
|
|
4
|
+
* Recasts an object (received from a web workder) into a concrete WebXMessage class
|
|
5
|
+
* @param object the message data
|
|
6
|
+
* @returns a concrete WebXMessage instance
|
|
7
|
+
*/
|
|
8
|
+
export declare const recastWebXMessage: (object: any) => WebXMessage;
|
|
9
|
+
/**
|
|
10
|
+
* Returns all image types that should be processed in the web worker: essentially all with
|
|
11
|
+
* image data
|
|
12
|
+
* @param messageBuffer the raw message buffer
|
|
13
|
+
* @return true if the message should be decoded by a web worker
|
|
14
|
+
*/
|
|
15
|
+
export declare const isWorkerMessage: (messageBuffer: WebXMessageBuffer) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns all elements of the message that can be transferred from the web worker (releasing ownership and
|
|
18
|
+
* avoiding copying).
|
|
19
|
+
* @param message the webx message
|
|
20
|
+
* @return an array of transferable objects
|
|
21
|
+
*/
|
|
22
|
+
export declare const getMessageTransfers: (message: WebXMessage) => Transferable[];
|
|
@@ -16,14 +16,17 @@ export declare abstract class WebXTunnel {
|
|
|
16
16
|
* Establishes a connection to the WebX Engine.
|
|
17
17
|
*
|
|
18
18
|
* @param data The data required to establish the connection.
|
|
19
|
-
* @param serializer The serializer to use for encoding/decoding messages.
|
|
20
19
|
* @returns A promise that resolves when the connection is successfully established.
|
|
21
20
|
*/
|
|
22
|
-
abstract connect(data: any
|
|
21
|
+
abstract connect(data: any): Promise<Event>;
|
|
23
22
|
/**
|
|
24
23
|
* Closes the connection to the WebX Engine.
|
|
25
24
|
*/
|
|
26
25
|
abstract disconnect(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Terminates the Web Worker and clears pending tasks.
|
|
28
|
+
*/
|
|
29
|
+
terminate(): void;
|
|
27
30
|
/**
|
|
28
31
|
* Sends data to the WebX Engine.
|
|
29
32
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WebXTunnel } from './WebXTunnel';
|
|
2
|
-
import { WebXBinarySerializer } from '../transport';
|
|
3
2
|
/**
|
|
4
3
|
* Represents a WebSocket-based implementation of the WebX communication tunnel.
|
|
5
4
|
*
|
|
@@ -9,7 +8,7 @@ import { WebXBinarySerializer } from '../transport';
|
|
|
9
8
|
export declare class WebXWebSocketTunnel extends WebXTunnel {
|
|
10
9
|
private readonly _url;
|
|
11
10
|
private _socket;
|
|
12
|
-
private _connectionOptions;
|
|
11
|
+
private readonly _connectionOptions;
|
|
13
12
|
private _socketOpen;
|
|
14
13
|
constructor(url: string, options?: any);
|
|
15
14
|
getSocket(): WebSocket;
|
|
@@ -23,10 +22,9 @@ export declare class WebXWebSocketTunnel extends WebXTunnel {
|
|
|
23
22
|
* Establishes a WebSocket connection to the WebX Engine.
|
|
24
23
|
*
|
|
25
24
|
* @param data The connection options.
|
|
26
|
-
* @param serializer The serializer to use for encoding/decoding messages.
|
|
27
25
|
* @returns A promise that resolves when the connection is successfully established.
|
|
28
26
|
*/
|
|
29
|
-
connect(data: any
|
|
27
|
+
connect(data: any): Promise<Event>;
|
|
30
28
|
/**
|
|
31
29
|
* Closes the WebSocket connection to the WebX Engine.
|
|
32
30
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("three"),t=require("@tweenjs/tween.js");function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}}),t.default=e,Object.freeze(t)}var i=s(e);class n{constructor(e){this.id=e.id,this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.shaped=e.shaped||!1}}class a{constructor(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.depth=e.depth,this.colorMap=e.colorMap,this.alphaMap=e.alphaMap}}const r=(e,t,s)=>{if(t&&s)for(let i=0;i<e.length;i+=4)s[i]<128?e[i+3]=0:e[i+3]=t[i+1];else if(t)for(let s=0;s<e.length;s+=4)e[s+3]=t[s+1];else if(s)for(let t=0;t<e.length;t+=4)e[t+3]=s[t]<128?0:e[t+3]},o=(e,t)=>{for(let s=0;s<e.length;s+=4)e[s+3]=t[s+1]};class h extends e.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get alphaMap(){return this.uniforms.alphaMap.value}set alphaMap(e){this.uniforms.alphaMap.value=e}get stencilMap(){return this.uniforms.stencilMap.value}set stencilMap(e){this.uniforms.stencilMap.value=e,e?this.defines.USE_STENCILMAP="":delete this.defines.USE_STENCILMAP}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value.copy(e)}constructor(t){super({uniforms:{map:{value:null},alphaMap:{value:null},stencilMap:{value:null},mapTransform:{value:new e.Matrix3},alphaMapTransform:{value:new e.Matrix3},diffuse:{value:new e.Color(16777215)},opacity:{value:1}},vertexShader:"\n#ifdef USE_MAP\nuniform mat3 mapTransform;\nvarying vec2 vMapUv;\n#endif\n\n#ifdef USE_ALPHAMAP\nuniform mat3 alphaMapTransform;\nvarying vec2 vAlphaMapUv;\n#endif\n\n#ifdef USE_STENCILMAP\nvarying vec2 vStencilMapUv;\n#endif\n\nvoid main() {\n#ifdef USE_MAP\n vMapUv = (mapTransform * vec3(uv, 1)).xy;\n#endif\n\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = (alphaMapTransform * vec3(uv, 1)).xy;\n#endif\n\n#ifdef USE_STENCILMAP\n vStencilMapUv = uv;\n#endif\n\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifdef USE_MAP\nuniform sampler2D map;\nvarying vec2 vMapUv;\n#endif\n\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\nvarying vec2 vAlphaMapUv;\n#endif\n\n#ifdef USE_STENCILMAP\nuniform sampler2D stencilMap;\nvarying vec2 vStencilMapUv;\n#endif\n\nvoid main() {\n vec4 diffuseColor = vec4(diffuse, opacity);\n\n#ifdef USE_STENCILMAP\n vec4 stencil = texture2D(stencilMap, vStencilMapUv);\n if (stencil.r < 0.5) {\n discard;\n }\n#endif\n\n#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D(map, vMapUv);\n diffuseColor *= sampledDiffuseColor;\n#endif\n\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D(alphaMap, vAlphaMapUv).g;\n#endif\n\n gl_FragColor = diffuseColor;\n gl_FragColor = linearToOutputTexel( gl_FragColor );\n}\n",transparent:!0,depthTest:!0,side:e.BackSide}),t&&t.color&&this.color.set(t.color)}onBeforeRender(){this.map&&this.map.matrixAutoUpdate&&(this.map.updateMatrix(),this.uniforms.mapTransform.value.copy(this.map.matrix)),this.alphaMap&&this.alphaMap.matrixAutoUpdate&&(this.alphaMap.updateMatrix(),this.uniforms.alphaMapTransform.value.copy(this.alphaMap.matrix))}}class l{}const c="srgb",d="srgb-linear";class u{constructor(e){this.image=e.image?e.image:null,this.data=e.data,this.width=e.image?e.image.width:e.width,this.height=e.image?e.image.height:e.height,this.colorSpace=c,this.flipY=!1}isTransferable(){return this.image&&this.image instanceof ImageBitmap||null!=this.data}get transferable(){return this.image&&this.image instanceof ImageBitmap?this.image:this.data?this.data.buffer:null}}class p{constructor(){}async createTextureFromArray(e,t,s){if(null!=e&&e.byteLength>0){const i=new Blob([e],{type:t}),n=await this.createTextureFromBlob(i);return n.flipY=!1,n.colorSpace=s,n}return null}createTextureFromBlob(e){return"function"==typeof createImageBitmap?new Promise((t,s)=>{createImageBitmap(e).then(e=>{const s=new u({image:e});t(s)}).catch(e=>{console.warn(`Failed to create texture using createImageBitmap from binary data: ${e}`),s(e)})}):new Promise((t,s)=>{const i=URL.createObjectURL(e),n=new Image;n.onload=()=>{URL.revokeObjectURL(i);const e=new u({image:n});t(e)},n.onerror=e=>{console.warn(`Failed to create texture from binary data: ${e}`),s(e)},n.src=i})}}const y=t=>{if(t){const s=t.data?new i.DataTexture(t.data,t.width,t.height):new i.Texture(t.image);return s.needsUpdate=!0,s.flipY=t.flipY,s.colorSpace=t.colorSpace,s.minFilter=e.LinearFilter,s}return null};class m{get mesh(){return this._mesh}get colorIndex(){return this._colorIndex}get id(){return this._id}get visible(){return this._material.visible}set visible(e){this._material.visible!==e&&(this._material.visible=e)}get loaded(){return this._loaded}get colorMap(){return this._material.map}set colorMap(e){this._material.map=e}get alphaMap(){return this._material.alphaMap}set alphaMap(e){this._material.alphaMap=e}get stencilMap(){return this._material.stencilMap}set stencilMap(e){this._material.stencilMap=e}get colorMapValid(){return null!=this.colorMap&&this.colorMap.image.width===this._width&&this.colorMap.image.height===this._height}get depth(){return this._depth}get x(){return this._x}set x(e){this._x=e,this._updatePosition()}get y(){return this._y}set y(e){this._y=e,this._updatePosition()}get z(){return this._z}set z(e){this._z=e,this._updatePosition()}get width(){return this._width}set width(e){this._width=e,this._updateScale(),this._updatePosition()}get height(){return this._height}set height(e){this._height=e,this._updateScale(),this._updatePosition()}get shaped(){return this._shaped}set shaped(e){this._shaped=e,e||this.updateStencilTexture(null)}constructor(e,t){this._width=1,this._height=1,this._shaped=!1,this._loaded=!1,this._windowRefreshTimeout=null,this._windowImageFactory=t,this._colorIndex=m._COLOR_INDEX++,this._material=new h,this.visible=!1;const{id:s,x:n,y:a,z:r,width:o,height:c,shaped:d}=e;this._id=s,this._mesh=new i.Mesh(m._PLANE_GEOMETRY,this._material),this._mesh.onBeforeRender=()=>this._material.onBeforeRender(),this._x=n,this._y=a,this._z=r,this._width=o,this._height=c,this._shaped=d&&l.version.versionNumber>=1.4,this._updateScale(),this._updatePosition()}async loadWindowImage(){const e=await this._windowImageFactory.getWindowTexture(this._id);e&&this.updateTexture(e.depth,y(e.colorMap),y(e.alphaMap),!0)}async loadWindowShape(){const e=await this._windowImageFactory.getWindowStencilTexture(this._id);e?this.updateStencilTexture(y(e.stencilMap)):(this._shaped=!1,this.visible=null!=this.colorMap)}async loadWindowImageAndShape(){if(this._shaped){const e=this.loadWindowImage(),t=this.loadWindowShape();await Promise.all([e,t])}else await this.loadWindowImage();this._loaded=!0}setRectangle(e,t,s,i,n){this._x=e,this._y=t,this._z=s,this._width=i,this._height=n,this.colorMap&&(this.colorMap.repeat.set(this._width/this.colorMap.image.width,this._height/this.colorMap.image.height),this.alphaMap&&this.alphaMap.repeat.set(this._width/this.alphaMap.image.width,this._height/this.alphaMap.image.height),this.colorMap.image.width===this._width&&this.colorMap.image.height===this._height||this.loadWindowImageAndShape()),this._updateScale(),this._updatePosition()}updateTexture(e,t,s,i){if(null==t)return;const n=null!=this.colorMap,a=null!=this.alphaMap;this._depth=e,t!=this.colorMap&&(this._disposeColorMap(),this.colorMap=t),this.colorMap.repeat.set(this._width/this.colorMap.image.width,this._height/this.colorMap.image.height),this.visible=!this._shaped||null!=this.stencilMap,s?(s!=this.alphaMap&&(this._disposeAlphaMap(),this.alphaMap=s),this.alphaMap.repeat.set(this._width/this.alphaMap.image.width,this._height/this.alphaMap.image.height)):24==e&&this._disposeAlphaMap(),this._material.transparent=null!=this.alphaMap||32===e;const r=null!=this.colorMap,o=null!=this.alphaMap;n==r&&a==o||(this._material.needsUpdate=!0),i||(this._windowRefreshTimeout&&(clearTimeout(this._windowRefreshTimeout),this._windowRefreshTimeout=null),this._windowRefreshTimeout=window.setTimeout(()=>{this._windowRefreshTimeout=null,this.loadWindowImage().then()},m.WINDOW_REFRESH_TIME_MS))}updateStencilTexture(t){const s=this._shaped;t!=this.stencilMap&&(this._disposeStencilMap(),this.stencilMap=t),t?(t.minFilter=e.LinearFilter,this.visible=null!=this.colorMap,this._shaped=!0):this._shaped=!1,s!==this._shaped&&(this._material.needsUpdate=!0)}_updateScale(){this._mesh.scale.set(this._width,this._height,1)}_updatePosition(){this._mesh.position.set(this._x+.5*this._width,this._y+.5*this._height,this._z)}dispose(){this._disposeColorMap(),this._disposeAlphaMap(),this._disposeStencilMap(),this._material.dispose(),this._windowRefreshTimeout&&(clearTimeout(this._windowRefreshTimeout),this._windowRefreshTimeout=null)}_disposeColorMap(){this.colorMap&&(this.colorMap.dispose(),this.colorMap=null)}_disposeAlphaMap(){this.alphaMap&&(this.alphaMap.dispose(),this.alphaMap=null)}_disposeStencilMap(){this.stencilMap&&(this.stencilMap.dispose(),this.stencilMap=null)}}m.WINDOW_REFRESH_TIME_MS=5e3,m._PLANE_GEOMETRY=new i.PlaneGeometry(1,1,2,2),m._COLOR_INDEX=0;class _{get canvas(){return this._canvas}get cursorId(){return this._cursorId}set x(e){this._x=e,this._updatePosition()}set y(e){this._y=e,this._updatePosition()}constructor(e){this._cursorFactory=e,this._x=-1,this._y=-1,this._xHot=0,this._yHot=0,this._width=1,this._height=1,this._canvas=document.createElement("canvas"),this._canvas.id="webx-cursor",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._context=this._canvas.getContext("2d"),this.setPosition(-1,-1),this.setCursorId(0)}setPosition(e,t){this._x=e,this._y=t,this._updatePosition()}setCursorId(e){this._cursorId!==e&&(this._cursorId=e,this._cursorFactory.getCursor(e).then(e=>{const t=e.cursor;(this._x<0||this._y<0)&&this.setPosition(e.x,e.y),this._updateCursor(t.xHot,t.yHot,t.cursorId,t.texture)}))}_updateCursor(e,t,s,i){this._xHot=e,this._yHot=t,this._cursorId=s,null!=i&&null!=i.image&&(this._width=i.image.width,this._height=i.image.height,this._canvas.style.width=`${this._width}px`,this._canvas.style.height=`${this._height}px`,this._canvas.width=this._width,this._canvas.height=this._height,this._texture=i,this._context.clearRect(0,0,this._width,this._height),this._context.drawImage(this._texture.image,0,0,this._width,this._height))}_updatePosition(){this._canvas.style.left=this._x-this._xHot+"px",this._canvas.style.top=this._y-this._yHot+"px"}}class g{get id(){return this._mesh.id}get canvas(){return this._canvas}get x(){return this._x}get y(){return this._y}get zIndex(){return this._zIndex}get width(){return this._width}get height(){return this._height}constructor(e,t){this._mesh=e,this._imageBlender=t,this._x=0,this._y=0,this._zIndex=0,this._width=0,this._height=0,this._regionUpdates=[],this._canvas=this.createElementNS("canvas"),this._canvas.id=`webx-window-${this.id}`,this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.style.top="0",this._canvas.style.left="0",this._canvas.style.overflow="hidden",this._context=this._canvas.getContext("2d"),this.updateGeometry(),this.updateCanvas()}updateGeometry(){const e=this._mesh.scale.x,t=this._mesh.scale.y,s=this._mesh.position.x-.5*e,i=this._mesh.position.y-.5*t,n=this._mesh.position.z;s===this._x&&i===this._y||(this._canvas.style.top=`${i}px`,this._canvas.style.left=`${s}px`,this._x=s,this._y=i),e===this._width&&t===this._height||(this._width=e,this._height=t),n!==this._zIndex&&(this._canvas.style.zIndex=`${this._mesh.position.z}`,this._zIndex=n)}async updateCanvas(){if(this._mesh.material instanceof h||this._mesh.material instanceof e.MeshBasicMaterial){const t=this._mesh.material;if(this.updateStencilMap(t),t.map?.image){if(t.map!=this._colorMap||t.alphaMap!=this._alphaMap){this._colorMap=t.map,this._alphaMap=t.alphaMap;const s=t.map.image,i=s.width,n=s.height;if(this.isValidAlphaMap(t.alphaMap)||null!=this._stencilMap){const e=await this.blendAlphaAndStencil(t.map,t.alphaMap,0,0);this.resizeCanvas(i,n),this._context.putImageData(e,0,0)}else if(this.resizeCanvas(i,n),t.map instanceof e.DataTexture){const e=this.dataTextureToImageData(s);this._context.putImageData(e,0,0)}else this._context.clearRect(0,0,i,n),this._context.drawImage(s,0,0,i,n)}await this.handleRegionUpdates()}else this._colorMap&&(this._colorMap=null,this._alphaMap=null,this._regionUpdates=[],this._context.clearRect(0,0,this._canvas.width,this._canvas.height))}}addRegionUpdate(e,t,s,i,n,a,r){this._regionUpdates.push({srcColorMap:e,dstColorMap:t,srcAlphaMap:s,dstAlphaMap:i,width:n,height:a,dstPosition:r})}resizeCanvas(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`)}async handleRegionUpdates(){for(const t of this._regionUpdates)if(t.dstColorMap===this._colorMap&&t.dstAlphaMap===this._alphaMap){const{srcColorMap:s,srcAlphaMap:i,width:n,height:a,dstPosition:r}=t,o=s.image;if(i||this._stencilData){const e=await this.blendAlphaAndStencil(s,i,r.x,r.y);e&&this._context.putImageData(e,r.x,r.y)}else if(s instanceof e.DataTexture){const e=this.dataTextureToImageData(o);this._context.putImageData(e,r.x,r.y)}else this._context.drawImage(o,0,0,n,a,r.x,r.y,n,a)}this._regionUpdates=[]}isValidAlphaMap(e){if(e){const t=e.image.width,s=e.image.height;return t===this._canvas.width&&s===this._canvas.height}return!1}updateStencilMap(t){if(t instanceof h&&t.stencilMap){if(t.stencilMap!=this._stencilMap){this._stencilMap=t.stencilMap;const s=this._stencilMap.image,{width:i,height:n}=s;if(this._stencilMap instanceof e.DataTexture)this._stencilData=this.dataTextureToImageData(s);else{const e=this.createElementNS("canvas");e.width=i,e.height=n;const t=e.getContext("2d",{willReadFrequently:!0});t.drawImage(s,0,0),this._stencilData=t.getImageData(0,0,i,n)}}}else this._stencilMap&&(this._stencilMap=null,this._stencilData=null)}async blendAlphaAndStencil(t,s,i,n){const a=t instanceof e.DataTexture?this.dataTextureToImageData(t.image):this.getImageData(t.image),r=null==s?null:s instanceof e.DataTexture?this.dataTextureToImageData(s.image):this.getImageData(s.image),o=null==this._stencilData?null:this.getStencilDataRegion(i,n,a.width,a.height);return r||o?await this._imageBlender.blendAlphaAndStencil(a,r,o):a}createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}getImageData(e){const t=this.createElementNS("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return s.drawImage(e,0,0),s.getImageData(0,0,e.width,e.height)}dataTextureToImageData(e){if(e.data.byteLength>0){const t=e.data instanceof Uint8ClampedArray?e.data:new Uint8ClampedArray(e.data.buffer);return new ImageData(t,e.width,e.height)}return new ImageData(new Uint8ClampedArray(4),1,1)}getStencilDataRegion(e,t,s,i){const n=this._stencilData.data,a=this._stencilData.width,r=new Uint8ClampedArray(s*i*4);for(let o=0;o<i;o++){const i=4*((t+o)*a+e),h=o*s*4;r.set(n.subarray(i,i+4*s),h)}return new ImageData(r,s,i)}}function b(e,t,s){var i=function(e){return atob(e)}(e),n=i.indexOf("\n",10)+1,a=i.substring(n)+"",r=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(r)}function f(e,t,s){var i;return function(t){return i=i||b(e),new Worker(i,t)}}var M,Z=f("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7c2VsZi5vbm1lc3NhZ2U9ZT0+e2NvbnN0e2lkOmYsY29sb3JCdWZmZXI6bCxhbHBoYUJ1ZmZlcjp0LHN0ZW5jaWxCdWZmZXI6cix3aWR0aDpuLGhlaWdodDppfT1lLmRhdGEscz1uZXcgVWludDhDbGFtcGVkQXJyYXkobCk7KChlLGYsbCk9PntpZihmJiZsKWZvcihsZXQgdD0wO3Q8ZS5sZW5ndGg7dCs9NClsW3RdPDEyOD9lW3QrM109MDplW3QrM109Zlt0KzFdO2Vsc2UgaWYoZilmb3IobGV0IGw9MDtsPGUubGVuZ3RoO2wrPTQpZVtsKzNdPWZbbCsxXTtlbHNlIGlmKGwpZm9yKGxldCBmPTA7ZjxlLmxlbmd0aDtmKz00KWVbZiszXT1sW2ZdPDEyOD8wOmVbZiszXX0pKHMsdD9uZXcgVWludDhDbGFtcGVkQXJyYXkodCk6bnVsbCxyP25ldyBVaW50OENsYW1wZWRBcnJheShyKTpudWxsKSxzZWxmLnBvc3RNZXNzYWdlKHtpZDpmLGNvbG9yQnVmZmVyOnMuYnVmZmVyLHdpZHRoOm4saGVpZ2h0Oml9LFtzLmJ1ZmZlcl0pfX0oKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9V2ViWEltYWdlQmxlbmRlcldvcmtlci5qcy5tYXAKCg==");class w{constructor(){this._pending=new Map,this._nextId=1,"undefined"!=typeof Worker&&(this._worker=new Z,this._worker.onmessage=e=>{const{id:t,colorBuffer:s,width:i,height:n}=e.data,a=this._pending.get(t);if(!a)return;this._pending.delete(t);const r=new Uint8ClampedArray(s);a(new ImageData(r,i,n))})}async blendAlphaAndStencil(e,t,s){return new Promise(i=>{if(this._worker){const n=this._nextId++;this._pending.set(n,i);const a=e.width,r=e.height,o=e.data.buffer;let h=null,l=null;const c=[o];t&&(h=t.data.buffer,c.push(h)),s&&(l=s.data.buffer,c.push(l)),this._worker.postMessage({id:n,colorBuffer:o,alphaBuffer:h,stencilBuffer:l,width:a,height:r},c)}else r(e.data,t?.data,s?.data),i(e)})}terminate(){this._worker.terminate(),this._pending.clear()}}class W{get domElement(){return this._desktopContainer}constructor(){this._clearColor=new e.Color(0,0,0),this._windowCanvases=new Map,this.createMainElement(),this._imageBlender=new w}setSize(e,t,s){this._width=e,this._height=t,this._desktop.style.width=`${e}px`,this._desktop.style.height=`${t}px`}setClearColor(e){this._clearColor.set(e),this._desktop.style.backgroundColor=`#${this._clearColor.getHexString()}`}render(t,s){if(t.children.length>0){const s=t.children[0],i=new Set;for(const t of s.children)if(t instanceof e.Mesh&&t.visible){this._windowCanvases.has(t.id)||this.createWindowCanvas(t);const e=this._windowCanvases.get(t.id);e.updateGeometry(),e.updateCanvas(),i.add(t.id)}for(const[e,t]of this._windowCanvases.entries())i.has(e)||this.removeWindowCanvas(t)}else if(this._windowCanvases.size>0)for(const[e,t]of this._windowCanvases.entries())this.removeWindowCanvas(t)}createScreenshot(e,t){return new Promise((s,i)=>{try{const i=this.createElementNS("canvas");i.width=this._width,i.height=this._height;const n=i.getContext("2d");n.fillStyle=`#${this._clearColor.getHexString()}`,n.fillRect(0,0,this._width,this._height),Array.from(this._windowCanvases.values()).sort((e,t)=>e.zIndex-t.zIndex).forEach(e=>{n.drawImage(e.canvas,e.x,e.y)}),i.toBlob(e=>{s(e)},e,t)}catch(e){i(e)}})}dispose(){for(const[e,t]of this._windowCanvases.entries())this.removeWindowCanvas(t);this._imageBlender.terminate()}updateWindowRegion(e,t,s,i,n,a,r,o){const h=this._windowCanvases.get(e);h&&h.addRegionUpdate(t,s,i,n,a,r,o)}createMainElement(){const e=this.createElementNS("div");e.id="webx-desktop-container",e.style.display="block",e.style.position="relative",e.style.overflow="hidden";const t=document.createElement("div");t.id="webx-desktop",e.style.position="absolute",e.style.transformOrigin="top left",e.appendChild(t),this._desktopContainer=e,this._desktop=t}createWindowCanvas(e){const t=new g(e,this._imageBlender);this._desktop.appendChild(t.canvas),this._windowCanvases.set(e.id,t)}removeWindowCanvas(e){this._desktop.removeChild(e.canvas),this._windowCanvases.delete(e.id)}createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}}class I{get overlayElement(){return this._overlayElement}set visible(e){this._overlayElement.style.visibility=e?"visible":"hidden"}constructor(e){this._cursor=e,this._overlayElement=this._createDisplayOverlayElement(),this._overlayElement.appendChild(this._cursor.canvas)}update(){}_createDisplayOverlayElement(){const e=document.createElement("div");return e.id="webx-overlay",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.zIndex="999",e.style.visibility="hidden",e.style.overflow="clip",e}}class x{constructor(e,t=0){this.type=e,this.commandId=t}static get convertToImageDataInWorker(){return x._convertToImageDataInWorker}static set convertToImageDataInWorker(e){x._convertToImageDataInWorker=e}}x._convertToImageDataInWorker=!1,exports.WebXMessageType=void 0,(M=exports.WebXMessageType||(exports.WebXMessageType={}))[M.NOP=0]="NOP",M[M.CONNECTION=1]="CONNECTION",M[M.WINDOWS=2]="WINDOWS",M[M.IMAGE=3]="IMAGE",M[M.SCREEN=4]="SCREEN",M[M.SUBIMAGES=5]="SUBIMAGES",M[M.MOUSE=6]="MOUSE",M[M.CURSOR_IMAGE=7]="CURSOR_IMAGE",M[M.PING=8]="PING",M[M.DISCONNECT=9]="DISCONNECT",M[M.QUALITY=10]="QUALITY",M[M.CLIPBOARD=11]="CLIPBOARD",M[M.SHAPE=12]="SHAPE";class X extends x{constructor(e,t,s,i){super(exports.WebXMessageType.SCREEN,i),this.screenSize=e,this.maxQualityIndex=t,this.engineVersion=s}}class S extends x{constructor(e,t){super(exports.WebXMessageType.WINDOWS,t),this.windows=e}}class G extends x{constructor(e,t,s,i,n,a){super(exports.WebXMessageType.IMAGE,n),this.windowId=e,this.depth=t,this.colorMap=s,this.alphaMap=i,this.size=a}}class R extends x{constructor(e,t,s,i){super(exports.WebXMessageType.SUBIMAGES,s),this.windowId=e,this.subImages=t,this.size=i}}class v extends x{constructor(e,t,s,i){super(exports.WebXMessageType.MOUSE,i),this.x=e,this.y=t,this.cursorId=s}}class T extends x{constructor(e,t,s,i,n,a,r){super(exports.WebXMessageType.CURSOR_IMAGE,r),this.x=e,this.y=t,this.xHot=s,this.yHot=i,this.cursorId=n,this.texture=a}}class U extends x{constructor(){super(exports.WebXMessageType.PING)}}class C extends x{constructor(e,t,s,i,n){super(exports.WebXMessageType.QUALITY),this.index=e,this.imageFPS=t,this.rgbQuality=s,this.alphaQuality=i,this.maxMbps=n}}class V extends x{constructor(e){super(exports.WebXMessageType.CLIPBOARD),this.clipboardContent=e}}class E extends x{constructor(e){super(exports.WebXMessageType.CONNECTION),this.isStarting=e}}class L extends x{constructor(){super(exports.WebXMessageType.NOP)}}class k extends x{constructor(e,t,s,i){super(exports.WebXMessageType.SHAPE,s),this.windowId=e,this.stencilMap=t,this.size=i}}class N{get renderer(){return this._renderer}get screenWidth(){return this._screenWidth}get screenHeight(){return this._screenHeight}get containerElement(){return this._containerElement}get scale(){return this._scale}get scene(){return this._scene}get camera(){return this._camera}get sceneDirty(){return this._sceneDirty}set sceneDirty(e){this._sceneDirty=e}constructor(t,s,n,a,r){this._windows=[],this._scale=1,this._disposed=!1,this._sceneDirty=!1,this._disableStencil=!1,this._containerElement=t,this._screenWidth=s,this._screenHeight=n,this._windowImageFactory=a,this._cursor=new _(r),this._displayOverlay=new I(this._cursor),this._scene=new i.Scene,this._screen=new i.Object3D;const o=new i.Mesh(new i.PlaneGeometry(1,1,2,2),new i.MeshBasicMaterial({map:new i.DataTexture(new Uint8ClampedArray(4),1,1),side:i.BackSide,transparent:!0}));o.position.set(0,0,999),this._screen.add(o),this._camera=new i.OrthographicCamera(0,s,0,n,.1,1e4),this._camera.position.z=1e3,this._camera.lookAt(new e.Vector3(0,0,0));const h=this._detectWebGL2(),l=new URL(window.location.href).searchParams,c="true"===l.get("webx-canvas");this._disableStencil="false"===l.get("webx-stencil"),!h.available||h.isSoftware||c?(console.log(`WebGL2 Info: available = ${h.available}, isSoftware = ${h.isSoftware}, vendor = ${h.vendor}, renderer = ${h.renderer}`),c?console.log("Canvas Renderer enabled through request param"):console.log("Falling back to Canvas Renderer"),this._renderer=new W,x.convertToImageDataInWorker=!0):this._renderer=new i.WebGLRenderer,this._renderer.setSize(s,n,!1);const d=window.getComputedStyle(this._containerElement).backgroundColor;this._renderer.setClearColor(d),this._render(),this._bindListeners(),this.resize(),this._renderer.render(this._scene,this._camera)}showScreen(){this._scene.add(this._screen),this._displayOverlay.visible=!0,this._sceneDirty=!0}hideScreen(){this._scene.remove(this._screen),this._displayOverlay.visible=!1,this._sceneDirty=!0}dispose(){this.hideScreen();for(const e of this._windows)this._screen.remove(e.mesh),e.dispose();this._clearElements(),this._renderer.dispose(),this._disposed=!0}animate(){this._disposed||(requestAnimationFrame(()=>{this.animate()}),this._displayOverlay.update(),this._sceneDirty&&(this._sceneDirty=!1,this.render()))}render(){this._renderer.render(this._scene,this._camera)}async createScreenshot(e,t){if(this._renderer instanceof W)return this._renderer.createScreenshot(e,t);{const s=this._renderer;return new Promise((i,n)=>{try{this.render(),s.domElement.toBlob(e=>{i(e)},e,t)}catch(e){n(e)}})}}addWindow(e){null==this._windows.find(t=>t.id===e.id)&&(this._windows.push(e),this._screen.add(e.mesh),this._sceneDirty=!0)}removeWindow(e){null!=this._windows.find(t=>t.id===e.id)&&(this._windows=this._windows.filter(t=>t.id!==e.id),e.dispose(),this._screen.remove(e.mesh),this._sceneDirty=!0)}updateWindows(e){return new Promise(t=>{this._windows.filter(t=>null==e.find(e=>e.id===t.id)).forEach(e=>this.removeWindow(e));let s=!1;e.forEach((i,n)=>{let a=this.getWindow(i.id);null==a?(s=!0,a=new m({id:i.id,x:i.x,y:i.y,z:n,width:i.width,height:i.height,shaped:i.shaped&&!this._disableStencil},this._windowImageFactory),this.addWindow(a),a.loadWindowImageAndShape().then(()=>{this.checkAllLoaded(e.map(e=>e.id))&&t()})):(a.shaped=i.shaped&&!this._disableStencil,a.setRectangle(i.x,i.y,n,i.width,i.height))}),s||t()})}checkAllLoaded(e){return e.map(e=>this.getWindow(e)).filter(e=>null!=e).map(e=>e.loaded).reduce((e,t)=>e&&t,!0)}updateImage(e,t,s,i){const n=this.getWindow(e);null==n||null==s&&null==i||(n.updateTexture(t,y(s),y(i),!0),this._sceneDirty=!0)}updateSubImages(e,t){const s=this.getWindow(e);if(null!=s&&s.colorMapValid){const e=s.colorMap,n=s.alphaMap;for(let a=0;a<t.length;a++){const r=t[a];this._renderer instanceof W?this._renderer.updateWindowRegion(s.mesh.id,y(r.colorMap),e,y(r.alphaMap),n,r.width,r.height,new i.Vector2(r.x,r.y)):(e&&r.colorMap&&this._renderer.copyTextureToTexture(y(r.colorMap),e,null,new i.Vector2(r.x,r.y)),n&&r.alphaMap&&this._renderer.copyTextureToTexture(y(r.alphaMap),n,null,new i.Vector2(r.x,r.y)))}s.updateTexture(s.depth,e,n,!1),this._sceneDirty=!0}}updateShape(e,t){if(this._disableStencil)return;const s=this.getWindow(e);null!=s&&null!=t&&(s.updateStencilTexture(y(t)),this._sceneDirty=!0)}setMouseCursor(e){this._cursor.setCursorId(e)}setMousePosition(e,t){this._cursor.setPosition(e,t)}getWindow(e){return this._windows.find(t=>t.id===e)}setScale(e){this._scale=e,this._sceneDirty=!0}autoScale(){const e=this._containerElement,{clientWidth:t,clientHeight:s}=e,{screenWidth:i,screenHeight:n}=this;this._scale=Math.min(t/i,s/n),this._sceneDirty=!0}resize(e){const t=this._boundsElement;e?this.setScale(e):this.autoScale(),t.style.transform=`scale(${this._scale},${this._scale})`}_clearElements(){for(;this._containerElement.firstChild;)this._containerElement.removeChild(this._containerElement.firstChild)}_createDisplayElement(){const e=document.createElement("div");return e.style.width=`${this._screenWidth}px`,e.style.height=`${this._screenHeight}px`,e.appendChild(this._displayOverlay.overlayElement),e.appendChild(this._renderer.domElement),e}_createDisplayBoundingElement(){const e=document.createElement("div");return e.appendChild(this._displayElement),e}_render(){this._clearElements(),this._displayElement=this._createDisplayElement(),this._boundsElement=this._createDisplayBoundingElement(),this._containerElement.appendChild(this._boundsElement)}_bindListeners(){this.resize=this.resize.bind(this)}_detectWebGL2(){const e=document.createElement("canvas").getContext("webgl2");if(!e)return{available:!1};const t=e.getParameter(e.RENDERER),s=e.getParameter(e.VENDOR);let i=null,n=null;const a=e.getExtension("WEBGL_debug_renderer_info");a&&(i=e.getParameter(a.UNMASKED_RENDERER_WEBGL),n=e.getParameter(a.UNMASKED_VENDOR_WEBGL));const r=(i||t||"").toLowerCase();return{available:!0,vendor:n||s,renderer:i||t,isSoftware:/swiftshader|llvmpipe|basic render|software/i.test(r)}}}var Y,F=F||{};F.Keyboard=function(e){var t=this,s="_GUAC_KEYBOARD_HANDLED_BY_"+F.Keyboard._nextID++;this.onkeydown=null,this.onkeyup=null;var i={keyupUnreliable:!1,altIsTypableOnly:!1,capsLockKeyupUnreliable:!1};navigator&&navigator.platform&&(navigator.platform.match(/ipad|iphone|ipod/i)?i.keyupUnreliable=!0:navigator.platform.match(/^mac/i)&&(i.altIsTypableOnly=!0,i.capsLockKeyupUnreliable=!0));var n=function(e){var t=this;this.keyCode=e?e.which||e.keyCode:0,this.keyIdentifier=e&&e.keyIdentifier,this.key=e&&e.key,this.location=e?S(e):0,this.modifiers=e?F.Keyboard.ModifierState.fromKeyboardEvent(e):new F.Keyboard.ModifierState,this.timestamp=(new Date).getTime(),this.defaultPrevented=!1,this.keysym=null,this.reliable=!1,this.getAge=function(){return(new Date).getTime()-t.timestamp}},a=function(e){n.call(this,e),this.keysym=f(this.key,this.location)||Z(this.keyCode,this.location),this.keyupReliable=!i.keyupUnreliable,this.keysym&&!b(this.keysym)&&(this.reliable=!0),!this.keysym&&w(this.keyCode,this.keyIdentifier)&&(this.keysym=f(this.keyIdentifier,this.location,this.modifiers.shift)),(this.modifiers.meta&&65511!==this.keysym&&65512!==this.keysym||65509===this.keysym&&i.capsLockKeyupUnreliable)&&(this.keyupReliable=!1);var t=!this.modifiers.ctrl&&!i.altIsTypableOnly;!i.altIsTypableOnly||65513!==this.keysym&&65514!==this.keysym||(this.keysym=65027),(!this.modifiers.alt&&this.modifiers.ctrl||t&&this.modifiers.alt||this.modifiers.meta||this.modifiers.hyper)&&(this.reliable=!0),y[this.keyCode]=this.keysym};a.prototype=new n;var r=function(e){n.call(this,e),this.keysym=M(this.keyCode),this.reliable=!0};r.prototype=new n;var o=function(e){n.call(this,e),this.keysym=Z(this.keyCode,this.location)||f(this.key,this.location),t.pressed[this.keysym]||(this.keysym=y[this.keyCode]||this.keysym),this.reliable=!0};o.prototype=new n;var h=[],l={8:[65288],9:[65289],12:[65291,65291,65291,65461],13:[65293],16:[65505,65505,65506],17:[65507,65507,65508],18:[65513,65513,65514],19:[65299],20:[65509],27:[65307],32:[32],33:[65365,65365,65365,65465],34:[65366,65366,65366,65459],35:[65367,65367,65367,65457],36:[65360,65360,65360,65463],37:[65361,65361,65361,65460],38:[65362,65362,65362,65464],39:[65363,65363,65363,65462],40:[65364,65364,65364,65458],45:[65379,65379,65379,65456],46:[65535,65535,65535,65454],91:[65511],92:[65512],93:[65383],96:[65456],97:[65457],98:[65458],99:[65459],100:[65460],101:[65461],102:[65462],103:[65463],104:[65464],105:[65465],106:[65450],107:[65451],109:[65453],110:[65454],111:[65455],112:[65470],113:[65471],114:[65472],115:[65473],116:[65474],117:[65475],118:[65476],119:[65477],120:[65478],121:[65479],122:[65480],123:[65481],144:[65407],145:[65300],225:[65027]},c={Again:[65382],AllCandidates:[65341],Alphanumeric:[65328],Alt:[65513,65513,65514],Attn:[64782],AltGraph:[65027],ArrowDown:[65364],ArrowLeft:[65361],ArrowRight:[65363],ArrowUp:[65362],Backspace:[65288],CapsLock:[65509],Cancel:[65385],Clear:[65291],Convert:[65315],Copy:[64789],Crsel:[64796],CrSel:[64796],CodeInput:[65335],Compose:[65312],Control:[65507,65507,65508],ContextMenu:[65383],Delete:[65535],Down:[65364],End:[65367],Enter:[65293],EraseEof:[64774],Escape:[65307],Execute:[65378],Exsel:[64797],ExSel:[64797],F1:[65470],F2:[65471],F3:[65472],F4:[65473],F5:[65474],F6:[65475],F7:[65476],F8:[65477],F9:[65478],F10:[65479],F11:[65480],F12:[65481],F13:[65482],F14:[65483],F15:[65484],F16:[65485],F17:[65486],F18:[65487],F19:[65488],F20:[65489],F21:[65490],F22:[65491],F23:[65492],F24:[65493],Find:[65384],GroupFirst:[65036],GroupLast:[65038],GroupNext:[65032],GroupPrevious:[65034],FullWidth:null,HalfWidth:null,HangulMode:[65329],Hankaku:[65321],HanjaMode:[65332],Help:[65386],Hiragana:[65317],HiraganaKatakana:[65319],Home:[65360],Hyper:[65517,65517,65518],Insert:[65379],JapaneseHiragana:[65317],JapaneseKatakana:[65318],JapaneseRomaji:[65316],JunjaMode:[65336],KanaMode:[65325],KanjiMode:[65313],Katakana:[65318],Left:[65361],Meta:[65511,65511,65512],ModeChange:[65406],NonConvert:[65314],NumLock:[65407],PageDown:[65366],PageUp:[65365],Pause:[65299],Play:[64790],PreviousCandidate:[65342],PrintScreen:[65377],Redo:[65382],Right:[65363],Romaji:[65316],RomanCharacters:null,Scroll:[65300],Select:[65376],Separator:[65452],Shift:[65505,65505,65506],SingleCandidate:[65340],Super:[65515,65515,65516],Tab:[65289],UIKeyInputDownArrow:[65364],UIKeyInputEscape:[65307],UIKeyInputLeftArrow:[65361],UIKeyInputRightArrow:[65363],UIKeyInputUpArrow:[65362],Up:[65362],Undo:[65381],Win:[65511,65511,65512],Zenkaku:[65320],ZenkakuHankaku:[65322]},d={65027:!0,65505:!0,65506:!0,65507:!0,65508:!0,65509:!0,65511:!0,65512:!0,65513:!0,65514:!0,65515:!0,65516:!0};this.modifiers=new F.Keyboard.ModifierState,this.pressed={};var u={},p={},y={},m=null,_=null,g=function(e,t){return e?e[t]||e[0]:null},b=function(e){return e>=0&&e<=255||16777216==(4294901760&e)};function f(e,t,s){if(!e)return null;var i,n=e.indexOf("U+");if(n>=0){var a=e.substring(n+2);i=String.fromCharCode(parseInt(a,16))}else{if(1!==e.length||3===t)return g(c[e],t);i=e}return!0===s?i=i.toUpperCase():!1===s&&(i=i.toLowerCase()),M(i.charCodeAt(0))}function M(e){return function(e){return e<=31||e>=127&&e<=159}(e)?65280|e:e>=0&&e<=255?e:e>=256&&e<=1114111?16777216|e:null}function Z(e,t){return g(l[e],t)}var w=function(e,t){if(!t)return!1;var s=t.indexOf("U+");return-1===s||(e!==parseInt(t.substring(s+2),16)||(e>=65&&e<=90||e>=48&&e<=57))};this.press=function(e){if(null!==e){if(!t.pressed[e]&&(t.pressed[e]=!0,t.onkeydown)){var s=t.onkeydown(e);return p[e]=s,window.clearTimeout(m),window.clearInterval(_),d[e]||(m=window.setTimeout(function(){_=window.setInterval(function(){t.onkeyup(e),t.onkeydown(e)},50)},500)),s}return p[e]||!1}},this.release=function(e){t.pressed[e]&&(delete t.pressed[e],delete u[e],window.clearTimeout(m),window.clearInterval(_),null!==e&&t.onkeyup&&t.onkeyup(e))},this.type=function(e){for(var s=0;s<e.length;s++){var i=M(e.codePointAt?e.codePointAt(s):e.charCodeAt(s));t.press(i),t.release(i)}},this.reset=function(){for(var e in t.pressed)t.release(parseInt(e));h=[]};var W=function(e,s,i){var n,a=i.modifiers[e],r=t.modifiers[e];if(-1===s.indexOf(i.keysym))if(r&&!1===a)for(n=0;n<s.length;n++)t.release(s[n]);else if(!r&&a){for(n=0;n<s.length;n++)if(t.pressed[s[n]])return;var o=s[0];i.keysym&&(u[o]=!0),t.press(o)}},I=function(e){W("alt",[65513,65514,65027],e),W("shift",[65505,65506],e),W("ctrl",[65507,65508],e),W("meta",[65511,65512],e),W("hyper",[65515,65516],e),t.modifiers=e.modifiers};function x(){var e,s=X();if(!s)return!1;do{e=s,s=X()}while(null!==s);return function(){for(var e in t.pressed)if(!u[e])return!1;return!0}()&&t.reset(),e.defaultPrevented}var X=function(){var e=h[0];if(!e)return null;if(!(e instanceof a))return e instanceof o&&!i.keyupUnreliable?(s=e.keysym)?(t.release(s),delete y[e.keyCode],e.defaultPrevented=!0,I(e),h.shift()):(t.reset(),e):h.shift();var s=null,n=[];if(65511===e.keysym||65512===e.keysym){if(1===h.length)return null;if(h[1].keysym!==e.keysym){if(!h[1].modifiers.meta)return h.shift()}else if(h[1]instanceof a)return h.shift()}if(e.reliable?(s=e.keysym,n=h.splice(0,1)):h[1]instanceof r?(s=h[1].keysym,n=h.splice(0,2)):h[1]&&(s=e.keysym,n=h.splice(0,1)),n.length>0){if(I(e),s){!function(e){t.modifiers.ctrl&&t.modifiers.alt&&(e>=65&&e<=90||e>=97&&e<=122||(e<=255||16777216==(4278190080&e))&&(t.release(65507),t.release(65508),t.release(65513),t.release(65514)))}(s);var l=!t.press(s);y[e.keyCode]=s,e.keyupReliable||t.release(s);for(var c=0;c<n.length;c++)n[c].defaultPrevented=l}return e}return null},S=function(e){return"location"in e?e.location:"keyLocation"in e?e.keyLocation:0},G=function(e){return!e[s]&&(e[s]=!0,!0)},R=function(e){if(t.onkeydown&&G(e)){var s=new a(e);e.isComposing||229===s.keyCode||(h.push(s),x()&&e.preventDefault())}},v=function(e){(t.onkeydown||t.onkeyup)&&G(e)&&(h.push(new r(e)),x()&&e.preventDefault())},T=function(e){t.onkeyup&&G(e)&&(e.preventDefault(),h.push(new o(e)),x())},U=function(e){(t.onkeydown||t.onkeyup)&&G(e)&&e.data&&!e.isComposing&&t.type(e.data)},C=function(t){e.removeEventListener("input",U,!1)},V=function(e){(t.onkeydown||t.onkeyup)&&G(e)&&e.data&&t.type(e.data)};this.listenTo=function(e){e.addEventListener("keydown",R,{passive:!1}),e.addEventListener("keypress",v,{passive:!1}),e.addEventListener("keyup",T,{passive:!1}),e.addEventListener("input",U,!1),e.addEventListener("compositionend",V,!1),e.addEventListener("compositionstart",C,!1)},e&&t.listenTo(e),this.dispose=function(){e&&(e.removeEventListener("keydown",R,!0),e.removeEventListener("keypress",v,!0),e.removeEventListener("keyup",T,!0),e.removeEventListener("input",U,!1),e.removeEventListener("compositionend",V,!1),e.removeEventListener("compositionstart",C,!1))}},F.Keyboard._nextID=0,F.Keyboard.ModifierState=function(){this.shift=!1,this.ctrl=!1,this.alt=!1,this.meta=!1,this.hyper=!1},F.Keyboard.ModifierState.fromKeyboardEvent=function(e){var t=new F.Keyboard.ModifierState;return t.shift=e.shiftKey,t.ctrl=e.ctrlKey,t.alt=e.altKey,t.meta=e.metaKey,e.getModifierState&&(t.hyper=e.getModifierState("OS")||e.getModifierState("Super")||e.getModifierState("Hyper")||e.getModifierState("Win")),t};class H{set onKeyDown(e){this._keyboard.onkeydown=e}set onKeyUp(e){this._keyboard.onkeyup=e}constructor(e){this._keyboard=new F.Keyboard(e)}dispose(){this._keyboard.onkeydown=null,this._keyboard.onkeyup=null,this._keyboard.dispose()}reset(){this._keyboard.reset()}}class z{get x(){return this._x}set x(e){this._x=e}get y(){return this._y}set y(e){this._y=e}get left(){return this._left}set left(e){this._left=e}get middle(){return this._middle}set middle(e){this._middle=e}get right(){return this._right}set right(e){this._right=e}get up(){return this._up}set up(e){this._up=e}get down(){return this._down}set down(e){this._down=e}get shift(){return this._shift}set shift(e){this._shift=e}get ctrl(){return this._ctrl}set ctrl(e){this._ctrl=e}get alt(){return this._alt}set alt(e){this._alt=e}constructor(e){const{x:t,y:s,left:i,middle:n,right:a,up:r,down:o}=e;this._x=t,this._y=s,this._left=i,this._middle=n,this._right=a,this._up=r,this._down=o}releaseButtons(){this._left=!1,this._middle=!1,this._right=!1}getButtonMask(){let e=0;return e|=this._left?256:0,e|=this._middle?512:0,e|=this._right?1024:0,e|=this._up?2048:0,e|=this._down?4096:0,e|=this._shift?1:0,e|=this._ctrl?4:0,e|=this._alt?8:0,e}clone(){return new z({x:this._x,y:this._y,left:this._left,middle:this._middle,right:this._right,up:this._up,down:this._down})}}class D{constructor(e){this._element=e,this._contextMenuHandler=this._handleContextMenu.bind(this),this._mouseMoveHandler=this._handleMouseMove.bind(this),this._mouseDownHandler=this._handleMouseDown.bind(this),this._mouseUpHandler=this._handleMouseUp.bind(this),this._mouseOutHandler=this._handleMouseOut.bind(this),this._mouseWheelHandler=this._handleMouseWheel.bind(this),this._bindListeners(),this._createDefaultState()}dispose(){this._unbindListeners()}_cancelEvent(e){e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1}_bindListeners(){const e=this._element;e.addEventListener("contextmenu",this._contextMenuHandler,!1),e.addEventListener("mousemove",this._mouseMoveHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mouseup",this._mouseUpHandler),e.addEventListener("mouseout",this._mouseOutHandler),["DOMMouseScroll","mousewheel","wheel"].forEach(t=>{e.addEventListener(t,this._mouseWheelHandler,{passive:!1})}),this.reset=this.reset.bind(this)}_unbindListeners(){const e=this._element;e.removeEventListener("contextmenu",this._contextMenuHandler,!1),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mouseout",this._mouseOutHandler),["DOMMouseScroll","mousewheel","wheel"].forEach(t=>{e.removeEventListener(t,this._mouseWheelHandler)}),this.reset=this.reset.bind(this)}_createDefaultState(){this._currentState=new z({x:0,y:0,left:!1,middle:!1,right:!1,up:!1,down:!1})}_handleMouseUp(e){switch(e.button){case 0:this._currentState.left=!1;break;case 1:this._currentState.middle=!1;break;case 2:this._currentState.right=!1}this._notifyMouseUp()}_handleMouseDown(e){switch(this._cancelEvent(e),e.button){case 0:this._currentState.left=!0;break;case 1:this._currentState.middle=!0;break;case 2:this._currentState.right=!0}this._notifyMouseDown()}_handleMouseWheel(e){e.deltaY<0&&(this._currentState.up=!0,this._notifyMouseDown(),this._currentState.up=!1,this._notifyMouseUp()),e.deltaY>0&&(this._currentState.down=!0,this._notifyMouseDown(),this._currentState.down=!1,this._notifyMouseUp()),this._cancelEvent(e)}_handleMouseOut(){this._currentState.releaseButtons(),this._notifyMouseOut()}_handleMouseMove(e){this._cancelEvent(e);const t=this._element.firstElementChild.getBoundingClientRect();this._currentState.x=e.clientX-t.left,this._currentState.y=e.clientY-t.top,this._notifyMouseMove()}reset(){this._currentState.releaseButtons()}_handleContextMenu(e){this._cancelEvent(e)}_notifyMouseMove(){this.onMouseMove(this._currentState.clone())}_notifyMouseUp(){this.onMouseUp(this._currentState.clone())}_notifyMouseDown(){this.onMouseDown(this._currentState.clone())}_notifyMouseOut(){this.onMouseOut(this._currentState.clone())}onMouseMove(e){}onMouseDown(e){}onMouseUp(e){}onMouseOut(e){}}class P{constructor(e){this.synchronous=!1,this.id=P._INSTRUCTION_COUNTER++,this.type=e}}P._INSTRUCTION_COUNTER=1;class K{constructor(e,t){this._timeoutId=0,this.instructionId=e.id,this.data=null,t&&(this._timeoutMs=t,this._timeoutId=setTimeout(()=>{this.reject("Request failed due to timeout")},this._timeoutMs))}then(e){return this._onResponseReceived=e,this}catch(e){return this._onError=e,this}resolve(e){this._timeoutId>0&&clearTimeout(this._timeoutId),null!=this._onResponseReceived&&this._onResponseReceived(e)}reject(e){this._onError&&this._onError(new Error(e))}}exports.WebXInstructionType=void 0,(Y=exports.WebXInstructionType||(exports.WebXInstructionType={}))[Y.CONNECT=1]="CONNECT",Y[Y.WINDOWS=2]="WINDOWS",Y[Y.IMAGE=3]="IMAGE",Y[Y.SCREEN=4]="SCREEN",Y[Y.MOUSE=5]="MOUSE",Y[Y.KEYBOARD=6]="KEYBOARD",Y[Y.CURSOR_IMAGE=7]="CURSOR_IMAGE",Y[Y.QUALITY=8]="QUALITY",Y[Y.PONG=9]="PONG",Y[Y.DATA_ACK=10]="DATA_ACK",Y[Y.CLIPBOARD=11]="CLIPBOARD",Y[Y.SHAPE=12]="SHAPE",function(e){e.fromString=function(t){switch(t){case"CONNECT":return e.CONNECT;case"WINDOWS":return e.WINDOWS;case"IMAGE":return e.IMAGE;case"SCREEN":return e.SCREEN;case"MOUSE":return e.MOUSE;case"KEYBOARD":return e.KEYBOARD;case"CURSOR_IMAGE":return e.CURSOR_IMAGE;case"QUALITY":return e.QUALITY;case"PONG":return e.PONG;case"DATA_ACK":return e.DATA_ACK;case"CLIPBOARD":return e.CLIPBOARD;case"SHAPE":return e.SHAPE}}}(exports.WebXInstructionType||(exports.WebXInstructionType={}));class O extends P{constructor(){super(exports.WebXInstructionType.SCREEN)}}class A extends P{constructor(){super(exports.WebXInstructionType.WINDOWS)}}class J extends P{constructor(e){super(exports.WebXInstructionType.IMAGE),this.windowId=e}}class B extends P{constructor(e,t,s){super(exports.WebXInstructionType.MOUSE),this.x=e,this.y=t,this.buttonMask=s}}class Q extends P{constructor(e,t){super(exports.WebXInstructionType.KEYBOARD),this.key=e,this.pressed=t}}class j extends P{constructor(e){super(exports.WebXInstructionType.CURSOR_IMAGE),this.cursorId=e}}class $ extends P{constructor(e){super(exports.WebXInstructionType.QUALITY),this.qualityIndex=e}}class q extends P{constructor(e){super(exports.WebXInstructionType.PONG),this.timestampMs=e}}class ee extends P{constructor(e,t){super(exports.WebXInstructionType.DATA_ACK),this.timestampMs=e,this.dataLength=t}}class te extends P{constructor(e){super(exports.WebXInstructionType.CLIPBOARD),this.clipboardContent=e}}class se extends P{constructor(e){super(exports.WebXInstructionType.SHAPE),this.windowId=e}}class ie{}class ne{}class ae{}class re{static randomColour(){const e=Math.floor(Math.random()*re._COLOURS.length);return re._COLOURS[e]}static indexedColour(e){return e%=re._COLOURS.length,re._COLOURS[e]}}re._COLOURS=["#FF6633","#FFB399","#FF33FF","#FFFF99","#00B3E6","#E6B333","#3366E6","#999966","#99FF99","#B34D4D","#80B300","#809900","#E6B3B3","#6680B3","#66991A","#FF99E6","#CCFF1A","#FF1A66","#E6331A","#33FFCC","#66994D","#B366CC","#4D8000","#B33300","#CC80CC","#66664D","#991AFF","#E666FF","#4DB3FF","#1AB399","#E666B3","#33991A","#CC9999","#B3B31A","#00E680","#4D8066","#809980","#E6FF80","#1AFF33","#999933","#FF3380","#CCCC00","#66E64D","#4D80CC","#9900B3","#E64D66","#4DB380","#FF4D4D","#99E6E6","#6666FF"];class oe{constructor(e=0,t=0,s=0){this.major=e,this.minor=t,this.patch=s,this.version=`${e}.${t}.${s}`,this.versionNumber=parseFloat(`${e}.${t}`)}}class he extends ne{constructor(s){super(),this._display=s,this._debugLayer=new e.Object3D,this._currentZ=0,this._disposed=!1,this._tweenGroup=new t.Group,this._debugLayer.position.set(0,0,999),this._scene=this._display.scene,this._scene.add(this._debugLayer),this._animate()}_createMesh(s,i,n,a,r){const o=new e.MeshBasicMaterial({color:r,opacity:.8,transparent:!0});o.side=e.BackSide;const h=new e.Mesh(he._PLANE_GEOMETRY,o);h.position.set(s+n/2,i+a/2,this._currentZ),h.scale.set(n,a,1),this._currentZ+=1e-4,this._debugLayer.add(h),new t.Tween(o,this._tweenGroup).to({opacity:0},500).easing(t.Easing.Quadratic.Out).onComplete(()=>this._debugLayer.remove(h)).onUpdate(()=>this._display.sceneDirty=!0).start()}handle(e){if(e.type===exports.WebXMessageType.IMAGE){const t=e,s=this._display.getWindow(t.windowId),{width:i,height:n}=t.colorMap.image;this._createMesh(s.x,s.y,i,n,re.indexedColour(s.colorIndex))}else if(e.type===exports.WebXMessageType.SUBIMAGES){const t=e,s=this._display.getWindow(t.windowId);t.subImages.forEach(e=>{this._createMesh(s.x+e.x,s.y+e.y,e.width,e.height,re.indexedColour(s.colorIndex))})}}destroy(){this._disposed=!0,this._debugLayer.children.forEach(e=>{e.material.dispose()}),this._debugLayer.clear(),this._debugLayer.removeFromParent()}_animate(){this._disposed||requestAnimationFrame(e=>{this._tweenGroup.update(e),this._animate()})}}he._PLANE_GEOMETRY=new e.PlaneGeometry(1,1,2,2);class le{constructor(e,t){this._buffer=new ArrayBuffer(t+32),this._offset=20,e.synchronous?this.putUInt32(2147483648|e.type):this.putUInt32(e.type),this.putUInt32(e.id),this.putUInt32(0)}_getNextOffset(e){const t=this._offset%e>0?e-this._offset%e:0,s=this._offset+t;return this._offset+=e+t,s}putInt32(e){const t=this._getNextOffset(4);return new Int32Array(this._buffer,t,1)[0]=e,this}putUInt8(e){const t=this._getNextOffset(1);return new Uint8Array(this._buffer,t,1)[0]=e,this}putUInt32(e){const t=this._getNextOffset(4);return new Uint32Array(this._buffer,t,1)[0]=e,this}putUInt8Array(e,t){const s=this._getNextOffset(8);return new Uint8Array(this._buffer,s,t).set(e),this}putString(e){for(let t=0;t<e.length;t++)this.putUInt8(e.charCodeAt(t));return this}putBoolean(e){return this.putUInt32(!0===e?255:0),this}buffer(){return this._buffer}}class ce{get readOffset(){return this._readOffset}get buffer(){return this._buffer}constructor(e){this._buffer=e,this._readOffset=24,this._encoder=new TextDecoder("utf-8"),this._readOffset=24,this.timestampMs=this.getUint8Array(8),this.messageTypeId=this.getUint32(),this.messageId=this.getUint32(),this.bufferLength=this.getUint32(),this._readOffset=ce.MESSAGE_HEADER_LENGTH}getInt32(){const e=this._getNextReadOffset(4);return new Int32Array(this._buffer,e,1)[0]}getUint32(){const e=this._getNextReadOffset(4);return new Uint32Array(this._buffer,e,1)[0]}getFloat(){const e=this._getNextReadOffset(4);return new Float32Array(this._buffer,e,1)[0]}getUint8Array(e){const t=new Uint8Array(this._buffer,this._readOffset,e);return this._readOffset+=e,t}getString(e){const t=new Uint8Array(this._buffer,this._readOffset,e);return this._readOffset+=e,this._encoder.decode(t)}_getNextReadOffset(e){const t=this._readOffset%e>0?e-this._readOffset%e:0,s=this._readOffset+t;return this._readOffset+=e+t,s}}ce.MESSAGE_HEADER_LENGTH=48;class de{encode(e){return e.type===exports.WebXInstructionType.MOUSE?this._createMouseInstruction(e):e.type===exports.WebXInstructionType.KEYBOARD?this._createKeyboardInstruction(e):e.type===exports.WebXInstructionType.CURSOR_IMAGE?this._createCursorImageInstruction(e):e.type===exports.WebXInstructionType.IMAGE?this._createImageInstruction(e):e.type===exports.WebXInstructionType.CONNECT?this._createConnectInstruction(e):e.type===exports.WebXInstructionType.SCREEN?this._createScreenInstruction(e):e.type===exports.WebXInstructionType.WINDOWS?this._createWindowsInstruction(e):e.type===exports.WebXInstructionType.QUALITY?this._createQualityInstruction(e):e.type===exports.WebXInstructionType.PONG?this._createPongInstruction(e):e.type===exports.WebXInstructionType.DATA_ACK?this._createDataAckInstruction(e):e.type===exports.WebXInstructionType.CLIPBOARD?this._createClipboardInstruction(e):e.type===exports.WebXInstructionType.SHAPE?this._createShapeInstruction(e):null}_createMouseInstruction(e){return new le(e,12).putInt32(e.x).putInt32(e.y).putUInt32(e.buttonMask).buffer()}_createCursorImageInstruction(e){return new le(e,4).putInt32(e.cursorId).buffer()}_createImageInstruction(e){return new le(e,4).putUInt32(e.windowId).buffer()}_createKeyboardInstruction(e){return new le(e,8).putUInt32(e.key).putBoolean(e.pressed).buffer()}_createScreenInstruction(e){return new le(e,0).buffer()}_createWindowsInstruction(e){return new le(e,0).buffer()}_createConnectInstruction(e){return new le(e,0).buffer()}_createQualityInstruction(e){return new le(e,4).putUInt32(e.qualityIndex).buffer()}_createPongInstruction(e){return new le(e,8).putUInt8Array(e.timestampMs,8).buffer()}_createDataAckInstruction(e){return new le(e,12).putUInt8Array(e.timestampMs,8).putUInt32(e.dataLength).buffer()}_createClipboardInstruction(e){const t=4+e.clipboardContent.length;return new le(e,t).putUInt32(e.clipboardContent.length).putString(e.clipboardContent).buffer()}_createShapeInstruction(e){return new le(e,4).putUInt32(e.windowId).buffer()}}class ue{constructor(){this._textureFactory=new p}decode(e){const{messageTypeId:t}=e;return t===exports.WebXMessageType.NOP?this._createNopMessage():t===exports.WebXMessageType.CONNECTION?this._createConnectionMessage(e):t===exports.WebXMessageType.SCREEN?this._createScreenMessage(e):t===exports.WebXMessageType.WINDOWS?this._createWindowsMessage(e):t===exports.WebXMessageType.IMAGE?this._createImageMessage(e):t===exports.WebXMessageType.SUBIMAGES?this._createSubImagesMessage(e):t===exports.WebXMessageType.MOUSE?this._createMouseMessage(e):t===exports.WebXMessageType.CURSOR_IMAGE?this._createCursorImageMessage(e):t===exports.WebXMessageType.PING?this._createPingMessage():t===exports.WebXMessageType.QUALITY?this._createQualityMessage(e):t===exports.WebXMessageType.CLIPBOARD?this._createClipboardMessage(e):t===exports.WebXMessageType.SHAPE?this._createShapeMessage(e):void console.error(`Failed to decode message with typeId ${t}`)}_determineMimeType(e){return"jpg"===e.substr(0,3)?"image/jpeg":"png"===e.substr(0,3)?"image/png":"image/bmp"}async _createNopMessage(){return new L}async _createConnectionMessage(e){const t=e.getUint32();return new E(t>0)}_createImageMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=e.getUint32(),a=e.getString(4),r=this._determineMimeType(a),o=e.getUint32(),h=e.getUint32(),l=e.getUint8Array(o),u=e.getUint8Array(h),p=this._textureFactory.createTextureFromArray(l,r,c),y=this._textureFactory.createTextureFromArray(u,r,d);Promise.all([p,y]).then(([a,r])=>{t(new G(i,n,a,r,s,e.bufferLength))})})}_createSubImagesMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=new Array,r=e.getUint32();for(let t=0;t<r;t++){const t=e.getInt32(),s=e.getInt32(),i=e.getInt32(),r=e.getInt32(),o=e.getUint32(),h=e.getString(4),l=this._determineMimeType(h),u=e.getUint32(),p=e.getUint32(),y=e.getUint8Array(u),m=e.getUint8Array(p),_=new Promise((e,n)=>{const h=this._textureFactory.createTextureFromArray(y,l,c),u=this._textureFactory.createTextureFromArray(m,l,d);Promise.all([h,u]).then(([n,h])=>{e(new a({x:t,y:s,width:i,height:r,depth:o,colorMap:n,alphaMap:h}))}).catch(n)});n.push(_)}Promise.all(n).then(n=>{t(new R(i,n,s,e.bufferLength))})})}async _createMouseMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32(),n=e.getUint32();return new v(s,i,n,t)}async _createWindowsMessage(e){const t=e.getUint32(),s=e.getUint32(),i=new Array;for(let t=0;t<s;t++){const t=e.getUint32(),s=e.getInt32(),n=e.getInt32(),a=e.getInt32(),r=e.getInt32();i.push({id:t,x:s,y:n,width:a,height:r,shaped:!1})}if(l.version.versionNumber>=1.4&&e.bufferLength-e.readOffset>=4){const t=e.getUint32();for(let s=0;s<t;s++){const t=e.getUint32();i.find(e=>e.id===t).shaped=!0}}return new S(i.map(e=>new n(e)),t)}async _createCursorImageMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32(),n=e.getInt32(),a=e.getInt32(),r=e.getUint32(),o=e.getUint32(),h=e.getUint8Array(o);try{const e=await this._textureFactory.createTextureFromArray(h,"image/png",c);return new T(s,i,n,a,r,e,t)}catch(e){console.error(`Failed to get texture for cursor image: ${e}`)}}async _createScreenMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32();let n=10;e.bufferLength-e.readOffset>=4&&(n=e.getInt32());let a=0,r=0,o=0;return e.bufferLength-e.readOffset>=12&&(a=e.getUint32(),r=e.getUint32(),o=e.getUint32()),l.version=new oe(a,r,o),new X({width:s,height:i},n,new oe(a,r,o),t)}async _createPingMessage(){return new U}async _createQualityMessage(e){const t=e.getUint32(),s=e.getFloat(),i=e.getFloat(),n=e.getFloat(),a=e.getFloat();return new C(t,s,i,n,a)}async _createClipboardMessage(e){const t=e.getUint32(),s=e.getString(t);return new V(s)}_createShapeMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=e.getString(4),a=this._determineMimeType(n),r=e.getUint32(),o=e.getUint8Array(r);this._textureFactory.createTextureFromArray(o,a,d).then(n=>{t(new k(i,n,s,e.bufferLength))})})}}var pe,ye=f("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZXtjb25zdHJ1Y3RvcihlLHQ9MCl7dGhpcy50eXBlPWUsdGhpcy5jb21tYW5kSWQ9dH1zdGF0aWMgZ2V0IGNvbnZlcnRUb0ltYWdlRGF0YUluV29ya2VyKCl7cmV0dXJuIGUuX2NvbnZlcnRUb0ltYWdlRGF0YUluV29ya2VyfXN0YXRpYyBzZXQgY29udmVydFRvSW1hZ2VEYXRhSW5Xb3JrZXIodCl7ZS5fY29udmVydFRvSW1hZ2VEYXRhSW5Xb3JrZXI9dH19dmFyIHQ7ZS5fY29udmVydFRvSW1hZ2VEYXRhSW5Xb3JrZXI9ITEsZnVuY3Rpb24oZSl7ZVtlLk5PUD0wXT0iTk9QIixlW2UuQ09OTkVDVElPTj0xXT0iQ09OTkVDVElPTiIsZVtlLldJTkRPV1M9Ml09IldJTkRPV1MiLGVbZS5JTUFHRT0zXT0iSU1BR0UiLGVbZS5TQ1JFRU49NF09IlNDUk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GcmVxdWVudGx5OiEwfSk7cmV0dXJuIHIuZHJhd0ltYWdlKGUsMCwwKSxyLmdldEltYWdlRGF0YSgwLDAsdCxzKX1yZXR1cm4gbnVsbH0pKGUuaW1hZ2UpO3JldHVybiBuZXcgdyh7ZGF0YTpyLmRhdGEsd2lkdGg6dCxoZWlnaHQ6c30pfXJldHVybiBudWxsfX0oKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9V2ViWE1lc3NhZ2VEZWNvZGVyV29ya2VyLmpzLm1hcAoK");class me{constructor(){this._pending=new Map,this._nextId=1,this._instructionEncoder=new de,this._messageDecoder=new ue,"undefined"!=typeof Worker&&(this._worker=new ye,this._worker.onmessage=e=>{const{id:t,message:s,error:i}=e.data,n=this._pending.get(t);if(this._pending.delete(t),i)console.error(i);else if(n){const e=(e=>{let t;return e&&(e.type===exports.WebXMessageType.NOP?t=Object.create(L.prototype):e.type===exports.WebXMessageType.CONNECTION?t=Object.create(E.prototype):e.type===exports.WebXMessageType.SCREEN?t=Object.create(X.prototype):e.type===exports.WebXMessageType.WINDOWS?t=Object.create(S.prototype):e.type===exports.WebXMessageType.IMAGE?t=Object.create(G.prototype):e.type===exports.WebXMessageType.SUBIMAGES?t=Object.create(R.prototype):e.type===exports.WebXMessageType.MOUSE?t=Object.create(v.prototype):e.type===exports.WebXMessageType.CURSOR_IMAGE?t=Object.create(T.prototype):e.type===exports.WebXMessageType.PING?t=Object.create(U.prototype):e.type===exports.WebXMessageType.QUALITY?t=Object.create(C.prototype):e.type===exports.WebXMessageType.CLIPBOARD?t=Object.create(V.prototype):e.type===exports.WebXMessageType.SHAPE&&(t=Object.create(k.prototype)),t&&Object.assign(t,e)),t})(s);n(e)}})}terminate(){this._worker.terminate(),this._pending.clear()}serializeInstruction(e){const t=this._instructionEncoder.encode(e);return null==t&&console.warn("Could not serialize instruction: Unknown type"),t}async deserializeMessage(e){if(this._worker&&(e=>{switch(e.messageTypeId){case exports.WebXMessageType.IMAGE:case exports.WebXMessageType.SUBIMAGES:case exports.WebXMessageType.SHAPE:return!0;default:return!1}})(e))return new Promise(t=>{const s=this._nextId++;this._pending.set(s,t);const i=[e.buffer];this._worker.postMessage({id:s,buffer:e.buffer,convertToImageData:x.convertToImageDataInWorker},i)});try{const t=await this._messageDecoder.decode(e);return null==t&&console.error("Failed to decode message data"),t}catch(e){console.error(`Caught error decoding message data: ${e.message}`)}}}class _e{constructor(){this._serializer=new me,this._instructionResponses=new Map}terminate(){this._serializer.terminate()}sendInstruction(e){const t=this._serializer.serializeInstruction(e);this.send(t)}sendRequest(e,t){e.synchronous=!0;const s=new K(e,t=t||1e4);return this._instructionResponses.set(e.id,s),new Promise((t,i)=>{const n=this._serializer.serializeInstruction(e);this.send(n),s.then(t).catch(t=>{this._instructionResponses.delete(e.id),i(t)})})}async onMessage(e){if(0===e.byteLength)return console.warn("Got a zero length message"),null;if(e.byteLength<ce.MESSAGE_HEADER_LENGTH)return console.warn("Message does not contain a valid header"),null;const t=new ce(e);this._handleCriticalMessages(t),this.handleReceivedBytes(e);const s=await this._serializer.deserializeMessage(t);if(null!=s)if(null!=s.commandId&&null!=this._instructionResponses.get(s.commandId)){const e=this._instructionResponses.get(s.commandId);this._instructionResponses.delete(s.commandId),e.resolve(s)}else this.handleMessage(s)}handleMessage(e){throw new Error("Method not implemented.")}handleReceivedBytes(e){throw new Error("Method not implemented.")}handleSentBytes(e){throw new Error("Method not implemented")}handleClose(e){this._instructionResponses.forEach(e=>{e.reject("Tunnel closed")}),this.onClosed()}onClosed(){console.log("Websocket closed")}_handleCriticalMessages(e){e.messageTypeId==exports.WebXMessageType.PING?this.sendInstruction(new q(e.timestampMs)):e.messageTypeId!=exports.WebXMessageType.SUBIMAGES&&e.messageTypeId!=exports.WebXMessageType.IMAGE||e.bufferLength>_e.MIN_BUFFER_LENGTH_FOR_ACK&&this.sendInstruction(new ee(e.timestampMs,e.bufferLength))}}_e.MIN_BUFFER_LENGTH_FOR_ACK=32768;class ge{constructor(e){this._tunnel=e,this._cursorMap=new Map}async getCursor(e){const t=this._cursorMap.get(e);if(null!=t)return{cursor:t};{const t=await this._tunnel.sendRequest(new j(e)),s={xHot:t.xHot,yHot:t.yHot,cursorId:t.cursorId,texture:t.texture};return this._cursorMap.set(t.cursorId,s),{x:t.x,y:t.y,cursor:s}}}}class be{constructor(e){this._tunnel=e}async getWindowTexture(e){try{const t=await this._tunnel.sendRequest(new J(e));return{depth:t.depth,colorMap:t.colorMap,alphaMap:t.alphaMap}}catch(e){console.warn("Failed to get texture: "+e)}}async getWindowStencilTexture(e){try{return{stencilMap:(await this._tunnel.sendRequest(new se(e))).stencilMap}}catch(e){return console.warn("Failed to get stencil texture: "+e),null}}}exports.WebXConnectionStatus=void 0,(pe=exports.WebXConnectionStatus||(exports.WebXConnectionStatus={}))[pe.STARTING=0]="STARTING",pe[pe.RUNNING=1]="RUNNING";class fe{constructor(){this._connected=!1,this._connectionCallback=()=>{},this._connectionError=()=>{},this._connectionStatusCallback=()=>{}}onConnected(e,t){return this._timeoutMs=e||1e4,this._connectionStatusCallback=t,new Promise((e,t)=>{this._connected?e():(this._connectionCallback=()=>{window.clearTimeout(this._timeout),this._timeout=null,e()},this._connectionError=()=>{this._timeout=null,t(new Error("Connection timed out"))},this._createTimer())})}setConnected(e){e?this._connectionStatusCallback(exports.WebXConnectionStatus.STARTING):(this._connected=!0,this._connectionStatusCallback(exports.WebXConnectionStatus.RUNNING),this._connectionCallback())}resetTimer(){this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null,this._createTimer())}dispose(){this._timeout&&window.clearTimeout(this._timeout)}_createTimer(){this._timeout=window.setTimeout(()=>{this._connectionError()},this._timeoutMs)}}const{version:Me}=require("../package.json");exports.LinearSRGBColorSpace=d,exports.SRGBColorSpace=c,exports.WebXClient=class{get tunnel(){return this._tunnel}get tracers(){return this._tracers}get display(){return this._display}get mouse(){return this._mouse}get keyboard(){return this._keyboard}set clipboardHandler(e){this._clipboardHandler=e}get maxQualityIndex(){return this._maxQualityIndex}constructor(e){this._tunnel=e,this._tracers=new Map,this._clipboardHandler=e=>{},this._connectionHandler=new fe,this._maxQualityIndex=10,this._windowImageFactory=new be(this._tunnel),this._cursorFactory=new ge(this._tunnel)}async connect(e,t){this._onCloseCallback=e,this._tunnel.handleMessage=this._handleMessage.bind(this),this._tunnel.handleReceivedBytes=this._handleReceivedBytes.bind(this),this._tunnel.handleSentBytes=this._handleSentBytes.bind(this),this._tunnel.onClosed=this._onTunnelClosed.bind(this),await this._tunnel.connect({...t,"client-version":Me})}disconnect(){this._tunnel.disconnect(),this._tunnel.terminate()}async initialise(e,t){try{t={useDefaultMouseAdapter:!0,useDefaultKeyboardAdapter:!0,waitForConnectionWithTimeout:1e4,connectionStatusCallback:()=>{},...t};const{useDefaultMouseAdapter:s,useDefaultKeyboardAdapter:i,waitForConnectionWithTimeout:n,connectionStatusCallback:a}=t;n>0&&await this._connectionHandler.onConnected(n,a);const r=await this._getScreenMessage(),{width:o,height:h}=r.screenSize;this._maxQualityIndex=r.maxQualityIndex,l.version=r.engineVersion,this._display=this.createDisplay(e,o,h);const c=await this._sendRequest(new A);return await this._display.updateWindows(c.windows),this._display.showScreen(),s&&(this._mouse=this.createMouse(e),this._addMouseListeners()),i&&(this._keyboard=this.createKeyboard(document.body),this._addKeyboardListeners()),this._display}catch(e){throw this._dispose(),new Error(`Failed to initialise display: ${e.message}`)}}createDisplay(e,t,s){return new N(e,t,s,this._windowImageFactory,this._cursorFactory)}createMouse(e){return new D(e)}createKeyboard(e){return new H(e)}sendMouse(e){this._display.setMousePosition(e.x,e.y),this._sendInstruction(new B(e.x,e.y,e.getButtonMask()))}sendKeyEvent(e,t){this._sendInstruction(new Q(e,t))}sendKeyDown(e){this.sendKeyEvent(e,!0)}sendKeyUp(e){this.sendKeyEvent(e,!1)}sendClipboardContent(e){this._sendInstruction(new te(e))}registerTracer(e,t){this._tracers.set(e,t)}createDebugImageMessageHandler(){return this._display?new he(this._display):(console.log("Cannot create DebugImageMessageHandler as display is null"),null)}resetInputs(){this._mouse&&this._mouse.reset(),this._keyboard&&this._keyboard.reset()}resizeDisplay(){this._display&&this._display.resize()}unregisterTracer(e){const t=this._tracers.get(e);t&&(t.destroy(),this._tracers.delete(e))}setQualityIndex(e){const t=new $(e);this._sendInstruction(t)}async createScreenshot(e,t){return this.display.createScreenshot(e,t)}async _getScreenMessage(){let e=0;for(;e<3;)try{return await this._sendRequest(new O,5e3)}catch(t){if(e++,console.log(`Failed to initialise screen size at attempt ${e}/3...`),3==e||!this._tunnel.isConnected())throw new Error(`unable to get screen size: ${t.message}`)}}_sendInstruction(e){this._tunnel.isConnected()&&(this._tunnel.sendInstruction(e),this._tracers.forEach(t=>{t instanceof ie&&t.handle(e)}))}_sendRequest(e,t){if(this._tunnel.isConnected())return this._tunnel.sendRequest(e,t)}_handleMessage(e){if(e.type===exports.WebXMessageType.CONNECTION){const t=e;return void this._connectionHandler.setConnected(t.isStarting)}if(e.type===exports.WebXMessageType.NOP&&this._connectionHandler.resetTimer(),this._display){if(e.type===exports.WebXMessageType.WINDOWS){const t=e.windows;this._display.updateWindows(t)}else if(e.type===exports.WebXMessageType.IMAGE){const t=e;this._display.updateImage(t.windowId,t.depth,t.colorMap,t.alphaMap)}else if(e.type===exports.WebXMessageType.SUBIMAGES){const t=e;this._display.updateSubImages(t.windowId,t.subImages)}else if(e.type===exports.WebXMessageType.SHAPE){const t=e;this._display.updateShape(t.windowId,t.stencilMap)}else if(e.type===exports.WebXMessageType.MOUSE){const t=e;t.x>0&&t.y>0&&this._display.setMousePosition(t.x,t.y),this._display.setMouseCursor(t.cursorId)}else if(e.type===exports.WebXMessageType.CLIPBOARD){const t=e;this._clipboardHandler(t.clipboardContent)}this._tracers.forEach(t=>{t instanceof ne&&t.handle(e)})}}_handleReceivedBytes(e){this._tracers.forEach(t=>{t instanceof ae&&t.handle({received:e.byteLength,sent:0})})}_handleSentBytes(e){this._tracers.forEach(t=>{t instanceof ae&&t.handle({received:0,sent:e.byteLength})})}_handleQuality(e){this._tracers.forEach(t=>{t instanceof ae&&t.handle({received:0,sent:e.byteLength})})}_onTunnelClosed(){this._dispose(),this._onCloseCallback&&this._onCloseCallback()}_dispose(){this._connectionHandler.dispose(),this._display&&this._display.dispose(),this._mouse&&this._mouse.dispose(),this._keyboard&&this._keyboard.dispose()}_addMouseListeners(){this._mouse.onMouseMove=this._mouse.onMouseOut=e=>{const t=this._display.scale;e.x=e.x/t,e.y=e.y/t,this.sendMouse(e)},this._mouse.onMouseDown=this._mouse.onMouseUp=e=>{const t=this._display.scale;e.x=e.x/t,e.y=e.y/t,this.sendMouse(e)}}_addKeyboardListeners(){this._keyboard.onKeyDown=e=>{this.sendKeyDown(e)},this._keyboard.onKeyUp=e=>{this.sendKeyUp(e)}}},exports.WebXClipboardInstruction=te,exports.WebXClipboardMessage=V,exports.WebXConnectInstruction=class extends P{constructor(e){super(exports.WebXInstructionType.CONNECT),this.parameters=e}},exports.WebXConnectionHandler=fe,exports.WebXConnectionMessage=E,exports.WebXCursorImageInstruction=j,exports.WebXCursorImageMessage=T,exports.WebXDataAckInstruction=ee,exports.WebXDebugImageMessageHandler=he,exports.WebXDisplay=N,exports.WebXImageInstruction=J,exports.WebXImageMessage=G,exports.WebXInstruction=P,exports.WebXInstructionHandler=ie,exports.WebXInstructionResponse=K,exports.WebXKeyboard=H,exports.WebXKeyboardInstruction=Q,exports.WebXMessage=x,exports.WebXMessageHandler=ne,exports.WebXMouse=D,exports.WebXMouseInstruction=B,exports.WebXMouseMessage=v,exports.WebXMouseState=z,exports.WebXNopMessage=L,exports.WebXPingMessage=U,exports.WebXPongInstruction=q,exports.WebXQualityInstruction=$,exports.WebXQualityMessage=C,exports.WebXScreenInstruction=O,exports.WebXScreenMessage=X,exports.WebXShapeInstruction=se,exports.WebXShapeMessage=k,exports.WebXStatsHandler=ae,exports.WebXSubImage=a,exports.WebXSubImagesMessage=R,exports.WebXTexture=u,exports.WebXTextureFactory=p,exports.WebXTunnel=_e,exports.WebXWebSocketTunnel=class extends _e{constructor(e,t={}){if(super(),this._socketOpen=!1,this._connectionOptions=t,"ws:"!==e.substring(0,3)&&"wss:"!==e.substring(0,4)){const t=window.location,s="https:"===t.protocol?"wss:":"ws:",i=t.hostname,n=t.port?`:${t.port}`:"";e="/"===e.substring(0,1)?`${s}//${i}${n}${e}`:`${s}//${i}${n}/${e}`}this._url=e}getSocket(){return this._socket}send(e){null!=this._socket&&(this._socket.send(e),this.handleSentBytes(e))}connect(e){const t={...this._connectionOptions,...e},s=new URLSearchParams(t),i=`${this._url}?${s}`;return new Promise((e,t)=>{this._socket=new WebSocket(i),this._socket.binaryType="arraybuffer",this._socket.onopen=()=>{this._socketOpen=!0,e(null)},this._socket.onerror=e=>t(e),this._socket.onclose=this.handleClose.bind(this),this._socket.onmessage=e=>this.onMessage(e.data)})}disconnect(){this._socket&&(this._socketOpen=!1,this._socket.close(),this._socket=null)}isConnected(){return this._socketOpen}},exports.WebXWindowProperties=n,exports.WebXWindowsInstruction=A,exports.WebXWindowsMessage=S,exports.alphaAndStencilBlend=r,exports.alphaBufferBlend=o,exports.colorAndAlphaBlendImageToImageData=(e,t)=>{const s=e.width,i=e.height,n=new OffscreenCanvas(s,i).getContext("2d",{willReadFrequently:!0});n.drawImage(e,0,0);const a=n.getImageData(0,0,s,i);n.drawImage(t,0,0);const r=n.getImageData(0,0,s,i);return o(a.data,r.data),a},exports.imageToImageData=e=>{if(e){const t=e.width,s=e.height,i=new OffscreenCanvas(t,s).getContext("2d",{willReadFrequently:!0});return i.drawImage(e,0,0),i.getImageData(0,0,t,s)}return null},exports.toThreeTexture=y;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"three";import{ShaderMaterial as t,BackSide as s,Color as i,Matrix3 as n,LinearFilter as a,MeshBasicMaterial as r,DataTexture as o,Mesh as h,Vector3 as l,PlaneGeometry as c,Object3D as d}from"three";import{Group as u,Tween as p,Easing as m}from"@tweenjs/tween.js";class _{constructor(e){this.id=e.id,this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.shaped=e.shaped||!1}}class y{constructor(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.depth=e.depth,this.colorMap=e.colorMap,this.alphaMap=e.alphaMap}}const g=(e,t,s)=>{if(t&&s)for(let i=0;i<e.length;i+=4)s[i]<128?e[i+3]=0:e[i+3]=t[i+1];else if(t)for(let s=0;s<e.length;s+=4)e[s+3]=t[s+1];else if(s)for(let t=0;t<e.length;t+=4)e[t+3]=s[t]<128?0:e[t+3]},f=(e,t)=>{for(let s=0;s<e.length;s+=4)e[s+3]=t[s+1]},Z=(e,t)=>{const s=e.width,i=e.height,n=new OffscreenCanvas(s,i).getContext("2d",{willReadFrequently:!0});n.drawImage(e,0,0);const a=n.getImageData(0,0,s,i);n.drawImage(t,0,0);const r=n.getImageData(0,0,s,i);return f(a.data,r.data),a},w=e=>{if(e){const t=e.width,s=e.height,i=new OffscreenCanvas(t,s).getContext("2d",{willReadFrequently:!0});return i.drawImage(e,0,0),i.getImageData(0,0,t,s)}return null};class b extends t{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get alphaMap(){return this.uniforms.alphaMap.value}set alphaMap(e){this.uniforms.alphaMap.value=e}get stencilMap(){return this.uniforms.stencilMap.value}set stencilMap(e){this.uniforms.stencilMap.value=e,e?this.defines.USE_STENCILMAP="":delete this.defines.USE_STENCILMAP}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value.copy(e)}constructor(e){super({uniforms:{map:{value:null},alphaMap:{value:null},stencilMap:{value:null},mapTransform:{value:new n},alphaMapTransform:{value:new n},diffuse:{value:new i(16777215)},opacity:{value:1}},vertexShader:"\n#ifdef USE_MAP\nuniform mat3 mapTransform;\nvarying vec2 vMapUv;\n#endif\n\n#ifdef USE_ALPHAMAP\nuniform mat3 alphaMapTransform;\nvarying vec2 vAlphaMapUv;\n#endif\n\n#ifdef USE_STENCILMAP\nvarying vec2 vStencilMapUv;\n#endif\n\nvoid main() {\n#ifdef USE_MAP\n vMapUv = (mapTransform * vec3(uv, 1)).xy;\n#endif\n\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = (alphaMapTransform * vec3(uv, 1)).xy;\n#endif\n\n#ifdef USE_STENCILMAP\n vStencilMapUv = uv;\n#endif\n\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifdef USE_MAP\nuniform sampler2D map;\nvarying vec2 vMapUv;\n#endif\n\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\nvarying vec2 vAlphaMapUv;\n#endif\n\n#ifdef USE_STENCILMAP\nuniform sampler2D stencilMap;\nvarying vec2 vStencilMapUv;\n#endif\n\nvoid main() {\n vec4 diffuseColor = vec4(diffuse, opacity);\n\n#ifdef USE_STENCILMAP\n vec4 stencil = texture2D(stencilMap, vStencilMapUv);\n if (stencil.r < 0.5) {\n discard;\n }\n#endif\n\n#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D(map, vMapUv);\n diffuseColor *= sampledDiffuseColor;\n#endif\n\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D(alphaMap, vAlphaMapUv).g;\n#endif\n\n gl_FragColor = diffuseColor;\n gl_FragColor = linearToOutputTexel( gl_FragColor );\n}\n",transparent:!0,depthTest:!0,side:s}),e&&e.color&&this.color.set(e.color)}onBeforeRender(){this.map&&this.map.matrixAutoUpdate&&(this.map.updateMatrix(),this.uniforms.mapTransform.value.copy(this.map.matrix)),this.alphaMap&&this.alphaMap.matrixAutoUpdate&&(this.alphaMap.updateMatrix(),this.uniforms.alphaMapTransform.value.copy(this.alphaMap.matrix))}}class M{}const I="srgb",S="srgb-linear";class W{constructor(e){this.image=e.image?e.image:null,this.data=e.data,this.width=e.image?e.image.width:e.width,this.height=e.image?e.image.height:e.height,this.colorSpace=I,this.flipY=!1}isTransferable(){return this.image&&this.image instanceof ImageBitmap||null!=this.data}get transferable(){return this.image&&this.image instanceof ImageBitmap?this.image:this.data?this.data.buffer:null}}class G{constructor(){}async createTextureFromArray(e,t,s){if(null!=e&&e.byteLength>0){const i=new Blob([e],{type:t}),n=await this.createTextureFromBlob(i);return n.flipY=!1,n.colorSpace=s,n}return null}createTextureFromBlob(e){return"function"==typeof createImageBitmap?new Promise((t,s)=>{createImageBitmap(e).then(e=>{const s=new W({image:e});t(s)}).catch(e=>{console.warn(`Failed to create texture using createImageBitmap from binary data: ${e}`),s(e)})}):new Promise((t,s)=>{const i=URL.createObjectURL(e),n=new Image;n.onload=()=>{URL.revokeObjectURL(i);const e=new W({image:n});t(e)},n.onerror=e=>{console.warn(`Failed to create texture from binary data: ${e}`),s(e)},n.src=i})}}const R=t=>{if(t){const s=t.data?new e.DataTexture(t.data,t.width,t.height):new e.Texture(t.image);return s.needsUpdate=!0,s.flipY=t.flipY,s.colorSpace=t.colorSpace,s.minFilter=a,s}return null};class x{get mesh(){return this._mesh}get colorIndex(){return this._colorIndex}get id(){return this._id}get visible(){return this._material.visible}set visible(e){this._material.visible!==e&&(this._material.visible=e)}get loaded(){return this._loaded}get colorMap(){return this._material.map}set colorMap(e){this._material.map=e}get alphaMap(){return this._material.alphaMap}set alphaMap(e){this._material.alphaMap=e}get stencilMap(){return this._material.stencilMap}set stencilMap(e){this._material.stencilMap=e}get colorMapValid(){return null!=this.colorMap&&this.colorMap.image.width===this._width&&this.colorMap.image.height===this._height}get depth(){return this._depth}get x(){return this._x}set x(e){this._x=e,this._updatePosition()}get y(){return this._y}set y(e){this._y=e,this._updatePosition()}get z(){return this._z}set z(e){this._z=e,this._updatePosition()}get width(){return this._width}set width(e){this._width=e,this._updateScale(),this._updatePosition()}get height(){return this._height}set height(e){this._height=e,this._updateScale(),this._updatePosition()}get shaped(){return this._shaped}set shaped(e){this._shaped=e,e||this.updateStencilTexture(null)}constructor(t,s){this._width=1,this._height=1,this._shaped=!1,this._loaded=!1,this._windowRefreshTimeout=null,this._windowImageFactory=s,this._colorIndex=x._COLOR_INDEX++,this._material=new b,this.visible=!1;const{id:i,x:n,y:a,z:r,width:o,height:h,shaped:l}=t;this._id=i,this._mesh=new e.Mesh(x._PLANE_GEOMETRY,this._material),this._mesh.onBeforeRender=()=>this._material.onBeforeRender(),this._x=n,this._y=a,this._z=r,this._width=o,this._height=h,this._shaped=l&&M.version.versionNumber>=1.4,this._updateScale(),this._updatePosition()}async loadWindowImage(){const e=await this._windowImageFactory.getWindowTexture(this._id);e&&this.updateTexture(e.depth,R(e.colorMap),R(e.alphaMap),!0)}async loadWindowShape(){const e=await this._windowImageFactory.getWindowStencilTexture(this._id);e?this.updateStencilTexture(R(e.stencilMap)):(this._shaped=!1,this.visible=null!=this.colorMap)}async loadWindowImageAndShape(){if(this._shaped){const e=this.loadWindowImage(),t=this.loadWindowShape();await Promise.all([e,t])}else await this.loadWindowImage();this._loaded=!0}setRectangle(e,t,s,i,n){this._x=e,this._y=t,this._z=s,this._width=i,this._height=n,this.colorMap&&(this.colorMap.repeat.set(this._width/this.colorMap.image.width,this._height/this.colorMap.image.height),this.alphaMap&&this.alphaMap.repeat.set(this._width/this.alphaMap.image.width,this._height/this.alphaMap.image.height),this.colorMap.image.width===this._width&&this.colorMap.image.height===this._height||this.loadWindowImageAndShape()),this._updateScale(),this._updatePosition()}updateTexture(e,t,s,i){if(null==t)return;const n=null!=this.colorMap,a=null!=this.alphaMap;this._depth=e,t!=this.colorMap&&(this._disposeColorMap(),this.colorMap=t),this.colorMap.repeat.set(this._width/this.colorMap.image.width,this._height/this.colorMap.image.height),this.visible=!this._shaped||null!=this.stencilMap,s?(s!=this.alphaMap&&(this._disposeAlphaMap(),this.alphaMap=s),this.alphaMap.repeat.set(this._width/this.alphaMap.image.width,this._height/this.alphaMap.image.height)):24==e&&this._disposeAlphaMap(),this._material.transparent=null!=this.alphaMap||32===e;const r=null!=this.colorMap,o=null!=this.alphaMap;n==r&&a==o||(this._material.needsUpdate=!0),i||(this._windowRefreshTimeout&&(clearTimeout(this._windowRefreshTimeout),this._windowRefreshTimeout=null),this._windowRefreshTimeout=window.setTimeout(()=>{this._windowRefreshTimeout=null,this.loadWindowImage().then()},x.WINDOW_REFRESH_TIME_MS))}updateStencilTexture(e){const t=this._shaped;e!=this.stencilMap&&(this._disposeStencilMap(),this.stencilMap=e),e?(e.minFilter=a,this.visible=null!=this.colorMap,this._shaped=!0):this._shaped=!1,t!==this._shaped&&(this._material.needsUpdate=!0)}_updateScale(){this._mesh.scale.set(this._width,this._height,1)}_updatePosition(){this._mesh.position.set(this._x+.5*this._width,this._y+.5*this._height,this._z)}dispose(){this._disposeColorMap(),this._disposeAlphaMap(),this._disposeStencilMap(),this._material.dispose(),this._windowRefreshTimeout&&(clearTimeout(this._windowRefreshTimeout),this._windowRefreshTimeout=null)}_disposeColorMap(){this.colorMap&&(this.colorMap.dispose(),this.colorMap=null)}_disposeAlphaMap(){this.alphaMap&&(this.alphaMap.dispose(),this.alphaMap=null)}_disposeStencilMap(){this.stencilMap&&(this.stencilMap.dispose(),this.stencilMap=null)}}x.WINDOW_REFRESH_TIME_MS=5e3,x._PLANE_GEOMETRY=new e.PlaneGeometry(1,1,2,2),x._COLOR_INDEX=0;class U{get canvas(){return this._canvas}get cursorId(){return this._cursorId}set x(e){this._x=e,this._updatePosition()}set y(e){this._y=e,this._updatePosition()}constructor(e){this._cursorFactory=e,this._x=-1,this._y=-1,this._xHot=0,this._yHot=0,this._width=1,this._height=1,this._canvas=document.createElement("canvas"),this._canvas.id="webx-cursor",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._context=this._canvas.getContext("2d"),this.setPosition(-1,-1),this.setCursorId(0)}setPosition(e,t){this._x=e,this._y=t,this._updatePosition()}setCursorId(e){this._cursorId!==e&&(this._cursorId=e,this._cursorFactory.getCursor(e).then(e=>{const t=e.cursor;(this._x<0||this._y<0)&&this.setPosition(e.x,e.y),this._updateCursor(t.xHot,t.yHot,t.cursorId,t.texture)}))}_updateCursor(e,t,s,i){this._xHot=e,this._yHot=t,this._cursorId=s,null!=i&&null!=i.image&&(this._width=i.image.width,this._height=i.image.height,this._canvas.style.width=`${this._width}px`,this._canvas.style.height=`${this._height}px`,this._canvas.width=this._width,this._canvas.height=this._height,this._texture=i,this._context.clearRect(0,0,this._width,this._height),this._context.drawImage(this._texture.image,0,0,this._width,this._height))}_updatePosition(){this._canvas.style.left=this._x-this._xHot+"px",this._canvas.style.top=this._y-this._yHot+"px"}}class v{get id(){return this._mesh.id}get canvas(){return this._canvas}get x(){return this._x}get y(){return this._y}get zIndex(){return this._zIndex}get width(){return this._width}get height(){return this._height}constructor(e,t){this._mesh=e,this._imageBlender=t,this._x=0,this._y=0,this._zIndex=0,this._width=0,this._height=0,this._regionUpdates=[],this._canvas=this.createElementNS("canvas"),this._canvas.id=`webx-window-${this.id}`,this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.style.top="0",this._canvas.style.left="0",this._canvas.style.overflow="hidden",this._context=this._canvas.getContext("2d"),this.updateGeometry(),this.updateCanvas()}updateGeometry(){const e=this._mesh.scale.x,t=this._mesh.scale.y,s=this._mesh.position.x-.5*e,i=this._mesh.position.y-.5*t,n=this._mesh.position.z;s===this._x&&i===this._y||(this._canvas.style.top=`${i}px`,this._canvas.style.left=`${s}px`,this._x=s,this._y=i),e===this._width&&t===this._height||(this._width=e,this._height=t),n!==this._zIndex&&(this._canvas.style.zIndex=`${this._mesh.position.z}`,this._zIndex=n)}async updateCanvas(){if(this._mesh.material instanceof b||this._mesh.material instanceof r){const e=this._mesh.material;if(this.updateStencilMap(e),e.map?.image){if(e.map!=this._colorMap||e.alphaMap!=this._alphaMap){this._colorMap=e.map,this._alphaMap=e.alphaMap;const t=e.map.image,s=t.width,i=t.height;if(this.isValidAlphaMap(e.alphaMap)||null!=this._stencilMap){const t=await this.blendAlphaAndStencil(e.map,e.alphaMap,0,0);this.resizeCanvas(s,i),this._context.putImageData(t,0,0)}else if(this.resizeCanvas(s,i),e.map instanceof o){const e=this.dataTextureToImageData(t);this._context.putImageData(e,0,0)}else this._context.clearRect(0,0,s,i),this._context.drawImage(t,0,0,s,i)}await this.handleRegionUpdates()}else this._colorMap&&(this._colorMap=null,this._alphaMap=null,this._regionUpdates=[],this._context.clearRect(0,0,this._canvas.width,this._canvas.height))}}addRegionUpdate(e,t,s,i,n,a,r){this._regionUpdates.push({srcColorMap:e,dstColorMap:t,srcAlphaMap:s,dstAlphaMap:i,width:n,height:a,dstPosition:r})}resizeCanvas(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`)}async handleRegionUpdates(){for(const e of this._regionUpdates)if(e.dstColorMap===this._colorMap&&e.dstAlphaMap===this._alphaMap){const{srcColorMap:t,srcAlphaMap:s,width:i,height:n,dstPosition:a}=e,r=t.image;if(s||this._stencilData){const e=await this.blendAlphaAndStencil(t,s,a.x,a.y);e&&this._context.putImageData(e,a.x,a.y)}else if(t instanceof o){const e=this.dataTextureToImageData(r);this._context.putImageData(e,a.x,a.y)}else this._context.drawImage(r,0,0,i,n,a.x,a.y,i,n)}this._regionUpdates=[]}isValidAlphaMap(e){if(e){const t=e.image.width,s=e.image.height;return t===this._canvas.width&&s===this._canvas.height}return!1}updateStencilMap(e){if(e instanceof b&&e.stencilMap){if(e.stencilMap!=this._stencilMap){this._stencilMap=e.stencilMap;const t=this._stencilMap.image,{width:s,height:i}=t;if(this._stencilMap instanceof o)this._stencilData=this.dataTextureToImageData(t);else{const e=this.createElementNS("canvas");e.width=s,e.height=i;const n=e.getContext("2d",{willReadFrequently:!0});n.drawImage(t,0,0),this._stencilData=n.getImageData(0,0,s,i)}}}else this._stencilMap&&(this._stencilMap=null,this._stencilData=null)}async blendAlphaAndStencil(e,t,s,i){const n=e instanceof o?this.dataTextureToImageData(e.image):this.getImageData(e.image),a=null==t?null:t instanceof o?this.dataTextureToImageData(t.image):this.getImageData(t.image),r=null==this._stencilData?null:this.getStencilDataRegion(s,i,n.width,n.height);return a||r?await this._imageBlender.blendAlphaAndStencil(n,a,r):n}createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}getImageData(e){const t=this.createElementNS("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return s.drawImage(e,0,0),s.getImageData(0,0,e.width,e.height)}dataTextureToImageData(e){if(e.data.byteLength>0){const t=e.data instanceof Uint8ClampedArray?e.data:new Uint8ClampedArray(e.data.buffer);return new ImageData(t,e.width,e.height)}return new ImageData(new Uint8ClampedArray(4),1,1)}getStencilDataRegion(e,t,s,i){const n=this._stencilData.data,a=this._stencilData.width,r=new Uint8ClampedArray(s*i*4);for(let o=0;o<i;o++){const i=4*((t+o)*a+e),h=o*s*4;r.set(n.subarray(i,i+4*s),h)}return new ImageData(r,s,i)}}function X(e,t,s){var i=function(e){return atob(e)}(e),n=i.indexOf("\n",10)+1,a=i.substring(n)+"",r=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(r)}function V(e,t,s){var i;return function(t){return i=i||X(e),new Worker(i,t)}}var C,E=V("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7c2VsZi5vbm1lc3NhZ2U9ZT0+e2NvbnN0e2lkOmYsY29sb3JCdWZmZXI6bCxhbHBoYUJ1ZmZlcjp0LHN0ZW5jaWxCdWZmZXI6cix3aWR0aDpuLGhlaWdodDppfT1lLmRhdGEscz1uZXcgVWludDhDbGFtcGVkQXJyYXkobCk7KChlLGYsbCk9PntpZihmJiZsKWZvcihsZXQgdD0wO3Q8ZS5sZW5ndGg7dCs9NClsW3RdPDEyOD9lW3QrM109MDplW3QrM109Zlt0KzFdO2Vsc2UgaWYoZilmb3IobGV0IGw9MDtsPGUubGVuZ3RoO2wrPTQpZVtsKzNdPWZbbCsxXTtlbHNlIGlmKGwpZm9yKGxldCBmPTA7ZjxlLmxlbmd0aDtmKz00KWVbZiszXT1sW2ZdPDEyOD8wOmVbZiszXX0pKHMsdD9uZXcgVWludDhDbGFtcGVkQXJyYXkodCk6bnVsbCxyP25ldyBVaW50OENsYW1wZWRBcnJheShyKTpudWxsKSxzZWxmLnBvc3RNZXNzYWdlKHtpZDpmLGNvbG9yQnVmZmVyOnMuYnVmZmVyLHdpZHRoOm4saGVpZ2h0Oml9LFtzLmJ1ZmZlcl0pfX0oKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9V2ViWEltYWdlQmxlbmRlcldvcmtlci5qcy5tYXAKCg==");class L{constructor(){this._pending=new Map,this._nextId=1,"undefined"!=typeof Worker&&(this._worker=new E,this._worker.onmessage=e=>{const{id:t,colorBuffer:s,width:i,height:n}=e.data,a=this._pending.get(t);if(!a)return;this._pending.delete(t);const r=new Uint8ClampedArray(s);a(new ImageData(r,i,n))})}async blendAlphaAndStencil(e,t,s){return new Promise(i=>{if(this._worker){const n=this._nextId++;this._pending.set(n,i);const a=e.width,r=e.height,o=e.data.buffer;let h=null,l=null;const c=[o];t&&(h=t.data.buffer,c.push(h)),s&&(l=s.data.buffer,c.push(l)),this._worker.postMessage({id:n,colorBuffer:o,alphaBuffer:h,stencilBuffer:l,width:a,height:r},c)}else g(e.data,t?.data,s?.data),i(e)})}terminate(){this._worker.terminate(),this._pending.clear()}}class N{get domElement(){return this._desktopContainer}constructor(){this._clearColor=new i(0,0,0),this._windowCanvases=new Map,this.createMainElement(),this._imageBlender=new L}setSize(e,t,s){this._width=e,this._height=t,this._desktop.style.width=`${e}px`,this._desktop.style.height=`${t}px`}setClearColor(e){this._clearColor.set(e),this._desktop.style.backgroundColor=`#${this._clearColor.getHexString()}`}render(e,t){if(e.children.length>0){const t=e.children[0],s=new Set;for(const e of t.children)if(e instanceof h&&e.visible){this._windowCanvases.has(e.id)||this.createWindowCanvas(e);const t=this._windowCanvases.get(e.id);t.updateGeometry(),t.updateCanvas(),s.add(e.id)}for(const[e,t]of this._windowCanvases.entries())s.has(e)||this.removeWindowCanvas(t)}else if(this._windowCanvases.size>0)for(const[e,t]of this._windowCanvases.entries())this.removeWindowCanvas(t)}createScreenshot(e,t){return new Promise((s,i)=>{try{const i=this.createElementNS("canvas");i.width=this._width,i.height=this._height;const n=i.getContext("2d");n.fillStyle=`#${this._clearColor.getHexString()}`,n.fillRect(0,0,this._width,this._height),Array.from(this._windowCanvases.values()).sort((e,t)=>e.zIndex-t.zIndex).forEach(e=>{n.drawImage(e.canvas,e.x,e.y)}),i.toBlob(e=>{s(e)},e,t)}catch(e){i(e)}})}dispose(){for(const[e,t]of this._windowCanvases.entries())this.removeWindowCanvas(t);this._imageBlender.terminate()}updateWindowRegion(e,t,s,i,n,a,r,o){const h=this._windowCanvases.get(e);h&&h.addRegionUpdate(t,s,i,n,a,r,o)}createMainElement(){const e=this.createElementNS("div");e.id="webx-desktop-container",e.style.display="block",e.style.position="relative",e.style.overflow="hidden";const t=document.createElement("div");t.id="webx-desktop",e.style.position="absolute",e.style.transformOrigin="top left",e.appendChild(t),this._desktopContainer=e,this._desktop=t}createWindowCanvas(e){const t=new v(e,this._imageBlender);this._desktop.appendChild(t.canvas),this._windowCanvases.set(e.id,t)}removeWindowCanvas(e){this._desktop.removeChild(e.canvas),this._windowCanvases.delete(e.id)}createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}}class k{get overlayElement(){return this._overlayElement}set visible(e){this._overlayElement.style.visibility=e?"visible":"hidden"}constructor(e){this._cursor=e,this._overlayElement=this._createDisplayOverlayElement(),this._overlayElement.appendChild(this._cursor.canvas)}update(){}_createDisplayOverlayElement(){const e=document.createElement("div");return e.id="webx-overlay",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.zIndex="999",e.style.visibility="hidden",e.style.overflow="clip",e}}class T{constructor(e,t=0){this.type=e,this.commandId=t}static get convertToImageDataInWorker(){return T._convertToImageDataInWorker}static set convertToImageDataInWorker(e){T._convertToImageDataInWorker=e}}T._convertToImageDataInWorker=!1,function(e){e[e.NOP=0]="NOP",e[e.CONNECTION=1]="CONNECTION",e[e.WINDOWS=2]="WINDOWS",e[e.IMAGE=3]="IMAGE",e[e.SCREEN=4]="SCREEN",e[e.SUBIMAGES=5]="SUBIMAGES",e[e.MOUSE=6]="MOUSE",e[e.CURSOR_IMAGE=7]="CURSOR_IMAGE",e[e.PING=8]="PING",e[e.DISCONNECT=9]="DISCONNECT",e[e.QUALITY=10]="QUALITY",e[e.CLIPBOARD=11]="CLIPBOARD",e[e.SHAPE=12]="SHAPE"}(C||(C={}));class Y extends T{constructor(e,t,s,i){super(C.SCREEN,i),this.screenSize=e,this.maxQualityIndex=t,this.engineVersion=s}}class F extends T{constructor(e,t){super(C.WINDOWS,t),this.windows=e}}class z extends T{constructor(e,t,s,i,n,a){super(C.IMAGE,n),this.windowId=e,this.depth=t,this.colorMap=s,this.alphaMap=i,this.size=a}}class H extends T{constructor(e,t,s,i){super(C.SUBIMAGES,s),this.windowId=e,this.subImages=t,this.size=i}}class D extends T{constructor(e,t,s,i){super(C.MOUSE,i),this.x=e,this.y=t,this.cursorId=s}}class P extends T{constructor(e,t,s,i,n,a,r){super(C.CURSOR_IMAGE,r),this.x=e,this.y=t,this.xHot=s,this.yHot=i,this.cursorId=n,this.texture=a}}class K extends T{constructor(){super(C.PING)}}class O extends T{constructor(e,t,s,i,n){super(C.QUALITY),this.index=e,this.imageFPS=t,this.rgbQuality=s,this.alphaQuality=i,this.maxMbps=n}}class A extends T{constructor(e){super(C.CLIPBOARD),this.clipboardContent=e}}class J extends T{constructor(e){super(C.CONNECTION),this.isStarting=e}}class B extends T{constructor(){super(C.NOP)}}class Q extends T{constructor(e,t,s,i){super(C.SHAPE,s),this.windowId=e,this.stencilMap=t,this.size=i}}class j{get renderer(){return this._renderer}get screenWidth(){return this._screenWidth}get screenHeight(){return this._screenHeight}get containerElement(){return this._containerElement}get scale(){return this._scale}get scene(){return this._scene}get camera(){return this._camera}get sceneDirty(){return this._sceneDirty}set sceneDirty(e){this._sceneDirty=e}constructor(t,s,i,n,a){this._windows=[],this._scale=1,this._disposed=!1,this._sceneDirty=!1,this._disableStencil=!1,this._containerElement=t,this._screenWidth=s,this._screenHeight=i,this._windowImageFactory=n,this._cursor=new U(a),this._displayOverlay=new k(this._cursor),this._scene=new e.Scene,this._screen=new e.Object3D;const r=new e.Mesh(new e.PlaneGeometry(1,1,2,2),new e.MeshBasicMaterial({map:new e.DataTexture(new Uint8ClampedArray(4),1,1),side:e.BackSide,transparent:!0}));r.position.set(0,0,999),this._screen.add(r),this._camera=new e.OrthographicCamera(0,s,0,i,.1,1e4),this._camera.position.z=1e3,this._camera.lookAt(new l(0,0,0));const o=this._detectWebGL2(),h=new URL(window.location.href).searchParams,c="true"===h.get("webx-canvas");this._disableStencil="false"===h.get("webx-stencil"),!o.available||o.isSoftware||c?(console.log(`WebGL2 Info: available = ${o.available}, isSoftware = ${o.isSoftware}, vendor = ${o.vendor}, renderer = ${o.renderer}`),c?console.log("Canvas Renderer enabled through request param"):console.log("Falling back to Canvas Renderer"),this._renderer=new N,T.convertToImageDataInWorker=!0):this._renderer=new e.WebGLRenderer,this._renderer.setSize(s,i,!1);const d=window.getComputedStyle(this._containerElement).backgroundColor;this._renderer.setClearColor(d),this._render(),this._bindListeners(),this.resize(),this._renderer.render(this._scene,this._camera)}showScreen(){this._scene.add(this._screen),this._displayOverlay.visible=!0,this._sceneDirty=!0}hideScreen(){this._scene.remove(this._screen),this._displayOverlay.visible=!1,this._sceneDirty=!0}dispose(){this.hideScreen();for(const e of this._windows)this._screen.remove(e.mesh),e.dispose();this._clearElements(),this._renderer.dispose(),this._disposed=!0}animate(){this._disposed||(requestAnimationFrame(()=>{this.animate()}),this._displayOverlay.update(),this._sceneDirty&&(this._sceneDirty=!1,this.render()))}render(){this._renderer.render(this._scene,this._camera)}async createScreenshot(e,t){if(this._renderer instanceof N)return this._renderer.createScreenshot(e,t);{const s=this._renderer;return new Promise((i,n)=>{try{this.render(),s.domElement.toBlob(e=>{i(e)},e,t)}catch(e){n(e)}})}}addWindow(e){null==this._windows.find(t=>t.id===e.id)&&(this._windows.push(e),this._screen.add(e.mesh),this._sceneDirty=!0)}removeWindow(e){null!=this._windows.find(t=>t.id===e.id)&&(this._windows=this._windows.filter(t=>t.id!==e.id),e.dispose(),this._screen.remove(e.mesh),this._sceneDirty=!0)}updateWindows(e){return new Promise(t=>{this._windows.filter(t=>null==e.find(e=>e.id===t.id)).forEach(e=>this.removeWindow(e));let s=!1;e.forEach((i,n)=>{let a=this.getWindow(i.id);null==a?(s=!0,a=new x({id:i.id,x:i.x,y:i.y,z:n,width:i.width,height:i.height,shaped:i.shaped&&!this._disableStencil},this._windowImageFactory),this.addWindow(a),a.loadWindowImageAndShape().then(()=>{this.checkAllLoaded(e.map(e=>e.id))&&t()})):(a.shaped=i.shaped&&!this._disableStencil,a.setRectangle(i.x,i.y,n,i.width,i.height))}),s||t()})}checkAllLoaded(e){return e.map(e=>this.getWindow(e)).filter(e=>null!=e).map(e=>e.loaded).reduce((e,t)=>e&&t,!0)}updateImage(e,t,s,i){const n=this.getWindow(e);null==n||null==s&&null==i||(n.updateTexture(t,R(s),R(i),!0),this._sceneDirty=!0)}updateSubImages(t,s){const i=this.getWindow(t);if(null!=i&&i.colorMapValid){const t=i.colorMap,n=i.alphaMap;for(let a=0;a<s.length;a++){const r=s[a];this._renderer instanceof N?this._renderer.updateWindowRegion(i.mesh.id,R(r.colorMap),t,R(r.alphaMap),n,r.width,r.height,new e.Vector2(r.x,r.y)):(t&&r.colorMap&&this._renderer.copyTextureToTexture(R(r.colorMap),t,null,new e.Vector2(r.x,r.y)),n&&r.alphaMap&&this._renderer.copyTextureToTexture(R(r.alphaMap),n,null,new e.Vector2(r.x,r.y)))}i.updateTexture(i.depth,t,n,!1),this._sceneDirty=!0}}updateShape(e,t){if(this._disableStencil)return;const s=this.getWindow(e);null!=s&&null!=t&&(s.updateStencilTexture(R(t)),this._sceneDirty=!0)}setMouseCursor(e){this._cursor.setCursorId(e)}setMousePosition(e,t){this._cursor.setPosition(e,t)}getWindow(e){return this._windows.find(t=>t.id===e)}setScale(e){this._scale=e,this._sceneDirty=!0}autoScale(){const e=this._containerElement,{clientWidth:t,clientHeight:s}=e,{screenWidth:i,screenHeight:n}=this;this._scale=Math.min(t/i,s/n),this._sceneDirty=!0}resize(e){const t=this._boundsElement;e?this.setScale(e):this.autoScale(),t.style.transform=`scale(${this._scale},${this._scale})`}_clearElements(){for(;this._containerElement.firstChild;)this._containerElement.removeChild(this._containerElement.firstChild)}_createDisplayElement(){const e=document.createElement("div");return e.style.width=`${this._screenWidth}px`,e.style.height=`${this._screenHeight}px`,e.appendChild(this._displayOverlay.overlayElement),e.appendChild(this._renderer.domElement),e}_createDisplayBoundingElement(){const e=document.createElement("div");return e.appendChild(this._displayElement),e}_render(){this._clearElements(),this._displayElement=this._createDisplayElement(),this._boundsElement=this._createDisplayBoundingElement(),this._containerElement.appendChild(this._boundsElement)}_bindListeners(){this.resize=this.resize.bind(this)}_detectWebGL2(){const e=document.createElement("canvas").getContext("webgl2");if(!e)return{available:!1};const t=e.getParameter(e.RENDERER),s=e.getParameter(e.VENDOR);let i=null,n=null;const a=e.getExtension("WEBGL_debug_renderer_info");a&&(i=e.getParameter(a.UNMASKED_RENDERER_WEBGL),n=e.getParameter(a.UNMASKED_VENDOR_WEBGL));const r=(i||t||"").toLowerCase();return{available:!0,vendor:n||s,renderer:i||t,isSoftware:/swiftshader|llvmpipe|basic render|software/i.test(r)}}}var $,q=q||{};q.Keyboard=function(e){var t=this,s="_GUAC_KEYBOARD_HANDLED_BY_"+q.Keyboard._nextID++;this.onkeydown=null,this.onkeyup=null;var i={keyupUnreliable:!1,altIsTypableOnly:!1,capsLockKeyupUnreliable:!1};navigator&&navigator.platform&&(navigator.platform.match(/ipad|iphone|ipod/i)?i.keyupUnreliable=!0:navigator.platform.match(/^mac/i)&&(i.altIsTypableOnly=!0,i.capsLockKeyupUnreliable=!0));var n=function(e){var t=this;this.keyCode=e?e.which||e.keyCode:0,this.keyIdentifier=e&&e.keyIdentifier,this.key=e&&e.key,this.location=e?R(e):0,this.modifiers=e?q.Keyboard.ModifierState.fromKeyboardEvent(e):new q.Keyboard.ModifierState,this.timestamp=(new Date).getTime(),this.defaultPrevented=!1,this.keysym=null,this.reliable=!1,this.getAge=function(){return(new Date).getTime()-t.timestamp}},a=function(e){n.call(this,e),this.keysym=Z(this.key,this.location)||b(this.keyCode,this.location),this.keyupReliable=!i.keyupUnreliable,this.keysym&&!f(this.keysym)&&(this.reliable=!0),!this.keysym&&M(this.keyCode,this.keyIdentifier)&&(this.keysym=Z(this.keyIdentifier,this.location,this.modifiers.shift)),(this.modifiers.meta&&65511!==this.keysym&&65512!==this.keysym||65509===this.keysym&&i.capsLockKeyupUnreliable)&&(this.keyupReliable=!1);var t=!this.modifiers.ctrl&&!i.altIsTypableOnly;!i.altIsTypableOnly||65513!==this.keysym&&65514!==this.keysym||(this.keysym=65027),(!this.modifiers.alt&&this.modifiers.ctrl||t&&this.modifiers.alt||this.modifiers.meta||this.modifiers.hyper)&&(this.reliable=!0),m[this.keyCode]=this.keysym};a.prototype=new n;var r=function(e){n.call(this,e),this.keysym=w(this.keyCode),this.reliable=!0};r.prototype=new n;var o=function(e){n.call(this,e),this.keysym=b(this.keyCode,this.location)||Z(this.key,this.location),t.pressed[this.keysym]||(this.keysym=m[this.keyCode]||this.keysym),this.reliable=!0};o.prototype=new n;var h=[],l={8:[65288],9:[65289],12:[65291,65291,65291,65461],13:[65293],16:[65505,65505,65506],17:[65507,65507,65508],18:[65513,65513,65514],19:[65299],20:[65509],27:[65307],32:[32],33:[65365,65365,65365,65465],34:[65366,65366,65366,65459],35:[65367,65367,65367,65457],36:[65360,65360,65360,65463],37:[65361,65361,65361,65460],38:[65362,65362,65362,65464],39:[65363,65363,65363,65462],40:[65364,65364,65364,65458],45:[65379,65379,65379,65456],46:[65535,65535,65535,65454],91:[65511],92:[65512],93:[65383],96:[65456],97:[65457],98:[65458],99:[65459],100:[65460],101:[65461],102:[65462],103:[65463],104:[65464],105:[65465],106:[65450],107:[65451],109:[65453],110:[65454],111:[65455],112:[65470],113:[65471],114:[65472],115:[65473],116:[65474],117:[65475],118:[65476],119:[65477],120:[65478],121:[65479],122:[65480],123:[65481],144:[65407],145:[65300],225:[65027]},c={Again:[65382],AllCandidates:[65341],Alphanumeric:[65328],Alt:[65513,65513,65514],Attn:[64782],AltGraph:[65027],ArrowDown:[65364],ArrowLeft:[65361],ArrowRight:[65363],ArrowUp:[65362],Backspace:[65288],CapsLock:[65509],Cancel:[65385],Clear:[65291],Convert:[65315],Copy:[64789],Crsel:[64796],CrSel:[64796],CodeInput:[65335],Compose:[65312],Control:[65507,65507,65508],ContextMenu:[65383],Delete:[65535],Down:[65364],End:[65367],Enter:[65293],EraseEof:[64774],Escape:[65307],Execute:[65378],Exsel:[64797],ExSel:[64797],F1:[65470],F2:[65471],F3:[65472],F4:[65473],F5:[65474],F6:[65475],F7:[65476],F8:[65477],F9:[65478],F10:[65479],F11:[65480],F12:[65481],F13:[65482],F14:[65483],F15:[65484],F16:[65485],F17:[65486],F18:[65487],F19:[65488],F20:[65489],F21:[65490],F22:[65491],F23:[65492],F24:[65493],Find:[65384],GroupFirst:[65036],GroupLast:[65038],GroupNext:[65032],GroupPrevious:[65034],FullWidth:null,HalfWidth:null,HangulMode:[65329],Hankaku:[65321],HanjaMode:[65332],Help:[65386],Hiragana:[65317],HiraganaKatakana:[65319],Home:[65360],Hyper:[65517,65517,65518],Insert:[65379],JapaneseHiragana:[65317],JapaneseKatakana:[65318],JapaneseRomaji:[65316],JunjaMode:[65336],KanaMode:[65325],KanjiMode:[65313],Katakana:[65318],Left:[65361],Meta:[65511,65511,65512],ModeChange:[65406],NonConvert:[65314],NumLock:[65407],PageDown:[65366],PageUp:[65365],Pause:[65299],Play:[64790],PreviousCandidate:[65342],PrintScreen:[65377],Redo:[65382],Right:[65363],Romaji:[65316],RomanCharacters:null,Scroll:[65300],Select:[65376],Separator:[65452],Shift:[65505,65505,65506],SingleCandidate:[65340],Super:[65515,65515,65516],Tab:[65289],UIKeyInputDownArrow:[65364],UIKeyInputEscape:[65307],UIKeyInputLeftArrow:[65361],UIKeyInputRightArrow:[65363],UIKeyInputUpArrow:[65362],Up:[65362],Undo:[65381],Win:[65511,65511,65512],Zenkaku:[65320],ZenkakuHankaku:[65322]},d={65027:!0,65505:!0,65506:!0,65507:!0,65508:!0,65509:!0,65511:!0,65512:!0,65513:!0,65514:!0,65515:!0,65516:!0};this.modifiers=new q.Keyboard.ModifierState,this.pressed={};var u={},p={},m={},_=null,y=null,g=function(e,t){return e?e[t]||e[0]:null},f=function(e){return e>=0&&e<=255||16777216==(4294901760&e)};function Z(e,t,s){if(!e)return null;var i,n=e.indexOf("U+");if(n>=0){var a=e.substring(n+2);i=String.fromCharCode(parseInt(a,16))}else{if(1!==e.length||3===t)return g(c[e],t);i=e}return!0===s?i=i.toUpperCase():!1===s&&(i=i.toLowerCase()),w(i.charCodeAt(0))}function w(e){return function(e){return e<=31||e>=127&&e<=159}(e)?65280|e:e>=0&&e<=255?e:e>=256&&e<=1114111?16777216|e:null}function b(e,t){return g(l[e],t)}var M=function(e,t){if(!t)return!1;var s=t.indexOf("U+");return-1===s||(e!==parseInt(t.substring(s+2),16)||(e>=65&&e<=90||e>=48&&e<=57))};this.press=function(e){if(null!==e){if(!t.pressed[e]&&(t.pressed[e]=!0,t.onkeydown)){var s=t.onkeydown(e);return p[e]=s,window.clearTimeout(_),window.clearInterval(y),d[e]||(_=window.setTimeout(function(){y=window.setInterval(function(){t.onkeyup(e),t.onkeydown(e)},50)},500)),s}return p[e]||!1}},this.release=function(e){t.pressed[e]&&(delete t.pressed[e],delete u[e],window.clearTimeout(_),window.clearInterval(y),null!==e&&t.onkeyup&&t.onkeyup(e))},this.type=function(e){for(var s=0;s<e.length;s++){var i=w(e.codePointAt?e.codePointAt(s):e.charCodeAt(s));t.press(i),t.release(i)}},this.reset=function(){for(var e in t.pressed)t.release(parseInt(e));h=[]};var I=function(e,s,i){var n,a=i.modifiers[e],r=t.modifiers[e];if(-1===s.indexOf(i.keysym))if(r&&!1===a)for(n=0;n<s.length;n++)t.release(s[n]);else if(!r&&a){for(n=0;n<s.length;n++)if(t.pressed[s[n]])return;var o=s[0];i.keysym&&(u[o]=!0),t.press(o)}},S=function(e){I("alt",[65513,65514,65027],e),I("shift",[65505,65506],e),I("ctrl",[65507,65508],e),I("meta",[65511,65512],e),I("hyper",[65515,65516],e),t.modifiers=e.modifiers};function W(){var e,s=G();if(!s)return!1;do{e=s,s=G()}while(null!==s);return function(){for(var e in t.pressed)if(!u[e])return!1;return!0}()&&t.reset(),e.defaultPrevented}var G=function(){var e=h[0];if(!e)return null;if(!(e instanceof a))return e instanceof o&&!i.keyupUnreliable?(s=e.keysym)?(t.release(s),delete m[e.keyCode],e.defaultPrevented=!0,S(e),h.shift()):(t.reset(),e):h.shift();var s=null,n=[];if(65511===e.keysym||65512===e.keysym){if(1===h.length)return null;if(h[1].keysym!==e.keysym){if(!h[1].modifiers.meta)return h.shift()}else if(h[1]instanceof a)return h.shift()}if(e.reliable?(s=e.keysym,n=h.splice(0,1)):h[1]instanceof r?(s=h[1].keysym,n=h.splice(0,2)):h[1]&&(s=e.keysym,n=h.splice(0,1)),n.length>0){if(S(e),s){!function(e){t.modifiers.ctrl&&t.modifiers.alt&&(e>=65&&e<=90||e>=97&&e<=122||(e<=255||16777216==(4278190080&e))&&(t.release(65507),t.release(65508),t.release(65513),t.release(65514)))}(s);var l=!t.press(s);m[e.keyCode]=s,e.keyupReliable||t.release(s);for(var c=0;c<n.length;c++)n[c].defaultPrevented=l}return e}return null},R=function(e){return"location"in e?e.location:"keyLocation"in e?e.keyLocation:0},x=function(e){return!e[s]&&(e[s]=!0,!0)},U=function(e){if(t.onkeydown&&x(e)){var s=new a(e);e.isComposing||229===s.keyCode||(h.push(s),W()&&e.preventDefault())}},v=function(e){(t.onkeydown||t.onkeyup)&&x(e)&&(h.push(new r(e)),W()&&e.preventDefault())},X=function(e){t.onkeyup&&x(e)&&(e.preventDefault(),h.push(new o(e)),W())},V=function(e){(t.onkeydown||t.onkeyup)&&x(e)&&e.data&&!e.isComposing&&t.type(e.data)},C=function(t){e.removeEventListener("input",V,!1)},E=function(e){(t.onkeydown||t.onkeyup)&&x(e)&&e.data&&t.type(e.data)};this.listenTo=function(e){e.addEventListener("keydown",U,{passive:!1}),e.addEventListener("keypress",v,{passive:!1}),e.addEventListener("keyup",X,{passive:!1}),e.addEventListener("input",V,!1),e.addEventListener("compositionend",E,!1),e.addEventListener("compositionstart",C,!1)},e&&t.listenTo(e),this.dispose=function(){e&&(e.removeEventListener("keydown",U,!0),e.removeEventListener("keypress",v,!0),e.removeEventListener("keyup",X,!0),e.removeEventListener("input",V,!1),e.removeEventListener("compositionend",E,!1),e.removeEventListener("compositionstart",C,!1))}},q.Keyboard._nextID=0,q.Keyboard.ModifierState=function(){this.shift=!1,this.ctrl=!1,this.alt=!1,this.meta=!1,this.hyper=!1},q.Keyboard.ModifierState.fromKeyboardEvent=function(e){var t=new q.Keyboard.ModifierState;return t.shift=e.shiftKey,t.ctrl=e.ctrlKey,t.alt=e.altKey,t.meta=e.metaKey,e.getModifierState&&(t.hyper=e.getModifierState("OS")||e.getModifierState("Super")||e.getModifierState("Hyper")||e.getModifierState("Win")),t};class ee{set onKeyDown(e){this._keyboard.onkeydown=e}set onKeyUp(e){this._keyboard.onkeyup=e}constructor(e){this._keyboard=new q.Keyboard(e)}dispose(){this._keyboard.onkeydown=null,this._keyboard.onkeyup=null,this._keyboard.dispose()}reset(){this._keyboard.reset()}}class te{get x(){return this._x}set x(e){this._x=e}get y(){return this._y}set y(e){this._y=e}get left(){return this._left}set left(e){this._left=e}get middle(){return this._middle}set middle(e){this._middle=e}get right(){return this._right}set right(e){this._right=e}get up(){return this._up}set up(e){this._up=e}get down(){return this._down}set down(e){this._down=e}get shift(){return this._shift}set shift(e){this._shift=e}get ctrl(){return this._ctrl}set ctrl(e){this._ctrl=e}get alt(){return this._alt}set alt(e){this._alt=e}constructor(e){const{x:t,y:s,left:i,middle:n,right:a,up:r,down:o}=e;this._x=t,this._y=s,this._left=i,this._middle=n,this._right=a,this._up=r,this._down=o}releaseButtons(){this._left=!1,this._middle=!1,this._right=!1}getButtonMask(){let e=0;return e|=this._left?256:0,e|=this._middle?512:0,e|=this._right?1024:0,e|=this._up?2048:0,e|=this._down?4096:0,e|=this._shift?1:0,e|=this._ctrl?4:0,e|=this._alt?8:0,e}clone(){return new te({x:this._x,y:this._y,left:this._left,middle:this._middle,right:this._right,up:this._up,down:this._down})}}class se{constructor(e){this._element=e,this._contextMenuHandler=this._handleContextMenu.bind(this),this._mouseMoveHandler=this._handleMouseMove.bind(this),this._mouseDownHandler=this._handleMouseDown.bind(this),this._mouseUpHandler=this._handleMouseUp.bind(this),this._mouseOutHandler=this._handleMouseOut.bind(this),this._mouseWheelHandler=this._handleMouseWheel.bind(this),this._bindListeners(),this._createDefaultState()}dispose(){this._unbindListeners()}_cancelEvent(e){e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1}_bindListeners(){const e=this._element;e.addEventListener("contextmenu",this._contextMenuHandler,!1),e.addEventListener("mousemove",this._mouseMoveHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mouseup",this._mouseUpHandler),e.addEventListener("mouseout",this._mouseOutHandler),["DOMMouseScroll","mousewheel","wheel"].forEach(t=>{e.addEventListener(t,this._mouseWheelHandler,{passive:!1})}),this.reset=this.reset.bind(this)}_unbindListeners(){const e=this._element;e.removeEventListener("contextmenu",this._contextMenuHandler,!1),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mouseout",this._mouseOutHandler),["DOMMouseScroll","mousewheel","wheel"].forEach(t=>{e.removeEventListener(t,this._mouseWheelHandler)}),this.reset=this.reset.bind(this)}_createDefaultState(){this._currentState=new te({x:0,y:0,left:!1,middle:!1,right:!1,up:!1,down:!1})}_handleMouseUp(e){switch(e.button){case 0:this._currentState.left=!1;break;case 1:this._currentState.middle=!1;break;case 2:this._currentState.right=!1}this._notifyMouseUp()}_handleMouseDown(e){switch(this._cancelEvent(e),e.button){case 0:this._currentState.left=!0;break;case 1:this._currentState.middle=!0;break;case 2:this._currentState.right=!0}this._notifyMouseDown()}_handleMouseWheel(e){e.deltaY<0&&(this._currentState.up=!0,this._notifyMouseDown(),this._currentState.up=!1,this._notifyMouseUp()),e.deltaY>0&&(this._currentState.down=!0,this._notifyMouseDown(),this._currentState.down=!1,this._notifyMouseUp()),this._cancelEvent(e)}_handleMouseOut(){this._currentState.releaseButtons(),this._notifyMouseOut()}_handleMouseMove(e){this._cancelEvent(e);const t=this._element.firstElementChild.getBoundingClientRect();this._currentState.x=e.clientX-t.left,this._currentState.y=e.clientY-t.top,this._notifyMouseMove()}reset(){this._currentState.releaseButtons()}_handleContextMenu(e){this._cancelEvent(e)}_notifyMouseMove(){this.onMouseMove(this._currentState.clone())}_notifyMouseUp(){this.onMouseUp(this._currentState.clone())}_notifyMouseDown(){this.onMouseDown(this._currentState.clone())}_notifyMouseOut(){this.onMouseOut(this._currentState.clone())}onMouseMove(e){}onMouseDown(e){}onMouseUp(e){}onMouseOut(e){}}class ie{constructor(e){this.synchronous=!1,this.id=ie._INSTRUCTION_COUNTER++,this.type=e}}ie._INSTRUCTION_COUNTER=1;class ne{constructor(e,t){this._timeoutId=0,this.instructionId=e.id,this.data=null,t&&(this._timeoutMs=t,this._timeoutId=setTimeout(()=>{this.reject("Request failed due to timeout")},this._timeoutMs))}then(e){return this._onResponseReceived=e,this}catch(e){return this._onError=e,this}resolve(e){this._timeoutId>0&&clearTimeout(this._timeoutId),null!=this._onResponseReceived&&this._onResponseReceived(e)}reject(e){this._onError&&this._onError(new Error(e))}}!function(e){e[e.CONNECT=1]="CONNECT",e[e.WINDOWS=2]="WINDOWS",e[e.IMAGE=3]="IMAGE",e[e.SCREEN=4]="SCREEN",e[e.MOUSE=5]="MOUSE",e[e.KEYBOARD=6]="KEYBOARD",e[e.CURSOR_IMAGE=7]="CURSOR_IMAGE",e[e.QUALITY=8]="QUALITY",e[e.PONG=9]="PONG",e[e.DATA_ACK=10]="DATA_ACK",e[e.CLIPBOARD=11]="CLIPBOARD",e[e.SHAPE=12]="SHAPE"}($||($={})),function(e){e.fromString=function(t){switch(t){case"CONNECT":return e.CONNECT;case"WINDOWS":return e.WINDOWS;case"IMAGE":return e.IMAGE;case"SCREEN":return e.SCREEN;case"MOUSE":return e.MOUSE;case"KEYBOARD":return e.KEYBOARD;case"CURSOR_IMAGE":return e.CURSOR_IMAGE;case"QUALITY":return e.QUALITY;case"PONG":return e.PONG;case"DATA_ACK":return e.DATA_ACK;case"CLIPBOARD":return e.CLIPBOARD;case"SHAPE":return e.SHAPE}}}($||($={}));class ae extends ie{constructor(e){super($.CONNECT),this.parameters=e}}class re extends ie{constructor(){super($.SCREEN)}}class oe extends ie{constructor(){super($.WINDOWS)}}class he extends ie{constructor(e){super($.IMAGE),this.windowId=e}}class le extends ie{constructor(e,t,s){super($.MOUSE),this.x=e,this.y=t,this.buttonMask=s}}class ce extends ie{constructor(e,t){super($.KEYBOARD),this.key=e,this.pressed=t}}class de extends ie{constructor(e){super($.CURSOR_IMAGE),this.cursorId=e}}class ue extends ie{constructor(e){super($.QUALITY),this.qualityIndex=e}}class pe extends ie{constructor(e){super($.PONG),this.timestampMs=e}}class me extends ie{constructor(e,t){super($.DATA_ACK),this.timestampMs=e,this.dataLength=t}}class _e extends ie{constructor(e){super($.CLIPBOARD),this.clipboardContent=e}}class ye extends ie{constructor(e){super($.SHAPE),this.windowId=e}}class ge{}class fe{}class Ze{}class we{static randomColour(){const e=Math.floor(Math.random()*we._COLOURS.length);return we._COLOURS[e]}static indexedColour(e){return e%=we._COLOURS.length,we._COLOURS[e]}}we._COLOURS=["#FF6633","#FFB399","#FF33FF","#FFFF99","#00B3E6","#E6B333","#3366E6","#999966","#99FF99","#B34D4D","#80B300","#809900","#E6B3B3","#6680B3","#66991A","#FF99E6","#CCFF1A","#FF1A66","#E6331A","#33FFCC","#66994D","#B366CC","#4D8000","#B33300","#CC80CC","#66664D","#991AFF","#E666FF","#4DB3FF","#1AB399","#E666B3","#33991A","#CC9999","#B3B31A","#00E680","#4D8066","#809980","#E6FF80","#1AFF33","#999933","#FF3380","#CCCC00","#66E64D","#4D80CC","#9900B3","#E64D66","#4DB380","#FF4D4D","#99E6E6","#6666FF"];class be{constructor(e=0,t=0,s=0){this.major=e,this.minor=t,this.patch=s,this.version=`${e}.${t}.${s}`,this.versionNumber=parseFloat(`${e}.${t}`)}}class Me extends fe{constructor(e){super(),this._display=e,this._debugLayer=new d,this._currentZ=0,this._disposed=!1,this._tweenGroup=new u,this._debugLayer.position.set(0,0,999),this._scene=this._display.scene,this._scene.add(this._debugLayer),this._animate()}_createMesh(e,t,i,n,a){const o=new r({color:a,opacity:.8,transparent:!0});o.side=s;const l=new h(Me._PLANE_GEOMETRY,o);l.position.set(e+i/2,t+n/2,this._currentZ),l.scale.set(i,n,1),this._currentZ+=1e-4,this._debugLayer.add(l),new p(o,this._tweenGroup).to({opacity:0},500).easing(m.Quadratic.Out).onComplete(()=>this._debugLayer.remove(l)).onUpdate(()=>this._display.sceneDirty=!0).start()}handle(e){if(e.type===C.IMAGE){const t=e,s=this._display.getWindow(t.windowId),{width:i,height:n}=t.colorMap.image;this._createMesh(s.x,s.y,i,n,we.indexedColour(s.colorIndex))}else if(e.type===C.SUBIMAGES){const t=e,s=this._display.getWindow(t.windowId);t.subImages.forEach(e=>{this._createMesh(s.x+e.x,s.y+e.y,e.width,e.height,we.indexedColour(s.colorIndex))})}}destroy(){this._disposed=!0,this._debugLayer.children.forEach(e=>{e.material.dispose()}),this._debugLayer.clear(),this._debugLayer.removeFromParent()}_animate(){this._disposed||requestAnimationFrame(e=>{this._tweenGroup.update(e),this._animate()})}}Me._PLANE_GEOMETRY=new c(1,1,2,2);class Ie{constructor(e,t){this._buffer=new ArrayBuffer(t+32),this._offset=20,e.synchronous?this.putUInt32(2147483648|e.type):this.putUInt32(e.type),this.putUInt32(e.id),this.putUInt32(0)}_getNextOffset(e){const t=this._offset%e>0?e-this._offset%e:0,s=this._offset+t;return this._offset+=e+t,s}putInt32(e){const t=this._getNextOffset(4);return new Int32Array(this._buffer,t,1)[0]=e,this}putUInt8(e){const t=this._getNextOffset(1);return new Uint8Array(this._buffer,t,1)[0]=e,this}putUInt32(e){const t=this._getNextOffset(4);return new Uint32Array(this._buffer,t,1)[0]=e,this}putUInt8Array(e,t){const s=this._getNextOffset(8);return new Uint8Array(this._buffer,s,t).set(e),this}putString(e){for(let t=0;t<e.length;t++)this.putUInt8(e.charCodeAt(t));return this}putBoolean(e){return this.putUInt32(!0===e?255:0),this}buffer(){return this._buffer}}class Se{get readOffset(){return this._readOffset}get buffer(){return this._buffer}constructor(e){this._buffer=e,this._readOffset=24,this._encoder=new TextDecoder("utf-8"),this._readOffset=24,this.timestampMs=this.getUint8Array(8),this.messageTypeId=this.getUint32(),this.messageId=this.getUint32(),this.bufferLength=this.getUint32(),this._readOffset=Se.MESSAGE_HEADER_LENGTH}getInt32(){const e=this._getNextReadOffset(4);return new Int32Array(this._buffer,e,1)[0]}getUint32(){const e=this._getNextReadOffset(4);return new Uint32Array(this._buffer,e,1)[0]}getFloat(){const e=this._getNextReadOffset(4);return new Float32Array(this._buffer,e,1)[0]}getUint8Array(e){const t=new Uint8Array(this._buffer,this._readOffset,e);return this._readOffset+=e,t}getString(e){const t=new Uint8Array(this._buffer,this._readOffset,e);return this._readOffset+=e,this._encoder.decode(t)}_getNextReadOffset(e){const t=this._readOffset%e>0?e-this._readOffset%e:0,s=this._readOffset+t;return this._readOffset+=e+t,s}}Se.MESSAGE_HEADER_LENGTH=48;class We{encode(e){return e.type===$.MOUSE?this._createMouseInstruction(e):e.type===$.KEYBOARD?this._createKeyboardInstruction(e):e.type===$.CURSOR_IMAGE?this._createCursorImageInstruction(e):e.type===$.IMAGE?this._createImageInstruction(e):e.type===$.CONNECT?this._createConnectInstruction(e):e.type===$.SCREEN?this._createScreenInstruction(e):e.type===$.WINDOWS?this._createWindowsInstruction(e):e.type===$.QUALITY?this._createQualityInstruction(e):e.type===$.PONG?this._createPongInstruction(e):e.type===$.DATA_ACK?this._createDataAckInstruction(e):e.type===$.CLIPBOARD?this._createClipboardInstruction(e):e.type===$.SHAPE?this._createShapeInstruction(e):null}_createMouseInstruction(e){return new Ie(e,12).putInt32(e.x).putInt32(e.y).putUInt32(e.buttonMask).buffer()}_createCursorImageInstruction(e){return new Ie(e,4).putInt32(e.cursorId).buffer()}_createImageInstruction(e){return new Ie(e,4).putUInt32(e.windowId).buffer()}_createKeyboardInstruction(e){return new Ie(e,8).putUInt32(e.key).putBoolean(e.pressed).buffer()}_createScreenInstruction(e){return new Ie(e,0).buffer()}_createWindowsInstruction(e){return new Ie(e,0).buffer()}_createConnectInstruction(e){return new Ie(e,0).buffer()}_createQualityInstruction(e){return new Ie(e,4).putUInt32(e.qualityIndex).buffer()}_createPongInstruction(e){return new Ie(e,8).putUInt8Array(e.timestampMs,8).buffer()}_createDataAckInstruction(e){return new Ie(e,12).putUInt8Array(e.timestampMs,8).putUInt32(e.dataLength).buffer()}_createClipboardInstruction(e){const t=4+e.clipboardContent.length;return new Ie(e,t).putUInt32(e.clipboardContent.length).putString(e.clipboardContent).buffer()}_createShapeInstruction(e){return new Ie(e,4).putUInt32(e.windowId).buffer()}}class Ge{constructor(){this._textureFactory=new G}decode(e){const{messageTypeId:t}=e;return t===C.NOP?this._createNopMessage():t===C.CONNECTION?this._createConnectionMessage(e):t===C.SCREEN?this._createScreenMessage(e):t===C.WINDOWS?this._createWindowsMessage(e):t===C.IMAGE?this._createImageMessage(e):t===C.SUBIMAGES?this._createSubImagesMessage(e):t===C.MOUSE?this._createMouseMessage(e):t===C.CURSOR_IMAGE?this._createCursorImageMessage(e):t===C.PING?this._createPingMessage():t===C.QUALITY?this._createQualityMessage(e):t===C.CLIPBOARD?this._createClipboardMessage(e):t===C.SHAPE?this._createShapeMessage(e):void console.error(`Failed to decode message with typeId ${t}`)}_determineMimeType(e){return"jpg"===e.substr(0,3)?"image/jpeg":"png"===e.substr(0,3)?"image/png":"image/bmp"}async _createNopMessage(){return new B}async _createConnectionMessage(e){const t=e.getUint32();return new J(t>0)}_createImageMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=e.getUint32(),a=e.getString(4),r=this._determineMimeType(a),o=e.getUint32(),h=e.getUint32(),l=e.getUint8Array(o),c=e.getUint8Array(h),d=this._textureFactory.createTextureFromArray(l,r,I),u=this._textureFactory.createTextureFromArray(c,r,S);Promise.all([d,u]).then(([a,r])=>{t(new z(i,n,a,r,s,e.bufferLength))})})}_createSubImagesMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=new Array,a=e.getUint32();for(let t=0;t<a;t++){const t=e.getInt32(),s=e.getInt32(),i=e.getInt32(),a=e.getInt32(),r=e.getUint32(),o=e.getString(4),h=this._determineMimeType(o),l=e.getUint32(),c=e.getUint32(),d=e.getUint8Array(l),u=e.getUint8Array(c),p=new Promise((e,n)=>{const o=this._textureFactory.createTextureFromArray(d,h,I),l=this._textureFactory.createTextureFromArray(u,h,S);Promise.all([o,l]).then(([n,o])=>{e(new y({x:t,y:s,width:i,height:a,depth:r,colorMap:n,alphaMap:o}))}).catch(n)});n.push(p)}Promise.all(n).then(n=>{t(new H(i,n,s,e.bufferLength))})})}async _createMouseMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32(),n=e.getUint32();return new D(s,i,n,t)}async _createWindowsMessage(e){const t=e.getUint32(),s=e.getUint32(),i=new Array;for(let t=0;t<s;t++){const t=e.getUint32(),s=e.getInt32(),n=e.getInt32(),a=e.getInt32(),r=e.getInt32();i.push({id:t,x:s,y:n,width:a,height:r,shaped:!1})}if(M.version.versionNumber>=1.4&&e.bufferLength-e.readOffset>=4){const t=e.getUint32();for(let s=0;s<t;s++){const t=e.getUint32();i.find(e=>e.id===t).shaped=!0}}return new F(i.map(e=>new _(e)),t)}async _createCursorImageMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32(),n=e.getInt32(),a=e.getInt32(),r=e.getUint32(),o=e.getUint32(),h=e.getUint8Array(o);try{const e=await this._textureFactory.createTextureFromArray(h,"image/png",I);return new P(s,i,n,a,r,e,t)}catch(e){console.error(`Failed to get texture for cursor image: ${e}`)}}async _createScreenMessage(e){const t=e.getUint32(),s=e.getInt32(),i=e.getInt32();let n=10;e.bufferLength-e.readOffset>=4&&(n=e.getInt32());let a=0,r=0,o=0;return e.bufferLength-e.readOffset>=12&&(a=e.getUint32(),r=e.getUint32(),o=e.getUint32()),M.version=new be(a,r,o),new Y({width:s,height:i},n,new be(a,r,o),t)}async _createPingMessage(){return new K}async _createQualityMessage(e){const t=e.getUint32(),s=e.getFloat(),i=e.getFloat(),n=e.getFloat(),a=e.getFloat();return new O(t,s,i,n,a)}async _createClipboardMessage(e){const t=e.getUint32(),s=e.getString(t);return new A(s)}_createShapeMessage(e){return new Promise(t=>{const s=e.getUint32(),i=e.getUint32(),n=e.getString(4),a=this._determineMimeType(n),r=e.getUint32(),o=e.getUint8Array(r);this._textureFactory.createTextureFromArray(o,a,S).then(n=>{t(new Q(i,n,s,e.bufferLength))})})}}var Re,xe=V("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZXtjb25zdHJ1Y3RvcihlLHQ9MCl7dGhpcy50eXBlPWUsdGhpcy5jb21tYW5kSWQ9dH1zdGF0aWMgZ2V0IGNvbnZlcnRUb0ltYWdlRGF0YUluV29ya2VyKCl7cmV0dXJuIGUuX2NvbnZlcnRUb0ltYWdlRGF0YUluV29ya2VyfXN0YXRpYyBzZXQgY29udmVydFRvSW1hZ2VEYXRhSW5Xb3JrZXIodCl7ZS5fY29udmVydFRvSW1hZ2VEYXRhSW5Xb3JrZXI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XJuIG5ldyB3KHtkYXRhOmEuZGF0YSx3aWR0aDpzLGhlaWdodDpyfSl9aWYoZSl7Y29uc3QgdD1lLndpZHRoLHM9ZS5oZWlnaHQscj0oZT0+e2lmKGUpe2NvbnN0IHQ9ZS53aWR0aCxzPWUuaGVpZ2h0LHI9bmV3IE9mZnNjcmVlbkNhbnZhcyh0LHMpLmdldENvbnRleHQoIjJkIix7d2lsbFJlYWRGcmVxdWVudGx5OiEwfSk7cmV0dXJuIHIuZHJhd0ltYWdlKGUsMCwwKSxyLmdldEltYWdlRGF0YSgwLDAsdCxzKX1yZXR1cm4gbnVsbH0pKGUuaW1hZ2UpO3JldHVybiBuZXcgdyh7ZGF0YTpyLmRhdGEsd2lkdGg6dCxoZWlnaHQ6c30pfXJldHVybiBudWxsfX0oKTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9V2ViWE1lc3NhZ2VEZWNvZGVyV29ya2VyLmpzLm1hcAoK");class Ue{constructor(){this._pending=new Map,this._nextId=1,this._instructionEncoder=new We,this._messageDecoder=new Ge,"undefined"!=typeof Worker&&(this._worker=new xe,this._worker.onmessage=e=>{const{id:t,message:s,error:i}=e.data,n=this._pending.get(t);if(this._pending.delete(t),i)console.error(i);else if(n){const e=(e=>{let t;return e&&(e.type===C.NOP?t=Object.create(B.prototype):e.type===C.CONNECTION?t=Object.create(J.prototype):e.type===C.SCREEN?t=Object.create(Y.prototype):e.type===C.WINDOWS?t=Object.create(F.prototype):e.type===C.IMAGE?t=Object.create(z.prototype):e.type===C.SUBIMAGES?t=Object.create(H.prototype):e.type===C.MOUSE?t=Object.create(D.prototype):e.type===C.CURSOR_IMAGE?t=Object.create(P.prototype):e.type===C.PING?t=Object.create(K.prototype):e.type===C.QUALITY?t=Object.create(O.prototype):e.type===C.CLIPBOARD?t=Object.create(A.prototype):e.type===C.SHAPE&&(t=Object.create(Q.prototype)),t&&Object.assign(t,e)),t})(s);n(e)}})}terminate(){this._worker.terminate(),this._pending.clear()}serializeInstruction(e){const t=this._instructionEncoder.encode(e);return null==t&&console.warn("Could not serialize instruction: Unknown type"),t}async deserializeMessage(e){if(this._worker&&(e=>{switch(e.messageTypeId){case C.IMAGE:case C.SUBIMAGES:case C.SHAPE:return!0;default:return!1}})(e))return new Promise(t=>{const s=this._nextId++;this._pending.set(s,t);const i=[e.buffer];this._worker.postMessage({id:s,buffer:e.buffer,convertToImageData:T.convertToImageDataInWorker},i)});try{const t=await this._messageDecoder.decode(e);return null==t&&console.error("Failed to decode message data"),t}catch(e){console.error(`Caught error decoding message data: ${e.message}`)}}}class ve{constructor(){this._serializer=new Ue,this._instructionResponses=new Map}terminate(){this._serializer.terminate()}sendInstruction(e){const t=this._serializer.serializeInstruction(e);this.send(t)}sendRequest(e,t){e.synchronous=!0;const s=new ne(e,t=t||1e4);return this._instructionResponses.set(e.id,s),new Promise((t,i)=>{const n=this._serializer.serializeInstruction(e);this.send(n),s.then(t).catch(t=>{this._instructionResponses.delete(e.id),i(t)})})}async onMessage(e){if(0===e.byteLength)return console.warn("Got a zero length message"),null;if(e.byteLength<Se.MESSAGE_HEADER_LENGTH)return console.warn("Message does not contain a valid header"),null;const t=new Se(e);this._handleCriticalMessages(t),this.handleReceivedBytes(e);const s=await this._serializer.deserializeMessage(t);if(null!=s)if(null!=s.commandId&&null!=this._instructionResponses.get(s.commandId)){const e=this._instructionResponses.get(s.commandId);this._instructionResponses.delete(s.commandId),e.resolve(s)}else this.handleMessage(s)}handleMessage(e){throw new Error("Method not implemented.")}handleReceivedBytes(e){throw new Error("Method not implemented.")}handleSentBytes(e){throw new Error("Method not implemented")}handleClose(e){this._instructionResponses.forEach(e=>{e.reject("Tunnel closed")}),this.onClosed()}onClosed(){console.log("Websocket closed")}_handleCriticalMessages(e){e.messageTypeId==C.PING?this.sendInstruction(new pe(e.timestampMs)):e.messageTypeId!=C.SUBIMAGES&&e.messageTypeId!=C.IMAGE||e.bufferLength>ve.MIN_BUFFER_LENGTH_FOR_ACK&&this.sendInstruction(new me(e.timestampMs,e.bufferLength))}}ve.MIN_BUFFER_LENGTH_FOR_ACK=32768;class Xe extends ve{constructor(e,t={}){if(super(),this._socketOpen=!1,this._connectionOptions=t,"ws:"!==e.substring(0,3)&&"wss:"!==e.substring(0,4)){const t=window.location,s="https:"===t.protocol?"wss:":"ws:",i=t.hostname,n=t.port?`:${t.port}`:"";e="/"===e.substring(0,1)?`${s}//${i}${n}${e}`:`${s}//${i}${n}/${e}`}this._url=e}getSocket(){return this._socket}send(e){null!=this._socket&&(this._socket.send(e),this.handleSentBytes(e))}connect(e){const t={...this._connectionOptions,...e},s=new URLSearchParams(t),i=`${this._url}?${s}`;return new Promise((e,t)=>{this._socket=new WebSocket(i),this._socket.binaryType="arraybuffer",this._socket.onopen=()=>{this._socketOpen=!0,e(null)},this._socket.onerror=e=>t(e),this._socket.onclose=this.handleClose.bind(this),this._socket.onmessage=e=>this.onMessage(e.data)})}disconnect(){this._socket&&(this._socketOpen=!1,this._socket.close(),this._socket=null)}isConnected(){return this._socketOpen}}class Ve{constructor(e){this._tunnel=e,this._cursorMap=new Map}async getCursor(e){const t=this._cursorMap.get(e);if(null!=t)return{cursor:t};{const t=await this._tunnel.sendRequest(new de(e)),s={xHot:t.xHot,yHot:t.yHot,cursorId:t.cursorId,texture:t.texture};return this._cursorMap.set(t.cursorId,s),{x:t.x,y:t.y,cursor:s}}}}class Ce{constructor(e){this._tunnel=e}async getWindowTexture(e){try{const t=await this._tunnel.sendRequest(new he(e));return{depth:t.depth,colorMap:t.colorMap,alphaMap:t.alphaMap}}catch(e){console.warn("Failed to get texture: "+e)}}async getWindowStencilTexture(e){try{return{stencilMap:(await this._tunnel.sendRequest(new ye(e))).stencilMap}}catch(e){return console.warn("Failed to get stencil texture: "+e),null}}}!function(e){e[e.STARTING=0]="STARTING",e[e.RUNNING=1]="RUNNING"}(Re||(Re={}));class Ee{constructor(){this._connected=!1,this._connectionCallback=()=>{},this._connectionError=()=>{},this._connectionStatusCallback=()=>{}}onConnected(e,t){return this._timeoutMs=e||1e4,this._connectionStatusCallback=t,new Promise((e,t)=>{this._connected?e():(this._connectionCallback=()=>{window.clearTimeout(this._timeout),this._timeout=null,e()},this._connectionError=()=>{this._timeout=null,t(new Error("Connection timed out"))},this._createTimer())})}setConnected(e){e?this._connectionStatusCallback(Re.STARTING):(this._connected=!0,this._connectionStatusCallback(Re.RUNNING),this._connectionCallback())}resetTimer(){this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null,this._createTimer())}dispose(){this._timeout&&window.clearTimeout(this._timeout)}_createTimer(){this._timeout=window.setTimeout(()=>{this._connectionError()},this._timeoutMs)}}const{version:Le}=require("../package.json");class Ne{get tunnel(){return this._tunnel}get tracers(){return this._tracers}get display(){return this._display}get mouse(){return this._mouse}get keyboard(){return this._keyboard}set clipboardHandler(e){this._clipboardHandler=e}get maxQualityIndex(){return this._maxQualityIndex}constructor(e){this._tunnel=e,this._tracers=new Map,this._clipboardHandler=e=>{},this._connectionHandler=new Ee,this._maxQualityIndex=10,this._windowImageFactory=new Ce(this._tunnel),this._cursorFactory=new Ve(this._tunnel)}async connect(e,t){this._onCloseCallback=e,this._tunnel.handleMessage=this._handleMessage.bind(this),this._tunnel.handleReceivedBytes=this._handleReceivedBytes.bind(this),this._tunnel.handleSentBytes=this._handleSentBytes.bind(this),this._tunnel.onClosed=this._onTunnelClosed.bind(this),await this._tunnel.connect({...t,"client-version":Le})}disconnect(){this._tunnel.disconnect(),this._tunnel.terminate()}async initialise(e,t){try{t={useDefaultMouseAdapter:!0,useDefaultKeyboardAdapter:!0,waitForConnectionWithTimeout:1e4,connectionStatusCallback:()=>{},...t};const{useDefaultMouseAdapter:s,useDefaultKeyboardAdapter:i,waitForConnectionWithTimeout:n,connectionStatusCallback:a}=t;n>0&&await this._connectionHandler.onConnected(n,a);const r=await this._getScreenMessage(),{width:o,height:h}=r.screenSize;this._maxQualityIndex=r.maxQualityIndex,M.version=r.engineVersion,this._display=this.createDisplay(e,o,h);const l=await this._sendRequest(new oe);return await this._display.updateWindows(l.windows),this._display.showScreen(),s&&(this._mouse=this.createMouse(e),this._addMouseListeners()),i&&(this._keyboard=this.createKeyboard(document.body),this._addKeyboardListeners()),this._display}catch(e){throw this._dispose(),new Error(`Failed to initialise display: ${e.message}`)}}createDisplay(e,t,s){return new j(e,t,s,this._windowImageFactory,this._cursorFactory)}createMouse(e){return new se(e)}createKeyboard(e){return new ee(e)}sendMouse(e){this._display.setMousePosition(e.x,e.y),this._sendInstruction(new le(e.x,e.y,e.getButtonMask()))}sendKeyEvent(e,t){this._sendInstruction(new ce(e,t))}sendKeyDown(e){this.sendKeyEvent(e,!0)}sendKeyUp(e){this.sendKeyEvent(e,!1)}sendClipboardContent(e){this._sendInstruction(new _e(e))}registerTracer(e,t){this._tracers.set(e,t)}createDebugImageMessageHandler(){return this._display?new Me(this._display):(console.log("Cannot create DebugImageMessageHandler as display is null"),null)}resetInputs(){this._mouse&&this._mouse.reset(),this._keyboard&&this._keyboard.reset()}resizeDisplay(){this._display&&this._display.resize()}unregisterTracer(e){const t=this._tracers.get(e);t&&(t.destroy(),this._tracers.delete(e))}setQualityIndex(e){const t=new ue(e);this._sendInstruction(t)}async createScreenshot(e,t){return this.display.createScreenshot(e,t)}async _getScreenMessage(){let e=0;for(;e<3;)try{return await this._sendRequest(new re,5e3)}catch(t){if(e++,console.log(`Failed to initialise screen size at attempt ${e}/3...`),3==e||!this._tunnel.isConnected())throw new Error(`unable to get screen size: ${t.message}`)}}_sendInstruction(e){this._tunnel.isConnected()&&(this._tunnel.sendInstruction(e),this._tracers.forEach(t=>{t instanceof ge&&t.handle(e)}))}_sendRequest(e,t){if(this._tunnel.isConnected())return this._tunnel.sendRequest(e,t)}_handleMessage(e){if(e.type===C.CONNECTION){const t=e;return void this._connectionHandler.setConnected(t.isStarting)}if(e.type===C.NOP&&this._connectionHandler.resetTimer(),this._display){if(e.type===C.WINDOWS){const t=e.windows;this._display.updateWindows(t)}else if(e.type===C.IMAGE){const t=e;this._display.updateImage(t.windowId,t.depth,t.colorMap,t.alphaMap)}else if(e.type===C.SUBIMAGES){const t=e;this._display.updateSubImages(t.windowId,t.subImages)}else if(e.type===C.SHAPE){const t=e;this._display.updateShape(t.windowId,t.stencilMap)}else if(e.type===C.MOUSE){const t=e;t.x>0&&t.y>0&&this._display.setMousePosition(t.x,t.y),this._display.setMouseCursor(t.cursorId)}else if(e.type===C.CLIPBOARD){const t=e;this._clipboardHandler(t.clipboardContent)}this._tracers.forEach(t=>{t instanceof fe&&t.handle(e)})}}_handleReceivedBytes(e){this._tracers.forEach(t=>{t instanceof Ze&&t.handle({received:e.byteLength,sent:0})})}_handleSentBytes(e){this._tracers.forEach(t=>{t instanceof Ze&&t.handle({received:0,sent:e.byteLength})})}_handleQuality(e){this._tracers.forEach(t=>{t instanceof Ze&&t.handle({received:0,sent:e.byteLength})})}_onTunnelClosed(){this._dispose(),this._onCloseCallback&&this._onCloseCallback()}_dispose(){this._connectionHandler.dispose(),this._display&&this._display.dispose(),this._mouse&&this._mouse.dispose(),this._keyboard&&this._keyboard.dispose()}_addMouseListeners(){this._mouse.onMouseMove=this._mouse.onMouseOut=e=>{const t=this._display.scale;e.x=e.x/t,e.y=e.y/t,this.sendMouse(e)},this._mouse.onMouseDown=this._mouse.onMouseUp=e=>{const t=this._display.scale;e.x=e.x/t,e.y=e.y/t,this.sendMouse(e)}}_addKeyboardListeners(){this._keyboard.onKeyDown=e=>{this.sendKeyDown(e)},this._keyboard.onKeyUp=e=>{this.sendKeyUp(e)}}}export{S as LinearSRGBColorSpace,I as SRGBColorSpace,Ne as WebXClient,_e as WebXClipboardInstruction,A as WebXClipboardMessage,ae as WebXConnectInstruction,Ee as WebXConnectionHandler,J as WebXConnectionMessage,Re as WebXConnectionStatus,de as WebXCursorImageInstruction,P as WebXCursorImageMessage,me as WebXDataAckInstruction,Me as WebXDebugImageMessageHandler,j as WebXDisplay,he as WebXImageInstruction,z as WebXImageMessage,ie as WebXInstruction,ge as WebXInstructionHandler,ne as WebXInstructionResponse,$ as WebXInstructionType,ee as WebXKeyboard,ce as WebXKeyboardInstruction,T as WebXMessage,fe as WebXMessageHandler,C as WebXMessageType,se as WebXMouse,le as WebXMouseInstruction,D as WebXMouseMessage,te as WebXMouseState,B as WebXNopMessage,K as WebXPingMessage,pe as WebXPongInstruction,ue as WebXQualityInstruction,O as WebXQualityMessage,re as WebXScreenInstruction,Y as WebXScreenMessage,ye as WebXShapeInstruction,Q as WebXShapeMessage,Ze as WebXStatsHandler,y as WebXSubImage,H as WebXSubImagesMessage,W as WebXTexture,G as WebXTextureFactory,ve as WebXTunnel,Xe as WebXWebSocketTunnel,_ as WebXWindowProperties,oe as WebXWindowsInstruction,F as WebXWindowsMessage,g as alphaAndStencilBlend,f as alphaBufferBlend,Z as colorAndAlphaBlendImageToImageData,w as imageToImageData,R as toThreeTexture};
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@illgrenoble/webx-client",
|
|
3
3
|
"description": "Client javascript library to display WebX remote desktop in a browser.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.1",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint . --ext .ts",
|
|
7
7
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
8
|
-
"
|
|
9
|
-
"build": "
|
|
10
|
-
"
|
|
8
|
+
"build": "npm run clean && NODE_ENV=production rollup -c",
|
|
9
|
+
"build:watch": "npm run clean && NODE_ENV=development rollup -c --watch",
|
|
10
|
+
"clean": "rm -rf dist"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"webx"
|
|
14
14
|
],
|
|
15
|
-
"main": "dist/
|
|
15
|
+
"main": "dist/webx-client.cjs.js",
|
|
16
|
+
"module": "dist/webx-client.esm.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
16
18
|
"typings": "dist/index.d.ts",
|
|
17
|
-
"module": "",
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
20
21
|
"url": "https://github.com/ILLGrenoble/webx-client.git"
|
|
@@ -27,14 +28,16 @@
|
|
|
27
28
|
"README.md"
|
|
28
29
|
],
|
|
29
30
|
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
30
32
|
"@types/three": "^0.174.0",
|
|
31
33
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
32
34
|
"@typescript-eslint/parser": "^4.33.0",
|
|
33
|
-
"buffer": "^6.0.3",
|
|
34
35
|
"eslint": "^7.32.0",
|
|
35
|
-
"nodemon": "^3.1.10",
|
|
36
36
|
"prettier": "^2.4.1",
|
|
37
|
-
"
|
|
37
|
+
"rollup": "^4.52.4",
|
|
38
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
39
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
40
|
+
"rollup-plugin-web-worker-loader": "^1.7.0",
|
|
38
41
|
"typescript": "^5.8.2"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|