@vertexvis/viewer 1.0.0-canary.2 → 1.0.0-canary.3

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.
Files changed (52) hide show
  1. package/dist/cjs/{entities-DKHUfheC.js → entities-BbFe_OSv.js} +24 -2
  2. package/dist/cjs/entities-BbFe_OSv.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/vertex-viewer-measurement-precise.cjs.entry.js +1 -1
  5. package/dist/collection/lib/measurement/controller.js +22 -0
  6. package/dist/collection/lib/measurement/controller.js.map +1 -1
  7. package/dist/components/index.js +1 -1
  8. package/dist/components/p-Bfbzt4ZR.js +5 -0
  9. package/dist/components/p-Bfbzt4ZR.js.map +1 -0
  10. package/dist/components/{p-DP0zP-Gr.js → p-C8zX6RrH.js} +2 -2
  11. package/dist/components/{p-DU6goRD0.js → p-Ce-6kPRQ.js} +2 -2
  12. package/dist/components/{p-BBKWC-yY.js → p-DrkwJOM4.js} +2 -2
  13. package/dist/components/vertex-viewer-measurement-distance.js +1 -1
  14. package/dist/components/vertex-viewer-measurement-overlays.js +1 -1
  15. package/dist/components/vertex-viewer-measurement-precise.js +1 -1
  16. package/dist/components/vertex-viewer-pin-group.js +1 -1
  17. package/dist/components/vertex-viewer-pin-tool.js +1 -1
  18. package/dist/esm/{entities-Bpi27lyT.js → entities-C3Psu9sn.js} +25 -3
  19. package/dist/esm/entities-C3Psu9sn.js.map +1 -0
  20. package/dist/esm/{geometry_pb-BeXN0y30.js → geometry_pb-mKM0mAGa.js} +3 -3
  21. package/dist/esm/{geometry_pb-BeXN0y30.js.map → geometry_pb-mKM0mAGa.js.map} +1 -1
  22. package/dist/esm/index.js +2 -2
  23. package/dist/esm/index.mjs +2 -2
  24. package/dist/esm/vertex-viewer-measurement-distance.entry.js +1 -1
  25. package/dist/esm/vertex-viewer-measurement-line_2.entry.js +1 -1
  26. package/dist/esm/vertex-viewer-measurement-precise.entry.js +2 -2
  27. package/dist/esm/vertex-viewer-pin-group.entry.js +1 -1
  28. package/dist/types/lib/measurement/controller.d.ts +3 -0
  29. package/dist/viewer/index.esm.js +1 -1
  30. package/dist/viewer/{p-7cca58e4.entry.js → p-6f02eb99.entry.js} +2 -2
  31. package/dist/viewer/{p-e62befb5.entry.js → p-73b3b95a.entry.js} +2 -2
  32. package/dist/viewer/{p-53b6e251.entry.js → p-7cee56a8.entry.js} +2 -2
  33. package/dist/viewer/p-Dr2r9bDY.js +5 -0
  34. package/dist/viewer/p-Dr2r9bDY.js.map +1 -0
  35. package/dist/viewer/{p-0545bbd6.entry.js → p-ae0fc09f.entry.js} +2 -2
  36. package/dist/viewer/{p-BU754187.js → p-oWeTwgJJ.js} +2 -2
  37. package/dist/viewer/{p-BU754187.js.map → p-oWeTwgJJ.js.map} +1 -1
  38. package/dist/viewer/viewer.esm.js +1 -1
  39. package/package.json +7 -7
  40. package/dist/cjs/entities-DKHUfheC.js.map +0 -1
  41. package/dist/components/p-BqEOBQcx.js +0 -5
  42. package/dist/components/p-BqEOBQcx.js.map +0 -1
  43. package/dist/esm/entities-Bpi27lyT.js.map +0 -1
  44. package/dist/viewer/p-DZ2ZtqUE.js +0 -5
  45. package/dist/viewer/p-DZ2ZtqUE.js.map +0 -1
  46. /package/dist/components/{p-DP0zP-Gr.js.map → p-C8zX6RrH.js.map} +0 -0
  47. /package/dist/components/{p-DU6goRD0.js.map → p-Ce-6kPRQ.js.map} +0 -0
  48. /package/dist/components/{p-BBKWC-yY.js.map → p-DrkwJOM4.js.map} +0 -0
  49. /package/dist/viewer/{p-7cca58e4.entry.js.map → p-6f02eb99.entry.js.map} +0 -0
  50. /package/dist/viewer/{p-e62befb5.entry.js.map → p-73b3b95a.entry.js.map} +0 -0
  51. /package/dist/viewer/{p-53b6e251.entry.js.map → p-7cee56a8.entry.js.map} +0 -0
  52. /package/dist/viewer/{p-0545bbd6.entry.js.map → p-ae0fc09f.entry.js.map} +0 -0
@@ -21,6 +21,7 @@ class MeasurementController {
21
21
  this.jwtProvider = jwtProvider;
22
22
  this.deviceId = deviceId;
23
23
  this.outcome = Promise.resolve(undefined);
24
+ this.debugLogs = false;
24
25
  }
25
26
  /**
26
27
  * Registers an entity to measure and performs a measurement if this entity
@@ -31,6 +32,10 @@ class MeasurementController {
31
32
  * entity.
32
33
  */
33
34
  addEntity(entity) {
35
+ if (this.debugLogs) {
36
+ const deserializedEntity = geometry_pb.model_entity_pbExports.ModelEntity.deserializeBinary(entity.modelEntity);
37
+ this.log(`Adding ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`);
38
+ }
34
39
  return this.performMeasurement(() => this.model.addEntity(entity));
35
40
  }
36
41
  /**
@@ -38,6 +43,7 @@ class MeasurementController {
38
43
  * of measurement results.
39
44
  */
40
45
  clearEntities() {
46
+ this.log('Clearing all ModelEntities.');
41
47
  return this.performMeasurement(() => {
42
48
  this.model.clearEntities();
43
49
  this.model.clearOutcome();
@@ -53,6 +59,10 @@ class MeasurementController {
53
59
  * entity.
54
60
  */
55
61
  removeEntity(entity) {
62
+ if (this.debugLogs) {
63
+ const deserializedEntity = geometry_pb.model_entity_pbExports.ModelEntity.deserializeBinary(entity.modelEntity);
64
+ this.log(`Removing ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`);
65
+ }
56
66
  return this.performMeasurement(() => this.model.removeEntity(entity));
57
67
  }
58
68
  /**
@@ -63,8 +73,15 @@ class MeasurementController {
63
73
  * entities.
64
74
  */
65
75
  setEntities(entities) {
76
+ if (this.debugLogs) {
77
+ const deserializedEntities = Array.from(entities).map((e) => geometry_pb.model_entity_pbExports.ModelEntity.deserializeBinary(e.modelEntity));
78
+ this.log(`Setting ${deserializedEntities.length} ModelEntities. [entityIds=[${deserializedEntities.map((e) => e.getEntityId()).join(', ')}], sceneItemIds=[${deserializedEntities.map((e) => e.getSceneItemId()).join(', ')}]]`);
79
+ }
66
80
  return this.performMeasurement(() => this.model.setEntities(entities));
67
81
  }
82
+ setDebugLogs(debugLogs) {
83
+ this.debugLogs = debugLogs;
84
+ }
68
85
  performMeasurement(effect) {
69
86
  const previous = this.model.getEntities();
70
87
  const changed = effect();
@@ -122,6 +139,11 @@ class MeasurementController {
122
139
  this.client.updateModelEntities(req, meta, handler);
123
140
  });
124
141
  }
142
+ log(message, ...optionalParams) {
143
+ if (this.debugLogs) {
144
+ console.debug(message, optionalParams);
145
+ }
146
+ }
125
147
  }
126
148
 
127
149
  class MeasurementEntity {
@@ -154,6 +176,6 @@ class MeasurementEntity {
154
176
 
155
177
  exports.MeasurementController = MeasurementController;
156
178
  exports.MeasurementEntity = MeasurementEntity;
157
- //# sourceMappingURL=entities-DKHUfheC.js.map
179
+ //# sourceMappingURL=entities-BbFe_OSv.js.map
158
180
 
159
- //# sourceMappingURL=entities-DKHUfheC.js.map
181
+ //# sourceMappingURL=entities-BbFe_OSv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities-BbFe_OSv.js","sources":["src/lib/measurement/controller.ts","src/lib/measurement/entities.ts"],"sourcesContent":["import { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport {\n MeasureRequest,\n MeasureResponse,\n ModelEntityUpdate,\n UpdateModelEntitiesRequest,\n} from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { BoolValue } from 'google-protobuf/google/protobuf/wrappers_pb';\n\nimport { createMetadata, JwtProvider, requestUnary } from '../grpc';\nimport { MeasurementEntity } from './entities';\nimport { mapMeasureResponseOrThrow } from './mapper';\nimport { MeasurementModel } from './model';\nimport { MeasurementOutcome } from './outcomes';\n\n/**\n * The `MeasurementController` is responsible for performing measurements of\n * registered entities, and updating the model with their measurement results.\n */\nexport class MeasurementController {\n private outcome = Promise.resolve<MeasurementOutcome | undefined>(undefined);\n private debugLogs = false;\n\n public constructor(\n private model: MeasurementModel,\n private client: SceneViewAPIClient,\n private jwtProvider: JwtProvider,\n private deviceId: string | undefined\n ) {}\n\n /**\n * Registers an entity to measure and performs a measurement if this entity\n * has not been previously registered.\n *\n * @param entity The entity to measure.\n * @returns A promise that resolves with the results after registering this\n * entity.\n */\n public addEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Adding ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.addEntity(entity));\n }\n\n /**\n * Clears all entities and returns a promise that resolves with an empty list\n * of measurement results.\n */\n public clearEntities(): Promise<MeasurementOutcome | undefined> {\n this.log('Clearing all ModelEntities.');\n\n return this.performMeasurement(() => {\n this.model.clearEntities();\n this.model.clearOutcome();\n return true;\n });\n }\n\n /**\n * Deregisters an entity and performs a measurement if this entity was\n * removed.\n *\n * @param entity The entity to remove.\n * @returns A promise that resolves with the results after removing this\n * entity.\n */\n public removeEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Removing ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.removeEntity(entity));\n }\n\n /**\n * Registers a set of entities and performs a measurement\n *\n * @param entities The entities to measure.\n * @returns A promise that resolves with the results after registering these\n * entities.\n */\n public setEntities(\n entities: Set<MeasurementEntity>\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntities = Array.from(entities).map((e) =>\n ModelEntity.deserializeBinary(e.modelEntity)\n );\n\n this.log(\n `Setting ${deserializedEntities.length} ModelEntities. [entityIds=[${deserializedEntities.map((e) => e.getEntityId()).join(', ')}], sceneItemIds=[${deserializedEntities.map((e) => e.getSceneItemId()).join(', ')}]]`\n );\n }\n\n return this.performMeasurement(() => this.model.setEntities(entities));\n }\n\n public setDebugLogs(debugLogs: boolean): void {\n this.debugLogs = debugLogs;\n }\n\n private performMeasurement(\n effect: () => boolean\n ): Promise<MeasurementOutcome | undefined> {\n const previous = this.model.getEntities();\n const changed = effect();\n const entities = this.model.getEntities();\n if (changed) {\n this.measureAndUpdateModel(entities);\n this.highlightEntities(previous, entities);\n }\n return this.outcome;\n }\n\n private measureAndUpdateModel(entities: MeasurementEntity[]): void {\n if (entities.length > 0) {\n this.outcome = this.measureEntities(entities).then((outcome) => {\n this.model.setOutcome(outcome);\n return this.model.getOutcome();\n });\n } else {\n this.outcome = Promise.resolve(undefined);\n }\n }\n\n private async measureEntities(\n entities: MeasurementEntity[]\n ): Promise<MeasurementOutcome | undefined> {\n if (entities.length > 0) {\n const res = await requestUnary<MeasureResponse>(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n const req = new MeasureRequest();\n req.setEntitiesList(entities.map((e) => e.toProto()));\n\n this.client.measure(req, meta, handler);\n });\n\n return mapMeasureResponseOrThrow(res.toObject());\n } else {\n return undefined;\n }\n }\n\n private async highlightEntities(\n previous: MeasurementEntity[],\n entities: MeasurementEntity[]\n ): Promise<void> {\n await requestUnary(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n\n const entitySet = new Set(entities);\n const newPrevious = previous.filter((e) => !entitySet.has(e));\n\n const clearEntities = newPrevious.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(false));\n return update;\n });\n const highlightEntities = entities.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(true));\n return update;\n });\n\n const req = new UpdateModelEntitiesRequest();\n req.setUpdatesList([...clearEntities, ...highlightEntities]);\n this.client.updateModelEntities(req, meta, handler);\n });\n }\n\n private log(message?: string, ...optionalParams: unknown[]): void {\n if (this.debugLogs) {\n console.debug(message, optionalParams);\n }\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { Vector3 } from '@vertexvis/geometry';\nimport { Vector3f } from '@vertexvis/scene-view-protos/core/protos/geometry_pb';\nimport { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport { MeasureEntity } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { Mapper } from '@vertexvis/utils';\n\nimport { fromPbVector3f } from '../mappers';\n\nexport class MeasurementEntity {\n public constructor(\n public readonly point: Vector3.Vector3,\n public readonly modelEntity: Uint8Array\n ) {}\n\n public static fromHit(\n hit: vertexvis.protobuf.stream.IHit\n ): MeasurementEntity {\n if (hit.hitPoint != null && hit.modelEntity != null) {\n const hitPoint = Mapper.ifInvalidThrow(fromPbVector3f)(hit.hitPoint);\n const modelEntity = vertexvis.protobuf.core.ModelEntity.encode(\n hit.modelEntity\n ).finish();\n return new MeasurementEntity(hitPoint, modelEntity);\n } else {\n throw new Error(\n 'Cannot create MeasurementEntity from Hit. Hit is missing hit point and model entity'\n );\n }\n }\n\n public toProto(): MeasureEntity {\n const entity = new MeasureEntity();\n\n const point = new Vector3f();\n point.setX(this.point.x);\n point.setY(this.point.y);\n point.setZ(this.point.z);\n entity.setPoint(point);\n\n const modelEntity = ModelEntity.deserializeBinary(this.modelEntity);\n entity.setModelEntity(modelEntity);\n\n return entity;\n }\n}\n"],"names":["ModelEntity","requestUnary","createMetadata","MeasureRequest","mapMeasureResponseOrThrow","ModelEntityUpdate","BoolValue","UpdateModelEntitiesRequest","Mapper","fromPbVector3f","vertexvis","MeasureEntity","Vector3f"],"mappings":";;;;;;;;;;;;AAgBA;;;AAGG;MACU,qBAAqB,CAAA;AAIhC,IAAA,WAAA,CAC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QAAA,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAEtB,MAAM,WAAW,GAAGZ,8CAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;AACnE,QAAA,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC;AAElC,QAAA,OAAO,MAAM;;AAEhB;;;;;"}
@@ -8,7 +8,7 @@ var controller = require('./controller-Bdoxn5mz.js');
8
8
  var row = require('./row-Cet6xXup.js');
9
9
  var types = require('./types-UbZMN9nQ.js');
10
10
  var cursors = require('./cursors-BjfBRMe4.js');
11
- var entities$1 = require('./entities-DKHUfheC.js');
11
+ var entities$1 = require('./entities-BbFe_OSv.js');
12
12
  var model = require('./model-CNYtD2Ho.js');
13
13
  var overlays = require('./overlays-CxiJArpE.js');
14
14
  var results = require('./results-BDTeOJrm.js');
@@ -6,7 +6,7 @@
6
6
  var index = require('./index-C_J7n4Dv.js');
7
7
  var scene_view_api_pb_service = require('./scene_view_api_pb_service-DOzeWJnj.js');
8
8
  var config = require('./config-DCwUHSdA.js');
9
- var entities = require('./entities-DKHUfheC.js');
9
+ var entities = require('./entities-BbFe_OSv.js');
10
10
  require('./bundle-Q3QjjVv1.js');
11
11
  require('./geometry_pb-B4FvDpcp.js');
12
12
  require('./wrappers_pb-B8CHp0iq.js');
@@ -17,6 +17,7 @@ export class MeasurementController {
17
17
  this.jwtProvider = jwtProvider;
18
18
  this.deviceId = deviceId;
19
19
  this.outcome = Promise.resolve(undefined);
20
+ this.debugLogs = false;
20
21
  }
21
22
  /**
22
23
  * Registers an entity to measure and performs a measurement if this entity
@@ -27,6 +28,10 @@ export class MeasurementController {
27
28
  * entity.
28
29
  */
29
30
  addEntity(entity) {
31
+ if (this.debugLogs) {
32
+ const deserializedEntity = ModelEntity.deserializeBinary(entity.modelEntity);
33
+ this.log(`Adding ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`);
34
+ }
30
35
  return this.performMeasurement(() => this.model.addEntity(entity));
31
36
  }
32
37
  /**
@@ -34,6 +39,7 @@ export class MeasurementController {
34
39
  * of measurement results.
35
40
  */
36
41
  clearEntities() {
42
+ this.log('Clearing all ModelEntities.');
37
43
  return this.performMeasurement(() => {
38
44
  this.model.clearEntities();
39
45
  this.model.clearOutcome();
@@ -49,6 +55,10 @@ export class MeasurementController {
49
55
  * entity.
50
56
  */
51
57
  removeEntity(entity) {
58
+ if (this.debugLogs) {
59
+ const deserializedEntity = ModelEntity.deserializeBinary(entity.modelEntity);
60
+ this.log(`Removing ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`);
61
+ }
52
62
  return this.performMeasurement(() => this.model.removeEntity(entity));
53
63
  }
54
64
  /**
@@ -59,8 +69,15 @@ export class MeasurementController {
59
69
  * entities.
60
70
  */
61
71
  setEntities(entities) {
72
+ if (this.debugLogs) {
73
+ const deserializedEntities = Array.from(entities).map((e) => ModelEntity.deserializeBinary(e.modelEntity));
74
+ this.log(`Setting ${deserializedEntities.length} ModelEntities. [entityIds=[${deserializedEntities.map((e) => e.getEntityId()).join(', ')}], sceneItemIds=[${deserializedEntities.map((e) => e.getSceneItemId()).join(', ')}]]`);
75
+ }
62
76
  return this.performMeasurement(() => this.model.setEntities(entities));
63
77
  }
78
+ setDebugLogs(debugLogs) {
79
+ this.debugLogs = debugLogs;
80
+ }
64
81
  performMeasurement(effect) {
65
82
  const previous = this.model.getEntities();
66
83
  const changed = effect();
@@ -118,5 +135,10 @@ export class MeasurementController {
118
135
  this.client.updateModelEntities(req, meta, handler);
119
136
  });
120
137
  }
138
+ log(message, ...optionalParams) {
139
+ if (this.debugLogs) {
140
+ console.debug(message, optionalParams);
141
+ }
142
+ }
121
143
  }
122
144
  //# sourceMappingURL=controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../src/lib/measurement/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,W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G,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC3C,MAAM,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;gBACvC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;gBACpE,MAAM,CAAC,YAAY,CAAC,IAAI,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpD,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,IAAI,0BAA0B,EAAE,CAAC;YAC7C,GAAG,CAAC,cAAc,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport {\n MeasureRequest,\n MeasureResponse,\n ModelEntityUpdate,\n UpdateModelEntitiesRequest,\n} from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { BoolValue } from 'google-protobuf/google/protobuf/wrappers_pb';\n\nimport { createMetadata, JwtProvider, requestUnary } from '../grpc';\nimport { MeasurementEntity } from './entities';\nimport { mapMeasureResponseOrThrow } from './mapper';\nimport { MeasurementModel } from './model';\nimport { MeasurementOutcome } from './outcomes';\n\n/**\n * The `MeasurementController` is responsible for performing measurements of\n * registered entities, and updating the model with their measurement results.\n */\nexport class MeasurementController {\n private outcome = Promise.resolve<MeasurementOutcome | undefined>(undefined);\n\n public constructor(\n private model: MeasurementModel,\n private client: SceneViewAPIClient,\n private jwtProvider: JwtProvider,\n private deviceId: string | undefined\n ) {}\n\n /**\n * Registers an entity to measure and performs a measurement if this entity\n * has not been previously registered.\n *\n * @param entity The entity to measure.\n * @returns A promise that resolves with the results after registering this\n * entity.\n */\n public addEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n return this.performMeasurement(() => this.model.addEntity(entity));\n }\n\n /**\n * Clears all entities and returns a promise that resolves with an empty list\n * of measurement results.\n */\n public clearEntities(): Promise<MeasurementOutcome | undefined> {\n return this.performMeasurement(() => {\n this.model.clearEntities();\n this.model.clearOutcome();\n return true;\n });\n }\n\n /**\n * Deregisters an entity and performs a measurement if this entity was\n * removed.\n *\n * @param entity The entity to remove.\n * @returns A promise that resolves with the results after removing this\n * entity.\n */\n public removeEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n return this.performMeasurement(() => this.model.removeEntity(entity));\n }\n\n /**\n * Registers a set of entities and performs a measurement\n *\n * @param entities The entities to measure.\n * @returns A promise that resolves with the results after registering these\n * entities.\n */\n public setEntities(\n entities: Set<MeasurementEntity>\n ): Promise<MeasurementOutcome | undefined> {\n return this.performMeasurement(() => this.model.setEntities(entities));\n }\n\n private performMeasurement(\n effect: () => boolean\n ): Promise<MeasurementOutcome | undefined> {\n const previous = this.model.getEntities();\n const changed = effect();\n const entities = this.model.getEntities();\n if (changed) {\n this.measureAndUpdateModel(entities);\n this.highlightEntities(previous, entities);\n }\n return this.outcome;\n }\n\n private measureAndUpdateModel(entities: MeasurementEntity[]): void {\n if (entities.length > 0) {\n this.outcome = this.measureEntities(entities).then((outcome) => {\n this.model.setOutcome(outcome);\n return this.model.getOutcome();\n });\n } else {\n this.outcome = Promise.resolve(undefined);\n }\n }\n\n private async measureEntities(\n entities: MeasurementEntity[]\n ): Promise<MeasurementOutcome | undefined> {\n if (entities.length > 0) {\n const res = await requestUnary<MeasureResponse>(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n const req = new MeasureRequest();\n req.setEntitiesList(entities.map((e) => e.toProto()));\n\n this.client.measure(req, meta, handler);\n });\n\n return mapMeasureResponseOrThrow(res.toObject());\n } else {\n return undefined;\n }\n }\n\n private async highlightEntities(\n previous: MeasurementEntity[],\n entities: MeasurementEntity[]\n ): Promise<void> {\n await requestUnary(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n\n const entitySet = new Set(entities);\n const newPrevious = previous.filter((e) => !entitySet.has(e));\n\n const clearEntities = newPrevious.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(false));\n return update;\n });\n const highlightEntities = entities.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(true));\n return update;\n });\n\n const req = new UpdateModelEntitiesRequest();\n req.setUpdatesList([...clearEntities, ...highlightEntities]);\n this.client.updateModelEntities(req, meta, handler);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../src/lib/measurement/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AACvF,OAAO,EACL,cAAc,EAEd,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,iEAAiE,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAExE,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAIhC,YACU,KAAuB,EACvB,MAA0B,EAC1B,WAAwB,EACxB,QAA4B;QAH5B,UAAK,GAAL,KAAK,CAAkB;QACvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,gBAAW,GAAX,WAAW,CAAa;QACxB,aAAQ,GAAR,QAAQ,CAAoB;QAP9B,YAAO,GAAG,OAAO,CAAC,OAAO,CAAiC,SA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AC,CAAC;IACL,CAAC;IAEO,GAAG,CAAC,OAAgB,EAAE,GAAG,cAAyB;QACxD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF","sourcesContent":["import { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport {\n MeasureRequest,\n MeasureResponse,\n ModelEntityUpdate,\n UpdateModelEntitiesRequest,\n} from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { BoolValue } from 'google-protobuf/google/protobuf/wrappers_pb';\n\nimport { createMetadata, JwtProvider, requestUnary } from '../grpc';\nimport { MeasurementEntity } from './entities';\nimport { mapMeasureResponseOrThrow } from './mapper';\nimport { MeasurementModel } from './model';\nimport { MeasurementOutcome } from './outcomes';\n\n/**\n * The `MeasurementController` is responsible for performing measurements of\n * registered entities, and updating the model with their measurement results.\n */\nexport class MeasurementController {\n private outcome = Promise.resolve<MeasurementOutcome | undefined>(undefined);\n private debugLogs = false;\n\n public constructor(\n private model: MeasurementModel,\n private client: SceneViewAPIClient,\n private jwtProvider: JwtProvider,\n private deviceId: string | undefined\n ) {}\n\n /**\n * Registers an entity to measure and performs a measurement if this entity\n * has not been previously registered.\n *\n * @param entity The entity to measure.\n * @returns A promise that resolves with the results after registering this\n * entity.\n */\n public addEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Adding ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.addEntity(entity));\n }\n\n /**\n * Clears all entities and returns a promise that resolves with an empty list\n * of measurement results.\n */\n public clearEntities(): Promise<MeasurementOutcome | undefined> {\n this.log('Clearing all ModelEntities.');\n\n return this.performMeasurement(() => {\n this.model.clearEntities();\n this.model.clearOutcome();\n return true;\n });\n }\n\n /**\n * Deregisters an entity and performs a measurement if this entity was\n * removed.\n *\n * @param entity The entity to remove.\n * @returns A promise that resolves with the results after removing this\n * entity.\n */\n public removeEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Removing ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.removeEntity(entity));\n }\n\n /**\n * Registers a set of entities and performs a measurement\n *\n * @param entities The entities to measure.\n * @returns A promise that resolves with the results after registering these\n * entities.\n */\n public setEntities(\n entities: Set<MeasurementEntity>\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntities = Array.from(entities).map((e) =>\n ModelEntity.deserializeBinary(e.modelEntity)\n );\n\n this.log(\n `Setting ${deserializedEntities.length} ModelEntities. [entityIds=[${deserializedEntities.map((e) => e.getEntityId()).join(', ')}], sceneItemIds=[${deserializedEntities.map((e) => e.getSceneItemId()).join(', ')}]]`\n );\n }\n\n return this.performMeasurement(() => this.model.setEntities(entities));\n }\n\n public setDebugLogs(debugLogs: boolean): void {\n this.debugLogs = debugLogs;\n }\n\n private performMeasurement(\n effect: () => boolean\n ): Promise<MeasurementOutcome | undefined> {\n const previous = this.model.getEntities();\n const changed = effect();\n const entities = this.model.getEntities();\n if (changed) {\n this.measureAndUpdateModel(entities);\n this.highlightEntities(previous, entities);\n }\n return this.outcome;\n }\n\n private measureAndUpdateModel(entities: MeasurementEntity[]): void {\n if (entities.length > 0) {\n this.outcome = this.measureEntities(entities).then((outcome) => {\n this.model.setOutcome(outcome);\n return this.model.getOutcome();\n });\n } else {\n this.outcome = Promise.resolve(undefined);\n }\n }\n\n private async measureEntities(\n entities: MeasurementEntity[]\n ): Promise<MeasurementOutcome | undefined> {\n if (entities.length > 0) {\n const res = await requestUnary<MeasureResponse>(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n const req = new MeasureRequest();\n req.setEntitiesList(entities.map((e) => e.toProto()));\n\n this.client.measure(req, meta, handler);\n });\n\n return mapMeasureResponseOrThrow(res.toObject());\n } else {\n return undefined;\n }\n }\n\n private async highlightEntities(\n previous: MeasurementEntity[],\n entities: MeasurementEntity[]\n ): Promise<void> {\n await requestUnary(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n\n const entitySet = new Set(entities);\n const newPrevious = previous.filter((e) => !entitySet.has(e));\n\n const clearEntities = newPrevious.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(false));\n return update;\n });\n const highlightEntities = entities.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(true));\n return update;\n });\n\n const req = new UpdateModelEntitiesRequest();\n req.setUpdatesList([...clearEntities, ...highlightEntities]);\n this.client.updateModelEntities(req, meta, handler);\n });\n }\n\n private log(message?: string, ...optionalParams: unknown[]): void {\n if (this.debugLogs) {\n console.debug(message, optionalParams);\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{g as o}from"./p-DmsAWRoU.js";export{a as getAssetPath,r as render,s as setAssetPath,b as setNonce,c as setPlatformOptions}from"./p-DmsAWRoU.js";export{C as Camera,c as ColorMaterial,a as CrossSectioner,I as ItemOperationBuilder,l as LoadableResource,M as ModelViewController,P as PmiAnnotationOperationsBuilder,b as PmiAnnotationsQueryExecutor,k as PmiController,R as Raycaster,d as RootQuery,S as Scene,e as SceneElementQueryExecutor,f as SceneElementsOperationExecutor,g as SceneItemOperationsBuilder,h as SceneItemQueryExecutor,i as SceneItemsOperationExecutor,s as SceneViewStateIdentifier,j as SynchronizedClock}from"./p-Ckz3KREU.js";export{S as SceneTreeController}from"./p-CWieLCfP.js";export{f as fromNodeProto,i as isLoadedRow}from"./p-CiSHWNC4.js";export{S as SCENE_ITEM_NAME_METADATA_KEY}from"./p-BZwvQkyb.js";export{C as CursorManager,b as boxQueryCursor,l as labelPinCursor,m as measurementCursor,a as measurementWithArrowCursor,p as pinCursor}from"./p-AZXboIdP.js";export{M as MeasurementController,a as MeasurementEntity}from"./p-BqEOBQcx.js";export{M as MeasurementModel}from"./p-CkUMpn7h.js";export{M as MeasurementOverlayManager}from"./p-CI-uemp_.js";export{m as makeMinimumDistanceResult}from"./p-BKId5xpb.js";import{v as n,q as u,m as x}from"./p-Tvs4yxd5.js";export{T as TransformController}from"./p-B6pxBmYG.js";export{f as flattenPointArray,a as toDegreesTransform,e as toLocalTransform,b as toMatrix,t as toRadiansTransform,c as toTransform,d as toWorldTransform}from"./p-B2SMWIov.js";export{A as AngleUnits,g as AreaUnits,c as CrossSectioning,D as DistanceUnits,E as EntityType,F as FrameCameraBase,O as Orientation,a as ReceivedFrame,b as ReceivedFrameImage,d as ReceivedFrameScene,e as ReceivedOrthographicCamera,f as ReceivedPerspectiveCamera,S as StandardView}from"./p-EXufj_Hh.js";export{A as ArrowMarkup,C as CircleMarkup,F as FreeformMarkup}from"./p-BvP_LmOT.js";export{V as Viewport}from"./p-Dpyl9pSp.js";export{V as VolumeIntersectionQueryController,a as VolumeIntersectionQueryModel}from"./p-LNbPAbCr.js";const y=.9999;function v(e){const r=n.create(0,e.z,-e.y);const a=n.create(-e.z,0,e.x);const s=n.magnitudeSquared(r)>n.magnitudeSquared(a)?r:a;return n.normalize(n.cross(e,s))}function B(e,r){const a=n.dot(e,r);if(a>y){const r=v(e);const a=u.fromAxisAngle(r,Math.PI);return x.makeRotation(a)}else if(a<=-y){return x.makeIdentity()}else{const a=n.angleTo(r,e);const s=n.normalize(n.cross(e,r));return x.makeRotation(u.fromAxisAngle(s,a+Math.PI))}}function _(e,r,a,s){const o=B(e,a);const t=x.makeTranslation(s);return x.multiply(x.multiply(t,o),x.makeTranslation(n.negate(r)))}var Q=Object.freeze({__proto__:null,ALMOST_ONE:y,calculateOrthogonalCoordinate:v,computeRotationMatrix:B,computeTransformationDelta:_});o();export{Q as TransformationDelta};
4
+ import{g as o}from"./p-DmsAWRoU.js";export{a as getAssetPath,r as render,s as setAssetPath,b as setNonce,c as setPlatformOptions}from"./p-DmsAWRoU.js";export{C as Camera,c as ColorMaterial,a as CrossSectioner,I as ItemOperationBuilder,l as LoadableResource,M as ModelViewController,P as PmiAnnotationOperationsBuilder,b as PmiAnnotationsQueryExecutor,k as PmiController,R as Raycaster,d as RootQuery,S as Scene,e as SceneElementQueryExecutor,f as SceneElementsOperationExecutor,g as SceneItemOperationsBuilder,h as SceneItemQueryExecutor,i as SceneItemsOperationExecutor,s as SceneViewStateIdentifier,j as SynchronizedClock}from"./p-Ckz3KREU.js";export{S as SceneTreeController}from"./p-CWieLCfP.js";export{f as fromNodeProto,i as isLoadedRow}from"./p-CiSHWNC4.js";export{S as SCENE_ITEM_NAME_METADATA_KEY}from"./p-BZwvQkyb.js";export{C as CursorManager,b as boxQueryCursor,l as labelPinCursor,m as measurementCursor,a as measurementWithArrowCursor,p as pinCursor}from"./p-AZXboIdP.js";export{M as MeasurementController,a as MeasurementEntity}from"./p-Bfbzt4ZR.js";export{M as MeasurementModel}from"./p-CkUMpn7h.js";export{M as MeasurementOverlayManager}from"./p-CI-uemp_.js";export{m as makeMinimumDistanceResult}from"./p-BKId5xpb.js";import{v as n,q as u,m as x}from"./p-Tvs4yxd5.js";export{T as TransformController}from"./p-B6pxBmYG.js";export{f as flattenPointArray,a as toDegreesTransform,e as toLocalTransform,b as toMatrix,t as toRadiansTransform,c as toTransform,d as toWorldTransform}from"./p-B2SMWIov.js";export{A as AngleUnits,g as AreaUnits,c as CrossSectioning,D as DistanceUnits,E as EntityType,F as FrameCameraBase,O as Orientation,a as ReceivedFrame,b as ReceivedFrameImage,d as ReceivedFrameScene,e as ReceivedOrthographicCamera,f as ReceivedPerspectiveCamera,S as StandardView}from"./p-EXufj_Hh.js";export{A as ArrowMarkup,C as CircleMarkup,F as FreeformMarkup}from"./p-BvP_LmOT.js";export{V as Viewport}from"./p-Dpyl9pSp.js";export{V as VolumeIntersectionQueryController,a as VolumeIntersectionQueryModel}from"./p-LNbPAbCr.js";const y=.9999;function v(e){const r=n.create(0,e.z,-e.y);const a=n.create(-e.z,0,e.x);const s=n.magnitudeSquared(r)>n.magnitudeSquared(a)?r:a;return n.normalize(n.cross(e,s))}function _(e,r){const a=n.dot(e,r);if(a>y){const r=v(e);const a=u.fromAxisAngle(r,Math.PI);return x.makeRotation(a)}else if(a<=-y){return x.makeIdentity()}else{const a=n.angleTo(r,e);const s=n.normalize(n.cross(e,r));return x.makeRotation(u.fromAxisAngle(s,a+Math.PI))}}function B(e,r,a,s){const o=_(e,a);const t=x.makeTranslation(s);return x.multiply(x.multiply(t,o),x.makeTranslation(n.negate(r)))}var w=Object.freeze({__proto__:null,ALMOST_ONE:y,calculateOrthogonalCoordinate:v,computeRotationMatrix:_,computeTransformationDelta:B});o();export{w as TransformationDelta};
5
5
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
+ */
4
+ import{m as t,a as s,g as i}from"./p-DrkwJOM4.js";import{s as e,w as n}from"./p-zTYgyBoa.js";import{r,c as o}from"./p-CjG1fMh1.js";import{v as h}from"./p-CtJtApsf.js";import{m as a}from"./p-Dc9KNUUp.js";import{n as c}from"./p-EXufj_Hh.js";class m{constructor(t,s,i,e){this.model=t;this.client=s;this.jwtProvider=i;this.deviceId=e;this.outcome=Promise.resolve(undefined);this.debugLogs=false}addEntity(s){if(this.debugLogs){const i=t.ModelEntity.deserializeBinary(s.modelEntity);this.log(`Adding ModelEntity. [entityId={${i.getEntityId()}}, sceneItemId={${i.getSceneItemId()}}]`)}return this.performMeasurement((()=>this.model.addEntity(s)))}clearEntities(){this.log("Clearing all ModelEntities.");return this.performMeasurement((()=>{this.model.clearEntities();this.model.clearOutcome();return true}))}removeEntity(s){if(this.debugLogs){const i=t.ModelEntity.deserializeBinary(s.modelEntity);this.log(`Removing ModelEntity. [entityId={${i.getEntityId()}}, sceneItemId={${i.getSceneItemId()}}]`)}return this.performMeasurement((()=>this.model.removeEntity(s)))}setEntities(s){if(this.debugLogs){const i=Array.from(s).map((s=>t.ModelEntity.deserializeBinary(s.modelEntity)));this.log(`Setting ${i.length} ModelEntities. [entityIds=[${i.map((t=>t.getEntityId())).join(", ")}], sceneItemIds=[${i.map((t=>t.getSceneItemId())).join(", ")}]]`)}return this.performMeasurement((()=>this.model.setEntities(s)))}setDebugLogs(t){this.debugLogs=t}performMeasurement(t){const s=this.model.getEntities();const i=t();const e=this.model.getEntities();if(i){this.measureAndUpdateModel(e);this.highlightEntities(s,e)}return this.outcome}measureAndUpdateModel(t){if(t.length>0){this.outcome=this.measureEntities(t).then((t=>{this.model.setOutcome(t);return this.model.getOutcome()}))}else{this.outcome=Promise.resolve(undefined)}}async measureEntities(t){if(t.length>0){const i=await r((async s=>{const i=await o(this.jwtProvider,this.deviceId);const n=new e.MeasureRequest;n.setEntitiesList(t.map((t=>t.toProto())));this.client.measure(n,i,s)}));return s(i.toObject())}else{return undefined}}async highlightEntities(s,i){await r((async r=>{const h=await o(this.jwtProvider,this.deviceId);const a=new Set(i);const c=s.filter((t=>!a.has(t)));const m=c.map((s=>{const i=new e.ModelEntityUpdate;i.setModelEntity(t.ModelEntity.deserializeBinary(s.modelEntity));i.setHighlight((new n.BoolValue).setValue(false));return i}));const u=i.map((s=>{const i=new e.ModelEntityUpdate;i.setModelEntity(t.ModelEntity.deserializeBinary(s.modelEntity));i.setHighlight((new n.BoolValue).setValue(true));return i}));const d=new e.UpdateModelEntitiesRequest;d.setUpdatesList([...m,...u]);this.client.updateModelEntities(d,h,r)}))}log(t,...s){if(this.debugLogs){console.debug(t,s)}}}class u{constructor(t,s){this.point=t;this.modelEntity=s}static fromHit(t){if(t.hitPoint!=null&&t.modelEntity!=null){const s=a.ifInvalidThrow(c)(t.hitPoint);const i=h.protobuf.core.ModelEntity.encode(t.modelEntity).finish();return new u(s,i)}else{throw new Error("Cannot create MeasurementEntity from Hit. Hit is missing hit point and model entity")}}toProto(){const s=new e.MeasureEntity;const n=new i.Vector3f;n.setX(this.point.x);n.setY(this.point.y);n.setZ(this.point.z);s.setPoint(n);const r=t.ModelEntity.deserializeBinary(this.modelEntity);s.setModelEntity(r);return s}}export{m as M,u as a};
5
+ //# sourceMappingURL=p-Bfbzt4ZR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MeasurementController","constructor","model","client","jwtProvider","deviceId","this","outcome","Promise","resolve","undefined","debugLogs","addEntity","entity","deserializedEntity","ModelEntity","deserializeBinary","modelEntity","log","getEntityId","getSceneItemId","performMeasurement","clearEntities","clearOutcome","removeEntity","setEntities","entities","deserializedEntities","Array","from","map","e","length","join","setDebugLogs","effect","previous","getEntities","changed","measureAndUpdateModel","highlightEntities","measureEntities","then","setOutcome","getOutcome","res","requestUnary","async","handler","meta","createMetadata","req","MeasureRequest","setEntitiesList","toProto","measure","mapMeasureResponseOrThrow","toObject","entitySet","Set","newPrevious","filter","has","update","ModelEntityUpdate","setModelEntity","setHighlight","BoolValue","setValue","UpdateModelEntitiesRequest","setUpdatesList","updateModelEntities","message","optionalParams","console","debug","MeasurementEntity","point","fromHit","hit","hitPoint","Mapper","ifInvalidThrow","fromPbVector3f","vertexvis","protobuf","core","encode","finish","Error","MeasureEntity","Vector3f","setX","x","setY","y","setZ","z","setPoint"],"sources":["src/lib/measurement/controller.ts","src/lib/measurement/entities.ts"],"sourcesContent":["import { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport {\n MeasureRequest,\n MeasureResponse,\n ModelEntityUpdate,\n UpdateModelEntitiesRequest,\n} from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { SceneViewAPIClient } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb_service';\nimport { BoolValue } from 'google-protobuf/google/protobuf/wrappers_pb';\n\nimport { createMetadata, JwtProvider, requestUnary } from '../grpc';\nimport { MeasurementEntity } from './entities';\nimport { mapMeasureResponseOrThrow } from './mapper';\nimport { MeasurementModel } from './model';\nimport { MeasurementOutcome } from './outcomes';\n\n/**\n * The `MeasurementController` is responsible for performing measurements of\n * registered entities, and updating the model with their measurement results.\n */\nexport class MeasurementController {\n private outcome = Promise.resolve<MeasurementOutcome | undefined>(undefined);\n private debugLogs = false;\n\n public constructor(\n private model: MeasurementModel,\n private client: SceneViewAPIClient,\n private jwtProvider: JwtProvider,\n private deviceId: string | undefined\n ) {}\n\n /**\n * Registers an entity to measure and performs a measurement if this entity\n * has not been previously registered.\n *\n * @param entity The entity to measure.\n * @returns A promise that resolves with the results after registering this\n * entity.\n */\n public addEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Adding ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.addEntity(entity));\n }\n\n /**\n * Clears all entities and returns a promise that resolves with an empty list\n * of measurement results.\n */\n public clearEntities(): Promise<MeasurementOutcome | undefined> {\n this.log('Clearing all ModelEntities.');\n\n return this.performMeasurement(() => {\n this.model.clearEntities();\n this.model.clearOutcome();\n return true;\n });\n }\n\n /**\n * Deregisters an entity and performs a measurement if this entity was\n * removed.\n *\n * @param entity The entity to remove.\n * @returns A promise that resolves with the results after removing this\n * entity.\n */\n public removeEntity(\n entity: MeasurementEntity\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntity = ModelEntity.deserializeBinary(\n entity.modelEntity\n );\n\n this.log(\n `Removing ModelEntity. [entityId={${deserializedEntity.getEntityId()}}, sceneItemId={${deserializedEntity.getSceneItemId()}}]`\n );\n }\n\n return this.performMeasurement(() => this.model.removeEntity(entity));\n }\n\n /**\n * Registers a set of entities and performs a measurement\n *\n * @param entities The entities to measure.\n * @returns A promise that resolves with the results after registering these\n * entities.\n */\n public setEntities(\n entities: Set<MeasurementEntity>\n ): Promise<MeasurementOutcome | undefined> {\n if (this.debugLogs) {\n const deserializedEntities = Array.from(entities).map((e) =>\n ModelEntity.deserializeBinary(e.modelEntity)\n );\n\n this.log(\n `Setting ${deserializedEntities.length} ModelEntities. [entityIds=[${deserializedEntities.map((e) => e.getEntityId()).join(', ')}], sceneItemIds=[${deserializedEntities.map((e) => e.getSceneItemId()).join(', ')}]]`\n );\n }\n\n return this.performMeasurement(() => this.model.setEntities(entities));\n }\n\n public setDebugLogs(debugLogs: boolean): void {\n this.debugLogs = debugLogs;\n }\n\n private performMeasurement(\n effect: () => boolean\n ): Promise<MeasurementOutcome | undefined> {\n const previous = this.model.getEntities();\n const changed = effect();\n const entities = this.model.getEntities();\n if (changed) {\n this.measureAndUpdateModel(entities);\n this.highlightEntities(previous, entities);\n }\n return this.outcome;\n }\n\n private measureAndUpdateModel(entities: MeasurementEntity[]): void {\n if (entities.length > 0) {\n this.outcome = this.measureEntities(entities).then((outcome) => {\n this.model.setOutcome(outcome);\n return this.model.getOutcome();\n });\n } else {\n this.outcome = Promise.resolve(undefined);\n }\n }\n\n private async measureEntities(\n entities: MeasurementEntity[]\n ): Promise<MeasurementOutcome | undefined> {\n if (entities.length > 0) {\n const res = await requestUnary<MeasureResponse>(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n const req = new MeasureRequest();\n req.setEntitiesList(entities.map((e) => e.toProto()));\n\n this.client.measure(req, meta, handler);\n });\n\n return mapMeasureResponseOrThrow(res.toObject());\n } else {\n return undefined;\n }\n }\n\n private async highlightEntities(\n previous: MeasurementEntity[],\n entities: MeasurementEntity[]\n ): Promise<void> {\n await requestUnary(async (handler) => {\n const meta = await createMetadata(this.jwtProvider, this.deviceId);\n\n const entitySet = new Set(entities);\n const newPrevious = previous.filter((e) => !entitySet.has(e));\n\n const clearEntities = newPrevious.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(false));\n return update;\n });\n const highlightEntities = entities.map((e) => {\n const update = new ModelEntityUpdate();\n update.setModelEntity(ModelEntity.deserializeBinary(e.modelEntity));\n update.setHighlight(new BoolValue().setValue(true));\n return update;\n });\n\n const req = new UpdateModelEntitiesRequest();\n req.setUpdatesList([...clearEntities, ...highlightEntities]);\n this.client.updateModelEntities(req, meta, handler);\n });\n }\n\n private log(message?: string, ...optionalParams: unknown[]): void {\n if (this.debugLogs) {\n console.debug(message, optionalParams);\n }\n }\n}\n","import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { Vector3 } from '@vertexvis/geometry';\nimport { Vector3f } from '@vertexvis/scene-view-protos/core/protos/geometry_pb';\nimport { ModelEntity } from '@vertexvis/scene-view-protos/core/protos/model_entity_pb';\nimport { MeasureEntity } from '@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb';\nimport { Mapper } from '@vertexvis/utils';\n\nimport { fromPbVector3f } from '../mappers';\n\nexport class MeasurementEntity {\n public constructor(\n public readonly point: Vector3.Vector3,\n public readonly modelEntity: Uint8Array\n ) {}\n\n public static fromHit(\n hit: vertexvis.protobuf.stream.IHit\n ): MeasurementEntity {\n if (hit.hitPoint != null && hit.modelEntity != null) {\n const hitPoint = Mapper.ifInvalidThrow(fromPbVector3f)(hit.hitPoint);\n const modelEntity = vertexvis.protobuf.core.ModelEntity.encode(\n hit.modelEntity\n ).finish();\n return new MeasurementEntity(hitPoint, modelEntity);\n } else {\n throw new Error(\n 'Cannot create MeasurementEntity from Hit. Hit is missing hit point and model entity'\n );\n }\n }\n\n public toProto(): MeasureEntity {\n const entity = new MeasureEntity();\n\n const point = new Vector3f();\n point.setX(this.point.x);\n point.setY(this.point.y);\n point.setZ(this.point.z);\n entity.setPoint(point);\n\n const modelEntity = ModelEntity.deserializeBinary(this.modelEntity);\n entity.setModelEntity(modelEntity);\n\n return entity;\n }\n}\n"],"mappings":";;;qPAoBaA,EAIX,WAAAC,CACUC,EACAC,EACAC,EACAC,GAHAC,KAAAJ,QACAI,KAAAH,SACAG,KAAAF,cACAE,KAAAD,WAPFC,KAAAC,QAAUC,QAAQC,QAAwCC,WAC1DJ,KAAAK,UAAY,K,CAiBb,SAAAC,CACLC,GAEA,GAAIP,KAAKK,UAAW,CAClB,MAAMG,EAAqBC,cAAYC,kBACrCH,EAAOI,aAGTX,KAAKY,IACH,kCAAkCJ,EAAmBK,gCAAgCL,EAAmBM,qB,CAI5G,OAAOd,KAAKe,oBAAmB,IAAMf,KAAKJ,MAAMU,UAAUC,I,CAOrD,aAAAS,GACLhB,KAAKY,IAAI,+BAET,OAAOZ,KAAKe,oBAAmB,KAC7Bf,KAAKJ,MAAMoB,gBACXhB,KAAKJ,MAAMqB,eACX,OAAO,IAAI,G,CAYR,YAAAC,CACLX,GAEA,GAAIP,KAAKK,UAAW,CAClB,MAAMG,EAAqBC,cAAYC,kBACrCH,EAAOI,aAGTX,KAAKY,IACH,oCAAoCJ,EAAmBK,gCAAgCL,EAAmBM,qB,CAI9G,OAAOd,KAAKe,oBAAmB,IAAMf,KAAKJ,MAAMsB,aAAaX,I,CAUxD,WAAAY,CACLC,GAEA,GAAIpB,KAAKK,UAAW,CAClB,MAAMgB,EAAuBC,MAAMC,KAAKH,GAAUI,KAAKC,GACrDhB,cAAYC,kBAAkBe,EAAEd,eAGlCX,KAAKY,IACH,WAAWS,EAAqBK,qCAAqCL,EAAqBG,KAAKC,GAAMA,EAAEZ,gBAAec,K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2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{h as e,F as t,t as r,p as s,H as a,e as n}from"./p-DmsAWRoU.js";import"./p-BBKWC-yY.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import"./p-EXufj_Hh.js";import{M as i}from"./p-CI-uemp_.js";import{l as o,p as l}from"./p-Tvs4yxd5.js";import{d as m}from"./p-Xr7Oa6iw.js";function v(e,t){const{camera:r,viewport:s}=t;const a=r.isPointBehindNear(e.start);const n=r.isPointBehindNear(e.end);if(a||n){const t=r.intersectLineWithNear(e);const i=o.create({start:a&&t!=null?t:e.start,end:n&&t!=null?t:e.end});const l=o.transformMatrix(i,r.projectionViewMatrix);return{start:s.transformVectorToViewport(l.start),end:s.transformVectorToViewport(l.end),hideStart:a,hideEnd:n}}else{const t=o.transformMatrix(e,r.projectionViewMatrix);return{start:s.transformVectorToViewport(t.start),end:s.transformVectorToViewport(t.end),hideStart:false,hideEnd:false}}}function d(e,t,r){const{start:s,end:a,hideStart:n,hideEnd:i}=v(e,r);const o=l.lerp(s,a,.5);const m=t!=="none"?c(e,t,r):undefined;return{startPt:s,endPt:a,labelPt:o,indicatorPt:m,hideStart:n,hideEnd:i}}function c(e,t,r){return r.viewport.transformWorldToViewport(t==="start"?e.start:e.end,r.camera.projectionViewMatrix)}const u=({overlay:t,viewport:r,camera:s})=>{if(t.type==="line"){return e(h,{overlay:t,viewport:r,camera:s})}else{return e(p,{overlay:t,viewport:r,camera:s})}};const h=({overlay:t,camera:r,viewport:s})=>{const{start:a,end:n}=v(t,{camera:r,viewport:s});return e("vertex-viewer-measurement-line",{class:"measurement-line",start:a,end:n})};const p=({overlay:{x:r,y:s,z:a},camera:n,viewport:i})=>{const o={camera:n,viewport:i};const{start:l,end:m}=v(r,o);const{start:d,end:c}=v(s,o);const{start:u,end:h}=v(a,o);return e(t,null,e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-x",start:l,end:m}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-y",start:d,end:c}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-z",start:u,end:h}))};const w=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;--viewer-measurement-overlays-x-axis-color:var(--x-axis-color);--viewer-measurement-overlays-y-axis-color:var(--y-axis-color);--viewer-measurement-overlays-z-axis-color:var(--z-axis-color)}.measurement-line{position:absolute;width:100%;height:100%}.measurement-line.distance-vector-x{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-x-axis-color )}.measurement-line.distance-vector-y{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-y-axis-color )}.measurement-line.distance-vector-z{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-z-axis-color )}`;const y=s(class t extends a{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementOverlays=new i;this.overlays=[];this.updateCamera=()=>{var e,t;this.camera=(t=(e=this.viewer)===null||e===void 0?void 0:e.frame)===null||t===void 0?void 0:t.scene.camera}}handleMeasurementOverlaysChanged(){this.removeModelListeners();this.addModelListeners();this.updateOverlays()}handleViewerChanged(e,t){this.removeViewerListeners(t);this.addViewerListeners();this.updateCamera()}componentWillLoad(){this.addModelListeners();this.addViewerListeners();this.updateOverlays();this.updateCamera()}addModelListeners(){this.onOverlaysChangedListener=this.measurementOverlays.onOverlaysChanged((()=>this.updateOverlays()))}removeModelListeners(){var e;(e=this.onOverlaysChangedListener)===null||e===void 0?void 0:e.dispose();this.onOverlaysChangedListener=undefined}addViewerListeners(){var e;(e=this.viewer)===null||e===void 0?void 0:e.addEventListener("frameReceived",this.updateCamera)}removeViewerListeners(e){e===null||e===void 0?void 0:e.removeEventListener("frameReceived",this.updateCamera)}updateOverlays(){this.overlays=this.measurementOverlays.getOverlays()}render(){return e(n,{key:"fbda189899fa87c57b11615693d1319eee341fea"},this.overlays.map((t=>{if(this.camera!=null&&this.viewer!=null){return e(u,{overlay:t,viewport:this.viewer.viewport,camera:this.camera})}})))}static get watchers(){return{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return w()}},[1,"vertex-viewer-measurement-overlays",{measurementOverlays:[16],camera:[1040],viewer:[16],overlays:[32]},undefined,{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}]);function f(){if(typeof customElements==="undefined"){return}const e=["vertex-viewer-measurement-overlays","vertex-viewer-measurement-line"];e.forEach((e=>{switch(e){case"vertex-viewer-measurement-overlays":if(!customElements.get(r(e))){customElements.define(r(e),y)}break;case"vertex-viewer-measurement-line":if(!customElements.get(r(e))){m()}break}}))}f();export{y as V,f as d,d as g};
5
- //# sourceMappingURL=p-DP0zP-Gr.js.map
4
+ import{h as e,F as t,t as r,p as s,H as a,e as n}from"./p-DmsAWRoU.js";import"./p-DrkwJOM4.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import"./p-EXufj_Hh.js";import{M as i}from"./p-CI-uemp_.js";import{l as o,p as l}from"./p-Tvs4yxd5.js";import{d as m}from"./p-Xr7Oa6iw.js";function v(e,t){const{camera:r,viewport:s}=t;const a=r.isPointBehindNear(e.start);const n=r.isPointBehindNear(e.end);if(a||n){const t=r.intersectLineWithNear(e);const i=o.create({start:a&&t!=null?t:e.start,end:n&&t!=null?t:e.end});const l=o.transformMatrix(i,r.projectionViewMatrix);return{start:s.transformVectorToViewport(l.start),end:s.transformVectorToViewport(l.end),hideStart:a,hideEnd:n}}else{const t=o.transformMatrix(e,r.projectionViewMatrix);return{start:s.transformVectorToViewport(t.start),end:s.transformVectorToViewport(t.end),hideStart:false,hideEnd:false}}}function d(e,t,r){const{start:s,end:a,hideStart:n,hideEnd:i}=v(e,r);const o=l.lerp(s,a,.5);const m=t!=="none"?c(e,t,r):undefined;return{startPt:s,endPt:a,labelPt:o,indicatorPt:m,hideStart:n,hideEnd:i}}function c(e,t,r){return r.viewport.transformWorldToViewport(t==="start"?e.start:e.end,r.camera.projectionViewMatrix)}const u=({overlay:t,viewport:r,camera:s})=>{if(t.type==="line"){return e(h,{overlay:t,viewport:r,camera:s})}else{return e(p,{overlay:t,viewport:r,camera:s})}};const h=({overlay:t,camera:r,viewport:s})=>{const{start:a,end:n}=v(t,{camera:r,viewport:s});return e("vertex-viewer-measurement-line",{class:"measurement-line",start:a,end:n})};const p=({overlay:{x:r,y:s,z:a},camera:n,viewport:i})=>{const o={camera:n,viewport:i};const{start:l,end:m}=v(r,o);const{start:d,end:c}=v(s,o);const{start:u,end:h}=v(a,o);return e(t,null,e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-x",start:l,end:m}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-y",start:d,end:c}),e("vertex-viewer-measurement-line",{class:"measurement-line distance-vector-z",start:u,end:h}))};const w=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;--viewer-measurement-overlays-x-axis-color:var(--x-axis-color);--viewer-measurement-overlays-y-axis-color:var(--y-axis-color);--viewer-measurement-overlays-z-axis-color:var(--z-axis-color)}.measurement-line{position:absolute;width:100%;height:100%}.measurement-line.distance-vector-x{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-x-axis-color )}.measurement-line.distance-vector-y{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-y-axis-color )}.measurement-line.distance-vector-z{--viewer-measurement-line-fill:var( --viewer-measurement-overlays-z-axis-color )}`;const y=s(class t extends a{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementOverlays=new i;this.overlays=[];this.updateCamera=()=>{var e,t;this.camera=(t=(e=this.viewer)===null||e===void 0?void 0:e.frame)===null||t===void 0?void 0:t.scene.camera}}handleMeasurementOverlaysChanged(){this.removeModelListeners();this.addModelListeners();this.updateOverlays()}handleViewerChanged(e,t){this.removeViewerListeners(t);this.addViewerListeners();this.updateCamera()}componentWillLoad(){this.addModelListeners();this.addViewerListeners();this.updateOverlays();this.updateCamera()}addModelListeners(){this.onOverlaysChangedListener=this.measurementOverlays.onOverlaysChanged((()=>this.updateOverlays()))}removeModelListeners(){var e;(e=this.onOverlaysChangedListener)===null||e===void 0?void 0:e.dispose();this.onOverlaysChangedListener=undefined}addViewerListeners(){var e;(e=this.viewer)===null||e===void 0?void 0:e.addEventListener("frameReceived",this.updateCamera)}removeViewerListeners(e){e===null||e===void 0?void 0:e.removeEventListener("frameReceived",this.updateCamera)}updateOverlays(){this.overlays=this.measurementOverlays.getOverlays()}render(){return e(n,{key:"fbda189899fa87c57b11615693d1319eee341fea"},this.overlays.map((t=>{if(this.camera!=null&&this.viewer!=null){return e(u,{overlay:t,viewport:this.viewer.viewport,camera:this.camera})}})))}static get watchers(){return{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return w()}},[1,"vertex-viewer-measurement-overlays",{measurementOverlays:[16],camera:[1040],viewer:[16],overlays:[32]},undefined,{measurementOverlays:[{handleMeasurementOverlaysChanged:0}],viewer:[{handleViewerChanged:0}]}]);function f(){if(typeof customElements==="undefined"){return}const e=["vertex-viewer-measurement-overlays","vertex-viewer-measurement-line"];e.forEach((e=>{switch(e){case"vertex-viewer-measurement-overlays":if(!customElements.get(r(e))){customElements.define(r(e),y)}break;case"vertex-viewer-measurement-line":if(!customElements.get(r(e))){m()}break}}))}f();export{y as V,f as d,d as g};
5
+ //# sourceMappingURL=p-C8zX6RrH.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{h as e,F as i,t,p as n,H as o}from"./p-DmsAWRoU.js";import{p as s,m as r,v as a}from"./p-Tvs4yxd5.js";import"./p-CWieLCfP.js";import"./p-AZXboIdP.js";import"./p-BBKWC-yY.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import"./p-EXufj_Hh.js";import"./p-BhXUumVg.js";import{V as l}from"./p-Dpyl9pSp.js";import{d,P as c,t as p}from"./p-BfvfuUhv.js";import{g as h,i as v,a as u,P as b}from"./p-zxYMoA6A.js";import{c as f}from"./p-C6gMOKYg.js";import{d as m}from"./p-ChMr_49H.js";import{d as w}from"./p-nGQgu0fu.js";import{d as x}from"./p-eQ-n5bzB.js";const y=({pin:t,selected:n,occluded:o,detached:s})=>{const{primaryColor:r}=h(t);return e(i,null,u(t)&&e("div",{id:"pin-anchor",class:f("pin-anchor",{selected:n,"pin-occluded":o,"pin-detached":s}),style:{background:r}}),v(t)&&e("vertex-viewer-icon",{name:"pin-fill",size:"lg",class:f("pin",{"pin-selected":n,"pin-occluded":o,"pin-detached":s}),style:{color:r}}))};function g(e,i,t){const n={x:e.x+t.width/2,y:e.y};const o={x:e.x+t.width/2,y:e.y+t.height};const r={x:e.x+t.width,y:e.y+t.height/2};const a={x:e.x,y:e.y+t.height/2};const l=[n,o,a,r];const d=l.map((e=>s.distance(e,i)));const c=d.indexOf(Math.min(...d));return l[c]}const P=()=>`:host{--viewer-annotations-pin-primary-color:var(--blue-700);--viewer-annotations-pin-accent-color:var(--blue-200);--viewer-annotations-pin-dot-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-font-size:0.75rem;--viewer-annotations-pin-selected-stroke:var(--white);--viewer-annotations-pin-selected-border:2px solid var(--white);--viewer-annotations-pin-label-border:2px solid var(--black);--viewer-annotations-pin-selected-stroke:var(--white);font-size:var(--viewer-annotations-pin-font-size);position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}.pin-anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;width:9px;height:9px;box-sizing:border-box;border:var(--viewer-annotations-pin-label-border);background:var(--viewer-annotations-pin-dot-color);pointer-events:auto;cursor:pointer}.selected{width:13px;height:13px;border:var(--viewer-annotations-pin-selected-border)}.pin{color:var(--viewer-annotations-pin-color);cursor:pointer;transition:opacity 0.3s ease-in;transform:translate(0px, -12px)}.pin-selected{stroke-width:1;stroke:var(--viewer-annotations-pin-selected-stroke)}.pin-occluded{opacity:.3;transition:opacity 0.3s ease-in}.pin-detached{visibility:hidden}`;const k=n(class t extends o{constructor(e){super();if(e!==false){this.__registerHost()}this.matrix=r.makeIdentity();this.projectionViewMatrix=r.makeIdentity();this.pinModel=new b;this.selected=false;this.occluded=false;this.detached=false;this.invalidateStateCounter=0;this.invalidateState=()=>{this.invalidateStateCounter=this.invalidateStateCounter+1}}componentDidLoad(){var e;this.setLabelObserver();if(this.pinController==null){this.pinController=new c(this.pinModel)}if(this.selected){(e=this.labelEl)===null||e===void 0?void 0:e.setFocus()}}async handleOcclusionStateChanged(e){this.occluded=e.detail}async handleDetachedStateChanged(e){this.detached=e.detail}disconnectedCallback(){var e,i;(e=this.labelEl)===null||e===void 0?void 0:e.removeEventListener("labelChanged",this.invalidateState);(i=this.resizeObserver)===null||i===void 0?void 0:i.disconnect()}render(){var t;if(this.pin==null){throw new Error("Unable to draw pin")}const{pinPoint:n,labelPoint:o}=this.computePinPoints(this.pin);return e(i,{key:"b26f95c0e4b86b263eca80c5db8576ef1c787b26"},e("vertex-viewer-dom-element",{key:"9fcb9d0f55f9abb3397db4051ed59c7a05d4ae6a","data-testid":`drawn-pin-${this.pin.id}`,position:this.pin.worldPosition,onPointerDown:async()=>{var e;await((e=this.labelEl)===null||e===void 0?void 0:e.submit());this.selectPin();this.handleAnchorPointerDown()},detachedOff:false},e(y,{key:"2264652f4c83539f47af324f6937fb6581edafe1",pin:this.pin,selected:this.selected,occluded:this.occluded,detached:this.detached})),u(this.pin)&&!this.occluded&&!this.detached&&e(i,{key:"04c86f573b99fb320b0a651dc903131e6654bd9e"},e("vertex-viewer-pin-label-line",{key:"cec6ee8195fba5fadd9e1b272abd61b6b6dd05c6",id:`pin-label-line-${(t=this.pin)===null||t===void 0?void 0:t.id}`,pinPoint:n,pin:this.pin,labelPoint:o,onPointerDown:()=>this.selectPin()}),e("vertex-viewer-pin-label",{key:"556a36ac8e9046b0e40c6973c1ecf47319f28ab6",pin:this.pin,ref:e=>this.labelEl=e,elementBounds:this.elementBounds,pinController:this.pinController,onPointerDown:()=>this.selectPin()})))}setLabelObserver(){if(this.labelEl!=null){this.labelEl.addEventListener("labelChanged",this.invalidateState);this.resizeObserver=new ResizeObserver((()=>this.invalidateState()));this.resizeObserver.observe(this.labelEl)}}computePinPoints(e){if(this.elementBounds!=null&&this.pin!=null){return u(this.pin)&&this.pin.label.point!=null?this.computeTextPinPoints(this.pin,this.elementBounds):this.computeDefaultPinPoints(this.pin,this.elementBounds)}return{pinPoint:e.worldPosition}}computeDefaultPinPoints(e,i){return{pinPoint:this.getFromWorldPosition(e.worldPosition,this.projectionViewMatrix,i)}}computeTextPinPoints(e,i){var t,n,o,s;const{pinPoint:r}=this.computeDefaultPinPoints(e,i);const a=p(e.label.point,i);const l=((n=(t=this.labelEl)===null||t===void 0?void 0:t.firstElementChild)===null||n===void 0?void 0:n.clientWidth)||0;const d=((s=(o=this.labelEl)===null||o===void 0?void 0:o.firstElementChild)===null||s===void 0?void 0:s.clientHeight)||0;return{pinPoint:r,labelPoint:g(a,r,{width:l,height:d})}}handleAnchorPointerDown(){var e,i;if(this.elementBounds!=null&&((e=this.pinController)===null||e===void 0?void 0:e.getToolMode())==="edit"&&this.pin!=null){(i=this.pinController)===null||i===void 0?void 0:i.setDraggable({id:this.pin.id})}}selectPin(){var e,i;(e=this.pinController)===null||e===void 0?void 0:e.setSelectedPinId((i=this.pin)===null||i===void 0?void 0:i.id)}getFromWorldPosition(e,i,t){const n=a.transformMatrix(e,i);return l.fromDimensions(t).transformVectorToViewport(n)}static get style(){return P()}},[0,"vertex-viewer-pin-group",{pin:[16],matrix:[1040],projectionViewMatrix:[16],elementBounds:[1040],pinModel:[16],pinController:[16],selected:[4],occluded:[1540],detached:[1540],invalidateStateCounter:[32]},[[0,"occlusionStateChanged","handleOcclusionStateChanged"],[0,"detachedStateChanged","handleDetachedStateChanged"]]]);function j(){if(typeof customElements==="undefined"){return}const e=["vertex-viewer-pin-group","vertex-viewer-dom-element","vertex-viewer-icon","vertex-viewer-pin-label","vertex-viewer-pin-label-line"];e.forEach((e=>{switch(e){case"vertex-viewer-pin-group":if(!customElements.get(t(e))){customElements.define(t(e),k)}break;case"vertex-viewer-dom-element":if(!customElements.get(t(e))){m()}break;case"vertex-viewer-icon":if(!customElements.get(t(e))){w()}break;case"vertex-viewer-pin-label":if(!customElements.get(t(e))){d()}break;case"vertex-viewer-pin-label-line":if(!customElements.get(t(e))){x()}break}}))}j();export{k as V,j as d};
5
- //# sourceMappingURL=p-DU6goRD0.js.map
4
+ import{h as e,F as i,t,p as n,H as o}from"./p-DmsAWRoU.js";import{p as s,m as r,v as a}from"./p-Tvs4yxd5.js";import"./p-CWieLCfP.js";import"./p-AZXboIdP.js";import"./p-DrkwJOM4.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import"./p-EXufj_Hh.js";import"./p-BhXUumVg.js";import{V as l}from"./p-Dpyl9pSp.js";import{d,P as c,t as p}from"./p-BfvfuUhv.js";import{g as h,i as v,a as u,P as b}from"./p-zxYMoA6A.js";import{c as f}from"./p-C6gMOKYg.js";import{d as m}from"./p-ChMr_49H.js";import{d as w}from"./p-nGQgu0fu.js";import{d as x}from"./p-eQ-n5bzB.js";const y=({pin:t,selected:n,occluded:o,detached:s})=>{const{primaryColor:r}=h(t);return e(i,null,u(t)&&e("div",{id:"pin-anchor",class:f("pin-anchor",{selected:n,"pin-occluded":o,"pin-detached":s}),style:{background:r}}),v(t)&&e("vertex-viewer-icon",{name:"pin-fill",size:"lg",class:f("pin",{"pin-selected":n,"pin-occluded":o,"pin-detached":s}),style:{color:r}}))};function g(e,i,t){const n={x:e.x+t.width/2,y:e.y};const o={x:e.x+t.width/2,y:e.y+t.height};const r={x:e.x+t.width,y:e.y+t.height/2};const a={x:e.x,y:e.y+t.height/2};const l=[n,o,a,r];const d=l.map((e=>s.distance(e,i)));const c=d.indexOf(Math.min(...d));return l[c]}const P=()=>`:host{--viewer-annotations-pin-primary-color:var(--blue-700);--viewer-annotations-pin-accent-color:var(--blue-200);--viewer-annotations-pin-dot-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-color:var(--viewer-annotations-pin-primary-color);--viewer-annotations-pin-font-size:0.75rem;--viewer-annotations-pin-selected-stroke:var(--white);--viewer-annotations-pin-selected-border:2px solid var(--white);--viewer-annotations-pin-label-border:2px solid var(--black);--viewer-annotations-pin-selected-stroke:var(--white);font-size:var(--viewer-annotations-pin-font-size);position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}.pin-anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;width:9px;height:9px;box-sizing:border-box;border:var(--viewer-annotations-pin-label-border);background:var(--viewer-annotations-pin-dot-color);pointer-events:auto;cursor:pointer}.selected{width:13px;height:13px;border:var(--viewer-annotations-pin-selected-border)}.pin{color:var(--viewer-annotations-pin-color);cursor:pointer;transition:opacity 0.3s ease-in;transform:translate(0px, -12px)}.pin-selected{stroke-width:1;stroke:var(--viewer-annotations-pin-selected-stroke)}.pin-occluded{opacity:.3;transition:opacity 0.3s ease-in}.pin-detached{visibility:hidden}`;const k=n(class t extends o{constructor(e){super();if(e!==false){this.__registerHost()}this.matrix=r.makeIdentity();this.projectionViewMatrix=r.makeIdentity();this.pinModel=new b;this.selected=false;this.occluded=false;this.detached=false;this.invalidateStateCounter=0;this.invalidateState=()=>{this.invalidateStateCounter=this.invalidateStateCounter+1}}componentDidLoad(){var e;this.setLabelObserver();if(this.pinController==null){this.pinController=new c(this.pinModel)}if(this.selected){(e=this.labelEl)===null||e===void 0?void 0:e.setFocus()}}async handleOcclusionStateChanged(e){this.occluded=e.detail}async handleDetachedStateChanged(e){this.detached=e.detail}disconnectedCallback(){var e,i;(e=this.labelEl)===null||e===void 0?void 0:e.removeEventListener("labelChanged",this.invalidateState);(i=this.resizeObserver)===null||i===void 0?void 0:i.disconnect()}render(){var t;if(this.pin==null){throw new Error("Unable to draw pin")}const{pinPoint:n,labelPoint:o}=this.computePinPoints(this.pin);return e(i,{key:"b26f95c0e4b86b263eca80c5db8576ef1c787b26"},e("vertex-viewer-dom-element",{key:"9fcb9d0f55f9abb3397db4051ed59c7a05d4ae6a","data-testid":`drawn-pin-${this.pin.id}`,position:this.pin.worldPosition,onPointerDown:async()=>{var e;await((e=this.labelEl)===null||e===void 0?void 0:e.submit());this.selectPin();this.handleAnchorPointerDown()},detachedOff:false},e(y,{key:"2264652f4c83539f47af324f6937fb6581edafe1",pin:this.pin,selected:this.selected,occluded:this.occluded,detached:this.detached})),u(this.pin)&&!this.occluded&&!this.detached&&e(i,{key:"04c86f573b99fb320b0a651dc903131e6654bd9e"},e("vertex-viewer-pin-label-line",{key:"cec6ee8195fba5fadd9e1b272abd61b6b6dd05c6",id:`pin-label-line-${(t=this.pin)===null||t===void 0?void 0:t.id}`,pinPoint:n,pin:this.pin,labelPoint:o,onPointerDown:()=>this.selectPin()}),e("vertex-viewer-pin-label",{key:"556a36ac8e9046b0e40c6973c1ecf47319f28ab6",pin:this.pin,ref:e=>this.labelEl=e,elementBounds:this.elementBounds,pinController:this.pinController,onPointerDown:()=>this.selectPin()})))}setLabelObserver(){if(this.labelEl!=null){this.labelEl.addEventListener("labelChanged",this.invalidateState);this.resizeObserver=new ResizeObserver((()=>this.invalidateState()));this.resizeObserver.observe(this.labelEl)}}computePinPoints(e){if(this.elementBounds!=null&&this.pin!=null){return u(this.pin)&&this.pin.label.point!=null?this.computeTextPinPoints(this.pin,this.elementBounds):this.computeDefaultPinPoints(this.pin,this.elementBounds)}return{pinPoint:e.worldPosition}}computeDefaultPinPoints(e,i){return{pinPoint:this.getFromWorldPosition(e.worldPosition,this.projectionViewMatrix,i)}}computeTextPinPoints(e,i){var t,n,o,s;const{pinPoint:r}=this.computeDefaultPinPoints(e,i);const a=p(e.label.point,i);const l=((n=(t=this.labelEl)===null||t===void 0?void 0:t.firstElementChild)===null||n===void 0?void 0:n.clientWidth)||0;const d=((s=(o=this.labelEl)===null||o===void 0?void 0:o.firstElementChild)===null||s===void 0?void 0:s.clientHeight)||0;return{pinPoint:r,labelPoint:g(a,r,{width:l,height:d})}}handleAnchorPointerDown(){var e,i;if(this.elementBounds!=null&&((e=this.pinController)===null||e===void 0?void 0:e.getToolMode())==="edit"&&this.pin!=null){(i=this.pinController)===null||i===void 0?void 0:i.setDraggable({id:this.pin.id})}}selectPin(){var e,i;(e=this.pinController)===null||e===void 0?void 0:e.setSelectedPinId((i=this.pin)===null||i===void 0?void 0:i.id)}getFromWorldPosition(e,i,t){const n=a.transformMatrix(e,i);return l.fromDimensions(t).transformVectorToViewport(n)}static get style(){return P()}},[0,"vertex-viewer-pin-group",{pin:[16],matrix:[1040],projectionViewMatrix:[16],elementBounds:[1040],pinModel:[16],pinController:[16],selected:[4],occluded:[1540],detached:[1540],invalidateStateCounter:[32]},[[0,"occlusionStateChanged","handleOcclusionStateChanged"],[0,"detachedStateChanged","handleDetachedStateChanged"]]]);function j(){if(typeof customElements==="undefined"){return}const e=["vertex-viewer-pin-group","vertex-viewer-dom-element","vertex-viewer-icon","vertex-viewer-pin-label","vertex-viewer-pin-label-line"];e.forEach((e=>{switch(e){case"vertex-viewer-pin-group":if(!customElements.get(t(e))){customElements.define(t(e),k)}break;case"vertex-viewer-dom-element":if(!customElements.get(t(e))){m()}break;case"vertex-viewer-icon":if(!customElements.get(t(e))){w()}break;case"vertex-viewer-pin-label":if(!customElements.get(t(e))){d()}break;case"vertex-viewer-pin-label-line":if(!customElements.get(t(e))){x()}break}}))}j();export{k as V,j as d};
5
+ //# sourceMappingURL=p-Ce-6kPRQ.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{b as a,c as s}from"./p-zTYgyBoa.js";import{m as t}from"./p-Dc9KNUUp.js";import{V as n,n as e}from"./p-EXufj_Hh.js";var o=a();const p=t.defineMapper(t.read(t.mapRequiredProp("start",n),t.mapRequiredProp("end",n)),(([a,s])=>({start:a,end:s})));const c=t.defineMapper(t.read(t.getProp("distance"),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("start"))),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("end")))),(([a,s,t])=>({type:"planar-distance",distance:a,plane1:s,plane2:t})));const r=t.defineMapper(t.read(t.getProp("angleInRadians"),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("start"))),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("end")))),(([a,s,t])=>({type:"planar-angle",angle:a,plane1:s,plane2:t})));const i=t.defineMapper(t.read(t.getProp("distance"),t.mapRequiredProp("closestPoint1",e),t.mapRequiredProp("closestPoint2",e)),(([a,s,t])=>({type:"minimum-distance",distance:a,point1:s,point2:t})));const l=t.defineMapper(t.read(t.getProp("area")),(([a])=>({type:"surface-area",area:a})));const m=t.mapProp("planarDistance",t.ifDefined(c));const d=t.mapProp("planarAngle",t.ifDefined(r));const u=t.mapProp("minimumDistance",t.ifDefined(i));const f=t.mapProp("totalSurfaceArea",t.ifDefined(l));const g=t.compose(t.pickFirst(m,d,u,f),t.required("Result field"));const y=t.defineMapper(t.read(t.mapRequiredProp("outcome",t.mapRequiredProp("resultsList",t.mapArray(g))),t.mapRequiredProp("outcome",t.getProp("isApproximate"))),(([a,s])=>({results:a,isApproximate:s})));const j=t.ifInvalidThrow(y);var A=s();export{o as a,A as g,j as m};
5
- //# sourceMappingURL=p-BBKWC-yY.js.map
4
+ import{b as a,c as s}from"./p-zTYgyBoa.js";import{m as t}from"./p-Dc9KNUUp.js";import{V as n,n as e}from"./p-EXufj_Hh.js";var o=a();const p=t.defineMapper(t.read(t.mapRequiredProp("start",n),t.mapRequiredProp("end",n)),(([a,s])=>({start:a,end:s})));const c=t.defineMapper(t.read(t.getProp("distance"),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("start"))),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("end")))),(([a,s,t])=>({type:"planar-distance",distance:a,plane1:s,plane2:t})));const r=t.defineMapper(t.read(t.getProp("angleInRadians"),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("start"))),t.mapRequiredProp("planes",t.compose(p,t.requiredProp("end")))),(([a,s,t])=>({type:"planar-angle",angle:a,plane1:s,plane2:t})));const i=t.defineMapper(t.read(t.getProp("distance"),t.mapRequiredProp("closestPoint1",e),t.mapRequiredProp("closestPoint2",e)),(([a,s,t])=>({type:"minimum-distance",distance:a,point1:s,point2:t})));const l=t.defineMapper(t.read(t.getProp("area")),(([a])=>({type:"surface-area",area:a})));const m=t.mapProp("planarDistance",t.ifDefined(c));const d=t.mapProp("planarAngle",t.ifDefined(r));const u=t.mapProp("minimumDistance",t.ifDefined(i));const f=t.mapProp("totalSurfaceArea",t.ifDefined(l));const g=t.compose(t.pickFirst(m,d,u,f),t.required("Result field"));const y=t.defineMapper(t.read(t.mapRequiredProp("outcome",t.mapRequiredProp("resultsList",t.mapArray(g))),t.mapRequiredProp("outcome",t.getProp("isApproximate"))),(([a,s])=>({results:a,isApproximate:s})));const j=t.ifInvalidThrow(y);var A=s();export{j as a,A as g,o as m};
5
+ //# sourceMappingURL=p-DrkwJOM4.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{h as t,t as e,p as i,H as n,d as s,e as r}from"./p-DmsAWRoU.js";import{v as a,a as o,p as h,l}from"./p-Tvs4yxd5.js";import{m as d}from"./p-AZXboIdP.js";import{b as c,g as u}from"./p-BSYTUXcE.js";import"./p-BBKWC-yY.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import{n as m,D as v}from"./p-EXufj_Hh.js";import{M as p}from"./p-CkUMpn7h.js";import{M as w}from"./p-CI-uemp_.js";import{m as f}from"./p-BKId5xpb.js";import{V as g}from"./p-Dpyl9pSp.js";import{E as b,m as y}from"./p-Dc9KNUUp.js";import{d as C,g as E}from"./p-DP0zP-Gr.js";import{c as P}from"./p-C6gMOKYg.js";import{d as x}from"./p-Xr7Oa6iw.js";const M=16;const k=10;function D(t){return t.getBoundingClientRect()}class j{constructor(t,e,i,n){this.stencil=t;this.depthBuffer=e;this.viewport=i;this.camera=n}hitTest(t){const e=this.viewport.transformPointToFrame(t,this.depthBuffer);if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);return this.stencil.hitTest(i)||this.depthBuffer.hitTest(e)}else{return this.depthBuffer.hitTest(e)}}snapToNearestPixel(t,e){if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);const n=this.stencil.snapToNearestPixel(i,e);return this.viewport.transformPointToViewport(n,this.stencil)}else{return t}}transformPointToWorld(t,{ignoreHitTest:e=false}={}){const i=this.pickDepthBuffer(t);if(i!=null){return this.viewport.transformPointToWorldSpace(t,i)}else if(e){return this.viewport.transformPointToWorldSpace(t,this.depthBuffer)}}pickDepthBuffer(t){if(this.stencil!=null){const e=this.viewport.transformPointToFrame(t,this.stencil);if(this.stencil.hitTest(e)){return this.stencil.depthBuffer}}const e=this.viewport.transformPointToFrame(t,this.depthBuffer);return this.depthBuffer.hitTest(e)?this.depthBuffer:undefined}}class A{constructor(t){this.model=t}newMeasurement(t,e){const i=e.hitTester().transformPointToWorld(t);return i!=null?new S(t,i,this.model):undefined}editMeasurement(t){const e=this.model.getMeasurement();if(e==null){throw new Error("Cannot edit measurement. Measurement is empty.")}return t==="start"?new B(e,this.model):new T(e,this.model)}clearIndicator(){this.model.setIndicator(undefined)}moveIndicator(t,e){const i=e.hitTester().transformPointToWorld(t);this.model.setIndicator(i);return i!=null}}class I{constructor(){this.measurementChanged=new b;this.indicatorChanged=new b}static empty(){return new I}getMeasurement(){return this.measurement}setMeasurement(t){if(this.measurement!==t){this.measurement=t;this.measurementChanged.emit(t)}}setMeasurementFromValues(t,e,i){if(t!=null&&e!=null){const n=i?U(t,e):H(t,e);this.setMeasurement(n)}else{this.setMeasurement(undefined)}}onMeasurementChanged(t){return this.measurementChanged.on(t)}getIndicator(){return this.indicator}setIndicator(t){if(this.indicator!==t){this.indicator=t;this.indicatorChanged.emit(t)}}onIndicatorChanged(t){return this.indicatorChanged.on(t)}}class S{constructor(t,e,i){this.pt=t;this.world=e;this.model=i;this.hitWorldValid=true;this.preventUpdate=false}fetchStartIfMissing(t){if(this.pendingStart==null){this.pendingStart=this.fetchStart(t)}}async fetchStart(t){const e=await t.raycaster();const i=await O(e,this.pt);if(i==null){const e=t.hitTester().transformPointToWorld(this.pt);this.hitWorld=e;this.hitWorldValid=false}else{this.hitWorld=i;this.hitWorldValid=true}}update(t,e){var i;if(!this.preventUpdate){this.fetchStartIfMissing(e);const n=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const s=e.hitTester().hitTest(t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;if(n==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!this.hitWorldValid||!s){this.model.setIndicator(n);this.setMeasurement(H(r,n))}else{this.model.setIndicator(n);this.setMeasurement(U(r,n))}}}async finish(t,e){var i;this.preventUpdate=true;this.fetchStartIfMissing(e);await this.pendingStart;this.model.setIndicator(undefined);const n=await e.raycaster();const s=await O(n,t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;this.preventUpdate=false;if(s==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete new measurement interaction. End point is empty.")}return this.setMeasurement(H(r,i))}else if(!this.hitWorldValid){return this.setMeasurement(H(r,s))}else{return this.setMeasurement(U(r,s))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class L{constructor(t,e){this.measurement=t;this.model=e}update(t,e){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const n=e.hitTester().hitTest(t);if(i==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!n){this.model.setIndicator(i);this.setMeasurement(this.getInvalidMeasurement(i))}else{this.model.setIndicator(i);this.setMeasurement(this.getValidMeasurement(i))}}async finish(t,e){const i=await e.raycaster();const n=await O(i,t);this.model.setIndicator(undefined);if(n==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete edit measurement interaction. End point is empty.")}return this.setMeasurement(this.getInvalidMeasurement(i))}else{return this.setMeasurement(this.getValidMeasurement(n))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class B extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return H(t,this.measurement.end)}getValidMeasurement(t){return U(t,this.measurement.end)}}class T extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return H(this.measurement.start,t)}getValidMeasurement(t){return U(this.measurement.start,t)}}async function O(t,e){var i;const n=await t.hitItems(e);const[s]=(i=n===null||n===void 0?void 0:n.hits)!==null&&i!==void 0?i:[];if((s===null||s===void 0?void 0:s.hitPoint)!=null){const t=m(s.hitPoint);if(y.isInvalid(t)){throw new Error(`Invalid hit response [${t.errors.join(",")}]`)}return t}else return undefined}function U(t,e){return{start:t,end:e,distance:a.distance(t,e),valid:true}}function H(t,e){return{start:t,end:e,valid:false}}const V=({startPt:e,endPt:i,centerPt:n,indicatorPt:s,distance:r,anchorLabelOffset:a,lineCapLength:l,linePointerEvents:d,hideStartAnchor:u,hideEndAnchor:m,onStartAnchorPointerDown:v,onEndAnchorPointerDown:p})=>{const w=e!=null&&i!=null?o.fromPoints(e,i):undefined;const f=w!=null&&e!=null&&a!=null?h.add(e,h.polar(-a,w)):undefined;const g=w!=null&&i!=null&&a!=null?h.add(i,h.polar(a,w)):undefined;return t("div",null,e!=null&&i!=null&&t("vertex-viewer-measurement-line",{class:P("line",{"hide-start-line-cap":u,"hide-end-line-cap":m}),start:e,end:i,capLength:l,pointerEvents:d}),!u&&e!=null&&t("div",{id:"start-anchor",class:"anchor anchor-start",style:{transform:c(e)},onPointerDown:v},t("slot",{name:"start-anchor"},t("div",{class:"anchor-placeholder"}))),!u&&f&&t("div",{class:"anchor-label anchor-label-start",style:{transform:c(f)}},t("slot",{name:"start-label"})),!m&&i!=null&&t("div",{id:"end-anchor",class:"anchor anchor-end",style:{transform:c(i)},onPointerDown:p},t("slot",{name:"end-anchor"},t("div",{class:"anchor-placeholder"}))),!m&&g&&t("div",{class:"anchor-label anchor-label-end",style:{transform:c(g)}},t("slot",{name:"end-label"})),n!=null&&t("div",{id:"label",class:"distance-label",style:{transform:c(n)}},r),s!=null&&t("div",{class:"indicator",style:{transform:c(s)}},t("slot",{name:"indicator"},t("div",{class:"indicator-placeholder"}))))};const z=()=>`:host{--viewer-measurement-distance-accent-color:var(--neutral-900);--viewer-measurement-distance-contrast-color:var(--white);--viewer-measurement-distance-invalid-accent-color:var(--red-600);--viewer-measurement-distance-invalid-contrast-color:var(--white);--viewer-measurement-distance-line-stroke-width:1.25px;--viewer-measurement-distance-line-fill-width:2px;--viewer-measurement-distance-distance-border:1px solid var(--viewer-measurement-distance-accent-color);--viewer-measurement-distance-distance-border-radius:0.25rem;--viewer-measurement-distance-distance-padding:0.375rem 0.5rem;color:var(--viewer-measurement-distance-accent-color);font-size:0.75rem;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}:host([invalid]:not([invalid='false'])){--viewer-measurement-distance-accent-color:var( --viewer-measurement-distance-invalid-accent-color ) !important;--viewer-measurement-distance-contrast-color:var( --viewer-measurement-distance-invalid-contrast-color ) !important}.line{--viewer-measurement-line-stroke:var( --viewer-measurement-distance-contrast-color );--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:var( --viewer-measurement-distance-line-stroke-width );--viewer-measurement-line-fill:var( --viewer-measurement-distance-accent-color );--viewer-measurement-line-fill-width:var( --viewer-measurement-distance-line-fill-width );position:absolute;width:100%;height:100%}.anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host([interacting-anchor='start']) .anchor-start,:host([interacting-anchor='start']) .anchor-label-start{visibility:hidden}.hide-start-line-cap,:host([interacting-anchor='start']) .line{--viewer-measurement-line-start-cap-visibility:hidden}:host([interacting-anchor='end']) .anchor-end,:host([interacting-anchor='end']) .anchor-label-end{visibility:hidden}.hide-end-line-cap,:host([interacting-anchor='end']) .line{--viewer-measurement-line-end-cap-visibility:hidden}.anchor-label{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host(:not([mode=''])){cursor:inherit}:host(:not([mode=''])) .anchor{cursor:move}:host([mode='']) .anchor{visibility:hidden}.anchor-placeholder{background:var(--viewer-measurement-distance-contrast-color);width:12px;height:12px;border-radius:50%;box-sizing:border-box}:host(:not([mode=''])) .anchor-placeholder{border:2px solid var(--viewer-measurement-distance-accent-color);background:var(--viewer-measurement-distance-contrast-color)}:host([mode='']) .distance-label{color:var(--viewer-measurement-distance-contrast-color);background:var(--viewer-measurement-distance-accent-color)}.distance-label{position:absolute;background:var(--viewer-measurement-distance-contrast-color);border:var(--viewer-measurement-distance-distance-border);border-radius:var(--viewer-measurement-distance-distance-border-radius);padding:var(--viewer-measurement-distance-distance-padding);pointer-events:auto}.indicator{position:absolute}.indicator-placeholder{background:var(--viewer-measurement-distance-accent-color);border:1px solid var(--viewer-measurement-distance-contrast-color);width:6px;height:6px;border-radius:50%;box-sizing:border-box}`;const W=3;const F=i(class e extends n{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.editBegin=s(this,"editBegin");this.editEnd=s(this,"editEnd");this.showAxisReferenceLines=false;this.snapDistance=M;this.units="millimeters";this.fractionalDigits=2;this.anchorLabelOffset=20;this.lineCapLength=k;this.mode="";this.interactingAnchor="none";this.invalid=false;this.measurementModel=new p;this.viewport=new g(0,0);this.interactionCount=0;this.invalidateStateCounter=0;this.stateMap={};this.measurementUnits=new v(this.units);this.model=I.empty();this.controller=new A(this.model);this.overlays=new w;this.isUserInteractingWithModel=false;this.handleFrameDrawn=()=>{this.invalidateState()};this.clearIndicator=()=>{this.controller.clearIndicator()};this.updateStartAnchor=async t=>{await this.getStencilBuffer();if(this.interactionCount===0){const e=u(t,this.elementBounds);const i=this.snapPoint(e,t);await this.updateIndicator(i)}};this.newMeasurement=t=>{if(this.interactionCount===0&&t.button===0){const e=t=>{const e=()=>{window.removeEventListener("pointerup",i);window.removeEventListener("pointermove",n)};const i=async()=>{e();t()};const n=t=>{if(t.buttons>0){e()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",i)};const i=t=>{let e=h.create(0,0);const i=i=>{const n=h.distance(e,u(i,this.elementBounds));if(n>=W){t()}};const n=()=>{window.removeEventListener("pointermove",i);window.removeEventListener("pointerup",s)};const s=()=>n();const r=t=>{e=u(t,this.elementBounds);window.addEventListener("pointermove",i);window.addEventListener("pointerup",s)};window.addEventListener("pointerdown",r);return{dispose:()=>window.removeEventListener("pointerdown",r)}};const n=()=>{const t=i((()=>{var t;this.isUserInteractingWithModel=true;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}));const e=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",s);t.dispose()};const n=this.createInteractionMoveHandler();const s=async t=>{var i;if(t.button===0){if(this.isUserInteractingWithModel){this.isUserInteractingWithModel=false}else{const n=this.getHitProvider();if(n!=null){const s=u(t,this.elementBounds);const r=this.snapPoint(s,t);await((i=this.interaction)===null||i===void 0?void 0:i.finish(r,n));e();this.updateMeasurementPropsFromModel();this.endEditing()}}}};this.beginEditing("replace","end");this.newInteractionHandler={dispose:e};window.addEventListener("pointermove",n);window.addEventListener("pointerup",s)};const s=this.getHitProvider();if(s!=null){const i=u(t,this.elementBounds);const r=this.snapPoint(i,t);this.interaction=this.controller.newMeasurement(r,s);if(this.interaction!=null){e(n)}}}}}async computeElementMetrics(){var t,e,i;const n=(t=this.hostEl.shadowRoot)===null||t===void 0?void 0:t.getElementById("start-anchor");const s=(e=this.hostEl.shadowRoot)===null||e===void 0?void 0:e.getElementById("end-anchor");const r=(i=this.hostEl.shadowRoot)===null||i===void 0?void 0:i.getElementById("label");if(n!=null&&s!=null&&r!=null){return{startAnchor:n.getBoundingClientRect(),endAnchor:s.getBoundingClientRect(),label:r.getBoundingClientRect()}}else{return undefined}}connectedCallback(){this.setDepthBuffers()}disconnectedCallback(){var t,e;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose();(e=this.newInteractionHandler)===null||e===void 0?void 0:e.dispose();this.resetDepthBuffers()}async componentWillLoad(){this.updatePropsFromJson();this.model.setMeasurementFromValues(this.start,this.end,!this.invalid);await this.getStencilBuffer();this.updateViewport();this.setDepthBuffers();await this.handleViewerChanged(this.viewer);await this.handleModeChanged();await this.computePropsAndState();this.model.onIndicatorChanged((t=>{this.indicatorPt=t}))}componentDidLoad(){const t=new ResizeObserver((()=>this.updateViewport()));t.observe(this.hostEl)}async componentWillUpdate(){await this.computePropsAndState()}render(){return t(r,{key:"58113224139c37a54bf9329ed27e6a8983d5cccd"},this.showAxisReferenceLines&&t("vertex-viewer-measurement-overlays",{key:"d2166c4a965761f472f5b3323844d82980baa29f",measurementOverlays:this.overlays,viewer:this.viewer}),this.renderMeasurement())}renderMeasurement(){const e=this.computeElementPositions();const{startPt:i,endPt:n,labelPt:s,indicatorPt:r,hideStart:a,hideEnd:o}=e;const h=this.formatDistance(this.distance);if(this.mode==="edit"||this.mode==="replace"){return t(V,{startPt:i,endPt:n,centerPt:s,indicatorPt:r,distance:h,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,hideStartAnchor:a,hideEndAnchor:o,onStartAnchorPointerDown:this.handleEditAnchor("start"),onEndAnchorPointerDown:this.handleEditAnchor("end")})}else{return t(V,{startPt:i,endPt:n,centerPt:s,indicatorPt:this.indicatorPt,distance:h,hideStartAnchor:a,hideEndAnchor:o,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,linePointerEvents:"painted"})}}async handleViewerChanged(t,e){if(e!=null){e.removeEventListener("frameDrawn",this.handleFrameDrawn);await this.removeInteractionListeners(e)}if(t!=null){t.addEventListener("frameDrawn",this.handleFrameDrawn);await this.addInteractionListeners(t)}}handleUnitsChanged(){this.measurementUnits=new v(this.units)}handleCameraChanged(){this.updateCamera()}async handleModeChanged(){var t;if(this.mode===""){(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}if(this.viewer!=null){await this.removeInteractionListeners(this.viewer);await this.addInteractionListeners(this.viewer)}}handleStartChanged(){this.updateInteractionModel()}handleEndChanged(){this.updateInteractionModel()}handleInvalidChanged(){this.updateInteractionModel()}async computePropsAndState(){this.updateCamera();await this.updateDepthBuffer();this.updateMeasurementPropsFromModel();this.updateOverlays()}updateOverlays(){var t;(t=this.overlay)===null||t===void 0?void 0:t.dispose();if(this.showAxisReferenceLines&&this.interactionCount===0&&!this.invalid&&this.start!=null&&this.end!=null){this.overlay=this.overlays.addDistanceVector(this.start,this.end)}}async setCursor(t){var e,i;(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose();if(!this.isUserInteractingWithModel){this.stateMap.hoverCursor=await((i=this.viewer)===null||i===void 0?void 0:i.addCursor(t))}}computeElementPositions(){if(this.mode==="replace"){return this.computeReplaceElementPositions()}else{return this.computeEditOrViewElementPositions()}}computeEditOrViewElementPositions(){const t=this.model.getMeasurement();if(this.internalCamera!=null&&t!=null){return this.computeLineElementPositions(l.create(t))}else{return{}}}computeReplaceElementPositions(){if(this.internalCamera!=null){const t=this.model.getMeasurement();const e=t!=null?this.computeLineElementPositions(l.create(t)):{};const i=this.indicatorPt!=null?{indicatorPt:this.viewport.transformWorldToViewport(this.indicatorPt,this.internalCamera.projectionViewMatrix)}:{};return{...e,...i}}else{return{}}}computeLineElementPositions(t){if(this.internalCamera!=null){return E(t,this.interactingAnchor,{viewport:this.viewport,camera:this.internalCamera})}else{return{}}}updateCamera(){var t,e;this.internalCamera=this.camera||((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.scene.camera)}async updateDepthBuffer(){var t,e;this.stateMap.depthBuffer=await((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.depthBuffer())}updateViewport(){const t=D(this.hostEl);this.viewport=new g(t.width,t.height);this.elementBounds=t}updatePropsFromJson(){var t,e;this.start=J((t=this.startJson)!==null&&t!==void 0?t:this.start);this.end=J((e=this.endJson)!==null&&e!==void 0?e:this.end)}updateInteractionModel(){this.model.setMeasurementFromValues(this.start,this.end,!this.invalid)}invalidateState(){this.invalidateStateCounter=this.invalidateStateCounter+1}async addInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();if(this.mode==="replace"){e.addEventListener("pointermove",this.updateStartAnchor);e.addEventListener("pointerdown",this.newMeasurement);e.addEventListener("pointerleave",this.clearIndicator)}}async removeInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();e.removeEventListener("pointermove",this.updateStartAnchor);e.removeEventListener("pointerdown",this.newMeasurement);e.removeEventListener("pointerleave",this.clearIndicator)}handleEditAnchor(t){if(this.mode==="edit"||this.mode==="replace"){const e=this.createInteractionMoveHandler();const i=async t=>{var n;const s=this.getHitProvider();if(s!=null){window.removeEventListener("pointermove",e);window.removeEventListener("pointerup",i);const r=u(t,this.elementBounds);const a=this.snapPoint(r,t);await((n=this.interaction)===null||n===void 0?void 0:n.finish(a,s));this.updateMeasurementPropsFromModel();this.endEditing()}};return async n=>{await this.getStencilBuffer();if(n.button===0){this.beginEditing("edit",t);this.interaction=this.controller.editMeasurement(t);window.addEventListener("pointermove",e);window.addEventListener("pointerup",i)}}}}createInteractionMoveHandler(){return async t=>{var e;const i=this.getHitProvider();if(this.elementBounds!=null&&i!=null){t.preventDefault();await this.getStencilBuffer();const n=u(t,this.elementBounds);const s=this.snapPoint(n,t);(e=this.interaction)===null||e===void 0?void 0:e.update(s,i);this.updateMeasurementPropsFromModel()}}}async getStencilBuffer(){var t;const e=await((t=this.viewer)===null||t===void 0?void 0:t.stencilBuffer.latestAfterInteraction());this.stateMap.stencil=e}snapPoint(t,e){const i=this.getHitProvider();if(i!=null&&!e.shiftKey){const e=Math.max(0,this.snapDistance);return i.hitTester().snapToNearestPixel(t,e)}return t}formatDistance(t){const e=t!=null?this.measurementUnits.convertWorldValueToReal(t):undefined;if(this.labelFormatter!=null){return this.labelFormatter(e)}else{const t=this.measurementUnits.unit.abbreviatedName;return e==null?"---":`~${e.toFixed(this.fractionalDigits)} ${t}`}}beginEditing(t,e){if(this.interactionCount===0){this.interactingAnchor=e;this.editBegin.emit({type:t,anchor:e})}this.interactionCount=this.interactionCount+1}endEditing(){if(this.interactionCount===1){const t=this.model.getMeasurement();this.interactingAnchor="none";this.updateMeasurementModel();if(t!=null){this.editEnd.emit(t)}}this.interactionCount=this.interactionCount-1}updateMeasurementModel(){this.measurementModel.clearOutcome();if(!this.invalid&&this.start!=null&&this.end!=null){this.measurementModel.setOutcome({isApproximate:true,results:[f(this.start,this.end)]})}}getHitProvider(){if(this.hitProvider==null){const t=this.getHitTester();const e=this.viewer;if(e!=null&&t!=null){return{hitTester:()=>t,raycaster:async()=>(await e.scene()).raycaster()}}}else return this.hitProvider}getHitTester(){const{stencil:t,depthBuffer:e}=this.stateMap;if(e!=null){return new j(t,e,this.viewport,this.internalCamera)}}updateMeasurementPropsFromModel(){const t=this.model.getMeasurement();this.start=t===null||t===void 0?void 0:t.start;this.end=t===null||t===void 0?void 0:t.end;this.distance=t===null||t===void 0?void 0:t.distance;this.invalid=t!=null&&!t.valid}async updateIndicator(t){var e;const i=this.getHitProvider();const n=i==null||!this.controller.moveIndicator(t,i);if(n){(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose()}else{await this.setCursor(d)}}setDepthBuffers(){if(this.mode!=null&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:0}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}}static get style(){return z()}},[1,"vertex-viewer-measurement-distance",{start:[1040],startJson:[1,"start-json"],end:[1040],endJson:[1,"end-json"],distance:[1026],showAxisReferenceLines:[4,"show-axis-reference-lines"],snapDistance:[2,"snap-distance"],units:[1],fractionalDigits:[2,"fractional-digits"],labelFormatter:[16],anchorLabelOffset:[2,"anchor-label-offset"],lineCapLength:[2,"line-cap-length"],mode:[513],interactingAnchor:[1537,"interacting-anchor"],invalid:[1540],camera:[16],hitProvider:[16],indicatorPt:[1040],viewer:[16],measurementModel:[16],viewport:[32],elementBounds:[32],interactionCount:[32],internalCamera:[32],invalidateStateCounter:[32],stateMap:[32],measurementUnits:[32],computeElementMetrics:[64]},undefined,{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:0}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}]);function J(t){return typeof t==="string"?a.fromJson(t):t}function K(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-distance","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-distance":if(!customElements.get(e(t))){customElements.define(e(t),F)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){x()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){C()}break}}))}K();const R=F;const X=K;export{R as VertexViewerMeasurementDistance,X as defineCustomElement};
4
+ import{h as t,t as e,p as i,H as n,d as s,e as r}from"./p-DmsAWRoU.js";import{v as a,a as o,p as h,l}from"./p-Tvs4yxd5.js";import{m as d}from"./p-AZXboIdP.js";import{b as c,g as u}from"./p-BSYTUXcE.js";import"./p-DrkwJOM4.js";import"./p-zTYgyBoa.js";import"./p-ux1ckSDN.js";import"./p-CtJtApsf.js";import{n as m,D as v}from"./p-EXufj_Hh.js";import{M as p}from"./p-CkUMpn7h.js";import{M as w}from"./p-CI-uemp_.js";import{m as f}from"./p-BKId5xpb.js";import{V as g}from"./p-Dpyl9pSp.js";import{E as b,m as y}from"./p-Dc9KNUUp.js";import{d as C,g as E}from"./p-C8zX6RrH.js";import{c as P}from"./p-C6gMOKYg.js";import{d as M}from"./p-Xr7Oa6iw.js";const x=16;const k=10;function D(t){return t.getBoundingClientRect()}class j{constructor(t,e,i,n){this.stencil=t;this.depthBuffer=e;this.viewport=i;this.camera=n}hitTest(t){const e=this.viewport.transformPointToFrame(t,this.depthBuffer);if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);return this.stencil.hitTest(i)||this.depthBuffer.hitTest(e)}else{return this.depthBuffer.hitTest(e)}}snapToNearestPixel(t,e){if(this.stencil!=null){const i=this.viewport.transformPointToFrame(t,this.stencil);const n=this.stencil.snapToNearestPixel(i,e);return this.viewport.transformPointToViewport(n,this.stencil)}else{return t}}transformPointToWorld(t,{ignoreHitTest:e=false}={}){const i=this.pickDepthBuffer(t);if(i!=null){return this.viewport.transformPointToWorldSpace(t,i)}else if(e){return this.viewport.transformPointToWorldSpace(t,this.depthBuffer)}}pickDepthBuffer(t){if(this.stencil!=null){const e=this.viewport.transformPointToFrame(t,this.stencil);if(this.stencil.hitTest(e)){return this.stencil.depthBuffer}}const e=this.viewport.transformPointToFrame(t,this.depthBuffer);return this.depthBuffer.hitTest(e)?this.depthBuffer:undefined}}class A{constructor(t){this.model=t}newMeasurement(t,e){const i=e.hitTester().transformPointToWorld(t);return i!=null?new S(t,i,this.model):undefined}editMeasurement(t){const e=this.model.getMeasurement();if(e==null){throw new Error("Cannot edit measurement. Measurement is empty.")}return t==="start"?new T(e,this.model):new B(e,this.model)}clearIndicator(){this.model.setIndicator(undefined)}moveIndicator(t,e){const i=e.hitTester().transformPointToWorld(t);this.model.setIndicator(i);return i!=null}}class I{constructor(){this.measurementChanged=new b;this.indicatorChanged=new b}static empty(){return new I}getMeasurement(){return this.measurement}setMeasurement(t){if(this.measurement!==t){this.measurement=t;this.measurementChanged.emit(t)}}setMeasurementFromValues(t,e,i){if(t!=null&&e!=null){const n=i?H(t,e):U(t,e);this.setMeasurement(n)}else{this.setMeasurement(undefined)}}onMeasurementChanged(t){return this.measurementChanged.on(t)}getIndicator(){return this.indicator}setIndicator(t){if(this.indicator!==t){this.indicator=t;this.indicatorChanged.emit(t)}}onIndicatorChanged(t){return this.indicatorChanged.on(t)}}class S{constructor(t,e,i){this.pt=t;this.world=e;this.model=i;this.hitWorldValid=true;this.preventUpdate=false}fetchStartIfMissing(t){if(this.pendingStart==null){this.pendingStart=this.fetchStart(t)}}async fetchStart(t){const e=await t.raycaster();const i=await O(e,this.pt);if(i==null){const e=t.hitTester().transformPointToWorld(this.pt);this.hitWorld=e;this.hitWorldValid=false}else{this.hitWorld=i;this.hitWorldValid=true}}update(t,e){var i;if(!this.preventUpdate){this.fetchStartIfMissing(e);const n=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const s=e.hitTester().hitTest(t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;if(n==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!this.hitWorldValid||!s){this.model.setIndicator(n);this.setMeasurement(U(r,n))}else{this.model.setIndicator(n);this.setMeasurement(H(r,n))}}}async finish(t,e){var i;this.preventUpdate=true;this.fetchStartIfMissing(e);await this.pendingStart;this.model.setIndicator(undefined);const n=await e.raycaster();const s=await O(n,t);const r=(i=this.hitWorld)!==null&&i!==void 0?i:this.world;this.preventUpdate=false;if(s==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete new measurement interaction. End point is empty.")}return this.setMeasurement(U(r,i))}else if(!this.hitWorldValid){return this.setMeasurement(U(r,s))}else{return this.setMeasurement(H(r,s))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class L{constructor(t,e){this.measurement=t;this.model=e}update(t,e){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});const n=e.hitTester().hitTest(t);if(i==null){throw new Error("Cannot update new measurement interaction. End point is empty.")}else if(!n){this.model.setIndicator(i);this.setMeasurement(this.getInvalidMeasurement(i))}else{this.model.setIndicator(i);this.setMeasurement(this.getValidMeasurement(i))}}async finish(t,e){const i=await e.raycaster();const n=await O(i,t);this.model.setIndicator(undefined);if(n==null){const i=e.hitTester().transformPointToWorld(t,{ignoreHitTest:true});if(i==null){throw new Error("Cannot complete edit measurement interaction. End point is empty.")}return this.setMeasurement(this.getInvalidMeasurement(i))}else{return this.setMeasurement(this.getValidMeasurement(n))}}setMeasurement(t){this.model.setMeasurement(t);return t}}class T extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return U(t,this.measurement.end)}getValidMeasurement(t){return H(t,this.measurement.end)}}class B extends L{constructor(t,e){super(t,e)}getInvalidMeasurement(t){return U(this.measurement.start,t)}getValidMeasurement(t){return H(this.measurement.start,t)}}async function O(t,e){var i;const n=await t.hitItems(e);const[s]=(i=n===null||n===void 0?void 0:n.hits)!==null&&i!==void 0?i:[];if((s===null||s===void 0?void 0:s.hitPoint)!=null){const t=m(s.hitPoint);if(y.isInvalid(t)){throw new Error(`Invalid hit response [${t.errors.join(",")}]`)}return t}else return undefined}function H(t,e){return{start:t,end:e,distance:a.distance(t,e),valid:true}}function U(t,e){return{start:t,end:e,valid:false}}const V=({startPt:e,endPt:i,centerPt:n,indicatorPt:s,distance:r,anchorLabelOffset:a,lineCapLength:l,linePointerEvents:d,hideStartAnchor:u,hideEndAnchor:m,onStartAnchorPointerDown:v,onEndAnchorPointerDown:p})=>{const w=e!=null&&i!=null?o.fromPoints(e,i):undefined;const f=w!=null&&e!=null&&a!=null?h.add(e,h.polar(-a,w)):undefined;const g=w!=null&&i!=null&&a!=null?h.add(i,h.polar(a,w)):undefined;return t("div",null,e!=null&&i!=null&&t("vertex-viewer-measurement-line",{class:P("line",{"hide-start-line-cap":u,"hide-end-line-cap":m}),start:e,end:i,capLength:l,pointerEvents:d}),!u&&e!=null&&t("div",{id:"start-anchor",class:"anchor anchor-start",style:{transform:c(e)},onPointerDown:v},t("slot",{name:"start-anchor"},t("div",{class:"anchor-placeholder"}))),!u&&f&&t("div",{class:"anchor-label anchor-label-start",style:{transform:c(f)}},t("slot",{name:"start-label"})),!m&&i!=null&&t("div",{id:"end-anchor",class:"anchor anchor-end",style:{transform:c(i)},onPointerDown:p},t("slot",{name:"end-anchor"},t("div",{class:"anchor-placeholder"}))),!m&&g&&t("div",{class:"anchor-label anchor-label-end",style:{transform:c(g)}},t("slot",{name:"end-label"})),n!=null&&t("div",{id:"label",class:"distance-label",style:{transform:c(n)}},r),s!=null&&t("div",{class:"indicator",style:{transform:c(s)}},t("slot",{name:"indicator"},t("div",{class:"indicator-placeholder"}))))};const z=()=>`:host{--viewer-measurement-distance-accent-color:var(--neutral-900);--viewer-measurement-distance-contrast-color:var(--white);--viewer-measurement-distance-invalid-accent-color:var(--red-600);--viewer-measurement-distance-invalid-contrast-color:var(--white);--viewer-measurement-distance-line-stroke-width:1.25px;--viewer-measurement-distance-line-fill-width:2px;--viewer-measurement-distance-distance-border:1px solid var(--viewer-measurement-distance-accent-color);--viewer-measurement-distance-distance-border-radius:0.25rem;--viewer-measurement-distance-distance-padding:0.375rem 0.5rem;color:var(--viewer-measurement-distance-accent-color);font-size:0.75rem;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden;pointer-events:none}:host([invalid]:not([invalid='false'])){--viewer-measurement-distance-accent-color:var( --viewer-measurement-distance-invalid-accent-color ) !important;--viewer-measurement-distance-contrast-color:var( --viewer-measurement-distance-invalid-contrast-color ) !important}.line{--viewer-measurement-line-stroke:var( --viewer-measurement-distance-contrast-color );--viewer-measurement-line-stroke-opacity:0.75;--viewer-measurement-line-stroke-width:var( --viewer-measurement-distance-line-stroke-width );--viewer-measurement-line-fill:var( --viewer-measurement-distance-accent-color );--viewer-measurement-line-fill-width:var( --viewer-measurement-distance-line-fill-width );position:absolute;width:100%;height:100%}.anchor{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host([interacting-anchor='start']) .anchor-start,:host([interacting-anchor='start']) .anchor-label-start{visibility:hidden}.hide-start-line-cap,:host([interacting-anchor='start']) .line{--viewer-measurement-line-start-cap-visibility:hidden}:host([interacting-anchor='end']) .anchor-end,:host([interacting-anchor='end']) .anchor-label-end{visibility:hidden}.hide-end-line-cap,:host([interacting-anchor='end']) .line{--viewer-measurement-line-end-cap-visibility:hidden}.anchor-label{position:absolute;border-radius:50%;transform:translate(-50%, -50%);display:block;pointer-events:auto}:host(:not([mode=''])){cursor:inherit}:host(:not([mode=''])) .anchor{cursor:move}:host([mode='']) .anchor{visibility:hidden}.anchor-placeholder{background:var(--viewer-measurement-distance-contrast-color);width:12px;height:12px;border-radius:50%;box-sizing:border-box}:host(:not([mode=''])) .anchor-placeholder{border:2px solid var(--viewer-measurement-distance-accent-color);background:var(--viewer-measurement-distance-contrast-color)}:host([mode='']) .distance-label{color:var(--viewer-measurement-distance-contrast-color);background:var(--viewer-measurement-distance-accent-color)}.distance-label{position:absolute;background:var(--viewer-measurement-distance-contrast-color);border:var(--viewer-measurement-distance-distance-border);border-radius:var(--viewer-measurement-distance-distance-border-radius);padding:var(--viewer-measurement-distance-distance-padding);pointer-events:auto}.indicator{position:absolute}.indicator-placeholder{background:var(--viewer-measurement-distance-accent-color);border:1px solid var(--viewer-measurement-distance-contrast-color);width:6px;height:6px;border-radius:50%;box-sizing:border-box}`;const J=3;const R=i(class e extends n{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.editBegin=s(this,"editBegin");this.editEnd=s(this,"editEnd");this.showAxisReferenceLines=false;this.snapDistance=x;this.units="millimeters";this.fractionalDigits=2;this.anchorLabelOffset=20;this.lineCapLength=k;this.mode="";this.interactingAnchor="none";this.invalid=false;this.measurementModel=new p;this.viewport=new g(0,0);this.interactionCount=0;this.invalidateStateCounter=0;this.stateMap={};this.measurementUnits=new v(this.units);this.model=I.empty();this.controller=new A(this.model);this.overlays=new w;this.isUserInteractingWithModel=false;this.handleFrameDrawn=()=>{this.invalidateState()};this.clearIndicator=()=>{this.controller.clearIndicator()};this.updateStartAnchor=async t=>{await this.getStencilBuffer();if(this.interactionCount===0){const e=u(t,this.elementBounds);const i=this.snapPoint(e,t);await this.updateIndicator(i)}};this.newMeasurement=t=>{if(this.interactionCount===0&&t.button===0){const e=t=>{const e=()=>{window.removeEventListener("pointerup",i);window.removeEventListener("pointermove",n)};const i=async()=>{e();t()};const n=t=>{if(t.buttons>0){e()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",i)};const i=t=>{let e=h.create(0,0);const i=i=>{const n=h.distance(e,u(i,this.elementBounds));if(n>=J){t()}};const n=()=>{window.removeEventListener("pointermove",i);window.removeEventListener("pointerup",s)};const s=()=>n();const r=t=>{e=u(t,this.elementBounds);window.addEventListener("pointermove",i);window.addEventListener("pointerup",s)};window.addEventListener("pointerdown",r);return{dispose:()=>window.removeEventListener("pointerdown",r)}};const n=()=>{const t=i((()=>{var t;this.isUserInteractingWithModel=true;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}));const e=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",s);t.dispose()};const n=this.createInteractionMoveHandler();const s=async t=>{var i;if(t.button===0){if(this.isUserInteractingWithModel){this.isUserInteractingWithModel=false}else{const n=this.getHitProvider();if(n!=null){const s=u(t,this.elementBounds);const r=this.snapPoint(s,t);await((i=this.interaction)===null||i===void 0?void 0:i.finish(r,n));e();this.updateMeasurementPropsFromModel();this.endEditing()}}}};this.beginEditing("replace","end");this.newInteractionHandler={dispose:e};window.addEventListener("pointermove",n);window.addEventListener("pointerup",s)};const s=this.getHitProvider();if(s!=null){const i=u(t,this.elementBounds);const r=this.snapPoint(i,t);this.interaction=this.controller.newMeasurement(r,s);if(this.interaction!=null){e(n)}}}}}async computeElementMetrics(){var t,e,i;const n=(t=this.hostEl.shadowRoot)===null||t===void 0?void 0:t.getElementById("start-anchor");const s=(e=this.hostEl.shadowRoot)===null||e===void 0?void 0:e.getElementById("end-anchor");const r=(i=this.hostEl.shadowRoot)===null||i===void 0?void 0:i.getElementById("label");if(n!=null&&s!=null&&r!=null){return{startAnchor:n.getBoundingClientRect(),endAnchor:s.getBoundingClientRect(),label:r.getBoundingClientRect()}}else{return undefined}}connectedCallback(){this.setDepthBuffers()}disconnectedCallback(){var t,e;(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose();(e=this.newInteractionHandler)===null||e===void 0?void 0:e.dispose();this.resetDepthBuffers()}async componentWillLoad(){this.updatePropsFromJson();this.model.setMeasurementFromValues(this.start,this.end,!this.invalid);await this.getStencilBuffer();this.updateViewport();this.setDepthBuffers();await this.handleViewerChanged(this.viewer);await this.handleModeChanged();await this.computePropsAndState();this.model.onIndicatorChanged((t=>{this.indicatorPt=t}))}componentDidLoad(){const t=new ResizeObserver((()=>this.updateViewport()));t.observe(this.hostEl)}async componentWillUpdate(){await this.computePropsAndState()}render(){return t(r,{key:"58113224139c37a54bf9329ed27e6a8983d5cccd"},this.showAxisReferenceLines&&t("vertex-viewer-measurement-overlays",{key:"d2166c4a965761f472f5b3323844d82980baa29f",measurementOverlays:this.overlays,viewer:this.viewer}),this.renderMeasurement())}renderMeasurement(){const e=this.computeElementPositions();const{startPt:i,endPt:n,labelPt:s,indicatorPt:r,hideStart:a,hideEnd:o}=e;const h=this.formatDistance(this.distance);if(this.mode==="edit"||this.mode==="replace"){return t(V,{startPt:i,endPt:n,centerPt:s,indicatorPt:r,distance:h,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,hideStartAnchor:a,hideEndAnchor:o,onStartAnchorPointerDown:this.handleEditAnchor("start"),onEndAnchorPointerDown:this.handleEditAnchor("end")})}else{return t(V,{startPt:i,endPt:n,centerPt:s,indicatorPt:this.indicatorPt,distance:h,hideStartAnchor:a,hideEndAnchor:o,anchorLabelOffset:this.anchorLabelOffset,lineCapLength:this.lineCapLength,linePointerEvents:"painted"})}}async handleViewerChanged(t,e){if(e!=null){e.removeEventListener("frameDrawn",this.handleFrameDrawn);await this.removeInteractionListeners(e)}if(t!=null){t.addEventListener("frameDrawn",this.handleFrameDrawn);await this.addInteractionListeners(t)}}handleUnitsChanged(){this.measurementUnits=new v(this.units)}handleCameraChanged(){this.updateCamera()}async handleModeChanged(){var t;if(this.mode===""){(t=this.stateMap.hoverCursor)===null||t===void 0?void 0:t.dispose()}if(this.viewer!=null){await this.removeInteractionListeners(this.viewer);await this.addInteractionListeners(this.viewer)}}handleStartChanged(){this.updateInteractionModel()}handleEndChanged(){this.updateInteractionModel()}handleInvalidChanged(){this.updateInteractionModel()}async computePropsAndState(){this.updateCamera();await this.updateDepthBuffer();this.updateMeasurementPropsFromModel();this.updateOverlays()}updateOverlays(){var t;(t=this.overlay)===null||t===void 0?void 0:t.dispose();if(this.showAxisReferenceLines&&this.interactionCount===0&&!this.invalid&&this.start!=null&&this.end!=null){this.overlay=this.overlays.addDistanceVector(this.start,this.end)}}async setCursor(t){var e,i;(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose();if(!this.isUserInteractingWithModel){this.stateMap.hoverCursor=await((i=this.viewer)===null||i===void 0?void 0:i.addCursor(t))}}computeElementPositions(){if(this.mode==="replace"){return this.computeReplaceElementPositions()}else{return this.computeEditOrViewElementPositions()}}computeEditOrViewElementPositions(){const t=this.model.getMeasurement();if(this.internalCamera!=null&&t!=null){return this.computeLineElementPositions(l.create(t))}else{return{}}}computeReplaceElementPositions(){if(this.internalCamera!=null){const t=this.model.getMeasurement();const e=t!=null?this.computeLineElementPositions(l.create(t)):{};const i=this.indicatorPt!=null?{indicatorPt:this.viewport.transformWorldToViewport(this.indicatorPt,this.internalCamera.projectionViewMatrix)}:{};return{...e,...i}}else{return{}}}computeLineElementPositions(t){if(this.internalCamera!=null){return E(t,this.interactingAnchor,{viewport:this.viewport,camera:this.internalCamera})}else{return{}}}updateCamera(){var t,e;this.internalCamera=this.camera||((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.scene.camera)}async updateDepthBuffer(){var t,e;this.stateMap.depthBuffer=await((e=(t=this.viewer)===null||t===void 0?void 0:t.frame)===null||e===void 0?void 0:e.depthBuffer())}updateViewport(){const t=D(this.hostEl);this.viewport=new g(t.width,t.height);this.elementBounds=t}updatePropsFromJson(){var t,e;this.start=X((t=this.startJson)!==null&&t!==void 0?t:this.start);this.end=X((e=this.endJson)!==null&&e!==void 0?e:this.end)}updateInteractionModel(){this.model.setMeasurementFromValues(this.start,this.end,!this.invalid)}invalidateState(){this.invalidateStateCounter=this.invalidateStateCounter+1}async addInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();if(this.mode==="replace"){e.addEventListener("pointermove",this.updateStartAnchor);e.addEventListener("pointerdown",this.newMeasurement);e.addEventListener("pointerleave",this.clearIndicator)}}async removeInteractionListeners(t){const e=await t.getInteractionTarget_DEPRECATED();e.removeEventListener("pointermove",this.updateStartAnchor);e.removeEventListener("pointerdown",this.newMeasurement);e.removeEventListener("pointerleave",this.clearIndicator)}handleEditAnchor(t){if(this.mode==="edit"||this.mode==="replace"){const e=this.createInteractionMoveHandler();const i=async t=>{var n;const s=this.getHitProvider();if(s!=null){window.removeEventListener("pointermove",e);window.removeEventListener("pointerup",i);const r=u(t,this.elementBounds);const a=this.snapPoint(r,t);await((n=this.interaction)===null||n===void 0?void 0:n.finish(a,s));this.updateMeasurementPropsFromModel();this.endEditing()}};return async n=>{await this.getStencilBuffer();if(n.button===0){this.beginEditing("edit",t);this.interaction=this.controller.editMeasurement(t);window.addEventListener("pointermove",e);window.addEventListener("pointerup",i)}}}}createInteractionMoveHandler(){return async t=>{var e;const i=this.getHitProvider();if(this.elementBounds!=null&&i!=null){t.preventDefault();await this.getStencilBuffer();const n=u(t,this.elementBounds);const s=this.snapPoint(n,t);(e=this.interaction)===null||e===void 0?void 0:e.update(s,i);this.updateMeasurementPropsFromModel()}}}async getStencilBuffer(){var t;const e=await((t=this.viewer)===null||t===void 0?void 0:t.stencilBuffer.latestAfterInteraction());this.stateMap.stencil=e}snapPoint(t,e){const i=this.getHitProvider();if(i!=null&&!e.shiftKey){const e=Math.max(0,this.snapDistance);return i.hitTester().snapToNearestPixel(t,e)}return t}formatDistance(t){const e=t!=null?this.measurementUnits.convertWorldValueToReal(t):undefined;if(this.labelFormatter!=null){return this.labelFormatter(e)}else{const t=this.measurementUnits.unit.abbreviatedName;return e==null?"---":`~${e.toFixed(this.fractionalDigits)} ${t}`}}beginEditing(t,e){if(this.interactionCount===0){this.interactingAnchor=e;this.editBegin.emit({type:t,anchor:e})}this.interactionCount=this.interactionCount+1}endEditing(){if(this.interactionCount===1){const t=this.model.getMeasurement();this.interactingAnchor="none";this.updateMeasurementModel();if(t!=null){this.editEnd.emit(t)}}this.interactionCount=this.interactionCount-1}updateMeasurementModel(){this.measurementModel.clearOutcome();if(!this.invalid&&this.start!=null&&this.end!=null){this.measurementModel.setOutcome({isApproximate:true,results:[f(this.start,this.end)]})}}getHitProvider(){if(this.hitProvider==null){const t=this.getHitTester();const e=this.viewer;if(e!=null&&t!=null){return{hitTester:()=>t,raycaster:async()=>(await e.scene()).raycaster()}}}else return this.hitProvider}getHitTester(){const{stencil:t,depthBuffer:e}=this.stateMap;if(e!=null){return new j(t,e,this.viewport,this.internalCamera)}}updateMeasurementPropsFromModel(){const t=this.model.getMeasurement();this.start=t===null||t===void 0?void 0:t.start;this.end=t===null||t===void 0?void 0:t.end;this.distance=t===null||t===void 0?void 0:t.distance;this.invalid=t!=null&&!t.valid}async updateIndicator(t){var e;const i=this.getHitProvider();const n=i==null||!this.controller.moveIndicator(t,i);if(n){(e=this.stateMap.hoverCursor)===null||e===void 0?void 0:e.dispose()}else{await this.setCursor(d)}}setDepthBuffers(){if(this.mode!=null&&this.viewer!=null&&this.viewer.depthBuffers==null){this.stateMap.shouldClearDepthBuffers=true;this.viewer.depthBuffers="final"}}resetDepthBuffers(){if(this.stateMap.shouldClearDepthBuffers&&this.viewer!=null){this.viewer.depthBuffers=undefined;this.stateMap.shouldClearDepthBuffers=undefined}}get hostEl(){return this}static get watchers(){return{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:0}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}}static get style(){return z()}},[1,"vertex-viewer-measurement-distance",{start:[1040],startJson:[1,"start-json"],end:[1040],endJson:[1,"end-json"],distance:[1026],showAxisReferenceLines:[4,"show-axis-reference-lines"],snapDistance:[2,"snap-distance"],units:[1],fractionalDigits:[2,"fractional-digits"],labelFormatter:[16],anchorLabelOffset:[2,"anchor-label-offset"],lineCapLength:[2,"line-cap-length"],mode:[513],interactingAnchor:[1537,"interacting-anchor"],invalid:[1540],camera:[16],hitProvider:[16],indicatorPt:[1040],viewer:[16],measurementModel:[16],viewport:[32],elementBounds:[32],interactionCount:[32],internalCamera:[32],invalidateStateCounter:[32],stateMap:[32],measurementUnits:[32],computeElementMetrics:[64]},undefined,{viewer:[{handleViewerChanged:0}],units:[{handleUnitsChanged:0}],camera:[{handleCameraChanged:0}],mode:[{handleModeChanged:0}],start:[{handleStartChanged:0}],end:[{handleEndChanged:0}],invalid:[{handleInvalidChanged:0}]}]);function X(t){return typeof t==="string"?a.fromJson(t):t}function F(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-distance","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-distance":if(!customElements.get(e(t))){customElements.define(e(t),R)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){M()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){C()}break}}))}F();const W=R;const K=F;export{W as VertexViewerMeasurementDistance,K as defineCustomElement};
5
5
  //# sourceMappingURL=vertex-viewer-measurement-distance.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{V as o,d as s}from"./p-DP0zP-Gr.js";const r=o;const t=s;export{r as VertexViewerMeasurementOverlays,t as defineCustomElement};
4
+ import{V as o,d as s}from"./p-C8zX6RrH.js";const r=o;const t=s;export{r as VertexViewerMeasurementOverlays,t as defineCustomElement};
5
5
  //# sourceMappingURL=vertex-viewer-measurement-overlays.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{t as e,p as t,H as s,h as i,e as n}from"./p-DmsAWRoU.js";import{s as r}from"./p-BHLZLTUV.js";import{p as o}from"./p-C8g4gOHX.js";import{a,M as l}from"./p-BqEOBQcx.js";import"./p-CtJtApsf.js";import"./p-BBKWC-yY.js";import"./p-zTYgyBoa.js";import{E as h}from"./p-EXufj_Hh.js";import{M as d}from"./p-CkUMpn7h.js";import{M as m}from"./p-CI-uemp_.js";import{p as u}from"./p-Tvs4yxd5.js";import{a as p}from"./p-AZXboIdP.js";import{g as c}from"./p-BSYTUXcE.js";import{E as v}from"./p-CFus3r7d.js";import{d as f}from"./p-Xr7Oa6iw.js";import{d as w}from"./p-DP0zP-Gr.js";class y{get elementRect(){return this.rectObserver.rect}constructor(e,t){this.rectObserver=new v;this.handlePointerMove=async e=>{if(await this.isMeasurableEntityUnderPointer(e)){this.clearCursor();this.addCursor(p)}else{this.clearCursor()}};this.handlePointerDown=e=>{this.ifNoInteraction(e,(async()=>{if(await this.isMeasurableEntityUnderPointer(e)){this.measureEntityUnderPointer(e)}else{await this.controller.clearEntities()}}))};this.controller=e;this.measurableEntityTypes=t}initialize(e,t){this.element=e;this.api=t;this.rectObserver.observe(e);e.addEventListener("pointermove",this.handlePointerMove);e.addEventListener("pointerdown",this.handlePointerDown)}dispose(){var e,t,s;this.rectObserver.disconnect();(e=this.measurementInteraction)===null||e===void 0?void 0:e.dispose();this.clearCursor();(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointermove",this.handlePointerMove);(s=this.element)===null||s===void 0?void 0:s.removeEventListener("pointerdown",this.handlePointerDown);this.element=undefined;this.api=undefined}addCursor(e){this.cursor=this.ifInitialized((({api:t})=>t.addCursor(e)))}clearCursor(){var e;(e=this.cursor)===null||e===void 0?void 0:e.dispose();this.cursor=undefined}async isMeasurableEntityUnderPointer(e){var t;const s=c(e,this.elementRect);const i=await((t=this.api)===null||t===void 0?void 0:t.getEntityTypeAtPoint(s));return i!=null&&this.measurableEntityTypes.includes(i)}measureEntityUnderPointer(e){this.ifInitialized((async({api:t})=>{const s=c(e,this.elementRect);const[i]=await t.hitItems(s);const n=i!=null?a.fromHit(i):undefined;if(n!=null){await this.controller.addEntity(n)}else{await this.controller.clearEntities()}}))}ifInitialized(e){if(this.element!=null&&this.api!=null){return e({element:this.element,api:this.api})}else{throw new Error("Measurement interaction handler not initialized.")}}ifNoInteraction(e,t){const s=u.create(e.clientX,e.clientY);let i=false;const n=e=>{const t=u.create(e.clientX,e.clientY);const n=u.distance(s,t);i=n>2};const r=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",r);if(!i){t()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",r)}}const C=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const g=t(class e extends s{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementModel=new d;this.measurementOverlays=new m;this.measurableEntityTypes=[h.PRECISE_SURFACE,h.IMPRECISE_SURFACE];this.configEnv="platprod"}connectedCallback(){this.setupInteractionHandler()}componentWillLoad(){this.setupController();this.setupInteractionHandler()}disconnectedCallback(){this.clearInteractionHandler()}handleMeasurableEntityTypesChanged(){this.setupInteractionHandler()}handleMeasurementControllerChanged(){this.setupInteractionHandler()}handleMeasurementModelChanged(){this.setupController()}handleViewerChanged(){this.setupInteractionHandler()}render(){return i(n,{key:"2113569601821e742598eae47086b8bbd9198257"},i("vertex-viewer-measurement-overlays",{key:"d5ad40dd490ee2f6e1bddf5190c08907d706e0b9",viewer:this.viewer,measurementOverlays:this.measurementOverlays}))}setupController(){var e;const t=o(this.configEnv,this.config);const s=new r.SceneViewAPIClient(t.network.sceneViewHost);this.measurementController=new l(this.measurementModel,s,(()=>{var e;return(e=this.viewer)===null||e===void 0?void 0:e.token}),(e=this.viewer)===null||e===void 0?void 0:e.deviceId)}clearInteractionHandler(){var e;(e=this.registeredInteractionHandler)===null||e===void 0?void 0:e.then((e=>e.dispose()));this.registeredInteractionHandler=undefined}setupInteractionHandler(){var e;this.clearInteractionHandler();if(this.measurementController!=null){this.registeredInteractionHandler=(e=this.viewer)===null||e===void 0?void 0:e.registerInteractionHandler(new y(this.measurementController,this.measurableEntityTypes))}}static get watchers(){return{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return C()}},[1,"vertex-viewer-measurement-precise",{measurementModel:[16],measurementOverlays:[16],measurementController:[1040],measurableEntityTypes:[16],viewer:[16],configEnv:[1,"config-env"],config:[1]},undefined,{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:0}],viewer:[{handleViewerChanged:0}]}]);function b(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-precise","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-precise":if(!customElements.get(e(t))){customElements.define(e(t),g)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){f()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){w()}break}}))}b();const M=g;const E=b;export{M as VertexViewerMeasurementPrecise,E as defineCustomElement};
4
+ import{t as e,p as t,H as s,h as i,e as n}from"./p-DmsAWRoU.js";import{s as r}from"./p-BHLZLTUV.js";import{p as o}from"./p-C8g4gOHX.js";import{a,M as l}from"./p-Bfbzt4ZR.js";import"./p-CtJtApsf.js";import"./p-DrkwJOM4.js";import"./p-zTYgyBoa.js";import{E as h}from"./p-EXufj_Hh.js";import{M as d}from"./p-CkUMpn7h.js";import{M as m}from"./p-CI-uemp_.js";import{p as u}from"./p-Tvs4yxd5.js";import{a as p}from"./p-AZXboIdP.js";import{g as c}from"./p-BSYTUXcE.js";import{E as v}from"./p-CFus3r7d.js";import{d as f}from"./p-Xr7Oa6iw.js";import{d as w}from"./p-C8zX6RrH.js";class y{get elementRect(){return this.rectObserver.rect}constructor(e,t){this.rectObserver=new v;this.handlePointerMove=async e=>{if(await this.isMeasurableEntityUnderPointer(e)){this.clearCursor();this.addCursor(p)}else{this.clearCursor()}};this.handlePointerDown=e=>{this.ifNoInteraction(e,(async()=>{if(await this.isMeasurableEntityUnderPointer(e)){this.measureEntityUnderPointer(e)}else{await this.controller.clearEntities()}}))};this.controller=e;this.measurableEntityTypes=t}initialize(e,t){this.element=e;this.api=t;this.rectObserver.observe(e);e.addEventListener("pointermove",this.handlePointerMove);e.addEventListener("pointerdown",this.handlePointerDown)}dispose(){var e,t,s;this.rectObserver.disconnect();(e=this.measurementInteraction)===null||e===void 0?void 0:e.dispose();this.clearCursor();(t=this.element)===null||t===void 0?void 0:t.removeEventListener("pointermove",this.handlePointerMove);(s=this.element)===null||s===void 0?void 0:s.removeEventListener("pointerdown",this.handlePointerDown);this.element=undefined;this.api=undefined}addCursor(e){this.cursor=this.ifInitialized((({api:t})=>t.addCursor(e)))}clearCursor(){var e;(e=this.cursor)===null||e===void 0?void 0:e.dispose();this.cursor=undefined}async isMeasurableEntityUnderPointer(e){var t;const s=c(e,this.elementRect);const i=await((t=this.api)===null||t===void 0?void 0:t.getEntityTypeAtPoint(s));return i!=null&&this.measurableEntityTypes.includes(i)}measureEntityUnderPointer(e){this.ifInitialized((async({api:t})=>{const s=c(e,this.elementRect);const[i]=await t.hitItems(s);const n=i!=null?a.fromHit(i):undefined;if(n!=null){await this.controller.addEntity(n)}else{await this.controller.clearEntities()}}))}ifInitialized(e){if(this.element!=null&&this.api!=null){return e({element:this.element,api:this.api})}else{throw new Error("Measurement interaction handler not initialized.")}}ifNoInteraction(e,t){const s=u.create(e.clientX,e.clientY);let i=false;const n=e=>{const t=u.create(e.clientX,e.clientY);const n=u.distance(s,t);i=n>2};const r=()=>{window.removeEventListener("pointermove",n);window.removeEventListener("pointerup",r);if(!i){t()}};window.addEventListener("pointermove",n);window.addEventListener("pointerup",r)}}const C=()=>`:host{display:block;position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}`;const g=t(class e extends s{constructor(e){super();if(e!==false){this.__registerHost()}this.__attachShadow();this.measurementModel=new d;this.measurementOverlays=new m;this.measurableEntityTypes=[h.PRECISE_SURFACE,h.IMPRECISE_SURFACE];this.configEnv="platprod"}connectedCallback(){this.setupInteractionHandler()}componentWillLoad(){this.setupController();this.setupInteractionHandler()}disconnectedCallback(){this.clearInteractionHandler()}handleMeasurableEntityTypesChanged(){this.setupInteractionHandler()}handleMeasurementControllerChanged(){this.setupInteractionHandler()}handleMeasurementModelChanged(){this.setupController()}handleViewerChanged(){this.setupInteractionHandler()}render(){return i(n,{key:"2113569601821e742598eae47086b8bbd9198257"},i("vertex-viewer-measurement-overlays",{key:"d5ad40dd490ee2f6e1bddf5190c08907d706e0b9",viewer:this.viewer,measurementOverlays:this.measurementOverlays}))}setupController(){var e;const t=o(this.configEnv,this.config);const s=new r.SceneViewAPIClient(t.network.sceneViewHost);this.measurementController=new l(this.measurementModel,s,(()=>{var e;return(e=this.viewer)===null||e===void 0?void 0:e.token}),(e=this.viewer)===null||e===void 0?void 0:e.deviceId)}clearInteractionHandler(){var e;(e=this.registeredInteractionHandler)===null||e===void 0?void 0:e.then((e=>e.dispose()));this.registeredInteractionHandler=undefined}setupInteractionHandler(){var e;this.clearInteractionHandler();if(this.measurementController!=null){this.registeredInteractionHandler=(e=this.viewer)===null||e===void 0?void 0:e.registerInteractionHandler(new y(this.measurementController,this.measurableEntityTypes))}}static get watchers(){return{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:0}],viewer:[{handleViewerChanged:0}]}}static get style(){return C()}},[1,"vertex-viewer-measurement-precise",{measurementModel:[16],measurementOverlays:[16],measurementController:[1040],measurableEntityTypes:[16],viewer:[16],configEnv:[1,"config-env"],config:[1]},undefined,{measurableEntityTypes:[{handleMeasurableEntityTypesChanged:0}],measurementController:[{handleMeasurementControllerChanged:0}],measurementModel:[{handleMeasurementModelChanged:0}],viewer:[{handleViewerChanged:0}]}]);function b(){if(typeof customElements==="undefined"){return}const t=["vertex-viewer-measurement-precise","vertex-viewer-measurement-line","vertex-viewer-measurement-overlays"];t.forEach((t=>{switch(t){case"vertex-viewer-measurement-precise":if(!customElements.get(e(t))){customElements.define(e(t),g)}break;case"vertex-viewer-measurement-line":if(!customElements.get(e(t))){f()}break;case"vertex-viewer-measurement-overlays":if(!customElements.get(e(t))){w()}break}}))}b();const M=g;const E=b;export{M as VertexViewerMeasurementPrecise,E as defineCustomElement};
5
5
  //# sourceMappingURL=vertex-viewer-measurement-precise.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
3
3
  */
4
- import{V as o,d as s}from"./p-DU6goRD0.js";const t=o;const p=s;export{t as VertexViewerPinGroup,p as defineCustomElement};
4
+ import{V as o,d as s}from"./p-Ce-6kPRQ.js";const t=o;const p=s;export{t as VertexViewerPinGroup,p as defineCustomElement};
5
5
  //# sourceMappingURL=vertex-viewer-pin-group.js.map