@vertexvis/viewer 0.20.1-testing.0 → 0.20.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/cjs/index.cjs.js +3 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{controller-0155a10a.js → model-2105e63b.js} +85 -1
- package/dist/cjs/model-2105e63b.js.map +1 -0
- package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js +7 -87
- package/dist/cjs/vertex-viewer-box-query-tool.cjs.entry.js.map +1 -1
- package/dist/cjs/vertex-viewer.cjs.entry.js +90 -24
- package/dist/cjs/vertex-viewer.cjs.entry.js.map +1 -1
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js +23 -1
- package/dist/collection/components/viewer-box-query-tool/viewer-box-query-tool.js.map +1 -1
- package/dist/collection/lib/interactions/multiPointerInteractionHandler.js +4 -2
- package/dist/collection/lib/interactions/multiPointerInteractionHandler.js.map +1 -1
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +79 -17
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js.map +1 -1
- package/dist/collection/lib/interactions/touchInteractionHandler.js +4 -5
- package/dist/collection/lib/interactions/touchInteractionHandler.js.map +1 -1
- package/dist/collection/lib/volume-intersection/index.js +1 -0
- package/dist/collection/lib/volume-intersection/index.js.map +1 -1
- package/dist/collection/lib/window.js +7 -0
- package/dist/collection/lib/window.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/model2.js +165 -128
- package/dist/components/model2.js.map +1 -1
- package/dist/components/model3.js +157 -0
- package/dist/components/model3.js.map +1 -0
- package/dist/components/vertex-viewer-box-query-tool.js +4 -86
- package/dist/components/vertex-viewer-box-query-tool.js.map +1 -1
- package/dist/components/vertex-viewer-pin-tool.js +1 -1
- package/dist/components/vertex-viewer.js +91 -25
- package/dist/components/vertex-viewer.js.map +1 -1
- package/dist/components/viewer-pin-group.js +1 -1
- package/dist/components/viewer-pin-label-line.js +1 -1
- package/dist/components/viewer-pin-label.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{controller-f0d7a836.js → model-4ba9fc30.js} +85 -2
- package/dist/esm/model-4ba9fc30.js.map +1 -0
- package/dist/esm/vertex-viewer-box-query-tool.entry.js +6 -86
- package/dist/esm/vertex-viewer-box-query-tool.entry.js.map +1 -1
- package/dist/esm/vertex-viewer.entry.js +91 -25
- package/dist/esm/vertex-viewer.entry.js.map +1 -1
- package/dist/types/components/viewer-box-query-tool/viewer-box-query-tool.d.ts +5 -1
- package/dist/types/components.d.ts +8 -0
- package/dist/types/lib/interactions/multiTouchInteractionHandler.d.ts +7 -2
- package/dist/types/lib/interactions/touchInteractionHandler.d.ts +1 -0
- package/dist/types/lib/volume-intersection/index.d.ts +1 -0
- package/dist/types/lib/window.d.ts +1 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/index.esm.js.map +1 -1
- package/dist/viewer/p-12a301e0.entry.js +5 -0
- package/dist/viewer/p-12a301e0.entry.js.map +1 -0
- package/dist/viewer/p-4c4019b2.entry.js +5 -0
- package/dist/viewer/p-4c4019b2.entry.js.map +1 -0
- package/dist/viewer/p-ee0c9d33.js +5 -0
- package/dist/viewer/p-ee0c9d33.js.map +1 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +7 -7
- package/readme.md +4 -4
- package/dist/cjs/controller-0155a10a.js.map +0 -1
- package/dist/components/controller3.js +0 -111
- package/dist/components/controller3.js.map +0 -1
- package/dist/esm/controller-f0d7a836.js.map +0 -1
- package/dist/viewer/p-b50678f0.js +0 -5
- package/dist/viewer/p-b50678f0.js.map +0 -1
- package/dist/viewer/p-c6e12cf7.entry.js +0 -5
- package/dist/viewer/p-c6e12cf7.entry.js.map +0 -1
- package/dist/viewer/p-cfa05845.entry.js +0 -5
- package/dist/viewer/p-cfa05845.entry.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h } from '../../stencil-public-runtime';
|
|
1
|
+
import { EventEmitter, h } from '../../stencil-public-runtime';
|
|
2
2
|
import { VolumeIntersectionQueryController } from '../../lib/volume-intersection/controller';
|
|
3
3
|
import { VolumeIntersectionQueryModel } from '../../lib/volume-intersection/model';
|
|
4
4
|
import { VolumeIntersectionQueryMode, VolumeIntersectionQueryType } from './types';
|
|
@@ -52,6 +52,10 @@ export declare class ViewerBoxQueryTool {
|
|
|
52
52
|
*/
|
|
53
53
|
mode?: VolumeIntersectionQueryMode;
|
|
54
54
|
private details?;
|
|
55
|
+
/**
|
|
56
|
+
* Event emitted when the `VolumeIntersectionQueryController` associated with this tool changes.
|
|
57
|
+
*/
|
|
58
|
+
controllerChanged: EventEmitter<VolumeIntersectionQueryController>;
|
|
55
59
|
private hostEl;
|
|
56
60
|
private interactionHandler?;
|
|
57
61
|
private interactionHandlerDisposable?;
|
|
@@ -1257,6 +1257,10 @@ export interface VertexViewerCustomEvent<T> extends CustomEvent<T> {
|
|
|
1257
1257
|
detail: T;
|
|
1258
1258
|
target: HTMLVertexViewerElement;
|
|
1259
1259
|
}
|
|
1260
|
+
export interface VertexViewerBoxQueryToolCustomEvent<T> extends CustomEvent<T> {
|
|
1261
|
+
detail: T;
|
|
1262
|
+
target: HTMLVertexViewerBoxQueryToolElement;
|
|
1263
|
+
}
|
|
1260
1264
|
export interface VertexViewerDomElementCustomEvent<T> extends CustomEvent<T> {
|
|
1261
1265
|
detail: T;
|
|
1262
1266
|
target: HTMLVertexViewerDomElementElement;
|
|
@@ -1908,6 +1912,10 @@ declare namespace LocalJSX {
|
|
|
1908
1912
|
* The model that contains the points representing the corners of the box displayed on screen, the type of the query to be performed, and methods for setting these values.
|
|
1909
1913
|
*/
|
|
1910
1914
|
"model"?: VolumeIntersectionQueryModel;
|
|
1915
|
+
/**
|
|
1916
|
+
* Event emitted when the `VolumeIntersectionQueryController` associated with this tool changes.
|
|
1917
|
+
*/
|
|
1918
|
+
"onControllerChanged"?: (event: VertexViewerBoxQueryToolCustomEvent<VolumeIntersectionQueryController>) => void;
|
|
1911
1919
|
/**
|
|
1912
1920
|
* The default operation to perform when a drag has completed and the intersection query will be run. Defaults to `clearAndSelect`, and can be changed to `select` or `deselect`. `clearAndSelect` will clear all existing selection, and select the results of the query. `select` will maintain existing selection, and select the results of the query. `deselect` will maintain existing selection, and deselect the results of the query. The operation behavior for this intersection query tool can also be changed by providing a custom implementation of the `VolumeIntersectionQueryController`, or by using the `setOperationTransform` method of the default controller.
|
|
1913
1921
|
*/
|
|
@@ -4,9 +4,14 @@ import { InteractionHandler } from './interactionHandler';
|
|
|
4
4
|
export declare abstract class MultiTouchInteractionHandler implements InteractionHandler {
|
|
5
5
|
protected element?: HTMLElement;
|
|
6
6
|
protected interactionApi?: InteractionApi;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
private previousFirstPoints;
|
|
8
|
+
private previousSecondPoints;
|
|
9
9
|
initialize(element: HTMLElement, api: InteractionApi): void;
|
|
10
10
|
dispose(): void;
|
|
11
|
+
protected beginTwoPointTouch(point1: Point.Point, point2: Point.Point): void;
|
|
11
12
|
protected handleTwoPointTouchMove(point1: Point.Point, point2: Point.Point): void;
|
|
13
|
+
protected endTwoPointTouch(): void;
|
|
14
|
+
private computeDelta;
|
|
15
|
+
private computeZoom;
|
|
16
|
+
private computeAngle;
|
|
12
17
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InteractionApi } from './interactionApi';
|
|
2
2
|
import { MultiTouchInteractionHandler } from './multiTouchInteractionHandler';
|
|
3
3
|
export declare class TouchInteractionHandler extends MultiTouchInteractionHandler {
|
|
4
|
+
private currentPosition1?;
|
|
4
5
|
private isInteracting?;
|
|
5
6
|
constructor();
|
|
6
7
|
dispose(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requestAnimationFrame(callback: VoidFunction): void;
|
package/dist/viewer/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2024 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
export{C as Camera,c as ColorMaterial,a as CrossSectioner,l as LoadableResource,R as Raycaster,b as RootQuery,S as Scene,d as SceneItemOperationsBuilder,e as SceneItemQueryExecutor,f as SceneOperationBuilder,s as SceneViewStateIdentifier,g as SynchronizedClock}from"./p-e3c977e4.js";export{S as SceneTreeController}from"./p-b39b374f.js";export{f as fromNodeProto,i as isLoadedRow}from"./p-67acaae6.js";export{C as CursorManager,b as boxQueryCursor,l as labelPinCursor,m as measurementCursor,a as measurementWithArrowCursor,p as pinCursor}from"./p-fb478135.js";export{M as MeasurementController,a as MeasurementEntity}from"./p-f6511238.js";export{M as MeasurementModel}from"./p-d4a8dcbe.js";export{M as MeasurementOverlayManager}from"./p-38decab8.js";export{m as makeMinimumDistanceResult}from"./p-c9bb2460.js";import{v as r,q as o,m as t}from"./p-a3a3abe7.js";export{T as TransformController}from"./p-feb95155.js";export{A as AngleUnits,g as AreaUnits,c as CrossSectioning,D as DistanceUnits,F as FrameCameraBase,a as ReceivedFrame,b as ReceivedFrameImage,d as ReceivedFrameScene,e as ReceivedOrthographicCamera,f as ReceivedPerspectiveCamera,S as StandardView}from"./p-f37b0dd7.js";export{E as EntityType}from"./p-d312d59a.js";export{A as ArrowMarkup,C as CircleMarkup,F as FreeformMarkup}from"./p-7f41cdfc.js";export{V as Viewport}from"./p-ed8843d7.js";export{V as VolumeIntersectionQueryController}from"./p-
|
|
4
|
+
export{C as Camera,c as ColorMaterial,a as CrossSectioner,l as LoadableResource,R as Raycaster,b as RootQuery,S as Scene,d as SceneItemOperationsBuilder,e as SceneItemQueryExecutor,f as SceneOperationBuilder,s as SceneViewStateIdentifier,g as SynchronizedClock}from"./p-e3c977e4.js";export{S as SceneTreeController}from"./p-b39b374f.js";export{f as fromNodeProto,i as isLoadedRow}from"./p-67acaae6.js";export{C as CursorManager,b as boxQueryCursor,l as labelPinCursor,m as measurementCursor,a as measurementWithArrowCursor,p as pinCursor}from"./p-fb478135.js";export{M as MeasurementController,a as MeasurementEntity}from"./p-f6511238.js";export{M as MeasurementModel}from"./p-d4a8dcbe.js";export{M as MeasurementOverlayManager}from"./p-38decab8.js";export{m as makeMinimumDistanceResult}from"./p-c9bb2460.js";import{v as r,q as o,m as t}from"./p-a3a3abe7.js";export{T as TransformController}from"./p-feb95155.js";export{A as AngleUnits,g as AreaUnits,c as CrossSectioning,D as DistanceUnits,F as FrameCameraBase,a as ReceivedFrame,b as ReceivedFrameImage,d as ReceivedFrameScene,e as ReceivedOrthographicCamera,f as ReceivedPerspectiveCamera,S as StandardView}from"./p-f37b0dd7.js";export{E as EntityType}from"./p-d312d59a.js";export{A as ArrowMarkup,C as CircleMarkup,F as FreeformMarkup}from"./p-7f41cdfc.js";export{V as Viewport}from"./p-ed8843d7.js";export{V as VolumeIntersectionQueryController,a as VolumeIntersectionQueryModel}from"./p-ee0c9d33.js";import"./p-86a55f3b.js";import"./p-9c3e35fd.js";import"./p-6a9fc9d7.js";import"./p-88c19f38.js";import"./p-96daf338.js";import"./p-10bf891d.js";import"./p-c93bea57.js";import"./p-125bcd9e.js";const n=.9999;function u(e){const a=r.create(0,e.z,-e.y);const s=r.create(-e.z,0,e.x);const o=r.magnitudeSquared(a)>r.magnitudeSquared(s)?a:s;return r.normalize(r.cross(e,o))}function j(e,a){const s=r.dot(e,a);if(s>n){const r=u(e);const a=o.fromAxisAngle(r,Math.PI);return t.makeRotation(a)}else if(s<=-n){return t.makeIdentity()}else{const s=r.angleTo(a,e);const n=r.normalize(r.cross(e,a));return t.makeRotation(o.fromAxisAngle(n,s+Math.PI))}}function x(e,a,s,o){const n=j(e,s);const c=t.makeTranslation(o);return t.multiply(t.multiply(c,n),t.makeTranslation(r.negate(a)))}const y=Object.freeze({__proto__:null,ALMOST_ONE:n,calculateOrthogonalCoordinate:u,computeRotationMatrix:j,computeTransformationDelta:x});export{y as TransformationDelta};
|
|
5
5
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["src/lib/transforms/transformation-delta.ts"],"names":["ALMOST_ONE","calculateOrthogonalCoordinate","norm","orthogonalCandidate0","Vector3","create","z","y","orthogonalCandidate1","x","theChosenOne","magnitudeSquared","normalize","cross","computeRotationMatrix","normal1","normal2","dot","axisDirection","quaternion","Quaternion","fromAxisAngle","Math","PI","Matrix4","makeRotation","makeIdentity","angle","angleTo","computeTransformationDelta","position1","position2","rotationMatrix","translationDeltaMatrix","makeTranslation","multiply","negate"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["src/lib/transforms/transformation-delta.ts"],"names":["ALMOST_ONE","calculateOrthogonalCoordinate","norm","orthogonalCandidate0","Vector3","create","z","y","orthogonalCandidate1","x","theChosenOne","magnitudeSquared","normalize","cross","computeRotationMatrix","normal1","normal2","dot","axisDirection","quaternion","Quaternion","fromAxisAngle","Math","PI","Matrix4","makeRotation","makeIdentity","angle","angleTo","computeTransformationDelta","position1","position2","rotationMatrix","translationDeltaMatrix","makeTranslation","multiply","negate"],"mappings":";;;inDAEO,MAAMA,EAAa,eAQVC,EACdC,GAEA,MAAMC,EAAuBC,EAAQC,OAAO,EAAGH,EAAKI,GAAIJ,EAAKK,GAC7D,MAAMC,EAAuBJ,EAAQC,QAAQH,EAAKI,EAAG,EAAGJ,EAAKO,GAE7D,MAAMC,EACJN,EAAQO,iBAAiBR,GACzBC,EAAQO,iBAAiBH,GACrBL,EACAK,EAEN,OAAOJ,EAAQQ,UAAUR,EAAQS,MAAMX,EAAMQ,aAa/BI,EACdC,EACAC,GAEA,MAAMC,EAAMb,EAAQa,IAAIF,EAASC,GAEjC,GAAIC,EAAMjB,EAAY,CACpB,MAAMkB,EAAgBjB,EAA8Bc,GAEpD,MAAMI,EAAaC,EAAWC,cAAcH,EAAeI,KAAKC,IAChE,OAAOC,EAAQC,aAAaN,QAGzB,GAAIF,IAAQjB,EAAY,CAC3B,OAAOwB,EAAQE,mBAGZ,CACH,MAAMC,EAAQvB,EAAQwB,QAAQZ,EAASD,GACvC,MAAMG,EAAgBd,EAAQQ,UAAUR,EAAQS,MAAME,EAASC,IAC/D,OAAOQ,EAAQC,aACbL,EAAWC,cAAcH,EAAeS,EAAQL,KAAKC,eAkB3CM,EACdd,EACAe,EACAd,EACAe,GAEA,MAAMC,EAAiBlB,EAAsBC,EAASC,GAEtD,MAAMiB,EAAyBT,EAAQU,gBAAgBH,GACvD,OAAOP,EAAQW,SACbX,EAAQW,SAASF,EAAwBD,GACzCR,EAAQU,gBAAgB9B,EAAQgC,OAAON","sourcesContent":["import { Matrix4, Quaternion, Vector3 } from '@vertexvis/geometry';\n\nexport const ALMOST_ONE = 0.9999;\n\n/**\n * For any single normal vector, there are an infinite number of potential orthogonal vectors. This function will\n * calculate a single vector evaluating the length of two candidates, and picking the one with the higher squared magnitude\n * @param normal\n * @returns\n */\nexport function calculateOrthogonalCoordinate(\n norm: Vector3.Vector3\n): Vector3.Vector3 {\n const orthogonalCandidate0 = Vector3.create(0, norm.z, -norm.y);\n const orthogonalCandidate1 = Vector3.create(-norm.z, 0, norm.x);\n\n const theChosenOne =\n Vector3.magnitudeSquared(orthogonalCandidate0) >\n Vector3.magnitudeSquared(orthogonalCandidate1)\n ? orthogonalCandidate0\n : orthogonalCandidate1;\n\n return Vector3.normalize(Vector3.cross(norm, theChosenOne));\n}\n\n/**\n * Computes the rotation matrix for two normals. If both normals are neither parallel or anti-parallel,\n * this will compute the rotation matrix delta based on the angle from both normals.\n * If the normals are anti-parallel, the identity matrix will be returned, as no rotation is necessary in this case.\n * If the normals are parallel, an axis direction based on a chosen orthogonal vector will be used\n * to compute the rotation matrix to rotate the plane 180 degrees.\n * @param normal1\n * @param normal2\n * @returns an anti-parallel rotation Matrix4 betwen the given normals\n */\nexport function computeRotationMatrix(\n normal1: Vector3.Vector3,\n normal2: Vector3.Vector3\n): Matrix4.Matrix4 {\n const dot = Vector3.dot(normal1, normal2);\n // the angle is almost 0 in this case.\n if (dot > ALMOST_ONE) {\n const axisDirection = calculateOrthogonalCoordinate(normal1);\n\n const quaternion = Quaternion.fromAxisAngle(axisDirection, Math.PI);\n return Matrix4.makeRotation(quaternion);\n }\n // the angle is almost 180 in this case.\n else if (dot <= -ALMOST_ONE) {\n return Matrix4.makeIdentity();\n }\n // the angle is between 0 & 180\n else {\n const angle = Vector3.angleTo(normal2, normal1);\n const axisDirection = Vector3.normalize(Vector3.cross(normal1, normal2));\n return Matrix4.makeRotation(\n Quaternion.fromAxisAngle(axisDirection, angle + Math.PI)\n );\n }\n}\n\n/**\n * Computes the translation & rotation matrix delta between two world positions and two normals.\n * such that the computed translation matrix will be the delta between position 1 and position 2,\n * and the rotation will be rotated to be anti-parallel.\n *\n * @param normal1\n * @param position1\n * @param normal2\n * @param position2\n *\n * @returns Matrix4 translation matrix delta from position1 to\n * position2 & an anti-parallel rotation delta.\n */\nexport function computeTransformationDelta(\n normal1: Vector3.Vector3,\n position1: Vector3.Vector3,\n normal2: Vector3.Vector3,\n position2: Vector3.Vector3\n): Matrix4.Matrix4 {\n const rotationMatrix = computeRotationMatrix(normal1, normal2);\n\n const translationDeltaMatrix = Matrix4.makeTranslation(position2);\n return Matrix4.multiply(\n Matrix4.multiply(translationDeltaMatrix, rotationMatrix),\n Matrix4.makeTranslation(Vector3.negate(position1))\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2024 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import{r as t,c as i,h as s,H as n,g as e}from"./p-e4ea1075.js";import{p as o,v as h,c as r,f as a,r as c,b as l,s as u,d}from"./p-a3a3abe7.js";import{t as f,p,a as w,S as v,c as m,W as g}from"./p-10bf891d.js";import{E as y,m as b,c as C,o as P,u as T,a as I,b as D}from"./p-86a55f3b.js";import{c as k}from"./p-5206da6c.js";import{p as S}from"./p-737f680b.js";import{C as M}from"./p-fb478135.js";import{g as E,c as x}from"./p-930dafc6.js";import{c as j,C as O,W as R,S as A,V as B,d as F,e as z}from"./p-9c3e35fd.js";import{l as L,m as N,n as $,t as K,o as H,p as W,q as V,r as q,s as U,u as _,x as J,y as X,z as Z,B as G}from"./p-f37b0dd7.js";import{E as Y}from"./p-d312d59a.js";import{V as Q}from"./p-ed8843d7.js";import{h as tt,g as it,S as st}from"./p-e3c977e4.js";import{w as nt}from"./p-de6e0a52.js";import"./p-88c19f38.js";import"./p-db5aed84.js";import"./p-6a9fc9d7.js";import"./p-96daf338.js";const et=0;const ot=255;class ht{constructor(t){this.viewer=t;this.handleInteractionStarted=()=>{this.invalidateStencilBuffer();this.pendingInteractionFinished=new Promise((t=>{this.pendingInteractionFinishedResolver=t}))};this.handleInteractionFinished=()=>{var t;(t=this.pendingInteractionFinishedResolver)===null||t===void 0?void 0:t.call(this);this.pendingInteractionFinished=undefined;this.pendingInteractionFinishedResolver=undefined};this.invalidateStencilBuffer=()=>{this.pendingStencilBuffer=undefined};t.addEventListener("interactionStarted",this.handleInteractionStarted);t.addEventListener("interactionFinished",this.handleInteractionFinished);t.addEventListener("frameReceived",(()=>{this.invalidateStencilBuffer()}))}async fetch(){var t;const i=await this.viewer.isSceneReady();const s=i?await this.viewer.scene():undefined;const n=s!=null?s.crossSectioning().current().sectionPlanes.length>0||this.viewer.featureLines!=null:false;const e=(t=this.viewer.frame)===null||t===void 0?void 0:t.scene.camera;if(n&&this.viewer.stream!=null&&e!=null){const t=await this.viewer.stream.getStencilBuffer({includeDepthBuffer:true});const{stencilBuffer:i,depthBuffer:s,imageAttributes:n}=L(t);const[o,h]=await Promise.all([N(new Uint8Array(i)),N(new Uint8Array(s))]);return rt.fromPng(o,n,i,$.fromPng(h,e,n))}else return undefined}latest(){if(this.pendingStencilBuffer==null){this.pendingStencilBuffer=this.fetch()}return this.pendingStencilBuffer}async latestAfterInteraction(){await this.pendingInteractionFinished;return this.latest()}}class rt{constructor(t,i,s,n,e){this.imageAttr=t;this.imageBytes=i;this.pixelBytes=s;this.imageChannels=n;this.depthBuffer=e}static fromPng(t,i,s,n){if(!(t.data instanceof Uint8Array)){throw new Error("Expected stencil PNG to have depth of 8-bit")}else if(t.channels!==1){throw new Error("Expected stencil PNG to have 1 color channel")}else{return new rt(i,s,t.data,t.channels,n)}}getValue(t){const{width:i,height:s}=this.imageAttr.imageRect;const n=o.subtract(t,this.imageAttr.imageRect);const e=1/this.imageAttr.imageScale;const h=o.scale(n,e,e);if(h.x>=0&&h.y>=0&&h.x<i&&h.y<s){const t=Math.floor(h.x)+Math.floor(h.y)*i;const s=this.pixelBytes[t];return s}else return 0}hitTest(t){return this.getValue(t)!==et}snapToNearestPixel(t,i,s=(()=>true)){const n=i*2;const e=o.create(t.x-i,t.y-i);const h=[];for(let r=0;r<n*n;r++){const a=r%n;const c=Math.floor(r/n);const l=o.add(e,{x:a,y:c});if(o.distance(l,t)<=i){const t=this.getValue(l);if(t===ot&&s(t)){h.push(l)}}}const r=h.sort(((i,s)=>o.distance(i,t)-o.distance(s,t)));const a=r[0];return a!=null?o.create(Math.floor(a.x)+.5,Math.floor(a.y)+.5):t}}function at(t){return t!=null&&t["then"]instanceof Function&&t["catch"]instanceof Function&&t["finally"]instanceof Function}class ct{constructor(t,i,s){this.stream=t;this.configProvider=i;this.imageScaleProvider=s}predicate(t){return t.altKey&&!t.shiftKey}async fn(t){var i;const s=this.imageScaleProvider();const n=await this.stream.hitItems({point:o.scale(t.position,(s===null||s===void 0?void 0:s.x)||1,(s===null||s===void 0?void 0:s.y)||1)},true);if(((i=n.hitItems)===null||i===void 0?void 0:i.hits)!=null&&n.hitItems.hits.length>0){await this.stream.flyTo({itemId:n.hitItems.hits[0].itemId,animation:{duration:f(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit results found for fly to part [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}}class lt{constructor(t,i,s,n,e,o,h,r,a,c,l){this.stream=t;this.cursors=i;this.getConfig=s;this.getScene=n;this.getFrame=e;this.getViewport=o;this.tapEmitter=h;this.doubleTapEmitter=r;this.longPressEmitter=a;this.interactionStartedEmitter=c;this.interactionFinishedEmitter=l;this.tap=this.tap.bind(this);this.doubleTap=this.doubleTap.bind(this);this.longPress=this.longPress.bind(this);this.emitTapEvent=this.emitTapEvent.bind(this)}addCursor(t,i){return this.cursors.add(t,i)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToWorldSpace(t,n,.5):undefined}async getEntityTypeAtPoint(t){var i;const s=this.getViewport();const n=await((i=this.getFrame())===null||i===void 0?void 0:i.featureMap());if(n!=null){const i=s.transformPointToFrame(t,n);return n.getEntityType(i)}else{return Y.NO_GEOMETRY}}getRayFromPoint(t){const i=this.getViewport();const s=this.getFrame();if(s!=null){return i.transformPointToRay(t,s.image,s.scene.camera)}else throw new Error("Cannot get camera. Frame is undefined.")}async tap(t,i={},s=0){this.emitTapEvent(this.tapEmitter.emit,t,i,s)}async doubleTap(t,i={},s=0){this.emitTapEvent(this.doubleTapEmitter.emit,t,i,s)}async longPress(t,i={},s=0){this.emitTapEvent(this.longPressEmitter.emit,t,i,s)}async beginInteraction(){if(!this.isInteracting()){this.interactionStartedEmitter.emit();this.sceneLoadingPromise=this.getScene();this.currentCamera=(await this.sceneLoadingPromise).camera();this.sceneLoadingPromise=undefined;await this.stream.beginInteraction()}}async transformCamera(...t){var i;const s=t[0];const n=t[1];if(this.isInteracting()){const t=await this.getScene();const e=this.getViewport();const o=this.getFrame();const h=await(o===null||o===void 0?void 0:o.depthBuffer());this.currentCamera=this.currentCamera!=null&&e!=null&&o!=null?s({camera:this.currentCamera,viewport:e,scale:t.scale(),boundingBox:t.boundingBox(),frame:o,depthBuffer:h}):undefined;await((i=this.currentCamera)===null||i===void 0?void 0:i.render(n))}}async twistCamera(...t){return this.transformCamera((({camera:i,viewport:s})=>{const n=h.normalize(h.subtract(i.lookAt,i.position));if(t.length===1&&typeof t[0]==="number"){const s=r.toRadians(-t[0]);return i.rotateAroundAxis(s,n)}else if(t.length===1){const n=o.create(s.width/2,s.height/2);const e=r.toDegrees(r.fromPoints(n,t[0]));const a=this.lastAngle!=null?e-this.lastAngle:0;this.lastAngle=e;const c=h.normalize(h.subtract(i.lookAt,i.position));const l=r.toRadians(-a);return i.rotateAroundAxis(l,c)}return i}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n,depthBuffer:e})=>{if(this.panData==null){const o=i.toFrameCamera();const h=o.direction;const r=n.transformPointToRay(t,s.image,o);const l=a.fromNormalAndCoplanarPoint(h,i.lookAt);const u=c.intersectPlane(r,l);if(u==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}const d=e!=null?this.getWorldPoint(t,e,u):u;const f=a.fromNormalAndCoplanarPoint(h,d);this.panData={hitPt:d,hitPlane:f,startingCamera:o}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const a=n.transformPointToRay(t,s.image,r);const l=c.intersectPlane(a,o);if(l!=null){const t=h.subtract(e,l);return i.update(r).moveBy(t)}}return i}))}async viewAll(){await(await this.getScene()).camera().viewAll().render()}async rotateCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=h.normalize(i.up);const e=h.normalize(h.subtract(i.lookAt,i.position));const o=h.cross(n,e);const r=h.cross(e,o);const a=h.normalize({x:t.x*o.x+t.y*r.x,y:t.x*o.y+t.y*r.y,z:t.x*o.z+t.y*r.z});const c=h.cross(a,e);const l=3*Math.PI*t.x/s.width;const u=3*Math.PI*t.y/s.height;const d=Math.abs(l)+Math.abs(u);return i.rotateAroundAxis(d,c)}))}async rotateCameraAtPoint(t,i){return this.transformCamera((({camera:s,viewport:n,boundingBox:e,depthBuffer:o})=>{if(this.worldRotationPoint==null){const t=l.center(e);this.worldRotationPoint=o!=null?this.getWorldPoint(i,o,t):s.lookAt}const r=h.normalize(s.up);const a=h.normalize(h.subtract(s.lookAt,s.position));const c=h.cross(r,a);const u=h.cross(a,c);const d=h.normalize({x:t.x*c.x+t.y*u.x,y:t.x*c.y+t.y*u.y,z:t.x*c.z+t.y*u.z});const f=h.cross(d,a);const p=3*Math.PI*t.x/n.width;const w=3*Math.PI*t.y/n.height;const v=Math.abs(p)+Math.abs(w);const m=s.rotateAroundAxisAtPoint(v,this.worldRotationPoint,f);return m.update({lookAt:h.add(h.scale(Math.abs(s.signedDistanceToBoundingBoxCenter())/h.magnitude(m.viewVector),m.viewVector),m.position)})}))}async zoomCamera(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=h.normalize(n);const o=h.magnitude(n);const r=3*o*t/s.height;const a=h.add(i.position,h.scale(r,e));const c=i.update({position:a});return c}))}async pivotCamera(t,i){return this.transformCamera((({camera:s})=>{const{position:n,up:e,lookAt:o}=s;const a=h.normalize(e);const c=h.normalize(s.viewVector);const l=h.cross(a,c);const u=h.cross(c,l);const d=h.rotateAboutAxis(r.toRadians(t),o,l,n);const f=h.rotateAboutAxis(r.toRadians(i),d,u,n);return s.update(Object.assign(Object.assign({},s),{lookAt:f}))}))}async endInteraction(){await this.sceneLoadingPromise;if(this.isInteracting()){this.currentCamera=undefined;this.worldRotationPoint=undefined;this.panData=undefined;this.zoomData=undefined;this.resetLastAngle();this.interactionFinishedEmitter.emit();await this.stream.endInteraction()}}resetLastAngle(){this.lastAngle=undefined}isInteracting(){return this.currentCamera!=null}pixelThreshold(t){const i=this.isCoarseInputDevice(t)?this.getConfig().coarsePointerThreshold:this.getConfig().finePointerThreshold;return i*window.devicePixelRatio}async hitItems(t){var i;const s=await(await this.getScene()).raycaster().hitItems(t);return(i=s===null||s===void 0?void 0:s.hits)!==null&&i!==void 0?i:[]}emitTapEvent(t,i,s={},n=0){const{altKey:e=false,ctrlKey:o=false,metaKey:h=false,shiftKey:r=false}=s;t({position:i,altKey:e,ctrlKey:o,metaKey:h,shiftKey:r,buttons:n})}isCoarseInputDevice(t){return t||window.matchMedia("(pointer: coarse)").matches}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToWorldSpace(t,i):s}}class ut extends lt{constructor(t,i,s,n,e,o,h,r,a,c,l){super(t,i,s,n,e,o,h,r,a,c,l)}async getWorldPointFromViewport(t){const i=this.getViewport();const s=this.getFrame();if(s==null){throw new Error("Cannot get world point. Frame is undefined.")}const n=await s.depthBuffer();return n!=null?i.transformPointToOrthographicWorldSpace(t,n,.5):undefined}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{const n=i.viewVector;const e=h.normalize(i.up);const r=h.normalize(n);const a=o.scale(t,.5,.5);const c=h.magnitude(n);const l=a.x*c/s.width;const u=a.y/s.width*c;const d=h.cross(e,r);const f=h.cross(r,d);const p=h.add(h.scale(l,d),h.scale(u,f));return i.moveBy(p)}))}async panCameraToScreenPoint(t){return this.transformCamera((({camera:i,frame:s,viewport:n})=>{if(this.panData==null){const e=i.toFrameCamera();const o=e.direction;const h=n.transformPointToOrthographicRay(t,s.image,e);const r=a.fromNormalAndCoplanarPoint(o,i.lookAt);const l=c.intersectPlane(h,r);if(l==null){console.warn("Cannot determine fallback for pan. Ray does not intersect plane.");return i}this.panData={hitPt:l,hitPlane:r,startingCamera:e}}if(this.panData!=null){const{hitPt:e,hitPlane:o,startingCamera:r}=this.panData;const a=n.transformPointToOrthographicRay(t,s.image,r);const l=c.intersectPlane(a,o);if(l!=null){const t=h.subtract(e,l);return i.update({lookAt:h.add(r.lookAt,t)})}}return i}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:r})=>{if(this.orthographicZoomData==null||o.distance(t,this.orthographicZoomData.startingScreenPt)>2){const i=s.toFrameCamera();const o=i.direction;const h=n.transformPointToOrthographicRay(t,e.image,i);const l=a.fromNormalAndCoplanarPoint(o,i.lookAt);const u=c.intersectPlane(h,l);if(u==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const d=r!=null?this.getWorldPoint(t,r,u):u;const f=a.fromNormalAndCoplanarPoint(o,d);this.orthographicZoomData={hitPt:d,hitPlane:f,startingScreenPt:t}}if(this.orthographicZoomData!=null){const{hitPt:t,hitPlane:e}=this.orthographicZoomData;const o=2*(s.fovHeight/n.height)*i*2;const r=Math.max(1,s.fovHeight-o);const c=a.projectPoint(e,s.lookAt);const l=h.scale((s.fovHeight-r)/s.fovHeight,h.subtract(t,c));return s.update({lookAt:h.add(s.lookAt,l),fovHeight:Math.max(1,s.fovHeight-o)})}return s}))}getWorldPoint(t,i,s){const n=this.getViewport();const e=n.transformPointToFrame(t,i);const o=i.hitTest(e);return o?n.transformPointToOrthographicWorldSpace(t,i):s}}const dt=.2;class ft extends lt{constructor(t,i,s,n,e,o,h,r,a,c,l){super(t,i,s,n,e,o,h,r,a,c,l)}async panCameraByDelta(t){return this.transformCamera((({camera:i,viewport:s})=>{var n;const e=i.viewVector;const r=h.normalize(i.up);const a=h.normalize(e);const c=o.scale(t,.25,.25);const l=h.magnitude(e)*Math.tan((n=i.fovY)!==null&&n!==void 0?n:45);const u=c.x*l/s.width;const d=c.y/s.width*l;const f=h.cross(r,a);const p=h.cross(a,f);const w=h.add(h.scale(u,f),h.scale(d,p));return i.moveBy(w)}))}async zoomCameraToPoint(t,i){return this.transformCamera((({camera:s,viewport:n,frame:e,depthBuffer:o,boundingBox:r})=>{const l=e.scene.camera;const u=l.direction;const d=s.toFrameCamera();const f=n.transformPointToRay(t,e.image,d);if(this.zoomData==null){const i=a.fromNormalAndCoplanarPoint(u,l.lookAt);const n=c.intersectPlane(f,i);if(n==null){console.warn("Cannot determine fallback point for zoom. Ray does not intersect plane.");return s}const e=o!=null?this.getWorldPoint(t,o,n):n;const h=a.fromNormalAndCoplanarPoint(u,e);this.zoomData={hitPt:e,hitPlane:h}}if(this.zoomData!=null){const{hitPlane:t}=this.zoomData;const{position:e,distance:o,isPastHitPlane:l,keepCurrent:u}=this.computeZoomDistances(i,s,n,r,f,this.zoomData);if(l&&!u){const t=c.create({origin:e,direction:h.normalize(s.viewVector)});return s.update({position:e,lookAt:c.at(t,o)})}else if(!u){return s.update({position:e,lookAt:a.projectPoint(t,e)})}}return s}))}walk(t){this.transformCamera((({camera:i,boundingBox:s})=>{const{position:n,up:e,lookAt:o}=i;const r=h.normalize(e);const a=h.normalize(i.viewVector);const c=Math.min(...h.toArray(l.lengths(s)));const u=h.scale(c,t);const d=h.cross(r,a);const f=h.cross(d,r);const p=h.scale(u.x,h.normalize(d));const w=h.scale(u.y,h.normalize(r));const v=h.scale(u.z,h.normalize(f));const m=h.negate(h.add(p,w,v));return i.update(Object.assign(Object.assign({},i),{position:h.add(n,m),lookAt:h.add(o,m)}))}))}computeZoomDistances(t,i,s,n,e,o){const r=this.getConfig();const{hitPt:a,hitPlane:l}=o;const u=r.useMinimumPerspectiveZoomDistance?this.computeZoomMinimumDistance(i,n):-1;const d=h.distance(i.position,a);const f=Math.max(u,d);const p=6*f*t/s.height;const w=c.at(e,p);const v=c.create({origin:w,direction:h.normalize(i.viewVector)});const m=c.intersectPlane(v,l);if(m==null&&r.useMinimumPerspectiveZoomDistance){const i=6*u*t/s.height;const n=c.at(e,i);return{position:n,distance:u,isPastHitPlane:true,keepCurrent:false}}else if(m==null){return{position:i.position,distance:f,isPastHitPlane:true,keepCurrent:true}}return{position:w,distance:f,isPastHitPlane:false,keepCurrent:false}}computeZoomMinimumDistance(t,i){const s=Math.abs(i.min.x)+Math.abs(i.max.x);const n=Math.abs(i.min.y)+Math.abs(i.max.y);const e=Math.abs(i.min.z)+Math.abs(i.max.z);const o=Math.max(s,n,e);const r=Math.abs(h.dot(h.normalize(t.viewVector),h.right()));const a=Math.abs(h.dot(h.normalize(t.viewVector),h.up()));const c=Math.abs(h.dot(h.normalize(t.viewVector),h.back()));const l=s*r;const u=n*a;const d=e*c;const f=o/s;const p=o/n;const w=o/e;return(l+u+d)/(f+p+w)*dt}}class pt{constructor(t,i,s,n){this.stream=t;this.configProvider=i;this.imageScaleProvider=s;this.sceneProvider=n}predicate(t){return t.altKey&&t.shiftKey}async fn(t){var i,s;const n=this.imageScaleProvider();const e=await this.stream.hitItems({point:o.scale(t.position,(n===null||n===void 0?void 0:n.x)||1,(n===null||n===void 0?void 0:n.y)||1)},true);if(((i=e.hitItems)===null||i===void 0?void 0:i.hits)!=null&&e.hitItems.hits.length>0&&e.hitItems.hits[0].hitPoint!=null){const i=(await this.sceneProvider()).camera();const n=e.hitItems.hits[0];if(n.hitPoint!=null&&n.hitPoint.x!=null&&n.hitPoint.y!=null&&n.hitPoint.z!=null){await this.stream.flyTo({camera:K(i.update({lookAt:h.create(n.hitPoint.x,n.hitPoint.y,n.hitPoint.z)}).toFrameCamera()),animation:{duration:f(this.configProvider().animation.durationMs)}})}else{console.debug(`No hit position found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}, hit-id={${(s=n.itemId)===null||s===void 0?void 0:s.hex}}]`)}}else{console.debug(`No hit results found for fly to position [position={x: ${t.position.x}, y: ${t.position.y}}]`)}}}const wt=[.2,.15,.25,.25,.15];const vt=16;const mt=1.2;class gt{constructor(t,i,s,n,e,o,h,r,a,c){this.downEvent=t;this.upEvent=i;this.moveEvent=s;this.rotateInteraction=n;this.rotatePointInteraction=e;this.zoomInteraction=o;this.panInteraction=h;this.twistInteraction=r;this.pivotInteraction=a;this.getConfig=c;this.primaryInteraction=this.rotateInteraction;this.isDragging=false;this.keyboardControls=false;this.disableIndividualInteractions=false;this.primaryInteractionTypeChange=new y;this.handleDownEvent=this.handleDownEvent.bind(this);this.handleMouseWheel=this.handleMouseWheel.bind(this);this.handleWindowMove=this.handleWindowMove.bind(this);this.handleWindowUp=this.handleWindowUp.bind(this);this.handleDoubleClick=this.handleDoubleClick.bind(this)}initialize(t,i){this.element=t;this.interactionApi=i;t.addEventListener(this.downEvent,this.handleDownEvent);t.addEventListener("mousedown",this.handleDoubleClick);t.addEventListener("wheel",this.handleMouseWheel,{passive:false})}dispose(){var t,i,s;(t=this.element)===null||t===void 0?void 0:t.removeEventListener(this.downEvent,this.handleDownEvent);(i=this.element)===null||i===void 0?void 0:i.removeEventListener("mousedown",this.handleDoubleClick);(s=this.element)===null||s===void 0?void 0:s.removeEventListener("wheel",this.handleMouseWheel);this.element=undefined}onPrimaryInteractionTypeChange(t){return this.primaryInteractionTypeChange.on(t)}setCurrentInteractionType(t){var i;switch(t){case"rotate":this.currentInteraction=this.rotateInteraction;break;case"zoom":this.currentInteraction=this.zoomInteraction;break;case"pan":this.currentInteraction=this.panInteraction;break;case"twist":this.currentInteraction=this.twistInteraction;break;case"rotate-point":this.currentInteraction=this.rotatePointInteraction;break;case"pivot":this.currentInteraction=this.pivotInteraction;break;default:this.currentInteraction=undefined}if(this.draggingInteraction){const t=this.draggingInteraction.getPosition();this.draggingInteraction=this.currentInteraction||this.primaryInteraction;(i=this.interactionApi)===null||i===void 0?void 0:i.resetLastAngle();this.draggingInteraction.setPosition(t)}}getPrimaryInteractionType(){return this.primaryInteraction.getType()}getCurrentInteractionType(){return(this.currentInteraction||this.primaryInteraction).getType()}setPrimaryInteractionType(t){switch(t){case"rotate":this.primaryInteraction=this.rotateInteraction;this.lastPrimaryRotateInteraction=this.rotateInteraction;break;case"rotate-point":this.primaryInteraction=this.rotatePointInteraction;this.lastPrimaryRotateInteraction=this.rotatePointInteraction;break;case"zoom":this.primaryInteraction=this.zoomInteraction;break;case"pan":this.primaryInteraction=this.panInteraction;break;case"pivot":this.primaryInteraction=this.pivotInteraction;break}this.primaryInteractionTypeChange.emit()}setDefaultKeyboardControls(t){this.keyboardControls=t}handleDownEvent(t){t.preventDefault();this.interactionTimer=window.setTimeout((()=>{this.downPosition=o.create(t.screenX,t.screenY);this.downPositionCanvas=this.getCanvasPosition(t);this.interactionTimer=undefined;if(this.lastMoveEvent!=null){this.handleWindowMove(this.lastMoveEvent)}}),this.getConfig().interactions.interactionDelay);window.addEventListener(this.moveEvent,this.handleWindowMove);window.addEventListener(this.upEvent,this.handleWindowUp)}handleWindowMove(t){if(this.interactionTimer==null){if(this.disableIndividualInteractions){return}const i=o.create(t.screenX,t.screenY);const s=this.interactionApi!=null?this.interactionApi.pixelThreshold(this.isTouch(t)):2;if(this.downPosition!=null&&o.distance(i,this.downPosition)>=s&&!this.isDragging){this.beginDrag(t);this.isDragging=true}if(this.isDragging){this.drag(t)}}this.lastMoveEvent=t}async handleWindowUp(t){if(this.isDragging){this.endDrag(t);this.isDragging=false}if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}window.removeEventListener(this.moveEvent,this.handleWindowMove);window.removeEventListener(this.upEvent,this.handleWindowUp);this.lastMoveEvent=undefined}async handleDoubleClick(t){if(t.detail===2&&t.buttons===4&&this.interactionApi!=null){this.interactionApi.viewAll()}}beginDrag(t){var i;if(this.keyboardControls&&t.metaKey&&t.shiftKey){this.currentInteraction=this.rotatePointInteraction}else if(this.keyboardControls&&t.shiftKey&&t.altKey){this.currentInteraction=this.twistInteraction}else if(this.keyboardControls&&t.shiftKey){this.currentInteraction=this.zoomInteraction}else if(this.keyboardControls&&(t.metaKey||t.ctrlKey)){this.currentInteraction=this.panInteraction}else if(this.keyboardControls&&t.altKey){this.currentInteraction=this.rotateInteraction}if(t.buttons===1){this.draggingInteraction=this.currentInteraction||this.primaryInteraction}else if(t.buttons===2){this.draggingInteraction=this.panInteraction}else if(t.buttons===4){this.draggingInteraction=(i=this.lastPrimaryRotateInteraction)!==null&&i!==void 0?i:this.rotateInteraction}if(this.draggingInteraction!=null&&this.interactionApi!=null&&this.element!=null){this.zoomInteraction.endDrag(t,this.interactionApi);this.draggingInteraction.beginDrag(t,this.downPositionCanvas||o.create(t.clientX,t.clientY),this.interactionApi,this.element)}}drag(t){if(this.keyboardControls&&t.altKey&&t.shiftKey){this.currentInteraction=this.twistInteraction}else{this.currentInteraction=undefined}this.draggingInteraction=this.currentInteraction||this.draggingInteraction||this.primaryInteraction;if(this.draggingInteraction!=null&&this.interactionApi!=null){this.draggingInteraction.drag(t,this.interactionApi)}}endDrag(t){if(this.keyboardControls&&this.currentInteraction===this.twistInteraction){this.currentInteraction=undefined}if(this.draggingInteraction!=null&&this.interactionApi!=null){this.draggingInteraction.endDrag(t,this.interactionApi);this.draggingInteraction=undefined}}handleMouseWheel(t){t.preventDefault();if(this.element!=null&&this.interactionApi!=null&&t.buttons!==4){const i=-this.wheelDeltaToPixels(t.deltaY,t.deltaMode)/10;const s=this.element.getBoundingClientRect();const n=E(t,s);wt.forEach(((t,s)=>{window.setTimeout((()=>{if(this.interactionApi!=null){const s=i*t;this.zoomInteraction.zoomToPoint(n,s,this.interactionApi)}}),s*2)}))}}wheelDeltaToPixels(t,i){if(this.computedBodyStyle==null){this.computedBodyStyle=window.getComputedStyle(document.body)}const s=this.computedBodyStyle.fontSize!=null&&this.computedBodyStyle.fontSize!==""&&!isNaN(parseFloat(this.computedBodyStyle.fontSize))?parseFloat(this.computedBodyStyle.fontSize)*mt:vt*mt;if(i===1){return this.computedBodyStyle.lineHeight!=null&&this.computedBodyStyle.lineHeight!==""&&!isNaN(parseFloat(this.computedBodyStyle.lineHeight))?t*parseFloat(this.computedBodyStyle.lineHeight):t*s}else if(i===2){return this.computedBodyStyle.height!=null&&this.computedBodyStyle.height!==""&&!isNaN(parseFloat(this.computedBodyStyle.height))?t*parseFloat(this.computedBodyStyle.height):t*window.innerHeight}return t}getCanvasPosition(t){var i;const s=(i=this.element)===null||i===void 0?void 0:i.getBoundingClientRect();const n=s!=null?o.create(s.left,s.top):undefined;return n!=null?o.subtract(o.create(t.clientX,t.clientY),n):undefined}isTouch(t){return window.PointerEvent!=null&&t instanceof PointerEvent?t.pointerType==="touch":false}}class yt{setPosition(t){this.currentPosition=t}getPosition(){return this.currentPosition}getType(){return this.type}beginDrag(t,i,s,n){}drag(t,i){}endDrag(t,i){if(this.currentPosition!=null){i.endInteraction();this.currentPosition=undefined}}zoom(t,i){}}class bt extends yt{constructor(){super(...arguments);this.type="rotate"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCamera(n);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Ct extends yt{constructor(){super(...arguments);this.type="rotate-point"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.startingPosition=i;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.startingPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.rotateCameraAtPoint(n,this.startingPosition);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class Pt extends yt{constructor(t=1e3){super();this.interactionTimeout=t;this.type="zoom";this.didTransformBegin=false}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.clientX,t.clientY);const i=n.getBoundingClientRect();const e=E(t,i);this.startPt=e;s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.clientX,t.clientY);const n=o.subtract(s,this.currentPosition);if(this.startPt!=null){i.zoomCameraToPoint(this.startPt,n.y);this.currentPosition=s}}}endDrag(t,i){super.endDrag(t,i);this.stopInteractionTimer();this.didTransformBegin=false;this.startPt=undefined}zoom(t,i){this.operateWithTimer(i,(()=>i.zoomCamera(t)))}zoomToPoint(t,i,s){this.operateWithTimer(s,(()=>s.zoomCameraToPoint(t,i)))}beginInteraction(t){this.didTransformBegin=true;t.beginInteraction()}endInteraction(t){this.didTransformBegin=false;t.endInteraction()}resetInteractionTimer(t){this.stopInteractionTimer();this.startInteractionTimer(t)}startInteractionTimer(t){this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined;this.endInteraction(t)}),this.interactionTimeout)}stopInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}operateWithTimer(t,i){if(!this.didTransformBegin){this.beginInteraction(t)}this.resetInteractionTimer(t);i()}}class Tt extends yt{constructor(){super(...arguments);this.type="pan"}beginDrag(t,i,s,n){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null&&this.canvasRect!=null){const s=E(t,this.canvasRect);i.panCameraToScreenPoint(s);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class It extends yt{constructor(){super(...arguments);this.type="twist"}beginDrag(t,i,s,n){this.currentPosition=o.create(t.offsetX,t.offsetY);this.canvasRect=n.getBoundingClientRect();s.beginInteraction()}drag(t,i){const s=E(t,this.canvasRect);this.currentPosition=s;i.twistCamera(s)}endDrag(t,i){super.endDrag(t,i)}}class Dt extends yt{constructor(){super(...arguments);this.type="pivot"}beginDrag(t,i,s){if(this.currentPosition==null){this.currentPosition=o.create(t.screenX,t.screenY);s.beginInteraction()}}drag(t,i){if(this.currentPosition!=null){const s=o.create(t.screenX,t.screenY);const n=o.subtract(s,this.currentPosition);i.pivotCamera(-.25*n.y,.25*n.x);this.currentPosition=s}}endDrag(t,i){super.endDrag(t,i)}}class kt extends gt{constructor(t,i=new bt,s=new Ct,n=new Pt,e=new Tt,o=new It,h=new Dt){super("mousedown","mouseup","mousemove",i,s,n,e,o,h,t)}}function St(t){window.requestAnimationFrame(t)}class Mt{constructor(){this.previousFirstPoints=[];this.previousSecondPoints=[]}initialize(t,i){this.element=t;this.interactionApi=i}dispose(){this.element=undefined}beginTwoPointTouch(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i]}handleTwoPointTouchMove(t,i){this.previousFirstPoints=[...this.previousFirstPoints,t];this.previousSecondPoints=[...this.previousSecondPoints,i];St((()=>{var t,i,s,n;if(this.previousFirstPoints.length>1&&this.previousSecondPoints.length>1&&this.previousFirstPoints.length===this.previousSecondPoints.length){const e=this.previousFirstPoints;const h=this.previousSecondPoints;this.previousFirstPoints=this.previousFirstPoints.slice(-1);this.previousSecondPoints=this.previousSecondPoints.slice(-1);const r=e.reduce(((t,i,s)=>{if(s<e.length-1){const n=e[s+1];const o=h[s];const r=h[s+1];return{deltas:[...t.deltas,this.computeDelta(i,o,n,r)],zooms:[...t.zooms,this.computeZoom(i,o,n,r)],angles:[...t.angles,this.computeAngle(i,o,n,r)]}}return t}),{deltas:[],zooms:[],angles:[]});const a=r.deltas.reduce(((t,i)=>o.add(t,i)),o.create());const c=r.zooms.reduce(((t,i)=>t+i),0);const l=r.angles.reduce(((t,i)=>t+i),0);const u=o.create((e[e.length-1].x+h[h.length-1].x)/2,(e[e.length-1].y+h[h.length-1].y)/2);(t=this.interactionApi)===null||t===void 0?void 0:t.beginInteraction();(i=this.interactionApi)===null||i===void 0?void 0:i.zoomCameraToPoint(u,c);(s=this.interactionApi)===null||s===void 0?void 0:s.panCameraByDelta(a);(n=this.interactionApi)===null||n===void 0?void 0:n.twistCamera(l)}}))}endTwoPointTouch(){this.previousFirstPoints=[];this.previousSecondPoints=[]}computeDelta(t,i,s,n){return o.add(o.subtract(s,t),o.subtract(n,i))}computeZoom(t,i,s,n){const e=o.distance(s,n)-o.distance(t,i);return e*.5}computeAngle(t,i,s,n){const e=u.create(o.subtract(t,i),o.subtract(s,n));return r.toDegrees(Math.atan2(u.determinant(e),u.dot(e)))}}class Et extends Mt{constructor(){super();this.touchPoints={};this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointerdown",this.handlePointerDown);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){const i=o.create(t.screenX,t.screenY);this.touchPoints=Object.assign(Object.assign({},this.touchPoints),{[t.pointerId]:i});const s=Object.keys(this.touchPoints);if(s.length===1){window.addEventListener("pointermove",this.handlePointerMove);window.addEventListener("pointerup",this.handlePointerUp)}else if(s.length===2){this.beginTwoPointTouch(this.touchPoints[0],this.touchPoints[1])}}handlePointerMove(t){if(this.touchPoints[t.pointerId]!=null){this.touchPoints[t.pointerId]=o.create(t.screenX,t.screenY)}const i=Object.keys(this.touchPoints);if(i.length===2){const t=this.touchPoints[i[0]];const s=this.touchPoints[i[1]];this.handleTwoPointTouchMove(t,s)}}handlePointerUp(t){var i;delete this.touchPoints[t.pointerId];const s=Object.keys(this.touchPoints);if(s.length===1){(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction()}if(s.length===0){window.removeEventListener("pointermove",this.handlePointerMove);window.removeEventListener("pointerup",this.handlePointerUp)}this.endTwoPointTouch()}}class xt extends gt{constructor(t){super("pointerdown","pointerup","pointermove",new bt,new Ct,new Pt,new Tt,new It,new Dt,t);this.touchPoints=new Set;this.handlePointerDown=this.handlePointerDown.bind(this);this.handlePointerUp=this.handlePointerUp.bind(this)}initialize(t,i){super.initialize(t,i);t.addEventListener("pointerdown",this.handlePointerDown)}handlePointerDown(t){this.downPosition=o.create(t.screenX,t.screenY);this.touchPoints.add(t.pointerId);if(this.touchPoints.size===1){window.addEventListener("pointerup",this.handlePointerUp)}if(this.touchPoints.size===2){this.disableIndividualInteractions=true}}handlePointerUp(t){this.touchPoints.delete(t.pointerId);if(this.touchPoints.size<2){this.disableIndividualInteractions=false}if(this.touchPoints.size===0){window.removeEventListener("pointerup",this.handlePointerUp)}}}class jt{constructor(t,i,s,n){this.downEvent=t;this.upEvent=i;this.moveEvent=s;this.getConfig=n;this.handleDown=this.handleDown.bind(this);this.handleUp=this.handleUp.bind(this);this.handleMove=this.handleMove.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this);this.handlePointerMove=this.handlePointerMove.bind(this);this.handlePointerEnd=this.handlePointerEnd.bind(this);this.clearPositions=this.clearPositions.bind(this);this.restartDoubleTapTimer=this.restartDoubleTapTimer.bind(this);this.clearDoubleTapTimer=this.clearDoubleTapTimer.bind(this);this.restartLongPressTimer=this.restartLongPressTimer.bind(this);this.clearLongPressTimer=this.clearLongPressTimer.bind(this);this.setPointerPositions=this.setPointerPositions.bind(this);this.emit=this.emit.bind(this)}dispose(){var t,i;(t=this.element)===null||t===void 0?void 0:t.removeEventListener(this.downEvent,this.handleDown);(i=this.element)===null||i===void 0?void 0:i.removeEventListener("touchstart",this.handleTouchStart);this.element=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer()}initialize(t,i){this.element=t;this.interactionApi=i;t.addEventListener(this.downEvent,this.handleDown);t.addEventListener("touchstart",this.handleTouchStart,{passive:true})}handleTouchStart(t){if(t.touches.length===1){this.setPointerPositions(o.create(t.touches[0].clientX,t.touches[0].clientY));this.restartLongPressTimer();window.addEventListener("touchend",this.handleTouchEnd);window.addEventListener("touchmove",this.handleTouchMove)}}handleTouchMove(t){if(t.touches.length>0){this.handlePointerMove(o.create(t.touches[0].clientX,t.touches[0].clientY),true)}}handleTouchEnd(t){if(this.pointerDownPosition!=null){window.removeEventListener("touchend",this.handleTouchEnd);window.removeEventListener("touchmove",this.handleTouchMove)}this.handlePointerEnd(this.pointerDownPosition)}handleDown(t){this.setPointerPositions(o.create(t.clientX,t.clientY));this.buttons=t.buttons;const i={altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey};this.restartLongPressTimer(i);window.addEventListener(this.upEvent,this.handleUp);window.addEventListener(this.moveEvent,this.handleMove)}handleMove(t){this.handlePointerMove(o.create(t.clientX,t.clientY),this.isTouch(t))}handleUp(t){if(this.pointerDownPosition!=null){window.removeEventListener(this.upEvent,this.handleUp);window.removeEventListener(this.moveEvent,this.handleMove)}this.handlePointerEnd(o.create(t.clientX,t.clientY),{altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey},this.buttons,this.isTouch(t));this.buttons=undefined}handlePointerMove(t,i){var s;const n=((s=this.interactionApi)===null||s===void 0?void 0:s.pixelThreshold(i))||2;if(this.pointerDownPosition!=null&&o.distance(t,this.pointerDownPosition)>=n&&this.interactionTimer==null){this.clearPositions()}}handlePointerEnd(t,i={},s=0,n=false){var e,o;if(t!=null){if(this.longPressTimer!=null){this.emit((e=this.interactionApi)===null||e===void 0?void 0:e.tap)(t,i,s)}if(this.doubleTapTimer!=null&&this.secondPointerDownPosition!=null){this.emit((o=this.interactionApi)===null||o===void 0?void 0:o.doubleTap)(t,i,s,this.secondPointerDownPosition);this.clearDoubleTapTimer()}}this.pointerDownPosition=undefined;this.clearLongPressTimer()}emit(t){return(i,s={},n=0,e,h=false)=>{var r;const a=e||this.pointerDownPosition;const c=((r=this.interactionApi)===null||r===void 0?void 0:r.pixelThreshold(h))||1;let l;if(this.interactionTimer!=null){l=this.getCanvasPosition(a||i)}else if(a!=null&&o.distance(a,i)<=c){l=this.getCanvasPosition(i)}if(l!=null&&t!=null){t(l,s,n)}}}getCanvasPosition(t){var i;const s=(i=this.element)===null||i===void 0?void 0:i.getBoundingClientRect();const n=s!=null?o.create(s.left,s.top):undefined;return n!=null?o.subtract(o.create(t.x,t.y),n):undefined}clearPositions(){this.pointerDownPosition=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined;this.clearDoubleTapTimer();this.clearLongPressTimer();this.clearInteractionTimer()}clearDoubleTapTimer(){if(this.doubleTapTimer!=null){window.clearTimeout(this.doubleTapTimer)}this.doubleTapTimer=undefined;this.firstPointerDownPosition=undefined;this.secondPointerDownPosition=undefined}restartDoubleTapTimer(){this.clearDoubleTapTimer();this.doubleTapTimer=window.setTimeout((()=>this.clearDoubleTapTimer()),this.getConfig().events.doubleTapThreshold)}clearLongPressTimer(){if(this.longPressTimer!=null){window.clearTimeout(this.longPressTimer)}this.longPressTimer=undefined}restartLongPressTimer(t={}){this.clearLongPressTimer();this.longPressTimer=window.setTimeout((()=>{var i;if(this.pointerDownPosition){this.emit((i=this.interactionApi)===null||i===void 0?void 0:i.longPress)(this.pointerDownPosition,t,this.buttons)}this.clearLongPressTimer()}),this.getConfig().events.longPressThreshold)}restartInteractionTimer(){this.clearInteractionTimer();this.interactionTimer=window.setTimeout((()=>{this.interactionTimer=undefined}),this.getConfig().interactions.interactionDelay)}clearInteractionTimer(){if(this.interactionTimer!=null){window.clearTimeout(this.interactionTimer);this.interactionTimer=undefined}}setPointerPositions(t){this.pointerDownPosition=t;this.restartInteractionTimer();if(this.firstPointerDownPosition==null){this.restartDoubleTapTimer();this.firstPointerDownPosition=t}else{this.secondPointerDownPosition=t}}isTouch(t){return window.PointerEvent!=null&&t instanceof PointerEvent?t.pointerType==="touch":false}}class Ot extends Mt{constructor(){super();this.handleTouchStart=this.handleTouchStart.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleTouchEnd=this.handleTouchEnd.bind(this)}dispose(){var t;(t=this.element)===null||t===void 0?void 0:t.removeEventListener("touchstart",this.handleTouchStart);super.dispose()}initialize(t,i){super.initialize(t,i);t.addEventListener("touchstart",this.handleTouchStart)}handleTouchStart(t){if(t.touches.length>=1){t.preventDefault();const i=t.touches[0];this.currentPosition1=o.create(i.screenX,i.screenY);if(t.touches[1]!=null){this.beginTwoPointTouch(this.currentPosition1,o.create(t.touches[1].screenX,t.touches[1].screenY))}window.addEventListener("touchmove",this.handleTouchMove,{passive:false});window.addEventListener("touchend",this.handleTouchEnd)}}handleTouchMove(t){t.preventDefault();if(t.touches.length===1){this.handleOnePointTouchMove(t.touches[0])}else if(t.touches.length===2){const i=o.create(t.touches[0].clientX,t.touches[0].clientY);const s=o.create(t.touches[1].clientX,t.touches[1].clientY);this.handleTwoPointTouchMove(i,s)}}handleTouchEnd(t){var i;t.preventDefault();(i=this.interactionApi)===null||i===void 0?void 0:i.endInteraction();this.isInteracting=false;window.removeEventListener("touchmove",this.handleTouchMove);window.removeEventListener("touchend",this.handleTouchEnd);this.endTwoPointTouch()}handleOnePointTouchMove(t){var i,s,n;const e=o.create(t.screenX,t.screenY);if(this.currentPosition1!=null){const t=o.subtract(e,this.currentPosition1);const h=((i=this.interactionApi)===null||i===void 0?void 0:i.pixelThreshold(true))||2;if(o.distance(e,this.currentPosition1)>=h||this.isInteracting){(s=this.interactionApi)===null||s===void 0?void 0:s.beginInteraction();(n=this.interactionApi)===null||n===void 0?void 0:n.rotateCamera(t);this.isInteracting=true}}this.currentPosition1=e}}class Rt{constructor(t,i=window.performance){this.name=t;this.perf=i;this.measures=new Set;this.nextId=0}clearMeasurements(){this.perf.clearMeasures(this.name)}measure(t){if(at(t)){const i=this.begin();return t.finally((()=>this.end(i)))}else if(typeof t==="function"){const i=this.begin();const s=t();this.end(i);return s}else{throw new Error("Input must be a function or Promise")}}takeMeasurements(){const t=this.perf.getEntriesByName(this.name);this.clearMeasurements();return t}takeLastMeasurement(){const t=this.takeMeasurements();return t[t.length-1]}begin(){const t=`${this.name}-${this.nextId++}`;this.measures.add(t);this.perf.mark(t);return t}end(t){this.perf.measure(this.name,t);this.perf.clearMarks(t);this.measures.delete(t)}}const At=new Rt("paint_time");function Bt(t){return new Promise(((i,s)=>{const n=new Blob([t]);const e=URL.createObjectURL(n);const o=new Image;o.addEventListener("load",(()=>{i({image:o,dispose:()=>undefined});URL.revokeObjectURL(e)}));o.addEventListener("error",(()=>{s(new j("Failed to load image data"));URL.revokeObjectURL(e)}));o.src=e}))}async function Ft(t){const i=new Blob([t]);const s=await window.createImageBitmap(i);return{image:s,dispose:()=>s.close()}}function zt(t){if(window.createImageBitmap!=null){return Ft(t)}else{return Bt(t)}}const Lt=1e3;function Nt(t,i){const s=i.viewport.calculateDrawRect(i.frame.image);i.canvas.clearRect(0,0,i.canvasDimensions.width,i.canvasDimensions.height);i.canvas.drawImage(t.image,s.x,s.y,s.width,s.height)}function $t(t,i){const s=t.takeMeasurements();if(s.length>0){i(s)}}function Kt(t,i,s,n,e=Lt){let o;let h=0;let r;let a=[];function c(){h++;if(o==null){o=setInterval((()=>{$t(t,n);if(h===0){u()}}),e)}}function l(){h--}function u(){if(o!=null){clearInterval(o);o=undefined}}if(s){setInterval((()=>{if(r!=null){if(a.length===5){a=[...a.slice(1),r]}else{a.push(r)}const t=a.reduce(((t,i)=>t+i))/a.length;console.debug(`Paint rate: ${r}fps`);console.debug(`Paint rate (avg): ${t}`);r=undefined}}),1e3)}return s=>{c();return t.measure((async()=>{const t=await i(s);r=r==null?1:r+1;return t})).finally((()=>l()))}}function Ht(){let t=[];function i(i){if(i!=null){const s=i.copy({correlationIds:[...i.correlationIds,...t.filter((t=>!i.correlationIds.includes(t)))]});t=[];return s}return i}function s(){let t=-1;return async i=>{if(i.frame.sequenceNumber>t){const s=await zt(i.frame.image.imageBytes);t=i.frame.sequenceNumber;return s}}}function n(){let t=-1;return async(i,s)=>{var n;if(s!=null&&i.frame.sequenceNumber>t){t=i.frame.sequenceNumber;(n=i.beforeDraw)===null||n===void 0?void 0:n.call(i);Nt(s,i);s.dispose();return i.frame}s===null||s===void 0?void 0:s.dispose()}}const e=s();const o=n();return async s=>{var n,h;const r=(h=(n=s.predicate)===null||n===void 0?void 0:n.call(s))!==null&&h!==void 0?h:true;t=[...t,...s.frame.correlationIds];if(r){return e(s).then((t=>o(s,t).then(i)))}}}function Wt(t){return i=>{var s;const n=(s=i.request.requestId)===null||s===void 0?void 0:s.value;if(n!=null){t(n)(i)}}}function Vt(t){return i=>{const{drawFrame:s}=i.request;if(s!=null){t(s)(i)}}}const qt=1*60;function Ut(t){let i=false;return s=>{const n=t();if(n!=null){const t=n.remoteTime(new Date(Date.now()));const e=f(s,t);const o=p(e).getTime();if(o>=0){return e}else{if(!i){console.warn(`Possible erroneous send to receive timing. Muting for ${qt}s. [sent-at=${s.toISOString()}, received-at=${t.toISOString()}, remote-time=${n.knownRemoteTime.toISOString()}]`);i=true;setTimeout((()=>i=false),qt*1e3)}return undefined}}}}function _t(t,i){const s=Ut(i);return Wt((i=>Vt((n=>n=>{const e=p(n.sentAtTime);if(e!=null){t.replyResult(i,{drawFrame:{sendToReceiveDuration:s(e)}})}}))))}var Jt;(function(t){t["DEVICE_ID"]="vertexvis:device-id"})(Jt||(Jt={}));function Xt(t,i,s=window.localStorage){const n=s.getItem(t);if(n!=null){const e=Object.assign(Object.assign({},JSON.parse(n)),i);s.setItem(t,JSON.stringify(e))}else{s.setItem(t,JSON.stringify(i))}}function Zt(t,i,s=window.localStorage){const n=s.getItem(t);if(n!=null){return i(JSON.parse(n))}}class Gt extends w{constructor(t,i={}){var s,n,e,o,h;super(t,{loggingEnabled:i.loggingEnabled});this.state={type:"disconnected"};this.stateChanged=new y;this.dimensions=d.create(0,0);this.streamAttributes={};this.enableTemporalRefinement=(s=i.enableTemporalRefinement)!==null&&s!==void 0?s:true;this.frameBgColor=C.create(255,255,255);this.config=S("platprod");this.options={tokenRefreshOffsetInSeconds:(n=i.tokenRefreshOffsetInSeconds)!==null&&n!==void 0?n:30,offlineThresholdInSeconds:(e=i.offlineThresholdInSeconds)!==null&&e!==void 0?e:30,loadTimeoutInSeconds:(o=i.loadTimeoutInSeconds)!==null&&o!==void 0?o:15,enableTemporalRefinement:(h=i.enableTemporalRefinement)!==null&&h!==void 0?h:true}}getState(){return this.state}disconnect(){if(this.state.type!=="disconnected"&&this.state.type!=="connection-failed"){console.debug("Disconnecting websocket");this.state.connection.dispose();this.updateState({type:"disconnected"})}}async load(t,i,s,n=S("platprod")){this.clientId=i;this.deviceId=s;this.config=n;if(this.state.type==="disconnected"){return this.loadIfDisconnected(t)}else if(this.state.type==="connection-failed"){return this.loadIfDisconnected(t)}else if(this.state.type==="reconnecting"){return this.loadIfConnectingOrConnected(t,this.state)}else if(this.state.type==="connecting"){return this.loadIfConnectingOrConnected(t,this.state)}else{return this.loadIfConnectingOrConnected(t,this.state)}}update(t){this.frameBgColor=t.frameBgColor?t.frameBgColor:this.frameBgColor;if(t.dimensions!=null&&t.dimensions!==this.dimensions){this.dimensions=t.dimensions;this.ifState("connected",(()=>this.updateDimensions({dimensions:this.getDimensions()})))}if(t.streamAttributes!=null&&this.streamAttributes!==t.streamAttributes){this.streamAttributes=t.streamAttributes;this.ifState("connected",(()=>this.updateStream({streamAttributes:Yt(this.streamAttributes)})))}if(t.enableTemporalRefinement!=null&&t.enableTemporalRefinement!==this.enableTemporalRefinement){this.enableTemporalRefinement=t.enableTemporalRefinement;if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}}async loadIfConnectingOrConnected(t,i){var s;const{resource:n,subResource:e}=i.resource;const o=tt(t);const h=!P.isEqual(n,o.resource);const r=!P.isEqual(e,o.subResource);const a=i.type==="connecting"||i.type==="reconnecting";const c=i.type==="connected";const l=o.queries.find((t=>t.type==="supplied-id"));if(h||a&&r){this.disconnect();return this.loadIfDisconnected(t)}else if(c&&r&&((s=o.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"){const t=Object.assign(Object.assign({},o.subResource.id!=null?{sceneViewStateId:{hex:o.subResource.id}}:{}),l!=null?{sceneViewStateSuppliedId:{value:l.id}}:{});await this.loadSceneViewState(t);this.updateState(Object.assign(Object.assign({},i),{resource:o}))}}async loadIfDisconnected(t){try{await this.connectWithNewStream(tt(t))}catch(t){if(t instanceof O){this.updateState({type:"connection-failed",message:`Cannot load scene. ${t.message}`,error:t})}else if(t instanceof v){this.updateState({type:"connection-failed",message:`Cannot load scene. Stream request failed to start stream.`,error:t})}else{this.updateState({type:"connection-failed",message:`Cannot load scene for unknown reason. See console logs.`,error:t})}throw t}}connectWithNewStream(t){return this.openWebsocketStream(t,"connecting",(()=>this.requestNewStream(t)))}connectToExistingStream(t){return this.openWebsocketStream(t.resource,"reconnecting",(()=>this.requestReconnectStream(t)),{maxRetries:Number.POSITIVE_INFINITY})}async openWebsocketStream(t,i,s,{maxRetries:n=3}={}){const e=ii(si(this.config,t.resource,this.clientId,this.deviceId));console.debug(`Initiating WS connection [uri=${e.url}]`);const o=new AbortController;const h=ti(this.config);this.updateState({type:i,resource:t,connection:{dispose:()=>{this.dispose();o.abort()}}});const r=await I.abort(o.signal,I.retry((()=>this.connect(e,h)),{maxRetries:n,delaysInMs:Gt.WS_RECONNECT_DELAYS})).catch((t=>{throw new R("Websocket connection failed.",t instanceof Error?t:undefined)}));if(!r.aborted){return this.requestNewOrExistingStream(t,r.result,s)}else{this.updateState({type:"disconnected"})}}async requestNewOrExistingStream(t,i,s){const n=this.requestClock();const e=await s();console.debug(`Stream connected [stream-id=${e.streamId}, scene-id=${e.sceneId}, scene-view-id=${e.sceneViewId}]`);const o=this.onRequest((t=>{const i=t.request.drawFrame;if(i!=null){const t=V(e.worldOrientation)(i);if(this.state.type==="connected"){if(t.depthBufferBytes!=null||this.state.frame.temporalRefinementCorrelationId!==t.temporalRefinementCorrelationId){this.updateState(Object.assign(Object.assign({},this.state),{frame:t,fallbackDepthBufferBytes:t.depthBufferBytes}))}else{this.updateState(Object.assign(Object.assign({},this.state),{frame:t.copy({depthBufferBytes:this.state.fallbackDepthBufferBytes})}))}}}}));const h=this.reconnectWhenNeeded();const r=this.refreshTokenWhenExpired(e.token);const a=this.acknowledgeFrameRequests();const c=e.frame==null?await this.waitForFrame(e.worldOrientation,this.options.loadTimeoutInSeconds):e.frame;const l=await n;console.debug(`Synchronized clocks [local-time=${l.knownLocalTime.toISOString()}, remote-time=${l.knownRemoteTime.toISOString()}]`);this.updateState({type:"connected",connection:{dispose:()=>{h.dispose();o.dispose();r.dispose();a.dispose();i.dispose()}},resource:t,streamId:e.streamId,deviceId:e.deviceId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,worldOrientation:e.worldOrientation,token:e.token,frame:c,clock:l,fallbackDepthBufferBytes:undefined})}async requestNewStream(t){var i,s;const n=t.queries.find((t=>t.type==="supplied-id"));const e=q(await this.startStream({streamKey:{value:t.resource.id},dimensions:this.getDimensions(),frameBackgroundColor:Qt(this.frameBgColor),clientSupportsTemporalRefinement:this.enableTemporalRefinement,streamAttributes:Yt(this.streamAttributes),sceneViewStateId:((i=t.subResource)===null||i===void 0?void 0:i.type)==="scene-view-state"&&t.subResource.id!=null?{hex:t.subResource.id}:undefined,sceneViewStateSuppliedId:((s=t.subResource)===null||s===void 0?void 0:s.type)==="scene-view-state"&&n!=null?{value:n.id}:undefined}));return{resource:t,streamId:e.streamId,sceneId:e.sceneId,sceneViewId:e.sceneViewId,deviceId:e.sessionId,token:e.token,worldOrientation:e.worldOrientation,frame:undefined,fallbackDepthBufferBytes:undefined}}async requestReconnectStream(t){const i=U(await this.reconnect({streamId:{hex:t.streamId},dimensions:this.getDimensions(),frameBackgroundColor:Qt(this.frameBgColor),streamAttributes:Yt(this.streamAttributes),clientSupportsTemporalRefinement:this.enableTemporalRefinement}));return Object.assign(Object.assign({},t),{token:i.token})}async requestClock(){const t=_(await this.syncTime({requestTime:m()}));return new it(t)}reconnectWhenNeeded(){const t=this.onClose((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}));const i=this.onRequest((t=>{const i=t.request.gracefulReconnection!=null;if(i&&this.state.type==="connected"){console.debug("Received request for graceful reconnect. Closing connection and attempting reconnect.");this.closeAndReconnect(this.state)}}));const s=this.reconnectWhenOffline();return{dispose:()=>{t.dispose();i.dispose();s.dispose()}}}refreshTokenWhenExpired(t){let i;const s=t=>{const{tokenRefreshOffsetInSeconds:n}=this.options;const e=t.remainingTimeInMs(n);i=window.setTimeout((async()=>{const t=await this.refreshToken();const i=J(t);s(i);if(this.state.type==="connected"){this.updateState(Object.assign(Object.assign({},this.state),{token:i}))}}),e)};s(t);return{dispose:()=>clearTimeout(i)}}reconnectWhenOffline(){let t;const i=()=>window.clearTimeout(t);const s=()=>{i();const s=this.options.offlineThresholdInSeconds;console.debug(`Detected that host is offline. Will attempt reconnect in ${s}s.`);t=window.setTimeout((()=>{if(this.state.type==="connected"){this.closeAndReconnect(this.state)}}),s*1e3)};const n=()=>{console.debug("Detected that host is online.");i()};const e=()=>s();window.addEventListener("offline",e);window.addEventListener("online",n);return{dispose:()=>{i();window.removeEventListener("offline",s);window.removeEventListener("online",i)}}}closeAndReconnect(t){t.connection.dispose();return this.connectToExistingStream(t)}async waitForFrame(t,i){let s;try{return await I.timeout(i*1e3,new Promise((i=>{s=this.onRequest((n=>{try{const e=n.request.drawFrame;if(e!=null){const s=V(t)(e);i(s)}}finally{s===null||s===void 0?void 0:s.dispose()}}))})))}catch(t){throw new A(`Frame timed out after ${i/1e3}s`,t instanceof Error?t:undefined)}finally{s===null||s===void 0?void 0:s.dispose()}}acknowledgeFrameRequests(){return this.onRequest(_t(this,(()=>this.state.type==="connected"?this.state.clock:undefined)))}updateState(t){if(this.state!==t){this.state=t;this.stateChanged.emit(this.state)}}getDimensions(){if(d.area(this.dimensions)===0){return d.create(1,1)}return this.dimensions}ifState(t,i){if(this.state.type===t){return i()}}onStateChanged(t){return this.stateChanged.on(t)}}Gt.WS_RECONNECT_DELAYS=[0,1e3,1e3,5e3];const Yt=b.ifInvalidThrow(H);const Qt=b.ifInvalidThrow(W);function ti(t){return{EXPERIMENTAL_frameDelivery:Object.assign(Object.assign({},t.EXPERIMENTAL_frameDelivery),{rateLimitingEnabled:t.flags.throttleFrameDelivery}),EXPERIMENTAL_adaptiveRendering:Object.assign(Object.assign({},t.EXPERIMENTAL_adaptiveRendering),{enabled:t.flags.adaptiveRendering}),EXPERIMENTAL_qualityOfService:Object.assign({},t.EXPERIMENTAL_qualityOfService)}}function ii(t){return{url:T.toString(t),protocols:["ws.vertexvis.com"]}}function si(t,i,s,n){if(s!=null){return T.appendPath(T.toString(T.parseAndAddParams("/ws",{clientId:s,deviceId:n})),T.parse(t.network.renderingHost))}else{return T.appendPath(`/stream-keys/${i.id}/session`,T.parse(t.network.renderingHost))}}const ni=15e3;function ei(t){return t.getBoundingClientRect()}function oi(t,i){const s=window.getComputedStyle(t);const n=s.getPropertyValue(i);return n!==""?n:undefined}const hi=":host{--image-background:var(--image-background);--viewer-background:var(--viewer-background);display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}.enable-pointer-events{touch-action:none}.viewer-container{width:100%;height:100%;overflow:hidden}.error-message{position:absolute;top:50%;width:100%;transform:translateY(-50%);text-align:center}";const ri=class{constructor(s){t(this,s);this.tap=i(this,"tap",7);this.doubletap=i(this,"doubletap",7);this.longpress=i(this,"longpress",7);this.frameReceived=i(this,"frameReceived",7);this.frameDrawn=i(this,"frameDrawn",7);this.tokenExpired=i(this,"tokenExpired",7);this.connectionChange=i(this,"connectionChange",7);this.sceneReady=i(this,"sceneReady",7);this.sceneChanged=i(this,"sceneChanged",7);this.interactionStarted=i(this,"interactionStarted",7);this.interactionFinished=i(this,"interactionFinished",7);this.cameraTypeChanged=i(this,"cameraTypeChanged",7);this.deviceIdChange=i(this,"deviceIdChange",7);this.dimensionschange=i(this,"dimensionschange",7);this.configEnv="platprod";this.cameraControls=true;this.cameraType="perspective";this.keyboardControls=true;this.rotateAroundTapPoint=true;this.phantom={opacity:.1};this.noDefaultLights=false;this.enableTemporalRefinement=true;this.experimentalRenderingOptions="";this.resizeDebounce=100;this.stencilBuffer=new ht(this.hostElement);this.viewport=Q.fromDimensions(d.create(0,0));this.stateMap={cursorManager:new M,streamState:{type:"disconnected"}};this.interactionHandlers=[];this.defaultInteractionHandlerDisposables=[];this.tapKeyInteractions=[];this.defaultTapKeyInteractions=[];this.internalFrameDrawnDispatcher=new y;this.handleElementResize=this.handleElementResize.bind(this)}componentWillLoad(){var t;this.updateResolvedConfig();this.calculateComponentDimensions();this.resizeObserver=new ResizeObserver(this.handleElementResize);this.registerSlotChangeListeners();this.stream=(t=this.stream)!==null&&t!==void 0?t:new Gt(new g,{loggingEnabled:this.getResolvedConfig().flags.logWsMessages,enableTemporalRefinement:this.enableTemporalRefinement});this.addStreamListeners();this.updateStreamAttributes();this.stateMap.cursorManager.onChanged.on((()=>this.handleCursorChanged()))}async componentDidLoad(){var t;this.interactionApi=this.createInteractionApi();if(this.canvasContainerElement!=null){(t=this.resizeObserver)===null||t===void 0?void 0:t.observe(this.canvasContainerElement)}if(this.src!=null){this.load(this.src).catch((t=>{console.error("Error loading scene",t)}))}await this.initializeDefaultInteractionHandlers();this.injectViewerApi()}render(){var t;return s(n,null,s("div",{ref:t=>this.viewerContainerElement=t,class:"viewer-container",style:{cursor:x((t=this.cursor)!==null&&t!==void 0?t:"")},onContextMenu:t=>t.preventDefault()},s("div",{ref:t=>this.canvasContainerElement=t,class:k("canvas-container",{"enable-pointer-events ":window.PointerEvent!=null})},s("canvas",{ref:t=>{this.canvasElement=t;this.stateMap.interactionTarget=t},class:"canvas"}),this.errorMessage!=null?s("div",{class:"error-message"},this.errorMessage):null),s("slot",null)))}async dispatchFrameDrawn(t){this.frame=t;this.internalFrameDrawnDispatcher.emit(t);this.frameDrawn.emit(t)}async registerInteractionHandler(t){this.interactionHandlers.push(t);this.initializeInteractionHandler(t);return{dispose:()=>{const i=this.interactionHandlers.indexOf(t);if(i!==-1){this.interactionHandlers[i].dispose();this.interactionHandlers.splice(i,1)}}}}async registerTapKeyInteraction(t){this.tapKeyInteractions=[...this.tapKeyInteractions,t]}async getInteractionTarget_DEPRECATED(){if(this.stateMap.interactionTarget!=null){return this.stateMap.interactionTarget}else throw new Error("Interaction target is undefined.")}async addCursor(t,i){return this.stateMap.cursorManager.add(t,i)}async getInteractionHandlers(){return this.interactionHandlers}async getKeyInteractions(){return this.tapKeyInteractions}async getBaseInteractionHandler(){return this.baseInteractionHandler}async getJwt(){return this.token}handleSrcChanged(t){if(t!=null){this.load(t)}else{this.unload()}}handleCameraControlsChanged(){this.initializeDefaultCameraInteractionHandlers()}handleKeyboardControlsChanged(){this.initializeDefaultKeyboardInteractionHandlers()}handleRotateAboutTapPointChanged(){var t,i;this.updateStreamAttributes();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}else{(i=this.baseInteractionHandler)===null||i===void 0?void 0:i.setPrimaryInteractionType("rotate")}}handleCameraTypeChanged(t,i){if(t!==i){this.updateCameraType()}}handleDepthBuffersChanged(){this.updateStreamAttributes()}handlePhantomChanged(){this.updateStreamAttributes()}handleNoDefaultLightsChanged(){this.updateStreamAttributes()}handleExperimentalRenderingOptionsChanged(){this.updateStreamAttributes()}handleEnableTemporalRefinementChanged(){this.updateEnableTemporalRefinement()}handleFeatureLinesChanged(){this.updateStreamAttributes()}handleSelectionHighlightingChanged(){this.updateStreamAttributes()}handleFeatureHighlightingChanged(){this.updateStreamAttributes()}handleFeatureMapsChanged(){this.updateStreamAttributes()}handleConfigChanged(){this.updateResolvedConfig()}handleConfigEnvChanged(){this.updateResolvedConfig()}async load(t){var i;if(this.stream!=null&&this.dimensions!=null){this.calculateComponentDimensions();this.stream.update({streamAttributes:this.getStreamAttributes(),config:S(this.configEnv,this.config),dimensions:this.dimensions,frameBgColor:this.getBackgroundColor()});await((i=this.stream)===null||i===void 0?void 0:i.load(t,this.clientId,this.getDeviceId(),this.getResolvedConfig()));this.sceneReady.emit()}else{throw new B("Cannot load scene. Viewer has not been initialized.")}}async unload(){if(this.stream!=null){this.stream.disconnect();this.frame=undefined;this.errorMessage=undefined}if(this.canvasElement!=null){const t=this.canvasElement.getContext("2d");if(t!=null){t.clearRect(0,0,this.canvasElement.width,this.canvasElement.height)}}}async scene(){return this.createScene()}async isSceneReady(){return this.stateMap.streamState.type==="connected"}async handleTapEvent(t){this.tapKeyInteractions.filter((i=>i.predicate(t.detail))).forEach((i=>i.fn(t.detail)))}emitConnectionChange(t){this.connectionChange.emit(t)}handleElementResize(t){const i=t.length>0&&this.dimensions!=null&&!d.isEqual(t[0].contentRect,this.viewport);if(i){if(this.resizeTimer!=null){clearTimeout(this.resizeTimer);this.resizeTimer=undefined}if(!this.isResizing){this.resizeTimer=setTimeout((()=>{this.isResizing=true;this.isResizeUpdate=true;this.recalculateComponentDimensions()}),this.resizeDebounce)}}}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((t=>this.injectViewerApi()));this.mutationObserver.observe(this.hostElement,{childList:true,subtree:true});this.styleObserver=new MutationObserver((t=>this.syncViewerStyles()));this.styleObserver.observe(this.hostElement,{attributes:true,attributeFilter:["style"]})}injectViewerApi(){function t(t){return Array.from(t.querySelectorAll("*"))}const i=t(this.hostElement);i.filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((i,s)=>[...i,s,...t(s)]),[]).forEach((t=>{t.viewer=this.hostElement}))}syncViewerStyles(){var t;const i=this.getBackgroundColor();(t=this.stream)===null||t===void 0?void 0:t.update({frameBgColor:i,streamAttributes:this.getStreamAttributes()})}calculateComponentDimensions(){var t;const i=2073600;const s=this.getBounds();if((s===null||s===void 0?void 0:s.width)!=null&&(s===null||s===void 0?void 0:s.height)!=null){const n=d.create(s.width,s.height);const e=d.scaleFit(i,n);this.hostDimensions=n;this.dimensions=e!=null?d.create(e.width,e.height):undefined;this.viewport=Q.fromDimensions((t=this.getCanvasDimensions())!==null&&t!==void 0?t:d.create(0,0))}}recalculateComponentDimensions(){var t;if(this.isResizing){this.calculateComponentDimensions();this.isResizing=false;if(((t=this.stream)===null||t===void 0?void 0:t.getState().type)==="connected"){this.updateDimensions(this.dimensions)}}}reportPerformance(t){if(this.stateMap.streamState.type==="connected"){const i={timings:t.map((t=>({receiveToPaintDuration:f(t.duration)})))};this.getStream().recordPerformance(i,false)}}addStreamListeners(){this.stateMap.streamListeners=this.getStream().stateChanged.on((t=>{this.handleStreamStateChanged(this.stateMap.streamState,t)}))}handleStreamStateChanged(t,i){this.stateMap.streamState=i;if(i.type==="connecting"){this.handleConnecting(t,i)}else if(i.type==="connected"){this.handleConnected(t,i)}else if(i.type==="connection-failed"){this.handleConnectionFailed(t,i)}else if(i.type==="disconnected"){this.handleDisconnected(t,i)}}handleConnecting(t,i){if(t.type!=="connecting"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"connecting"})}}handleConnected(t,i){var s;this.token=i.token.token;if(t.type!=="connected"){this.errorMessage=undefined;this.canvasRenderer=Kt(At,Ht(),this.getResolvedConfig().flags.logFrameRate,(t=>this.reportPerformance(t)));this.emitConnectionChange({status:"connected",jwt:i.token.token});this.deviceIdChange.emit(i.deviceId)}if(((s=this.frame)===null||s===void 0?void 0:s.getId())!==i.frame.getId()){this.updateFrame(i.frame)}this.updateDimensions(this.dimensions)}handleConnectionFailed(t,i){if(t.type!=="connection-failed"){this.token=undefined;this.errorMessage=i.message;this.emitConnectionChange({status:"connection-failed",errorMessage:i.message})}}handleDisconnected(t,i){if(t.type!=="disconnected"){this.token=undefined;this.errorMessage=undefined;this.emitConnectionChange({status:"disconnected"})}}updateDimensions(t){var i;(i=this.stream)===null||i===void 0?void 0:i.update({dimensions:t});this.dimensionschange.emit(t)}async updateFrame(t){var i;const s=this.getCanvasDimensions();if(this.canvasElement!=null&&s!=null&&((i=this.frame)===null||i===void 0?void 0:i.getId())!==t.getId()){const i=this.canvasElement.getContext("2d");if(i!=null){const n=this.frame;this.frame=X(t,n);this.updateInteractionApi(n);const e={canvas:i,canvasDimensions:s,dimensions:this.dimensions,frame:this.frame,viewport:this.viewport,beforeDraw:()=>{this.updateCanvasDimensions(s);this.isResizeUpdate=false},predicate:()=>{if(this.isResizeUpdate){return this.dimensions==null||d.isEqual(this.dimensions,e.frame.image.imageAttr.frameDimensions)}return true}};this.frameReceived.emit(this.frame);if(this.frame.scene.hasChanged){this.sceneChanged.emit()}const o=await this.canvasRenderer(e);if(o!=null){this.updateViewerBackground();this.dispatchFrameDrawn(o)}}}}updateViewerBackground(){const t=this.getBackgroundColor();nt((()=>{var i,s;(i=this.viewerContainerElement)===null||i===void 0?void 0:i.style.setProperty("background",t!=null?C.toHexString(t):"#ffffff");(s=this.canvasContainerElement)===null||s===void 0?void 0:s.style.setProperty("background",t!=null?C.toHexString(t):"#ffffff")}))}async initializeDefaultInteractionHandlers(){var t;await this.initializeDefaultCameraInteractionHandlers();await this.initializeDefaultTapInteractionHandler();this.initializeDefaultKeyboardInteractionHandlers();if(this.rotateAroundTapPoint){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setPrimaryInteractionType("rotate-point")}}clearDefaultCameraInteractionHandlers(){this.defaultInteractionHandlerDisposables.forEach((t=>t.dispose()));this.defaultInteractionHandlerDisposables=[]}clearDefaultKeyboardInteractions(){this.defaultTapKeyInteractions.forEach((t=>{const i=this.tapKeyInteractions.indexOf(t);if(i!==-1){this.tapKeyInteractions.splice(i,1)}}));this.tapKeyInteractions=[]}async initializeDefaultCameraInteractionHandlers(){var t,i;this.clearDefaultCameraInteractionHandlers();if(this.cameraControls){if(window.PointerEvent!=null){this.baseInteractionHandler=(t=this.baseInteractionHandler)!==null&&t!==void 0?t:new xt((()=>this.getResolvedConfig()));const i=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Et);this.defaultInteractionHandlerDisposables=[i,s]}else{this.baseInteractionHandler=(i=this.baseInteractionHandler)!==null&&i!==void 0?i:new kt((()=>this.getResolvedConfig()));const t=await this.registerInteractionHandler(this.baseInteractionHandler);const s=await this.registerInteractionHandler(new Ot);this.defaultInteractionHandlerDisposables=[t,s]}}}initializeDefaultKeyboardInteractionHandlers(){var t;this.clearDefaultKeyboardInteractions();if(this.keyboardControls&&this.stream!=null){(t=this.baseInteractionHandler)===null||t===void 0?void 0:t.setDefaultKeyboardControls(this.keyboardControls);const i=new ct(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()));const s=new pt(this.stream,(()=>this.getResolvedConfig()),(()=>this.getImageScale()),(()=>this.createScene()));this.registerTapKeyInteraction(i);this.registerTapKeyInteraction(s);this.defaultTapKeyInteractions=[i,s]}}async initializeDefaultTapInteractionHandler(){if(this.tapHandlerDisposable==null){if(window.PointerEvent!=null){const t=new jt("pointerdown","pointerup","pointermove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}else{const t=new jt("mousedown","mouseup","mousemove",(()=>this.getResolvedConfig()));this.tapHandlerDisposable=await this.registerInteractionHandler(t)}}}initializeInteractionHandler(t){if(this.stateMap.interactionTarget==null){throw new F("Cannot initialize interaction handler. Interaction target is undefined.")}if(this.interactionApi==null){throw new F("Cannot initialize interaction handler. Interaction APi is undefined.")}t.initialize(this.stateMap.interactionTarget,this.interactionApi)}createInteractionApi(){if(this.stream==null){throw new z("Cannot create interaction API. Component has not been initialized.")}return this.frame==null||this.frame.scene.camera.isPerspective()?new ft(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished):new ut(this.stream,this.stateMap.cursorManager,(()=>this.getResolvedConfig().interactions),(()=>this.createScene()),(()=>this.frame),(()=>this.viewport),this.tap,this.doubletap,this.longpress,this.interactionStarted,this.interactionFinished)}handleCursorChanged(){window.requestAnimationFrame((()=>{this.cursor=this.stateMap.cursorManager.getActiveCursor()}))}async createScene(){const t=await this.waitForConnectedState();const{frame:i,sceneId:s,sceneViewId:n,worldOrientation:e}=t;return new st(this.getStream(),i,V(e),(()=>this.getImageScale()),this.viewport,s,n)}getBackgroundColor(){if(this.canvasContainerElement!=null){const t=oi(this.hostElement,"--image-background");const i=oi(this.hostElement,"--viewer-background");const s=t!==null&&t!==void 0?t:i;return s!=null?C.fromCss(s):C.create(255,255,255)}}getBounds(){return ei(this.hostElement)}getCanvasDimensions(){return this.getResolvedConfig().flags.letterboxFrames?this.dimensions:this.hostDimensions}getImageScale(){const t=this.getCanvasDimensions();if(this.dimensions!=null&&t!=null){return o.create(this.dimensions.width/t.width,this.dimensions.height/t.height)}}getStreamAttributes(){return{depthBuffers:this.getDepthBufferStreamAttributesValue(),phantom:this.phantom,noDefaultLights:this.noDefaultLights,featureLines:this.featureLines,featureHighlighting:this.featureHighlighting,featureMaps:this.featureMaps,experimentalRenderingOptions:this.experimentalRenderingOptions,selectionHighlighting:this.selectionHighlighting,frames:{frameBackgroundColor:this.getBackgroundColor()}}}updateCanvasDimensions(t){if(this.canvasElement!=null){this.canvasElement.width=t.width;this.canvasElement.height=t.height}}updateStreamAttributes(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({streamAttributes:this.getStreamAttributes()})}updateEnableTemporalRefinement(){var t;(t=this.stream)===null||t===void 0?void 0:t.update({enableTemporalRefinement:this.enableTemporalRefinement})}updateInteractionApi(t){if(this.frame!=null){const i=(t==null||t.scene.camera.isPerspective())&&this.frame.scene.camera.isOrthographic();const s=(t==null||t.scene.camera.isOrthographic())&&this.frame.scene.camera.isPerspective();if(i||s){this.interactionApi=this.createInteractionApi();this.cameraType=this.frame.scene.camera.isPerspective()?"perspective":"orthographic";this.cameraTypeChanged.emit(this.cameraType);this.interactionHandlers.forEach((t=>this.initializeInteractionHandler(t)))}}}updateCameraType(){var t,i;if(this.frame!=null){if(this.cameraType==="orthographic"&&this.frame.scene.camera.isPerspective()){(t=this.stream)===null||t===void 0?void 0:t.replaceCamera({camera:K(Z(this.frame.scene.camera,this.frame.scene.boundingBox))})}else if(this.cameraType==="perspective"&&this.frame.scene.camera.isOrthographic()){(i=this.stream)===null||i===void 0?void 0:i.replaceCamera({camera:K(G(this.frame.scene.camera))})}}}getDepthBufferStreamAttributesValue(){var t;const i=(t=this.depthBuffers)!==null&&t!==void 0?t:this.rotateAroundTapPoint?"final":undefined;return i}updateResolvedConfig(){this.resolvedConfig=S(this.configEnv,this.config)}getResolvedConfig(){return ai("Resolved config is undefined",(()=>this.resolvedConfig))}getStream(){return ai("Stream is undefined",(()=>this.stream))}getDeviceId(){if(this.deviceId==null){try{this.deviceId=Zt(Jt.DEVICE_ID,(t=>t["device-id"]))}catch(t){console.warn("Cannot read device ID. Local storage is not supported.")}if(this.deviceId==null){this.deviceId=D.create();try{Xt(Jt.DEVICE_ID,{["device-id"]:this.deviceId})}catch(t){console.warn("Cannot write device ID. Local storage is not supported.")}}}return this.deviceId}async waitForConnectedState(){if(this.stateMap.streamState.type!=="connected"){console.debug("Stream was not in a connected state. Waiting for successful connection.");return new Promise(((t,i)=>{const s=this.getStream().onStateChanged((i=>{if(i.type==="connected"){t(i)}}));setTimeout((()=>{s.dispose();i(new Error("Timed out waiting for connected state."))}),ni)}))}return this.stateMap.streamState}get hostElement(){return e(this)}static get watchers(){return{src:["handleSrcChanged"],cameraControls:["handleCameraControlsChanged"],keyboardControls:["handleKeyboardControlsChanged"],rotateAroundTapPoint:["handleRotateAboutTapPointChanged"],cameraType:["handleCameraTypeChanged"],depthBuffers:["handleDepthBuffersChanged"],phantom:["handlePhantomChanged"],noDefaultLights:["handleNoDefaultLightsChanged"],experimentalRenderingOptions:["handleExperimentalRenderingOptionsChanged"],enableTemporalRefinement:["handleEnableTemporalRefinementChanged"],featureLines:["handleFeatureLinesChanged"],selectionHighlighting:["handleSelectionHighlightingChanged"],featureHighlighting:["handleFeatureHighlightingChanged"],featureMaps:["handleFeatureMapsChanged"],config:["handleConfigChanged"],configEnv:["handleConfigEnvChanged"]}}};function ai(t,i){const s=i();if(s!=null){return s}else throw new Error(t)}ri.style=hi;export{ri as vertex_viewer};
|
|
5
|
+
//# sourceMappingURL=p-12a301e0.entry.js.map
|