@arcgis/core 5.2.0-next.21 → 5.2.0-next.23

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 (214) hide show
  1. package/Graphic.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js → 1040bce57ea63a6dbca4.js} +2 -2
  4. package/assets/esri/core/workers/chunks/1a7c0a1dc6ecc93ea03a.js +1 -0
  5. package/assets/esri/core/workers/chunks/292498a9c7d462d215c6.js +1 -0
  6. package/assets/esri/core/workers/chunks/2d6d01913096f7cb5ff8.js +1 -0
  7. package/assets/esri/core/workers/chunks/30298f84bd414f9dea64.js +1 -0
  8. package/assets/esri/core/workers/chunks/353c67da4b25c29360db.js +2 -0
  9. package/assets/esri/core/workers/chunks/3b4fc67f6cb7393fbd97.js +1 -0
  10. package/assets/esri/core/workers/chunks/47948c72bc01bd173c20.js +2 -0
  11. package/assets/esri/core/workers/chunks/{f0519b06987471456b69.js → 502464c4eab7667f6566.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{d7acbc2ddff4cee8a465.js → 5ee887fc6e1e0e70e02f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/6c0c77de1934f35dc45f.js +1 -0
  14. package/assets/esri/core/workers/chunks/{f7f820483e45c05ab9e4.js → 75df436e6e9773bdcfc2.js} +1 -1
  15. package/assets/esri/core/workers/chunks/780519b60aa674a61a74.js +1 -0
  16. package/assets/esri/core/workers/chunks/7dbaa089c7472825b80c.js +1 -0
  17. package/assets/esri/core/workers/chunks/7dec8c453fdee1968d12.js +1 -0
  18. package/assets/esri/core/workers/chunks/{a2247f4c3116efb16c4f.js → 7e23de8d9b2d938808f6.js} +1 -1
  19. package/assets/esri/core/workers/chunks/7e4093f42795ba2f8cfd.js +1 -0
  20. package/assets/esri/core/workers/chunks/{6649acaceab00ad30e7f.js → 8ba3e0462a9bdaae5f40.js} +1 -1
  21. package/assets/esri/core/workers/chunks/928b18e13e015330d44b.js +1 -0
  22. package/assets/esri/core/workers/chunks/9434c76ad39c936dba90.js +1 -0
  23. package/assets/esri/core/workers/chunks/{909e67dee8c30e391d69.js → a8310f55de4749f973d0.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{ac16016964be3b684e98.js → aded4e704e09a28edc8f.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{7175f0c6a6e56b685d20.js → b419fd36337e76e2d4a3.js} +6 -6
  26. package/assets/esri/core/workers/chunks/{05d597dd117766beadd8.js → b91a15522692781560b4.js} +1 -1
  27. package/assets/esri/core/workers/chunks/c86d388d216adbb15a05.js +1 -0
  28. package/assets/esri/core/workers/chunks/{f1ff33584680d8718400.js → c9ce408675dae6a0edd1.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{0b522e05668bef729b1b.js → ceb5bd9f2afaa2ea0808.js} +1 -1
  30. package/assets/esri/core/workers/chunks/d07068c44d560e4ce02e.js +1 -0
  31. package/assets/esri/core/workers/chunks/{da47fdffb5969694a2ae.js → d41eed41916ed0422059.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{19493c9c7e1d2ac0f80f.js → d4e0346209fabc58f929.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{b375abfb2a2d9c63e20a.js → db90fb8ac96579259566.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js → dd0acd0f8b96839b4f24.js} +2 -2
  35. package/assets/esri/core/workers/chunks/{5809e70a8e57e9b05959.js → dd795c95cdc3812b5b49.js} +1 -1
  36. package/assets/esri/core/workers/chunks/f7344d855f1092383abe.js +1 -0
  37. package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.js → f859c53432f258af77e3.js} +2 -2
  38. package/assets/esri/core/workers/chunks/{ecbf84a1f42e6188faab.js → fd629872b5c07853f695.js} +1 -1
  39. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  40. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +5 -1
  41. package/assets/esri/themes/dark/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/chunks/GaussianSplat.glsl.js +4 -4
  45. package/chunks/GaussianSplatShadow.glsl.js +1 -1
  46. package/config.d.ts +9 -2
  47. package/config.js +1 -1
  48. package/core/date.js +1 -1
  49. package/form/FormTemplate.d.ts +15 -20
  50. package/form/elements/AttachmentElement.d.ts +38 -11
  51. package/form/elements/Element.d.ts +9 -6
  52. package/form/elements/FieldElement.d.ts +0 -1
  53. package/form/elements/GroupElement.d.ts +4 -6
  54. package/form/elements/RelationshipElement.d.ts +8 -8
  55. package/form/elements/inputs/attachments/AttachmentInput.d.ts +34 -18
  56. package/form/elements/inputs/attachments/AudioInput.d.ts +4 -3
  57. package/form/elements/inputs/attachments/DocumentInput.d.ts +2 -6
  58. package/form/elements/inputs/attachments/ImageInput.d.ts +4 -3
  59. package/form/elements/inputs/attachments/Input.d.ts +6 -3
  60. package/form/elements/inputs/attachments/SignatureInput.d.ts +3 -3
  61. package/form/elements/inputs/attachments/VideoInput.d.ts +4 -3
  62. package/form/elements.d.ts +6 -12
  63. package/form/types.d.ts +0 -4
  64. package/kernel.js +1 -1
  65. package/layers/AnnotationFeatureLayer.d.ts +2 -1
  66. package/layers/DimensionFeatureLayer.d.ts +2 -1
  67. package/layers/OrientedImageryLayer.d.ts +20 -2
  68. package/layers/OrientedImageryLayer.js +1 -1
  69. package/layers/ParquetLayer.js +1 -1
  70. package/layers/graphics/sources/ParquetSource.js +1 -1
  71. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  72. package/layers/graphics/sources/geojson/geojson.js +1 -1
  73. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  74. package/layers/graphics/sources/parquet/PortalParquetLayerFileProvider.js +1 -1
  75. package/layers/graphics/sources/parquet/fileProviderChangedError.js +2 -0
  76. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  77. package/layers/mixins/EditBusLayer.js +1 -1
  78. package/layers/orientedImagery/core/utils.js +1 -1
  79. package/layers/orientedImagery/types.d.ts +4 -1
  80. package/layers/support/RasterBandInfo.js +1 -1
  81. package/layers/types.d.ts +1 -0
  82. package/package.json +3 -3
  83. package/rest/support/AttachmentQuery.d.ts +13 -1
  84. package/rest/support/AttachmentQuery.js +1 -1
  85. package/rest/support/OutDistance.d.ts +5 -1
  86. package/rest/support/PrintParameters.d.ts +2 -1
  87. package/rest/support/Query.d.ts +2 -0
  88. package/support/basemapUtils.js +1 -1
  89. package/support/revision.js +1 -1
  90. package/symbols/SimpleMarkerSymbol.d.ts +2 -2
  91. package/views/2d/engine/AFeatureContainer.js +1 -1
  92. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  93. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  94. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  95. package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
  96. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  97. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  101. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  102. package/views/2d/layers/features/FeatureContainer.js +1 -1
  103. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  104. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  105. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  106. package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
  107. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  108. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  109. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  110. package/views/3d/analysis/Viewshed/ViewshedComputedData.js +1 -1
  111. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  112. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  113. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  114. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  115. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  116. package/views/3d/layers/GaussianSplatLayerViewPerformanceInfo.js +1 -1
  117. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  118. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  119. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  120. package/views/3d/state/utils/navigationUtils.js +1 -1
  121. package/views/3d/support/gaussianSplatting/GaussianSplatAtlasPages.js +1 -1
  122. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  123. package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +2 -0
  124. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  125. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +4 -4
  126. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatTextureFetch.glsl.js +13 -12
  127. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  128. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  129. package/views/3d/webgl-engine/lib/GaussianSplatShadowRenderNode.js +1 -1
  130. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  131. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  132. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
  133. package/views/PopupView.d.ts +3 -0
  134. package/views/View2D.d.ts +2 -2
  135. package/views/layers/AnnotationFeatureLayerView.d.ts +9 -1
  136. package/views/layers/DimensionFeatureLayerView.d.ts +9 -1
  137. package/views/layers/FeatureLikeLayerView.js +1 -1
  138. package/widgets/BasemapGallery.js +1 -1
  139. package/widgets/BatchAttributeForm/attachmentUtils.js +1 -1
  140. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  141. package/widgets/BatchAttributeForm/css.js +1 -1
  142. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  143. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  144. package/widgets/BatchAttributeForm/types.d.ts +0 -7
  145. package/widgets/BatchAttributeForm.d.ts +7 -9
  146. package/widgets/BatchAttributeForm.js +1 -1
  147. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  148. package/widgets/Editor/EditorViewModel.d.ts +12 -2
  149. package/widgets/Editor/EditorViewModel.js +1 -1
  150. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  151. package/widgets/Editor/UpdateWorkflow.js +1 -1
  152. package/widgets/Editor/compatibilityAdapters.js +2 -0
  153. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  154. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  155. package/widgets/Editor/legacy/AddAssociationWorkflow.js +2 -0
  156. package/widgets/Editor/legacy/AddAssociationWorkflowData.js +2 -0
  157. package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +2 -0
  158. package/widgets/Editor/legacy/CreateFeaturesWorkflowData.js +2 -0
  159. package/widgets/Editor/legacy/MergeFeaturesWorkflow.js +2 -0
  160. package/widgets/Editor/legacy/MergeFeaturesWorkflowData.js +2 -0
  161. package/widgets/Editor/legacy/SplitFeatureWorkflow.js +2 -0
  162. package/widgets/Editor/legacy/SplitFeatureWorkflowData.js +2 -0
  163. package/widgets/Editor/legacy/UpdateFeatureWorkflow.js +2 -0
  164. package/widgets/Editor/legacy/UpdateFeatureWorkflowData.js +2 -0
  165. package/widgets/Editor/legacy/UpdateFeaturesWorkflow.js +2 -0
  166. package/widgets/Editor/legacy/UpdateFeaturesWorkflowData.js +2 -0
  167. package/widgets/Editor/legacy/UpdateRecordWorkflow.js +2 -0
  168. package/widgets/Editor/legacy/UpdateRecordWorkflowData.js +2 -0
  169. package/widgets/Editor/legacy/UpdateWorkflow.js +2 -0
  170. package/widgets/Editor/legacy/UpdateWorkflowData.js +2 -0
  171. package/widgets/Editor/legacy/Workflow.js +2 -0
  172. package/widgets/Editor/legacy/workflowUtils.js +2 -0
  173. package/widgets/Editor/types.d.ts +12 -0
  174. package/widgets/Editor/workflowUtils.js +1 -1
  175. package/widgets/Editor.js +1 -1
  176. package/widgets/FeatureForm/FeatureFormViewModel.d.ts +16 -12
  177. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  178. package/widgets/FeatureForm.d.ts +14 -16
  179. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +2 -1
  180. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  181. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +3 -0
  182. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  183. package/widgets/FeatureTable/Grid/types.d.ts +20 -0
  184. package/widgets/FeatureTable.d.ts +14 -2
  185. package/widgets/FeatureTable.js +1 -1
  186. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  187. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  188. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  189. package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
  190. package/widgets/OrientedImageryViewer/support/panConstraint.js +1 -1
  191. package/widgets/OrientedImageryViewer.js +1 -1
  192. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  193. package/assets/esri/core/workers/chunks/057d288d795b853295f1.js +0 -2
  194. package/assets/esri/core/workers/chunks/26aa8190ac439f634c5b.js +0 -1
  195. package/assets/esri/core/workers/chunks/3192586ec7fc73ed1165.js +0 -1
  196. package/assets/esri/core/workers/chunks/33866e6e6de1bab64599.js +0 -1
  197. package/assets/esri/core/workers/chunks/360fd810d70d21c092d9.js +0 -1
  198. package/assets/esri/core/workers/chunks/3e89f487c5851c954d8b.js +0 -1
  199. package/assets/esri/core/workers/chunks/5aa375b0c6a205134703.js +0 -1
  200. package/assets/esri/core/workers/chunks/5f0bc019add4aff3130c.js +0 -1
  201. package/assets/esri/core/workers/chunks/630ad47857de3cf726d1.js +0 -1
  202. package/assets/esri/core/workers/chunks/754f7ed62afc4e0a1972.js +0 -2
  203. package/assets/esri/core/workers/chunks/7ee76504e7fea389a1c9.js +0 -1
  204. package/assets/esri/core/workers/chunks/8331e04ebe0a54b04ab6.js +0 -1
  205. package/assets/esri/core/workers/chunks/8c64c6b8d7376a9d1c91.js +0 -1
  206. package/assets/esri/core/workers/chunks/c30ca771dd3f7198142b.js +0 -1
  207. package/assets/esri/core/workers/chunks/e5fcd8e7a4a660ef6ad6.js +0 -1
  208. package/assets/esri/core/workers/chunks/f47319d36f1527277923.js +0 -1
  209. package/assets/esri/core/workers/chunks/ff00ac01f0baaecaa890.js +0 -1
  210. /package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js.LICENSE.txt → 1040bce57ea63a6dbca4.js.LICENSE.txt} +0 -0
  211. /package/assets/esri/core/workers/chunks/{057d288d795b853295f1.js.LICENSE.txt → 353c67da4b25c29360db.js.LICENSE.txt} +0 -0
  212. /package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js.LICENSE.txt → 47948c72bc01bd173c20.js.LICENSE.txt} +0 -0
  213. /package/assets/esri/core/workers/chunks/{754f7ed62afc4e0a1972.js.LICENSE.txt → dd0acd0f8b96839b4f24.js.LICENSE.txt} +0 -0
  214. /package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.js.LICENSE.txt → f859c53432f258af77e3.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{getOrCreateMapValue as e}from"../../../../../../core/MapUtils.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{throwIfAborted as a,onAbort as i}from"../../../../../../core/promiseUtils.js";import{QueueProcessor as r}from"../../../../../../core/QueueProcessor.js";import{difference as o}from"../../../../../../core/SetUtils.js";import{openWithPorts as l}from"../../../../../../core/workers/workers.js";import{loadParquetModule as n}from"../../../../../../libs/parquet/loadParquetModule.js";import{ALoadStrategy as d}from"./ALoadStrategy.js";import{fetchQueueConcurrency as h}from"./constants.js";import{ParquetSourceChunk as c}from"./chunks/ParquetSourceChunk.js";import{FeatureSetReaderParquet as u}from"../../support/FeatureSetReaderParquet.js";class p{constructor(e,s){this.subscription=e,this.chunks=[],this.ids=[],this._controller=new AbortController,this._handles=t([i(e.signal,()=>this._controller.abort()),i(s,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get options(){return{signal:this._controller.signal}}addBinaryData(t){this.chunks.push(t)}addSourceChunkId(t){this.ids.push(t)}}class m extends d{constructor(t,e,s,a){if(super(t.metadata,e,s),this._service=t,this._loadStates=new Map,this._queue=new r({concurrency:h,process:t=>this._loadTile(t)}),!t.geometryInfo.displayOptimization)throw new Error("InternalError: ParquetTileLoadStrategy only supports XZ-enabled parquet files");this._loaded=this._load(a)}destroy(){super.destroy(),this._loaded.finally(()=>{this._client.close(),this._client=null;for(const t of this._ports)t.close()}).catch(()=>{})}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}async tryUpdate(t,e){await this._loaded;let a=!0;return s(this.availableFields,e.availableFields)&&await this._updateFields(e.availableFields),this._schema.partial.dataSourceHash!==e.dataSourceHash&&(a=!1),this._schema.partial=e,a}async load(t){return await this._loaded,e(this._loadStates,t.key.id,()=>new p(t,this._options)),this._queue.push(t)}unload(t){const e=this._loadStates.get(t.tile.id);if(null!=e){for(const t of e.ids)this.store.removeById(t);e.destroy(),this._loadStates.delete(t.tile.id)}}async _load(t){this._ports=await t.layerView.openMemoryPorts(),this._client=await l(this._ports,{maxNumberOfConcurrentJobs:20}),this._proxy=this._client.createInvokeProxy(),this._indexMap=await this._proxy.getIndexMap()}_onOverride(){}async _updateFields(t){const e=new Set(t),s=o(e,new Set(this.availableFields));if(null!=this._service.metadata.fieldsIndex&&s.size){const t=Array.from(this.store.insertedChunks()).map(t=>t.updateFields(this._proxy,Array.from(s),this._options));await Promise.all(t)}}async _loadTile(t){const e=t.tile,s=t.signal,i=this._loadStates.get(e.id);await this._downloadTileData(t),a(s);const r=new c(this.metadata,null,e,null,0,!0);i.addSourceChunkId(r.chunkId),this.store.insert(r)}async _downloadTileData(t){const e=await n(),s=t.tile,i=t.signal,r=this._loadStates.get(s.id),o=await this._proxy.queryStream({type:"tile",extent:s.extent,transform:s.normalizedTransform,outFields:Array.from(this.availableFields),returnGeometry:!0,outSpatialReference:this.metadata.outSpatialReference.toJSON(),scale:s.scale,where:this.definitionExpression},{signal:i});let l=0;for(;;){const t=await this._proxy.getStreamNext(o,{signal:i});if(a(i),null==t)break;const{fileId:n,buffer:d}=t,h=e.ParquetChunk.deserialize(new Uint8Array(d)),p=new u(this.metadata,this._indexMap,h,n,s.transform),m=new c(this.metadata,p,s,n,l++,!1);r.addBinaryData({data:h,fileId:n}),r.addSourceChunkId(m.chunkId),this.store.insert(m)}}}export{m as ParquetTileLoadStrategy};
2
+ import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{getOrCreateMapValue as e}from"../../../../../../core/MapUtils.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{throwIfAborted as r,onAbort as a}from"../../../../../../core/promiseUtils.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import{difference as o}from"../../../../../../core/SetUtils.js";import{openWithPorts as l}from"../../../../../../core/workers/workers.js";import{isFileProviderChangedError as n}from"../../../../../../layers/graphics/sources/parquet/fileProviderChangedError.js";import{loadParquetModule as d}from"../../../../../../libs/parquet/loadParquetModule.js";import{ALoadStrategy as h}from"./ALoadStrategy.js";import{fetchQueueConcurrency as c}from"./constants.js";import{ParquetSourceChunk as u}from"./chunks/ParquetSourceChunk.js";import{FeatureSetReaderParquet as p}from"../../support/FeatureSetReaderParquet.js";class m{constructor(e,s){this.subscription=e,this.chunks=[],this.ids=[],this._controller=new AbortController,this._handles=t([a(e.signal,()=>this._controller.abort()),a(s,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get options(){return{signal:this._controller.signal}}addBinaryData(t){this.chunks.push(t)}addSourceChunkId(t){this.ids.push(t)}}class _ extends h{constructor(t,e,s,r){if(super(t.metadata,e,s),this._service=t,this._loadStates=new Map,this._queue=new i({concurrency:c,process:t=>this._loadTile(t)}),!t.geometryInfo.displayOptimization)throw new Error("InternalError: ParquetTileLoadStrategy only supports XZ-enabled parquet files");this._loaded=this._load(r)}destroy(){super.destroy(),this._loaded.finally(()=>{this._client.close(),this._client=null;for(const t of this._ports)t.close()}).catch(()=>{})}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}async tryUpdate(t,e){await this._loaded;let r=!0;return s(this.availableFields,e.availableFields)&&await this._updateFields(e.availableFields),this._schema.partial.dataSourceHash!==e.dataSourceHash&&(r=!1),this._schema.partial=e,r}async load(t){try{return await this._loaded,e(this._loadStates,t.key.id,()=>new m(t,this._options)),await this._queue.push(t)}catch(s){if(!f(s))throw s}}unload(t){const e=this._loadStates.get(t.tile.id);if(null!=e){for(const t of e.ids)this.store.removeById(t);e.destroy(),this._loadStates.delete(t.tile.id)}}async _load(t){this._ports=await t.layerView.openMemoryPorts(),this._client=await l(this._ports,{maxNumberOfConcurrentJobs:20}),this._proxy=this._client.createInvokeProxy(),this._indexMap=await this._proxy.getIndexMap()}_onOverride(){}async _updateFields(t){const e=new Set(t),s=o(e,new Set(this.availableFields));if(null!=this._service.metadata.fieldsIndex&&s.size){const t=Array.from(this.store.insertedChunks()).map(t=>t.updateFields(this._proxy,Array.from(s),this._options));await Promise.all(t)}}async _loadTile(t){const e=t.tile,s=t.signal,a=this._loadStates.get(e.id);await this._downloadTileData(t),r(s);const i=new u(this.metadata,null,e,null,0,!0);a.addSourceChunkId(i.chunkId),this.store.insert(i)}async _downloadTileData(t){const e=await d(),s=t.tile,a=t.signal,i=this._loadStates.get(s.id),o=await this._proxy.queryStream({type:"tile",extent:s.extent,transform:s.normalizedTransform,outFields:Array.from(this.availableFields),returnGeometry:!0,outSpatialReference:this.metadata.outSpatialReference.toJSON(),scale:s.scale,where:this.definitionExpression},{signal:a});let l=0;for(;;){const t=await this._proxy.getStreamNext(o,{signal:a});if(r(a),null==t)break;const{fileId:n,buffer:d}=t,h=e.ParquetChunk.deserialize(new Uint8Array(d)),c=new p(this.metadata,this._indexMap,h,n,s.transform),m=new u(this.metadata,c,s,n,l++,!1);i.addBinaryData({data:h,fileId:n}),i.addSourceChunkId(m.chunkId),this.store.insert(m)}}}function f(t){return n(t)||y(t)}function y(t){return null!=t&&"object"==typeof t&&"message"in t&&"Protocol Violation: transport error"===t.message}export{_ as ParquetTileLoadStrategy};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import i from"../../../../../core/Error.js";import{deg2rad as t,rad2deg as n}from"../../../../../core/mathUtils.js";import{dist as e,set as s,equals as o,subtract as r}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as h,create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as m}from"../../../../../geometry/support/jsonTypeUtils.js";import _ from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as a}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as d,fromCIMVerticalAlignment as u,fromCIMFontDecoration as g}from"../../../../../symbols/cim/utils.js";import P from"../../../arcade/callExpressionWithFeature.js";import{glyphSize as c,magicLabelLineHeight as b}from"../../../engine/webgl/definitions.js";import x from"../../../engine/webgl/Rect.js";import{shapeGlyphs as p}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{queryPointOnLine as f,angleFromXAxis as y,intersectRaysByPointsAndAngles as D}from"../../features/support/FeatureSetReaderDimensionJSON.js";import{roundPtToWholePixel as M,getLineWidth as S}from"../../graphics/graphicsUtils.js";import{DimensionRealFieldName as k}from"./dimensionUtils.js";import{getAttributeValue as L}from"./utils.js";class w{static async create(i,t,n,e){const s=e(i.textSymbol),o=new w(i,s);return await o.initialize(t,n),o}constructor(i,t){if(this._dimensionStyle=i,this._mosaicItems=t,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerPoint=null,this._endMarkerPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!")}async initialize(t,n){if(!this._dimensionStyle)return;const{attributes:e}=t;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:e,expressionParserName:s}=this._dimensionStyle;if(e&&s){if(s&&"arcade"!==s.toLocaleLowerCase())throw new i("dimension-layer",`Unsupported expression parser (${s}) for dimension text.`);this._compiledExpression=await a(e,n),this._fieldsIndex=E(t)}}const s=Number(L(k.extAngle,e));this._extAngleRad=isNaN(s)?Math.PI/2:s,this._systemLength=Number(L("__SYSTEM_LENGTH__",e));const{geometry:o}=t;if(o&&!m(o))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const r=o?.rings[0];if(!r||r.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==r[3][0]&&0!==r[3][1]&&void 0!==r[3][0]&&void 0!==r[3][1],this._hasTextPoint&&(this._textPoint=r[3]);const h=this._dimensionStyle.textSymbol;e.__DIMENSION_ANGLE__+=h?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,t){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,t),this._evaluateDefaultPlacement(t),this._updateExtensionLines(t),this._updateTextPoint(i,t),this._dimensionIsEvaluated=!0)}_updateTextPoint(i,t){if(this._hasTextPoint)return;const{textFit:n}=this._dimensionStyle;let e=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===n||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(e=!0);if((N(this._beginMarkerRect,this._textRect)||N(this._endMarkerRect,this._textRect))&&(e=!1),!e){const i=t*(this._textRect.width/2);"MoveBegin"===n?this._textPoint=f(this._beginMarkerPoint,this._endMarkerPoint,-i):"MoveEnd"===n&&(this._textPoint=f(this._endMarkerPoint,this._beginMarkerPoint,-i))}}if(e){if(!this._dimensionStyle.textSymbol)return;const i=t*(this._textRect.width/2),n=this._dimensionPolyline[0],e=this._dimensionPolyline[1],s=f(n[0],n[1],i),o=f(e[0],e[1],i);this._dimensionPolyline=[[s,n[1]],[o,e[1]]]}}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:t,extensionLineOffset:n}=this._dimensionStyle;let s=this._dimensionLinePoint,o=this._endDimensionPoint;null==t||isNaN(t)||0===t||(s=f(this._dimensionLinePoint,this._beginBaselinePoint,-t*i),o=f(this._endDimensionPoint,this._endBaselinePoint,-t*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=n&&!isNaN(n)&&0!==n){const i=e(s,this._beginBaselinePoint),t=e(o,this._endBaselinePoint);r=f(s,this._beginBaselinePoint,i-n),h=f(o,this._endBaselinePoint,t-n)}this._dimensionExtensionLines=[[s,r],[o,h]]}_computeDimensionLineInfo(r,_){if(!r||!m(r)||r.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const a=r.rings[0],d=h(a[0][0],a[0][1]),u=h(a[1][0],a[1][1]),g=h(a[2][0],a[2][1]);this._beginBaselinePoint=s(l(),d[0],d[1]),this._endBaselinePoint=s(l(),u[0],u[1]),this._dimensionLinePoint=g;let P=this._extAngleRad;if(o(d,g))this._beginDimensionPoint=s(l(),d[0],d[1]),this._endDimensionPoint=s(l(),u[0],u[1]),this._displayExtLines=!1;else{const e=y([u[0]-d[0],u[1]-d[1]]),o=n(P);o>=-1&&o<=1?P+=t(1):o>=179&&o<=181&&(P-=t(1));const r=D(g,e,u,e+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=s(l(),g[0],g[1]),this._endDimensionPoint=s(l(),r[0],r[1])}this._dimensionLength=e(this._beginDimensionPoint,this._endDimensionPoint),this._hasTextPoint||(this._textPoint=f(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:t,endMarkerSymbol:n}=this._dimensionStyle,e=this._measureMarkerSymbolSize(t,this._beginDimensionPoint,this._dimensionAngleRad,i),s=this._measureMarkerSymbolSize(n,this._endDimensionPoint,this._dimensionAngleRad+Math.PI,i),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const h=i*((e?.width??0)/2),l=i*((s?.width??0)/2);this._beginMarkerPoint=f(this._beginDimensionPoint,this._endDimensionPoint,h),this._endMarkerPoint=f(this._endDimensionPoint,this._beginDimensionPoint,l);const m=[0,0];if(e&&this._beginMarkerPoint){const i=r(m,this._beginMarkerPoint,this._beginDimensionPoint);e.x+=i[0],e.y+=i[1]}if(s&&this._endMarkerPoint){const i=r(m,this._endMarkerPoint,this._endDimensionPoint);s.x+=i[0],s.y+=i[1]}if(this._beginMarkerRect=e,this._endMarkerRect=s,this._doMarkersFit=this._checkMarkerFit(e,s,o,i),this._doMarkersFit){const i=f(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else this._beginMarkerPoint=f(this._beginDimensionPoint,this._endDimensionPoint,-4*h),this._endMarkerPoint=f(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*l),this._dimensionPolyline=[[this._beginMarkerPoint,this._beginDimensionPoint],[this._endMarkerPoint,this._endDimensionPoint]]}_checkMarkerFit(i,t,n,e){if(!i||!t)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;if("Tolerance"===s)r*e>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?N(i,t)&&(h=!1):(N(i,t)&&(h=!1),h&&n&&(N(n,i)||N(n,t))&&(h=!1))}return h||(this._beginMarkerPoint=f(this._beginDimensionPoint,this._endDimensionPoint,-i.width/2),this._endMarkerPoint=f(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+t.width/2)),h}_measureDimensionText(i,t,n){if(null==this._textString||null==t||null==this._mosaicItems)return null;const e=[];for(const d of i)d.codePointAt(0),e.push(this._mosaicItems.glyphs[d.codePointAt(0)]);const s=this._dimensionStyle.textSymbol;if(!s)return null;const o=d(s.horizontalAlignment),r=u(s.verticalAlignment),h=g(s),l=M(s.height||10),m=!0,_=s.angle||0,a=l/c,P=S(s.lineWidth),f=b*Math.max(.25,Math.min(l||1,4)),y={...this._mosaicItems,glyphs:e.filter(i=>null!=i)},D=p(y,{scale:a,angle:_,xOffset:0,yOffset:0,horizontalAlignment:o,verticalAlignment:r,decoration:h,lineHeight:f,useCIMAngleBehavior:m,maxLineWidth:P,hasBackground:!1}),k=t;if(!k)return null;const L=n,w=[D.bounds.blX,D.bounds.trY],E=[D.bounds.trX,D.bounds.trY],T=[D.bounds.blX,D.bounds.blY],N=[D.bounds.trX,D.bounds.blY];return w[0]-=D.bounds.x,w[1]-=D.bounds.y,E[0]-=D.bounds.x,E[1]-=D.bounds.y,T[0]-=D.bounds.x,T[1]-=D.bounds.y,N[0]-=D.bounds.x,N[1]-=D.bounds.y,w[0]*=L,w[1]*=L,E[0]*=L,E[1]*=L,T[0]*=L,T[1]*=L,N[0]*=L,N[1]*=L,w[0]+=k[0],w[1]+=k[1],E[0]+=k[0],E[1]+=k[1],T[0]+=k[0],T[1]+=k[1],N[0]+=k[0],N[1]+=k[1],new x(E[0],E[1],1.1*Math.abs(w[0]-E[0]),1.1*Math.abs(N[1]-E[1]))}_measureMarkerSymbolSize(i,t,n,e){return i?new x(-16,-16,32,32):null}_getDimensionText(i){const{attributes:t}=i;let n=null;const e=1===Number(L(k.useCustomLength,t));n=Number(L(e?k.customLength:k.dimLength,t)),(0===n||isNaN(n)||null==n)&&(n=this._systemLength);let s=this._getDimensionString(n,i);return"number"==typeof s&&(s=s.toString()),t.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,t){const{convertUnits:n,displayUnits:e,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&t)return P(this._compiledExpression,t,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function E(i){const{attributes:t}=i,n=Object.keys(k).map(i=>({name:i,alias:i,type:"string"==typeof t[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new _(n)}function T(i){return{left:i.x,right:i.x+i.width,top:i.y+i.height,bottom:i.y}}function N(i,t){const n=T(i),e=T(t),s=n.left<=e.right&&e.left<=n.right,o=n.bottom<=e.top&&e.bottom<=n.top;return s&&o}export{w as default};
2
+ import i from"../../../../../core/Error.js";import{deg2rad as t,rad2deg as n}from"../../../../../core/mathUtils.js";import{dist as e,set as s,equals as o,subtract as r,len as h,scale as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as m,create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as a}from"../../../../../geometry/support/jsonTypeUtils.js";import d from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as u}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as g,fromCIMVerticalAlignment as c,fromCIMFontDecoration as x}from"../../../../../symbols/cim/utils.js";import P from"../../../arcade/callExpressionWithFeature.js";import{glyphSize as b,magicLabelLineHeight as f}from"../../../engine/webgl/definitions.js";import p from"../../../engine/webgl/Rect.js";import{shapeGlyphs as y}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{queryPointOnLine as D,angleFromXAxis as S,intersectRaysByPointsAndAngles as L}from"../../features/support/FeatureSetReaderDimensionJSON.js";import{roundPtToWholePixel as M,getLineWidth as E}from"../../graphics/graphicsUtils.js";import{DimensionRealFieldName as T}from"./dimensionUtils.js";import{getAttributeValue as w}from"./utils.js";class k{static async create(i,t,n,e){const s=e(i.textSymbol),o=new k(i,s);return await o.initialize(t,n),o}constructor(i,t){if(this._dimensionStyle=i,this._mosaicItems=t,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!")}async initialize(t,n){if(!this._dimensionStyle)return;const{attributes:e}=t;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:e,expressionParserName:s}=this._dimensionStyle;if(e&&s){if(s&&"arcade"!==s.toLocaleLowerCase())throw new i("dimension-layer",`Unsupported expression parser (${s}) for dimension text.`);this._compiledExpression=await u(e,n),this._fieldsIndex=N(t)}}const s=Number(w(T.extAngle,e));this._extAngleRad=isNaN(s)?Math.PI/2:s,this._systemLength=Number(w("__SYSTEM_LENGTH__",e));const{geometry:o}=t;if(o&&!a(o))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const r=o?.rings[0];if(!r||r.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==r[3][0]&&0!==r[3][1]&&void 0!==r[3][0]&&void 0!==r[3][1],this._hasTextPoint&&(this._textPoint=r[3]);const h=this._dimensionStyle.textSymbol;e.__DIMENSION_ANGLE__+=h?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,t){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,t),this._evaluateDefaultPlacement(t),this._updateExtensionLines(t),this._updateTextPoint(t),this._offsetTextPoint(t),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:t}=this._dimensionStyle;let n=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===t||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(n=!0);if((B(this._beginMarkerRect,this._textRect)||B(this._endMarkerRect,this._textRect))&&(n=!1),!n){const n=i*(this._textRect.width/2);"MoveBegin"===t?this._textPoint=D(this._beginDimensionPoint,this._endDimensionPoint,-n):"MoveEnd"===t&&(this._textPoint=D(this._endDimensionPoint,this._beginDimensionPoint,-n))}}}_offsetTextPoint(i){if(this._hasTextPoint)return;const t=this._textPoint;if(!t)return;const n=.5*this._textSize*i,e=-n*this._dimensionDirection[1],s=n*this._dimensionDirection[0];t[0]+=e,t[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:t,extensionLineOffset:n}=this._dimensionStyle;let s=this._dimensionLinePoint,o=this._endDimensionPoint;null==t||isNaN(t)||0===t||(s=D(this._dimensionLinePoint,this._beginBaselinePoint,-t*i),o=D(this._endDimensionPoint,this._endBaselinePoint,-t*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=n&&!isNaN(n)&&0!==n){const i=e(s,this._beginBaselinePoint),t=e(o,this._endBaselinePoint);r=D(s,this._beginBaselinePoint,i-n),h=D(o,this._endBaselinePoint,t-n)}this._dimensionExtensionLines=[[s,r],[o,h]]}_computeDimensionLineInfo(e,d){if(!e||!a(e)||e.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const u=e.rings[0],g=m(u[0][0],u[0][1]),c=m(u[1][0],u[1][1]),x=m(u[2][0],u[2][1]);this._beginBaselinePoint=s(_(),g[0],g[1]),this._endBaselinePoint=s(_(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(o(g,x))this._beginDimensionPoint=s(_(),g[0],g[1]),this._endDimensionPoint=s(_(),c[0],c[1]),this._displayExtLines=!1;else{const e=S([c[0]-g[0],c[1]-g[1]]),o=n(P);o>=-1&&o<=1?P+=t(1):o>=179&&o<=181&&(P-=t(1));const r=L(x,e,c,e+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=s(_(),x[0],x[1]),this._endDimensionPoint=s(_(),r[0],r[1])}this._dimensionDirection=r(_(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionLength=h(this._dimensionDirection),this._dimensionDirection=l(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=D(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:t,endMarkerSymbol:n}=this._dimensionStyle,e=this._measureMarkerSymbolSize(t,this._beginDimensionPoint,this._dimensionAngleRad,i),s=this._measureMarkerSymbolSize(n,this._endDimensionPoint,this._dimensionAngleRad+Math.PI,i),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((e?.width??0)/2),h=i*((s?.width??0)/2);if(e&&this._beginDimensionPoint&&(e.x+=this._beginDimensionPoint[0],e.y+=this._beginDimensionPoint[1]),s&&this._endDimensionPoint&&(s.x+=this._endDimensionPoint[0],s.y+=this._endDimensionPoint[1]),this._beginMarkerRect=e,this._endMarkerRect=s,this._doMarkersFit=this._checkMarkerFit(e,s,o,i),this._doMarkersFit){const i=D(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=D(this._beginDimensionPoint,this._endDimensionPoint,-4*r),t=D(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[t,this._endDimensionPoint]]}}_checkMarkerFit(i,t,n,e){if(!i||!t)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;if("Tolerance"===s)r*e>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?B(i,t)&&(h=!1):(B(i,t)&&(h=!1),h&&n&&(B(n,i)||B(n,t))&&(h=!1))}return h}_measureDimensionText(i,t,n){if(null==this._textString||null==t||null==this._mosaicItems)return null;const e=[];for(const g of i)g.codePointAt(0),e.push(this._mosaicItems.glyphs[g.codePointAt(0)]);const s=this._dimensionStyle.textSymbol;if(!s)return null;const o=g(s.horizontalAlignment),r=c(s.verticalAlignment),h=x(s),l=M(s.height||10);this._textSize=l;const m=!0,_=s.angle||0,a=l/b,d=E(s.lineWidth),u=f*Math.max(.25,Math.min(l||1,4)),P={...this._mosaicItems,glyphs:e.filter(i=>null!=i)},D=y(P,{scale:a,angle:_,xOffset:0,yOffset:0,horizontalAlignment:o,verticalAlignment:r,decoration:h,lineHeight:u,useCIMAngleBehavior:m,maxLineWidth:d,hasBackground:!1}),S=t;if(!S)return null;const L=n,T=[D.bounds.blX,D.bounds.trY],w=[D.bounds.trX,D.bounds.trY],k=[D.bounds.blX,D.bounds.blY],N=[D.bounds.trX,D.bounds.blY];return T[0]-=D.bounds.x,T[1]-=D.bounds.y,w[0]-=D.bounds.x,w[1]-=D.bounds.y,k[0]-=D.bounds.x,k[1]-=D.bounds.y,N[0]-=D.bounds.x,N[1]-=D.bounds.y,T[0]*=L,T[1]*=L,w[0]*=L,w[1]*=L,k[0]*=L,k[1]*=L,N[0]*=L,N[1]*=L,T[0]+=S[0],T[1]+=S[1],w[0]+=S[0],w[1]+=S[1],k[0]+=S[0],k[1]+=S[1],N[0]+=S[0],N[1]+=S[1],new p(w[0],w[1],1.1*Math.abs(T[0]-w[0]),1.1*Math.abs(N[1]-w[1]))}_measureMarkerSymbolSize(i,t,n,e){return i?new p(-16,-16,32,32):null}_getDimensionText(i){const{attributes:t}=i;let n=null;const e=1===Number(w(T.useCustomLength,t));n=Number(w(e?T.customLength:T.dimLength,t)),(0===n||isNaN(n)||null==n)&&(n=this._systemLength);let s=this._getDimensionString(n,i);return"number"==typeof s&&(s=s.toString()),t.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,t){const{convertUnits:n,displayUnits:e,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&t)return P(this._compiledExpression,t,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function N(i){const{attributes:t}=i,n=Object.keys(T).map(i=>({name:i,alias:i,type:"string"==typeof t[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new d(n)}function R(i){return{left:i.x,right:i.x+i.width,top:i.y+i.height,bottom:i.y}}function B(i,t){const n=R(i),e=R(t),s=n.left<=e.right&&e.left<=n.right,o=n.bottom<=e.top&&e.bottom<=n.top;return s&&o}export{k as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{fixCIMUnsupported as e}from"./unsupported.js";import{featureFields as t}from"./virtualFields.js";function o(o,r){let i,n;o=e(o);let l=[];"line"===r?(i="CIMLineSymbol",n={type:"CIMMarkerPlacementOnLine",angleToLine:!0,offset:5,placePerPart:!1,relativeTo:"LineMiddle",startPointOffset:0,keepUpright:!1},l=t.filter(e=>"Rotation"!==e.cimPropertyName)):"multipoint"===r?(i="CIMLineSymbol",n={type:"PrivatePlacementMultipoint"},l=t):(i="CIMPointSymbol",n=void 0,l=t);const a={type:"CIMSymbolReference",primitiveOverrides:[],symbol:{type:i,symbolLayers:[{type:"CIMVectorMarker",markerPlacement:n,enable:!0,size:40,colorLocked:!1,anchorPointUnits:"Relative",frame:{xmin:-20,ymin:-20,xmax:20,ymax:20},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:o}],scaleSymbolsProportionally:!0,respectFrame:!0}]}};for(const e of l)e.addToSymbol(a);return{data:a}}function r(e){return{point:o(e,"point"),line:o(e,"line"),multipoint:o(e,"multipoint")}}function i(e){const t={};for(const o of e){const e=o.iD??0,{symbol:i}=o,n=r(i);t[e]=n}return t}export{o as getCIMSymbol,i as getCIMSymbols,r as getTrio};
2
+ import{fixCIMUnsupported as e}from"./unsupported.js";import{featureFields as t}from"./virtualFields.js";function o(o,i){let r,n;o=e(o),o={...o,verticalAlignment:"Baseline",horizontalAlignment:"Center"};let l=[];"line"===i?(r="CIMLineSymbol",n={type:"CIMMarkerPlacementOnLine",angleToLine:!0,offset:5,placePerPart:!1,relativeTo:"LineMiddle",startPointOffset:0,keepUpright:!1},l=t.filter(e=>"Rotation"!==e.cimPropertyName)):"multipoint"===i?(r="CIMLineSymbol",n={type:"PrivatePlacementMultipoint"},l=t):(r="CIMPointSymbol",n=void 0,l=t);const a={type:"CIMSymbolReference",primitiveOverrides:[],symbol:{type:r,symbolLayers:[{type:"CIMVectorMarker",markerPlacement:n,enable:!0,size:40,colorLocked:!1,anchorPointUnits:"Relative",frame:{xmin:-20,ymin:-20,xmax:20,ymax:20},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:o}],scaleSymbolsProportionally:!0,respectFrame:!0}]}};for(const e of l)e.addToSymbol(a);return{data:a}}function i(e){return{point:o(e,"point"),line:o(e,"line"),multipoint:o(e,"multipoint")}}function r(e){const t={};for(const o of e){const e=o.iD??0,{symbol:r}=o,n=i(r);t[e]=n}return t}export{o as getCIMSymbol,r as getCIMSymbols,i as getTrio};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{when as a,watch as s,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{create as l,fromPoints as h}from"../../../../geometry/support/lineSegment.js";import{LineOfSightAggregateManipulatedObject3D as p}from"./LineOfSightAggregateManipulatedObject3D.js";import{LineOfSightInteractionVisuals as u}from"./LineOfSightInteractionVisuals.js";import{ReshapeTool3D as c}from"../../interactive/editingTools/reshape/ReshapeTool3D.js";import g from"../../../interactive/sketch/SketchOptions.js";import{acquire as d}from"../../../interactive/snapping/SnappingManagerPool.js";const _=Symbol("line-of-sight-reshape-laser-line-manipulators"),v=Symbol("line-of-sight-reshape-tool-operations"),b=l();let M=class extends t{constructor(e){super(e),this.visible=!0,this._editing=!1,this._grabbedManipulator=null,this._interactionVisuals=null,this._snappingManagerResult=d(e.view),this._object=new p({analysis:e.analysis,analysisViewData:e.analysisViewData,intersector:e.intersector,view:e.view}),this._reshapeTool=new c({autoHideManipulators:!1,enableDeleteVertices:!0,enableEdgeOffset:!1,enableMidpoints:!1,enableMoveObject:!1,object:this._object,sketchOptions:new g({tooltips:{enabled:!0}}),snappingManager:this._snappingManagerResult.snappingManager,view:e.view})}initialize(){this.view.tools.add(this._reshapeTool),this._interactionVisuals=new u({view:this.view}),this.addHandles([this._snappingManagerResult,this._reshapeTool.events.on("manipulators-changed",()=>{this._syncLaserLineManipulatorHandles(),this._updateLaserLineRenderer()}),this._reshapeTool.events.on("reshape",e=>{"reshape-start"===e.type?this._editing=!0:"reshape-stop"===e.type&&(this._editing=!1,this._grabbedManipulator=null),this._updateLaserLineRenderer()}),this._reshapeTool.events.on("move",e=>{"move-start"===e.type?this._editing=!0:"move-stop"===e.type&&(this._editing=!1,this._grabbedManipulator=null),this._updateLaserLineRenderer()}),this._reshapeTool.events.on("before-vertex-remove",e=>{let t=this.analysis.targets.length;for(const i of e.vertices){if(0===i.componentIndex)return void e.preventDefault();if(t-=1,0===t)return void e.preventDefault()}}),a(()=>!this.active,()=>{this._cleanupAfterDeactivate()}),s(()=>({active:this.active,analysisVisible:this.analysisViewData.visible,targetCount:this.analysis.targets.length,visible:this.visible}),()=>{this._syncLaserLineManipulatorHandles(),this._updateLaserLineRenderer()},n),s(()=>this._object.operations,e=>{this.removeHandles(v),null!=e&&this.addHandles([e.on("can-redo-change",()=>this.notifyChange("canRedo")),e.on("can-undo-change",()=>this.notifyChange("canUndo"))],v),this.notifyChange("canUndo"),this.notifyChange("canRedo")},n)])}destroy(){this.stop(),this.removeHandles(_),this.view.tools.remove(this._reshapeTool),this._reshapeTool.destroy(),this._object.destroy(),this._interactionVisuals=i(this._interactionVisuals)}get active(){return this._reshapeTool.active}get canRedo(){return this._reshapeTool.canRedo}get canUndo(){return this._reshapeTool.canUndo}get updating(){return this._reshapeTool.updating}get snappingManager(){return this.active?this._reshapeTool.snappingManager:null}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}activate(){this._reshapeTool.visible=this.visible,this.view.activeTool!==this._reshapeTool&&(this.view.activeTool=this._reshapeTool),this._reshapeTool.activate()}getTargetManipulator(e){return this._object.getTargetManipulator(e)}getObserverManipulator(){return this._object.getObserverManipulator()}hasManipulatorAt(e,t){if(f(this._object.getObserverManipulator(),e,t))return!0;for(const i of this.analysis.targets)if(f(this._object.getTargetManipulator(i),e,t))return!0;return!1}redo(){this._reshapeTool.redo()}clearSelection(){this._reshapeTool.clearSelection()}applySelection(e){const t="observer"===e.type?this._object.getObserverManipulator():this._object.getTargetManipulator(e.target);return null!=t&&this._reshapeTool.selectManipulator(t)}setEditableFlag(e,t){this._reshapeTool.setEditableFlag(e,t)}stop(){this.view.activeTool===this._reshapeTool&&(this.view.activeTool=null),this._editing=!1,this._grabbedManipulator=null,this._hideLaserLine()}suspend(){this.clearSelection(),this.snappingManager?.doneSnapping(),this.stop()}undo(){this._reshapeTool.undo()}_cleanupAfterDeactivate(){this._editing=!1,this._grabbedManipulator=null,this._reshapeTool.snappingManager?.doneSnapping(),this._hideLaserLine()}_updateLaserLineRenderer(){const e=this._object.getObserverManipulator(),t=this._getLaserLineManipulator();null!=this._interactionVisuals&&this.active&&this.visible&&this.analysisViewData.visible&&null!=e&&null!=t?this._interactionVisuals.update({target:t.renderLocation,lineVerticalPlaneSegment:t===e?null:h(e.renderLocation,t.renderLocation,b),visible:!0}):this._hideLaserLine()}_hideLaserLine(){this._interactionVisuals?.hide()}_getLaserLineManipulator(){const e=this._grabbedManipulator;if(this._editing){const e=this._getSelectedManipulator();if(null!=e)return e}if(null!=e?.view)return e;for(const i of this.analysis.targets){const e=this._object.getTargetManipulator(i);if(y(e))return e}const t=this._object.getObserverManipulator();return y(t)?t:null}_getSelectedManipulator(){let e=null;for(const t of this._getLaserLineManipulators())if(t.selected){if(null!=e)return null;e=t}return e}_syncLaserLineManipulatorHandles(){this.removeHandles(_);const e=this._getLaserLineManipulators();null==this._grabbedManipulator||e.includes(this._grabbedManipulator)||(this._grabbedManipulator=null),this.addHandles(e.flatMap(e=>[e.events.on("grab-changed",t=>{"start"===t.action?this._grabbedManipulator=e:this._grabbedManipulator===e&&(this._grabbedManipulator=null),this._updateLaserLineRenderer()}),e.events.on("location-update",()=>this._updateLaserLineRenderer())]),_)}_getLaserLineManipulators(){return[this._object.getObserverManipulator(),...this.analysis.targets.toArray().map(e=>this._object.getTargetManipulator(e))].filter(e=>null!=e)}};function f(e,t,i){return!0===e?.interactive&&e.consumesClicks&&null!=e.intersectionDistance(t,i)}function y(e){return null!=e&&e.grabbing}e([r({constructOnly:!0})],M.prototype,"analysisViewData",void 0),e([r({constructOnly:!0})],M.prototype,"analysis",void 0),e([r({constructOnly:!0})],M.prototype,"intersector",void 0),e([r({constructOnly:!0})],M.prototype,"view",void 0),e([r()],M.prototype,"visible",void 0),e([r()],M.prototype,"active",null),e([r()],M.prototype,"canRedo",null),e([r()],M.prototype,"canUndo",null),e([r()],M.prototype,"updating",null),M=e([o("esri.views.3d.analysis.LineOfSight.LineOfSightReshapeTool3D")],M);export{M as LineOfSightReshapeTool3D};
2
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{when as s,watch as a,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{create as l,fromPoints as h}from"../../../../geometry/support/lineSegment.js";import{LineOfSightAggregateManipulatedObject3D as p}from"./LineOfSightAggregateManipulatedObject3D.js";import{LineOfSightInteractionVisuals as u}from"./LineOfSightInteractionVisuals.js";import{ReshapeTool3D as c}from"../../interactive/editingTools/reshape/ReshapeTool3D.js";import g from"../../../interactive/sketch/SketchOptions.js";import{acquire as d}from"../../../interactive/snapping/SnappingManagerPool.js";const _=Symbol("line-of-sight-reshape-line-of-sight-manipulators"),v=Symbol("line-of-sight-reshape-tool-operations"),b=l();let f=class extends t{constructor(e){super(e),this.visible=!0,this._editing=!1,this._grabbedManipulator=null,this._interactionVisuals=null,this._snappingManagerResult=d(e.view),this._object=new p({analysis:e.analysis,analysisViewData:e.analysisViewData,intersector:e.intersector,view:e.view}),this._reshapeTool=new c({autoHideManipulators:!1,enableDeleteVertices:!0,enableEdgeOffset:!1,enableMidpoints:!1,enableMoveObject:!1,object:this._object,snapToScene:!0,sketchOptions:new g({tooltips:{enabled:!0}}),snappingManager:this._snappingManagerResult.snappingManager,view:e.view})}initialize(){this.view.tools.add(this._reshapeTool),this._interactionVisuals=new u({view:this.view}),this.addHandles([this._snappingManagerResult,this._reshapeTool.events.on("manipulators-changed",()=>{this._syncLineOfSightManipulatorHandles(),this._updateLaserLineRenderer()}),this._reshapeTool.on("cancel",()=>this.clearSelection()),this._reshapeTool.events.on("reshape",e=>{"reshape-start"===e.type?this._editing=!0:"reshape-stop"===e.type&&(this._editing=!1,this._grabbedManipulator=null),this._updateLaserLineRenderer()}),this._reshapeTool.events.on("move",e=>{"move-start"===e.type?this._editing=!0:"move-stop"===e.type&&(this._editing=!1,this._grabbedManipulator=null),this._updateLaserLineRenderer()}),this._reshapeTool.events.on("before-vertex-remove",e=>{let t=this.analysis.targets.length;for(const i of e.vertices){if(0===i.componentIndex)return void e.preventDefault();if(t-=1,0===t)return void e.preventDefault()}}),s(()=>!this.active,()=>{this._cleanupAfterDeactivate()}),a(()=>({active:this.active,analysisVisible:this.analysisViewData.visible,targetCount:this.analysis.targets.length,visible:this.visible}),()=>{this._syncLineOfSightManipulatorHandles(),this._updateLaserLineRenderer()},n),a(()=>this._object.operations,e=>{this.removeHandles(v),null!=e&&this.addHandles([e.on("can-redo-change",()=>this.notifyChange("canRedo")),e.on("can-undo-change",()=>this.notifyChange("canUndo"))],v),this.notifyChange("canUndo"),this.notifyChange("canRedo")},n)])}destroy(){this.stop(),this.removeHandles(_),this.view.tools.remove(this._reshapeTool),this._reshapeTool.destroy(),this._object.destroy(),this._interactionVisuals=i(this._interactionVisuals)}get active(){return this._reshapeTool.active}get canRedo(){return this._reshapeTool.canRedo}get canUndo(){return this._reshapeTool.canUndo}get updating(){return this._reshapeTool.updating}get snappingManager(){return this.active?this._reshapeTool.snappingManager:null}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}activate(){this._reshapeTool.visible=this.visible,this.view.activeTool!==this._reshapeTool&&(this.view.activeTool=this._reshapeTool),this._reshapeTool.activate()}getTargetManipulator(e){return this._object.getTargetManipulator(e)}getObserverManipulator(){return this._object.getObserverManipulator()}hasManipulatorAt(e,t){if(M(this._object.getObserverManipulator(),e,t))return!0;for(const i of this.analysis.targets)if(M(this._object.getTargetManipulator(i),e,t))return!0;return!1}redo(){this._reshapeTool.redo()}clearSelection(){this._reshapeTool.clearSelection()}hasSelection(){return this._getLineOfSightManipulators().some(e=>e.selected)}applySelection(e){const t="observer"===e.type?this._object.getObserverManipulator():this._object.getTargetManipulator(e.target);return null!=t&&this._reshapeTool.selectManipulator(t)}setEditableFlag(e,t){this._reshapeTool.setEditableFlag(e,t)}stop(){this.view.activeTool===this._reshapeTool&&(this.view.activeTool=null),this._editing=!1,this._grabbedManipulator=null,this._hideLaserLine()}suspend(){this.clearSelection(),this.snappingManager?.doneSnapping(),this.stop()}undo(){this._reshapeTool.undo()}_cleanupAfterDeactivate(){this._editing=!1,this._grabbedManipulator=null,this._reshapeTool.snappingManager?.doneSnapping(),this._hideLaserLine()}_updateLaserLineRenderer(){const e=this._object.getObserverManipulator(),t=this._getLaserLineTargetManipulator();null!=this._interactionVisuals&&this.active&&this.visible&&this.analysisViewData.visible&&null!=e&&null!=t?this._interactionVisuals.update({target:t.renderLocation,lineVerticalPlaneSegment:t===e?null:h(e.renderLocation,t.renderLocation,b),visible:!0}):this._hideLaserLine()}_hideLaserLine(){this._interactionVisuals?.hide()}_getLaserLineTargetManipulator(){const e=this._grabbedManipulator;if(this._editing){const e=this._getSelectedManipulator();if(null!=e)return e}if(null!=e?.view)return e;for(const i of this.analysis.targets){const e=this._object.getTargetManipulator(i);if(y(e))return e}const t=this._object.getObserverManipulator();return y(t)?t:null}_getSelectedManipulator(){let e=null;for(const t of this._getLineOfSightManipulators())if(t.selected){if(null!=e)return null;e=t}return e}_syncLineOfSightManipulatorHandles(){this.removeHandles(_);const e=this._getLineOfSightManipulators();null==this._grabbedManipulator||e.includes(this._grabbedManipulator)||(this._grabbedManipulator=null),this.addHandles(e.flatMap(e=>[e.events.on("grab-changed",t=>{"start"===t.action?this._grabbedManipulator=e:this._grabbedManipulator===e&&(this._grabbedManipulator=null),this._updateLaserLineRenderer()}),e.events.on("location-update",()=>this._updateLaserLineRenderer())]),_)}_getLineOfSightManipulators(){return[this._object.getObserverManipulator(),...this.analysis.targets.toArray().map(e=>this._object.getTargetManipulator(e))].filter(e=>null!=e)}};function M(e,t,i){return!0===e?.interactive&&e.consumesClicks&&null!=e.intersectionDistance(t,i)}function y(e){return null!=e&&e.grabbing}e([r({constructOnly:!0})],f.prototype,"analysisViewData",void 0),e([r({constructOnly:!0})],f.prototype,"analysis",void 0),e([r({constructOnly:!0})],f.prototype,"intersector",void 0),e([r({constructOnly:!0})],f.prototype,"view",void 0),e([r()],f.prototype,"visible",void 0),e([r()],f.prototype,"active",null),e([r()],f.prototype,"canRedo",null),e([r()],f.prototype,"canUndo",null),e([r()],f.prototype,"updating",null),f=e([o("esri.views.3d.analysis.LineOfSight.LineOfSightReshapeTool3D")],f);export{f as LineOfSightReshapeTool3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{makeHandle as e}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{watch as i,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{LineOfSightPlacementController as n}from"./LineOfSightPlacementController.js";import{LineOfSightRayIntersector as r}from"./LineOfSightRayIntersector.js";import{LineOfSightReshapeTool3D as l}from"./LineOfSightReshapeTool3D.js";import{ExclusiveOperationManager as h}from"../../../analysis/ExclusiveOperationManager.js";import{ViewEventPriorities as c}from"../../../input/InputManager.js";import{AnalysisToolBase as p}from"../../../interactive/AnalysisToolBase.js";import{deactivevateTool as v}from"../../../interactive/interactiveToolUtils.js";import{sketchKeys as d}from"../../../interactive/keybindings.js";const y={ready:"ready",creating:"creating",created:"created"};let _=class extends p{constructor(t){super(t),this._operationManager=new h,this._syncingActiveTool=!1,this.analysisViewData=null,this.removeIncompleteOnCancel=!1,this._reshapeIntersector=new r({view:t.view}),this._reshapeTool=new l({analysis:t.analysis,analysisViewData:t.analysisViewData,intersector:this._reshapeIntersector,view:t.view}),this._placementController=new n({...t,parent:this,shouldPreventVertexAdd:(t,e)=>this._reshapeTool.hasManipulatorAt(t,e)})}get active(){return this._reshapeTool.active||this._placementController.active}get canRedo(){return this._activeUndoRedoComponent?.canRedo??!1}get canUndo(){return this._activeUndoRedoComponent?.canUndo??!1}get state(){return this._placementController.active?y.creating:null!=this.analysis.observer?.position?y.created:y.ready}get cursor(){return this._placementController.active?"crosshair":null}get updating(){return this._reshapeTool.updating||this._placementController.updating}initialize(){this.addHandles([this.view.on("key-down",t=>this._onKeyDown(t),c.WIDGET),i(()=>({editable:this.editable,interactive:this.analysisViewData.interactive,placementActive:this._placementController.active,valid:this.analysis.valid,visible:this.visible}),()=>this._syncActiveTool(),s),i(()=>this.state===y.created,t=>{t?this.finishToolCreation():this._set("created",!1)},s),i(()=>this.analysisViewData.visible,t=>{this.visible=t},s),i(()=>{const{analysis:t}=this,{observer:e,targets:i}=t;return{observer:e,observerPosition:e?.position,observerElevationInfo:e?.elevationInfo,observerFeature:e?.feature,targets:i.toArray().map(t=>[t,t.position,t.elevationInfo,t.feature])}},()=>this._syncItemsFromAnalysis(),s),i(()=>this.editable,t=>{this.analysisViewData.editable=t},s)])}destroy(){this._operationManager.destroy(),this._reshapeTool.stop(),this._placementController.stop(),this._reshapeTool.destroy(),this._placementController.destroy(),this._reshapeIntersector.destroy()}place(t){return this.analysisViewData.interactive=!0,this._operationManager.start("place",async(t,o)=>{const a=this.analysis.clone();let n=!1,r=!1;const l=()=>{r||(r=!0,this.stop(),o.aborted||!this.analysis.valid||this.analysis.equals(a)?t.reject():t.resolve({}))};t.handles.push(e(()=>this.stop()),i(()=>this._placementController.active,t=>{t?n=!0:n&&l()},s)),this.continue()},t)}activate(){this.view.focus(),this.analysisViewData.interactive=!0,this._syncActiveTool(),this.analysis.valid||this._placementController.active||this.continue()}deactivate(){this.onDeactivate()}continue(){this.analysisViewData.interactive=!0,this._placementController.continue()}stop(){this._placementController.stop(),this._placementController.placementElevationInfo=null,this._syncActiveTool()}redo(){this._activeUndoRedoComponent?.redo()}undo(){this._activeUndoRedoComponent?.undo()}get testInfo(){}onEditableChange(){this.analysisViewData.editable=this.editable,this._reshapeTool.setEditableFlag(1,!0),this._reshapeTool.setEditableFlag(0,this.editable),this._syncActiveTool()}_hideReshapeTool(){this._reshapeTool.suspend(),this._reshapeTool.visible=!1}_onKeyDown(t){const e=t.key;e===d.undo&&this.canUndo?(t.stopPropagation(),this.undo()):e===d.redo&&this.canRedo&&(t.stopPropagation(),this.redo())}get _activeUndoRedoComponent(){return this.analysisViewData.interactive?this._placementController.active||!this._canActivateReshapeTool?this._placementController.active?this._placementController:null:this._reshapeTool:null}get _canActivateReshapeTool(){return this.visible&&this.editable&&this.analysis.valid&&null!=this.analysis.observer?.position}_syncActiveTool(){if(!this._syncingActiveTool){this._syncingActiveTool=!0;try{const t=this.analysisViewData.interactive,e=this._canActivateReshapeTool;if(this._placementController.visible=this.visible&&t,!t)return this._placementController.stop(),this._hideReshapeTool(),this.analysisViewData.cursorTarget=null,void v(this.view,this);if(this._placementController.active||!e)return this._hideReshapeTool(),void v(this.view,this);if(this._reshapeTool.visible=!0,this.analysisViewData.cursorTarget=null,!this._reshapeTool.active){const t=this.analysis.targets.at(-1);null!=t&&this._reshapeTool.applySelection({type:"target",target:t})}v(this.view,this)}finally{this._syncingActiveTool=!1}}}_syncItemsFromAnalysis(){this._syncActiveTool()}};t([o({constructOnly:!0})],_.prototype,"view",void 0),t([o({constructOnly:!0})],_.prototype,"analysis",void 0),t([o({constructOnly:!0})],_.prototype,"analysisViewData",void 0),t([o()],_.prototype,"active",null),t([o()],_.prototype,"canRedo",null),t([o()],_.prototype,"canUndo",null),t([o()],_.prototype,"state",null),t([o()],_.prototype,"cursor",null),t([o()],_.prototype,"updating",null),t([o()],_.prototype,"removeIncompleteOnCancel",void 0),t([o()],_.prototype,"_canActivateReshapeTool",null),_=t([a("esri.views.3d.analysis.LineOfSight.LineOfSightTool2")],_);export{_ as LineOfSightTool2};
2
+ import{__decorate as t}from"tslib";import{makeHandle as e}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{watch as i,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{LineOfSightPlacementController as n}from"./LineOfSightPlacementController.js";import{LineOfSightRayIntersector as r}from"./LineOfSightRayIntersector.js";import{LineOfSightReshapeTool3D as l}from"./LineOfSightReshapeTool3D.js";import{ExclusiveOperationManager as h}from"../../../analysis/ExclusiveOperationManager.js";import{ViewEventPriorities as c}from"../../../input/InputManager.js";import{AnalysisToolBase as p}from"../../../interactive/AnalysisToolBase.js";import{deactivevateTool as v}from"../../../interactive/interactiveToolUtils.js";import{sketchKeys as d}from"../../../interactive/keybindings.js";const y={ready:"ready",creating:"creating",created:"created"};let _=class extends p{constructor(t){super(t),this._operationManager=new h,this._syncingActiveTool=!1,this.analysisViewData=null,this.removeIncompleteOnCancel=!1,this._reshapeIntersector=new r({view:t.view}),this._reshapeTool=new l({analysis:t.analysis,analysisViewData:t.analysisViewData,intersector:this._reshapeIntersector,view:t.view}),this._placementController=new n({...t,parent:this,shouldPreventVertexAdd:(t,e)=>this._reshapeTool.hasManipulatorAt(t,e)})}get active(){return this._reshapeTool.active||this._placementController.active}get canRedo(){return this._activeUndoRedoComponent?.canRedo??!1}get canUndo(){return this._activeUndoRedoComponent?.canUndo??!1}get state(){return this._placementController.active?y.creating:null!=this.analysis.observer?.position?y.created:y.ready}get cursor(){return this._placementController.active?"crosshair":null}get updating(){return this._reshapeTool.updating||this._placementController.updating}initialize(){this.addHandles([this.view.on("key-down",t=>this._onKeyDown(t),c.WIDGET),i(()=>({editable:this.editable,interactive:this.analysisViewData.interactive,placementActive:this._placementController.active,valid:this.analysis.valid,visible:this.visible}),()=>this._syncActiveTool(),s),i(()=>this.state===y.created,t=>{t?this.finishToolCreation():this._set("created",!1)},s),i(()=>this.analysisViewData.visible,t=>{this.visible=t},s),i(()=>{const{analysis:t}=this,{observer:e,targets:i}=t;return{observer:e,observerPosition:e?.position,observerElevationInfo:e?.elevationInfo,observerFeature:e?.feature,targets:i.toArray().map(t=>[t,t.position,t.elevationInfo,t.feature])}},()=>this._syncItemsFromAnalysis(),s),i(()=>this.editable,t=>{this.analysisViewData.editable=t},s)])}destroy(){this._operationManager.destroy(),this._reshapeTool.stop(),this._placementController.stop(),this._reshapeTool.destroy(),this._placementController.destroy(),this._reshapeIntersector.destroy()}place(t){return this.analysisViewData.interactive=!0,this._operationManager.start("place",async(t,o)=>{const a=this.analysis.clone();let n=!1,r=!1;const l=()=>{r||(r=!0,this.stop(),o.aborted||!this.analysis.valid||this.analysis.equals(a)?t.reject():t.resolve({}))};t.handles.push(e(()=>this.stop()),i(()=>this._placementController.active,t=>{t?n=!0:n&&l()},s)),this.continue()},t)}activate(){this.view.focus(),this.analysisViewData.interactive=!0,this._syncActiveTool(),this.analysis.valid||this._placementController.active||this.continue()}deactivate(){this.onDeactivate()}continue(){this.analysisViewData.interactive=!0,this._placementController.continue()}stop(){this._placementController.stop(),this._placementController.placementElevationInfo=null,this._syncActiveTool()}redo(){this._activeUndoRedoComponent?.redo()}undo(){this._activeUndoRedoComponent?.undo()}get testInfo(){}onEditableChange(){this.analysisViewData.editable=this.editable,this._reshapeTool.setEditableFlag(1,!0),this._reshapeTool.setEditableFlag(0,this.editable),this._syncActiveTool()}_hideReshapeTool(){this._reshapeTool.suspend(),this._reshapeTool.visible=!1}_onKeyDown(t){const e=t.key;e===d.undo&&this.canUndo?(t.stopPropagation(),this.undo()):e===d.redo&&this.canRedo?(t.stopPropagation(),this.redo()):e===d.cancel&&!this.active&&this._reshapeTool.hasSelection()&&this._reshapeTool.clearSelection()}get _activeUndoRedoComponent(){return this.analysisViewData.interactive?this._placementController.active||!this._canActivateReshapeTool?this._placementController.active?this._placementController:null:this._reshapeTool:null}get _canActivateReshapeTool(){return this.visible&&this.editable&&this.analysis.valid&&null!=this.analysis.observer?.position}_syncActiveTool(){if(!this._syncingActiveTool){this._syncingActiveTool=!0;try{const t=this.analysisViewData.interactive,e=this._canActivateReshapeTool;if(this._placementController.visible=this.visible&&t,!t)return this._placementController.stop(),this._hideReshapeTool(),this.analysisViewData.cursorTarget=null,void v(this.view,this);if(this._placementController.active||!e)return this._hideReshapeTool(),void v(this.view,this);if(this._reshapeTool.visible=!0,this.analysisViewData.cursorTarget=null,!this._reshapeTool.active&&!this._reshapeTool.hasSelection()){const t=this.analysis.targets.at(-1);null!=t&&this._reshapeTool.applySelection({type:"target",target:t})}v(this.view,this)}finally{this._syncingActiveTool=!1}}}_syncItemsFromAnalysis(){this._syncActiveTool()}};t([o({constructOnly:!0})],_.prototype,"view",void 0),t([o({constructOnly:!0})],_.prototype,"analysis",void 0),t([o({constructOnly:!0})],_.prototype,"analysisViewData",void 0),t([o()],_.prototype,"active",null),t([o()],_.prototype,"canRedo",null),t([o()],_.prototype,"canUndo",null),t([o()],_.prototype,"state",null),t([o()],_.prototype,"cursor",null),t([o()],_.prototype,"updating",null),t([o()],_.prototype,"removeIncompleteOnCancel",void 0),t([o()],_.prototype,"_canActivateReshapeTool",null),_=t([a("esri.views.3d.analysis.LineOfSight.LineOfSightTool2")],_);export{_ as LineOfSightTool2};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t,equals as i}from"../../../core/arrayUtils.js";import{createTask as s}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{abortMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{after as l,throwIfAborted as u,isPromiseLike as c}from"../../../core/promiseUtils.js";import{watch as p,syncAndInitial as d}from"../../../core/reactiveUtils.js";import{createScreenPointArray as h,createRenderScreenPointArray as m}from"../../../core/screenUtils.js";import{convertTime as g,offsetDateUTC as y}from"../../../core/timeUtils.js";import{property as _,subclass as f}from"../../../core/accessorSupport/decorators.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as D}from"../../../core/support/UpdatingHandles.js";import{projectAsync as C}from"../../../geometry/projectionUtils.js";import{e as b}from"../../../chunks/containsOperator.js";import{g as S}from"../../../chunks/boundedPlane.js";import{polygonToVolume as V}from"../focusAreaUtils.js";import T from"./AnalysisView3D.js";import{registerAnalysisView as U,hideOtherAnalysisViews as P}from"./ShadowCast/analysisViewRegister.js";import{ShadowCastTooltip as O}from"./ShadowCast/ShadowCastTooltip.js";import{ElevationContext as x}from"../layers/graphics/ElevationContext.js";import{longitudeToTimezone as j}from"../support/earthUtils.js";import{computeDirectionsOverTime as z}from"../support/sunUtils.js";import{maxColorRampSize as A}from"../webgl-engine/shaders/colorRampParameters.js";import{breadthFirstBinaryPartitioning as R}from"../../../widgets/support/traversalUtils.js";let k=class extends T{constructor(e){super(e),this.type="shadow-cast-view-3d",this.analysis=null,this._updatingHandles=new D,this._stopPreviewingTask=null,this._updatedRecently=!1,this._tooltip=null,this._previousVolume=null}initialize(){this.addHandles([U(this.view,this),p(()=>({dependencies:this._previewDependencies,sceneUpdating:this._sceneUpdating}),()=>{a(this._stopPreviewingTask),this._updatedRecently=!0,this._stopPreviewingTask=s(async e=>{await l(G,e),u(e),this._updatedRecently=!1})},{sync:!0,initial:!0,equals:(e,t)=>I(e.dependencies,t.dependencies)&&(e.sceneUpdating===t.sceneUpdating||!e.sceneUpdating)}),p(()=>({renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t})=>{t&&P(this.view,this),e?.setParameters({shadowCast:{enabled:t}})},d),p(()=>({renderer:this._renderer,parameters:this._visualizationParameters,visible:this.visible}),({renderer:e,parameters:t,visible:i})=>{E(e,i,t)},d),p(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext,visible:this.visible}),({renderer:e,lightDirections:t,lightDirectionsContext:i,visible:s})=>{E(e,s,{lightDirections:t,lightDirectionsContext:i})},d),p(()=>({renderer:this._renderer,previewing:this._previewing,visible:this.visible}),({renderer:e,previewing:t,visible:i})=>{E(e,i,{previewing:t})},d),p(()=>({analysisVolume:this._analysisVolume,renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t,analysisVolume:i})=>{E(e,t,{analysisVolume:i})},d)]),this.interactive=!0,this._tooltip=new O({getDuration:(e,t)=>this._getDurationAtScreen(e,t),getMode:()=>this.analysis.mode,getShowsSeparateZeroBucketInHourlyMode:()=>this._showsSeparateZeroBucketInHourlyMode,getTotalDuration:()=>this._totalDuration,getTotalDurationMode:()=>this.analysis.totalDurationOptions.mode,getVisualizeSunlight:()=>this.analysis.visualizeSunlight,isVisible:()=>this.interactive&&this.visible,view:this.view})}destroy(){this.visible&&E(this._renderer,!0,{enabled:!1}),this._tooltip=o(this._tooltip),this._stopPreviewingTask=a(this._stopPreviewingTask),this._updatingHandles=o(this._updatingHandles)}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return this._previewing||null!=this._stopPreviewingTask&&!this._stopPreviewingTask.finished||!0===this._tooltip?.updating||this._updatingHandles.updating}get visible(){return super.visible}set visible(e){super.visible=e}get _previewing(){return this._updatedRecently||this._sceneUpdating}get _sceneUpdating(){const{view:e}=this;if(null==e?.allLayerViews)return!0;const{stationary:t,graphicsView:i}=e;return!t||this._shadowLayerViews.some(e=>e.updating)||!i?.suspended&&!!i?.updating}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?j(e[0],!1):0}get _dateUTCOffset(){let e=this.analysis.date;return e=y(e,-e.getTimezoneOffset(),"minutes"),e=y(e,-this._effectiveUtcOffset,"hours"),e}get _startDateTimeUTC(){return y(this._dateUTCOffset,this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return y(this._dateUTCOffset,this.analysis.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _totalDurationInterval(){return this._totalDuration>0?Math.floor(this._totalDuration/(Z-1)):Z}get _interval(){const e=this._totalDurationInterval;switch(this.analysis.mode){case"min-duration":return this._totalDuration>0?e:0;case"total-duration":return e;case"discrete":return this.analysis.discreteOptions.interval||e}}get _intervalContext(){const{mode:e,minDurationOptions:t}=this.analysis;return"min-duration"===e&&t.contextEnabled?t.contextOptions.interval||this._totalDurationInterval:-1}get _totalDurationSampleCount(){return this._lightDirections.length}get _totalDuration(){const{startTimeOfDay:e,endTimeOfDay:t}=this.analysis;return t-e}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(e<=0)return[];const i="global"===t.viewingMode?q:this._referencePosition;if(null==i)return[];const s=z(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode,Z),r=s.length;F.length=0;const n=R(0,r,F),a=new Array(r);for(let o=0;o<r;++o)a[o]=s[n[o]];return a}get _analysisVolume(){const{geometry:e}=this.analysis;if(null==e)return this._previousVolume=null,null;try{const t=V(e,this.view,N);return null==t?(this._previousVolume=null,null):c(t)?(this._updatingHandles.consumePromise(t),this._previousVolume):(this._previousVolume=t,t)}catch(t){return n.getLogger(this).error(new r("shadowcastanalysisview3d:projection-failed","Failed to project analysis area geometry to view spatial reference",{geometry:e,error:t})),null}}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case"min-duration":return this._minDurationVisualizationParameters;case"total-duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _minDurationVisualizationParameters(){const{color:e,minDuration:t}=this.analysis.minDurationOptions,i=this._totalDuration;return{rendersSunlight:this.analysis.visualizeSunlight,visualization:2,thresholdColor:e.toUnitRGBA(),threshold:i>0?t/this._totalDuration:0,...this._minDurationContextVisualizationParameters}}get _minDurationContextVisualizationParameters(){const{minDurationOptions:e,visualizeSunlight:t}=this.analysis;if(!e.contextEnabled||t)return{};const{color:i,colorStops:s}=e.contextOptions,r=1/this._lightDirectionsContext.length;return{visualization:3,gradientColorRamp:this._getEffectiveShadowCastColorRamp(i,s,r)}}get _durationVisualizationParameters(){const{color:e,colorStops:t,mode:i}=this.analysis.totalDurationOptions,s=this._totalDuration,r=s>0&&"hourly"===i?B/s:0,n=this._getEffectiveShadowCastColorRamp(e,t,1/s);return 0===r?{...this._discreteVisualizationParameters,gradientColorRamp:n}:{rendersSunlight:this.analysis.visualizeSunlight,bandedGradientColorRamp:n,visualization:1,bandSize:r}}get _showsSeparateZeroBucketInHourlyMode(){const{colorStops:e}=this.analysis.totalDurationOptions;if(null==e||0===e.length)return!0;return e.reduce((e,t)=>Math.min(e,t.value),1/0)<=0}get _discreteVisualizationParameters(){const{color:e,colorStops:t}=this.analysis.discreteOptions,i=1/this._lightDirections.length;return{rendersSunlight:this.analysis.visualizeSunlight,gradientColorRamp:this._getEffectiveShadowCastColorRamp(e,t,i),visualization:0}}get _shadowLayerViews(){return this.view.allLayerViews.items.filter(M)}get _previewDependencies(){const{view:e}=this,i=e.slice.plane,s=this._shadowLayerViews,r=s.map(e=>e.layer).filter(t),n=s.map(e=>e.suspended),a=r.map(e=>e.visible),o=r.map(e=>e.opacity),l=!!e.graphicsView?.suspended,u=r.filter(e=>"definitionExpression"in e).map(e=>e.definitionExpression),c=s.filter(e=>"filter"in e).map(e=>e.filter);return{slicePlane:i,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:n,graphicsViewSuspended:l,layerVisibilities:a,layerOpacities:o,filters:c,definitionExpressions:u}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){return this._getDurationAtScreen(e)}async _getDurationAtScreen(e,t){if(!await this._isScreenPointInAnalysisArea(e,t))return-1;const{_renderer:i,_totalDurationSampleCount:s}=this;if(null==i||0===s)return 0;const r=this.view.state.camera.screenToRender(h(e.x,e.y),m()),n=i.readAccumulatedShadow(r);return(this.analysis.visualizeSunlight?1-n:n)*this._totalDuration}async _isScreenPointInAnalysisArea(e,t){const{geometry:i}=this.analysis;if(!i)return!0;const s=await this.view.hitTest(e);u(t);const r=s.results.find(e=>e.mapPoint)?.mapPoint??s?.ground?.mapPoint;if(!r)return!1;const n=await C(r,i.spatialReference,{signal:t});return u(t),null!=n&&b(i,n)}_getEffectiveShadowCastColorRamp(e,t,i){if(null!=t){t.length>A&&n.getLogger(this).warnOnce("ShadowCastAnalysis supports at most 8 color stops");const e=t.map(e=>[e.value*i,e.color.toUnitRGBA()]);return e.sort(([e],[t])=>e-t),e}return H(e)}};e([_({readOnly:!0,type:["shadow-cast-view-3d"]})],k.prototype,"type",void 0),e([_({constructOnly:!0,nonNullable:!0})],k.prototype,"analysis",void 0),e([_({readOnly:!0})],k.prototype,"updating",null),e([_()],k.prototype,"_stopPreviewingTask",void 0),e([_()],k.prototype,"_updatedRecently",void 0),e([_()],k.prototype,"_tooltip",void 0),e([_()],k.prototype,"_sceneUpdating",null),e([_()],k.prototype,"_effectiveUtcOffset",null),e([_()],k.prototype,"_utcOffsetAuto",null),e([_()],k.prototype,"_dateUTCOffset",null),e([_()],k.prototype,"_startDateTimeUTC",null),e([_()],k.prototype,"_endDateTimeUTC",null),e([_()],k.prototype,"_referencePosition",null),e([_()],k.prototype,"_interval",null),e([_()],k.prototype,"_intervalContext",null),e([_()],k.prototype,"_totalDurationSampleCount",null),e([_()],k.prototype,"_totalDuration",null),e([_()],k.prototype,"_lightDirections",null),e([_()],k.prototype,"_lightDirectionsContext",null),e([_()],k.prototype,"_analysisVolume",null),e([_()],k.prototype,"_visualizationParameters",null),e([_()],k.prototype,"_minDurationVisualizationParameters",null),e([_()],k.prototype,"_minDurationContextVisualizationParameters",null),e([_()],k.prototype,"_durationVisualizationParameters",null),e([_()],k.prototype,"_showsSeparateZeroBucketInHourlyMode",null),e([_()],k.prototype,"_discreteVisualizationParameters",null),e([_()],k.prototype,"_shadowLayerViews",null),e([_()],k.prototype,"_previewDependencies",null),e([_()],k.prototype,"_renderer",null),k=e([f("esri.views.3d.analysis.ShadowCastAnalysisView3D")],k);const L=k;function E(e,t,i){t&&null!=i&&e?.setParameters({shadowCast:i})}function H(e){const t=e.toUnitRGBA();return[[0,w(t[0],t[1],t[2],0)],[1,t]]}function M(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"gaussian-splat-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":case"group":default:return!1;case"graphics-3d":return e.layer.graphics.some(e=>{const{symbol:t}=e;return null==t||"text"!==t.type&&!("symbolLayers"in t)||"text"!==t.type&&t.symbolLayers.some(e=>"text"!==e.type)})}}function I(e,t){if(e===t)return!0;if(null==e&&null==t)return!0;if(null==e||null==t)return!1;const s=S(e.slicePlane,t.slicePlane),r=e.startDateUTC.valueOf()===t.startDateUTC.valueOf()&&e.endDateUTC.valueOf()===t.endDateUTC.valueOf(),n=i(e.layerViewSuspended,t.layerViewSuspended)&&e.graphicsViewSuspended===t.graphicsViewSuspended,a=i(e.layerVisibilities,t.layerVisibilities),o=i(e.layerOpacities,t.layerOpacities),l=i(e.filters,t.filters),u=i(e.definitionExpressions,t.definitionExpressions);return s&&r&&n&&a&&o&&l&&u}const B=g(1,"hours","milliseconds"),G=500,Z=255,q=v(),F=[],N=new x;export{L as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t,equals as i}from"../../../core/arrayUtils.js";import{createTask as s}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{abortMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{after as l,throwIfAborted as u,isPromiseLike as c}from"../../../core/promiseUtils.js";import{watch as p,syncAndInitial as d}from"../../../core/reactiveUtils.js";import{createScreenPointArray as h,createRenderScreenPointArray as m}from"../../../core/screenUtils.js";import{convertTime as g,offsetDateUTC as y}from"../../../core/timeUtils.js";import{property as _,subclass as f}from"../../../core/accessorSupport/decorators.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as D}from"../../../core/support/UpdatingHandles.js";import{projectAsync as C}from"../../../geometry/projectionUtils.js";import{e as b}from"../../../chunks/containsOperator.js";import{g as S}from"../../../chunks/boundedPlane.js";import{polygonToVolume as V}from"../focusAreaUtils.js";import T from"./AnalysisView3D.js";import{registerAnalysisView as U,hideOtherAnalysisViews as P}from"./ShadowCast/analysisViewRegister.js";import{ShadowCastTooltip as O}from"./ShadowCast/ShadowCastTooltip.js";import{ElevationContext as x}from"../layers/graphics/ElevationContext.js";import{longitudeToTimezone as j}from"../support/earthUtils.js";import{computeDirectionsOverTime as z}from"../support/sunUtils.js";import{maxColorRampSize as A}from"../webgl-engine/shaders/colorRampParameters.js";import{breadthFirstBinaryPartitioning as R}from"../../../widgets/support/traversalUtils.js";let k=class extends T{constructor(e){super(e),this.type="shadow-cast-view-3d",this.analysis=null,this._updatingHandles=new D,this._stopPreviewingTask=null,this._updatedRecently=!1,this._tooltip=null,this._previousVolume=null}initialize(){this.addHandles([U(this.view,this),p(()=>({dependencies:this._previewDependencies,sceneUpdating:this._sceneUpdating}),()=>{a(this._stopPreviewingTask),this._updatedRecently=!0,this._stopPreviewingTask=s(async e=>{await l(G,e),u(e),this._updatedRecently=!1})},{sync:!0,initial:!0,equals:(e,t)=>I(e.dependencies,t.dependencies)&&(e.sceneUpdating===t.sceneUpdating||!e.sceneUpdating)}),p(()=>({renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t})=>{t&&P(this.view,this),e?.setParameters({shadowCast:{enabled:t}})},d),p(()=>({renderer:this._renderer,parameters:this._visualizationParameters,visible:this.visible}),({renderer:e,parameters:t,visible:i})=>{E(e,i,t)},d),p(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext,visible:this.visible}),({renderer:e,lightDirections:t,lightDirectionsContext:i,visible:s})=>{E(e,s,{lightDirections:t,lightDirectionsContext:i})},d),p(()=>({renderer:this._renderer,previewing:this._previewing,visible:this.visible}),({renderer:e,previewing:t,visible:i})=>{E(e,i,{previewing:t})},{sync:!0,initial:!0,equals:()=>!1}),p(()=>({analysisVolume:this._analysisVolume,renderer:this._renderer,visible:this.visible}),({renderer:e,visible:t,analysisVolume:i})=>{E(e,t,{analysisVolume:i})},d)]),this.interactive=!0,this._tooltip=new O({getDuration:(e,t)=>this._getDurationAtScreen(e,t),getMode:()=>this.analysis.mode,getShowsSeparateZeroBucketInHourlyMode:()=>this._showsSeparateZeroBucketInHourlyMode,getTotalDuration:()=>this._totalDuration,getTotalDurationMode:()=>this.analysis.totalDurationOptions.mode,getVisualizeSunlight:()=>this.analysis.visualizeSunlight,isVisible:()=>this.interactive&&this.visible,view:this.view})}destroy(){this.visible&&E(this._renderer,!0,{enabled:!1}),this._tooltip=o(this._tooltip),this._stopPreviewingTask=a(this._stopPreviewingTask),this._updatingHandles=o(this._updatingHandles)}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return this._previewing||null!=this._stopPreviewingTask&&!this._stopPreviewingTask.finished||!0===this._tooltip?.updating||this._updatingHandles.updating}get visible(){return super.visible}set visible(e){super.visible=e}get _previewing(){const e=this._updatedRecently,t=this._sceneUpdating;return e||t}get _sceneUpdating(){const{view:e}=this;if(null==e?.allLayerViews)return!0;const{stationary:t,navigating:i,interacting:s,graphicsView:r}=e,n=!t||i||s,a=this._shadowLayerViews.some(e=>e.updating);return n||a||!r?.suspended&&!!r?.updating}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?j(e[0],!1):0}get _dateUTCOffset(){let e=this.analysis.date;return e=y(e,-e.getTimezoneOffset(),"minutes"),e=y(e,-this._effectiveUtcOffset,"hours"),e}get _startDateTimeUTC(){return y(this._dateUTCOffset,this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return y(this._dateUTCOffset,this.analysis.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _totalDurationInterval(){return this._totalDuration>0?Math.floor(this._totalDuration/(Z-1)):Z}get _interval(){const e=this._totalDurationInterval;switch(this.analysis.mode){case"min-duration":return this._totalDuration>0?e:0;case"total-duration":return e;case"discrete":return this.analysis.discreteOptions.interval||e}}get _intervalContext(){const{mode:e,minDurationOptions:t}=this.analysis;return"min-duration"===e&&t.contextEnabled?t.contextOptions.interval||this._totalDurationInterval:-1}get _totalDurationSampleCount(){return this._lightDirections.length}get _totalDuration(){const{startTimeOfDay:e,endTimeOfDay:t}=this.analysis;return t-e}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(e<=0)return[];const i="global"===t.viewingMode?q:this._referencePosition;if(null==i)return[];const s=z(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode,Z),r=s.length;F.length=0;const n=R(0,r,F),a=new Array(r);for(let o=0;o<r;++o)a[o]=s[n[o]];return a}get _analysisVolume(){const{geometry:e}=this.analysis;if(null==e)return this._previousVolume=null,null;try{const t=V(e,this.view,N);return null==t?(this._previousVolume=null,null):c(t)?(this._updatingHandles.consumePromise(t),this._previousVolume):(this._previousVolume=t,t)}catch(t){return n.getLogger(this).error(new r("shadowcastanalysisview3d:projection-failed","Failed to project analysis area geometry to view spatial reference",{geometry:e,error:t})),null}}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case"min-duration":return this._minDurationVisualizationParameters;case"total-duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _minDurationVisualizationParameters(){const{color:e,minDuration:t}=this.analysis.minDurationOptions,i=this._totalDuration;return{rendersSunlight:this.analysis.visualizeSunlight,visualization:2,thresholdColor:e.toUnitRGBA(),threshold:i>0?t/this._totalDuration:0,...this._minDurationContextVisualizationParameters}}get _minDurationContextVisualizationParameters(){const{minDurationOptions:e,visualizeSunlight:t}=this.analysis;if(!e.contextEnabled||t)return{};const{color:i,colorStops:s}=e.contextOptions,r=1/this._lightDirectionsContext.length;return{visualization:3,gradientColorRamp:this._getEffectiveShadowCastColorRamp(i,s,r)}}get _durationVisualizationParameters(){const{color:e,colorStops:t,mode:i}=this.analysis.totalDurationOptions,s=this._totalDuration,r=s>0&&"hourly"===i?B/s:0,n=this._getEffectiveShadowCastColorRamp(e,t,1/s);return 0===r?{...this._discreteVisualizationParameters,gradientColorRamp:n}:{rendersSunlight:this.analysis.visualizeSunlight,bandedGradientColorRamp:n,visualization:1,bandSize:r}}get _showsSeparateZeroBucketInHourlyMode(){const{colorStops:e}=this.analysis.totalDurationOptions;if(null==e||0===e.length)return!0;return e.reduce((e,t)=>Math.min(e,t.value),1/0)<=0}get _discreteVisualizationParameters(){const{color:e,colorStops:t}=this.analysis.discreteOptions,i=1/this._lightDirections.length;return{rendersSunlight:this.analysis.visualizeSunlight,gradientColorRamp:this._getEffectiveShadowCastColorRamp(e,t,i),visualization:0}}get _shadowLayerViews(){return this.view.allLayerViews.items.filter(M)}get _previewDependencies(){const{view:e}=this,i=e.slice.plane,s=this._shadowLayerViews,r=s.map(e=>e.layer).filter(t),n=s.map(e=>e.suspended),a=r.map(e=>e.visible),o=r.map(e=>e.opacity),l=!!e.graphicsView?.suspended,u=r.filter(e=>"definitionExpression"in e).map(e=>e.definitionExpression),c=s.filter(e=>"filter"in e).map(e=>e.filter);return{slicePlane:i,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:n,graphicsViewSuspended:l,layerVisibilities:a,layerOpacities:o,filters:c,definitionExpressions:u}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){return this._getDurationAtScreen(e)}async _getDurationAtScreen(e,t){if(!await this._isScreenPointInAnalysisArea(e,t))return-1;const{_renderer:i,_totalDurationSampleCount:s}=this;if(null==i||0===s)return 0;const r=this.view.state.camera.screenToRender(h(e.x,e.y),m()),n=i.readAccumulatedShadow(r);return(this.analysis.visualizeSunlight?1-n:n)*this._totalDuration}async _isScreenPointInAnalysisArea(e,t){const{geometry:i}=this.analysis;if(!i)return!0;const s=await this.view.hitTest(e);u(t);const r=s.results.find(e=>e.mapPoint)?.mapPoint??s?.ground?.mapPoint;if(!r)return!1;const n=await C(r,i.spatialReference,{signal:t});return u(t),null!=n&&b(i,n)}_getEffectiveShadowCastColorRamp(e,t,i){if(null!=t){t.length>A&&n.getLogger(this).warnOnce("ShadowCastAnalysis supports at most 8 color stops");const e=t.map(e=>[e.value*i,e.color.toUnitRGBA()]);return e.sort(([e],[t])=>e-t),e}return H(e)}};e([_({readOnly:!0,type:["shadow-cast-view-3d"]})],k.prototype,"type",void 0),e([_({constructOnly:!0,nonNullable:!0})],k.prototype,"analysis",void 0),e([_({readOnly:!0})],k.prototype,"updating",null),e([_()],k.prototype,"_stopPreviewingTask",void 0),e([_()],k.prototype,"_updatedRecently",void 0),e([_()],k.prototype,"_tooltip",void 0),e([_()],k.prototype,"_sceneUpdating",null),e([_()],k.prototype,"_effectiveUtcOffset",null),e([_()],k.prototype,"_utcOffsetAuto",null),e([_()],k.prototype,"_dateUTCOffset",null),e([_()],k.prototype,"_startDateTimeUTC",null),e([_()],k.prototype,"_endDateTimeUTC",null),e([_()],k.prototype,"_referencePosition",null),e([_()],k.prototype,"_interval",null),e([_()],k.prototype,"_intervalContext",null),e([_()],k.prototype,"_totalDurationSampleCount",null),e([_()],k.prototype,"_totalDuration",null),e([_()],k.prototype,"_lightDirections",null),e([_()],k.prototype,"_lightDirectionsContext",null),e([_()],k.prototype,"_analysisVolume",null),e([_()],k.prototype,"_visualizationParameters",null),e([_()],k.prototype,"_minDurationVisualizationParameters",null),e([_()],k.prototype,"_minDurationContextVisualizationParameters",null),e([_()],k.prototype,"_durationVisualizationParameters",null),e([_()],k.prototype,"_showsSeparateZeroBucketInHourlyMode",null),e([_()],k.prototype,"_discreteVisualizationParameters",null),e([_()],k.prototype,"_shadowLayerViews",null),e([_()],k.prototype,"_previewDependencies",null),e([_()],k.prototype,"_renderer",null),k=e([f("esri.views.3d.analysis.ShadowCastAnalysisView3D")],k);const L=k;function E(e,t,i){t&&null!=i&&e?.setParameters({shadowCast:i})}function H(e){const t=e.toUnitRGBA();return[[0,w(t[0],t[1],t[2],0)],[1,t]]}function M(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"gaussian-splat-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":case"group":default:return!1;case"graphics-3d":return e.layer.graphics.some(e=>{const{symbol:t}=e;return null==t||"text"!==t.type&&!("symbolLayers"in t)||"text"!==t.type&&t.symbolLayers.some(e=>"text"!==e.type)})}}function I(e,t){if(e===t)return!0;if(null==e&&null==t)return!0;if(null==e||null==t)return!1;const s=S(e.slicePlane,t.slicePlane),r=e.startDateUTC.valueOf()===t.startDateUTC.valueOf()&&e.endDateUTC.valueOf()===t.endDateUTC.valueOf(),n=i(e.layerViewSuspended,t.layerViewSuspended)&&e.graphicsViewSuspended===t.graphicsViewSuspended,a=i(e.layerVisibilities,t.layerVisibilities),o=i(e.layerOpacities,t.layerOpacities),l=i(e.filters,t.filters),u=i(e.definitionExpressions,t.definitionExpressions);return s&&r&&n&&a&&o&&l&&u}const B=g(1,"hours","milliseconds"),G=500,Z=255,q=v(),F=[],N=new x;export{L as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as s,normalize as l,cross as p,negate as a,add as c,scale as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as v,fromArray as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{zValueInAbsoluteHeightMode as g,getGeometryEffectiveElevationInfo as S}from"../../../../support/elevationInfoUtils.js";import{rotateBy as R}from"./viewshedToolUtils.js";var b;let m=b=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null}get elevationAlignedObserver(){const{observer:e,view:t}=this,{x:r,y:i,z:o,spatialReference:n}=e,{absoluteZ:s}=g(r,i,o??0,n,t,this._effectiveElevationInfo),l=e.clone();return l.z=s,l}get observer(){return this.viewshed.observer??new f}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.elevationAlignedObserverRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get elevationAlignedObserverRenderSpace(){return this._pointToRenderSpace(this.elevationAlignedObserver,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get elevationAlignedTargetRenderSpace(){return this._computeTargetRenderSpace(this.elevationAlignedObserverRenderSpace)}get targetDirection(){const e=s(d(),this.elevationAlignedTargetRenderSpace,this.elevationAlignedObserverRenderSpace);return l(e,e)}get tiltedUpVector(){const e=R(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return l(e,e)}get renderCoordsHelper(){return this.view.renderCoordsHelper}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.elevationAlignedObserverRenderSpace,n())}get _effectiveElevationInfo(){return S(this.viewshed.observer,this.viewshed.elevationInfo)}get upVector(){const e=this._basis;return v(e[8],e[9],e[10])}get northVector(){const e=this._basis;return v(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=R(d(),this.northVector,-r(this.heading),e);return p(t,e,t)}get rightVector(){return a(d(),this.leftVector)}clone(){return new b({view:this.view,viewshed:this.viewshed.clone()})}get valid(){return this.viewshed.valid}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,i){const{elevationAlignedObserverRenderSpace:o,elevationAlignedTargetRenderSpace:n}=this,l=s(O,n,o);return R(l,l,-r(t),this.leftVector),R(l,l,-r(e),this.tiltedUpVector),c(i,l,o)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.elevationAlignedObserverRenderSpace,i=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),o=h(O,this.tiltedUpVector,i);c(e.top,t,o),s(e.bottom,t,o)}renderSpaceToPoint(e,t){const r=O;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new f(r[0],r[1],r[2],t)}onElevationChange(){this.notifyChange("elevationAlignedObserver")}_pointToRenderSpace(e,t){const r=u(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:i,upVector:o}=this,n=this.farDistanceRenderSpace,s=d();return h(s,i,n),R(s,s,-r(this.heading),o),R(s,s,-r(this.tiltParallelToSurface),t),c(s,e,s),s}};e([i()],m.prototype,"view",void 0),e([i()],m.prototype,"viewshed",void 0),e([i()],m.prototype,"observerRenderSpaceOverride",void 0),e([i()],m.prototype,"elevationAlignedObserver",null),e([i()],m.prototype,"observer",null),e([i()],m.prototype,"effectiveObserverRenderSpace",null),e([i()],m.prototype,"effectiveObserver",null),e([i()],m.prototype,"effectiveTargetRenderSpace",null),e([i()],m.prototype,"farDistance",null),e([i()],m.prototype,"farDistanceRenderSpace",null),e([i()],m.prototype,"heading",null),e([i()],m.prototype,"tilt",null),e([i()],m.prototype,"feature",null),e([i()],m.prototype,"tiltParallelToSurface",null),e([i()],m.prototype,"horizontalFieldOfView",null),e([i()],m.prototype,"verticalFieldOfView",null),e([i()],m.prototype,"observerRenderSpace",null),e([i()],m.prototype,"elevationAlignedObserverRenderSpace",null),e([i()],m.prototype,"target",null),e([i()],m.prototype,"targetRenderSpace",null),e([i()],m.prototype,"elevationAlignedTargetRenderSpace",null),e([i()],m.prototype,"targetDirection",null),e([i()],m.prototype,"tiltedUpVector",null),e([i()],m.prototype,"renderCoordsHelper",null),e([i()],m.prototype,"_basis",null),e([i()],m.prototype,"_effectiveElevationInfo",null),e([i()],m.prototype,"upVector",null),e([i()],m.prototype,"northVector",null),e([i()],m.prototype,"leftVector",null),e([i()],m.prototype,"rightVector",null),e([i()],m.prototype,"valid",null),e([i()],m.prototype,"metersPerUnit",null),m=b=e([o("esri.views.3d.analysis.Viewshed.ViewshedComputedData")],m);const O=d();export{m as ViewshedComputedData};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as s,normalize as l,cross as p,negate as a,add as c,scale as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as v,fromArray as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{zValueInAbsoluteHeightMode as g,getGeometryEffectiveElevationInfo as S}from"../../../../support/elevationInfoUtils.js";import{rotateBy as R}from"./viewshedToolUtils.js";var b;let m=b=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null}get elevationAlignedObserver(){const{observer:e,view:t}=this,{x:r,y:i,z:o,spatialReference:n}=e,{absoluteZ:s}=g(r,i,o??0,n,t,this.effectiveElevationInfo),l=e.clone();return l.z=s,l}get observer(){return this.viewshed.observer??new f}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.elevationAlignedObserverRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get elevationAlignedObserverRenderSpace(){return this._pointToRenderSpace(this.elevationAlignedObserver,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get elevationAlignedTargetRenderSpace(){return this._computeTargetRenderSpace(this.elevationAlignedObserverRenderSpace)}get targetDirection(){const e=s(d(),this.elevationAlignedTargetRenderSpace,this.elevationAlignedObserverRenderSpace);return l(e,e)}get tiltedUpVector(){const e=R(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return l(e,e)}get renderCoordsHelper(){return this.view.renderCoordsHelper}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.elevationAlignedObserverRenderSpace,n())}get effectiveElevationInfo(){return S(this.viewshed.observer,this.viewshed.elevationInfo)}get upVector(){const e=this._basis;return v(e[8],e[9],e[10])}get northVector(){const e=this._basis;return v(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=R(d(),this.northVector,-r(this.heading),e);return p(t,e,t)}get rightVector(){return a(d(),this.leftVector)}clone(){return new b({view:this.view,viewshed:this.viewshed.clone()})}get valid(){return this.viewshed.valid}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,i){const{elevationAlignedObserverRenderSpace:o,elevationAlignedTargetRenderSpace:n}=this,l=s(O,n,o);return R(l,l,-r(t),this.leftVector),R(l,l,-r(e),this.tiltedUpVector),c(i,l,o)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.elevationAlignedObserverRenderSpace,i=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),o=h(O,this.tiltedUpVector,i);c(e.top,t,o),s(e.bottom,t,o)}renderSpaceToPoint(e,t){const r=O;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new f(r[0],r[1],r[2],t)}onElevationChange(){this.notifyChange("elevationAlignedObserver")}_pointToRenderSpace(e,t){const r=u(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:i,upVector:o}=this,n=this.farDistanceRenderSpace,s=d();return h(s,i,n),R(s,s,-r(this.heading),o),R(s,s,-r(this.tiltParallelToSurface),t),c(s,e,s),s}};e([i()],m.prototype,"view",void 0),e([i()],m.prototype,"viewshed",void 0),e([i()],m.prototype,"observerRenderSpaceOverride",void 0),e([i()],m.prototype,"elevationAlignedObserver",null),e([i()],m.prototype,"observer",null),e([i()],m.prototype,"effectiveObserverRenderSpace",null),e([i()],m.prototype,"effectiveObserver",null),e([i()],m.prototype,"effectiveTargetRenderSpace",null),e([i()],m.prototype,"farDistance",null),e([i()],m.prototype,"farDistanceRenderSpace",null),e([i()],m.prototype,"heading",null),e([i()],m.prototype,"tilt",null),e([i()],m.prototype,"feature",null),e([i()],m.prototype,"tiltParallelToSurface",null),e([i()],m.prototype,"horizontalFieldOfView",null),e([i()],m.prototype,"verticalFieldOfView",null),e([i()],m.prototype,"observerRenderSpace",null),e([i()],m.prototype,"elevationAlignedObserverRenderSpace",null),e([i()],m.prototype,"target",null),e([i()],m.prototype,"targetRenderSpace",null),e([i()],m.prototype,"elevationAlignedTargetRenderSpace",null),e([i()],m.prototype,"targetDirection",null),e([i()],m.prototype,"tiltedUpVector",null),e([i()],m.prototype,"renderCoordsHelper",null),e([i()],m.prototype,"_basis",null),e([i()],m.prototype,"effectiveElevationInfo",null),e([i()],m.prototype,"upVector",null),e([i()],m.prototype,"northVector",null),e([i()],m.prototype,"leftVector",null),e([i()],m.prototype,"rightVector",null),e([i()],m.prototype,"valid",null),e([i()],m.prototype,"metersPerUnit",null),m=b=e([o("esri.views.3d.analysis.Viewshed.ViewshedComputedData")],m);const O=d();export{m as ViewshedComputedData};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as n}from"tslib";import e from"../../../../core/Accessor.js";import{property as t,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as a}from"../../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as p}from"../../../../support/elevationInfoUtils.js";import{SnappingVisualizer3D as r}from"../../interactive/SnappingVisualizer3D.js";import{SnappingContext as s}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as o}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as g}from"../../../interactive/snapping/SnappingManagerPool.js";let l=class extends e{constructor(n){super(n),this._updatingHandles=new a,this._snappingManagerResult=null}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get _snappingManager(){return this._snappingManagerResult?.snappingManager}destroy(){this._updatingHandles.destroy()}createObserverMoveSnappingPipeline(n,e,t){if(0!==n)return null;const i=new s({elevationInfo:p,pointer:t,editGeometryOperations:e,visualizer:new r});return o({snappingContext:i,snappingManager:this._ensureSnappingManager(),updatingHandles:this._updatingHandles,useZ:!1})}_ensureSnappingManager(){if(null==this._snappingManagerResult){const n=g(this.view);this._snappingManagerResult=n,this.addHandles(n)}return this._snappingManagerResult.snappingManager}};n([t({constructOnly:!0})],l.prototype,"view",void 0),n([t()],l.prototype,"updating",null),n([t()],l.prototype,"_snappingManager",null),n([t()],l.prototype,"_snappingManagerResult",void 0),l=n([i("esri.views.3d.analysis.Viewshed.ViewshedSnappingController")],l);export{l as ViewshedSnappingController};
2
+ import{__decorate as e}from"tslib";import n from"../../../../core/Accessor.js";import"../../../../core/has.js";import{property as t,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as r}from"../../../../core/support/UpdatingHandles.js";import{SnappingVisualizer3D as a}from"../../interactive/SnappingVisualizer3D.js";import{createCoordinateHelper as p}from"../../../interactive/coordinateHelper.js";import{EditGeometry as s}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as o}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as g}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as l}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as d}from"../../../interactive/snapping/SnappingManagerPool.js";let u=class extends n{constructor(e){super(e),this._updatingHandles=new r,this._snappingManagerResult=null}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get _snappingManager(){return this._snappingManagerResult?.snappingManager}destroy(){this._updatingHandles.destroy()}createObserverMoveSnappingPipeline(e,n,t){if(0!==e)return null;const i=new g({elevationInfo:t,pointer:n,editGeometryOperations:new o(new s("point",p(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new a});return l({snappingContext:i,snappingManager:this._ensureSnappingManager(),updatingHandles:this._updatingHandles,useZ:!1})}_ensureSnappingManager(){if(null==this._snappingManagerResult){const e=d(this.view);this._snappingManagerResult=e,this.addHandles(e)}return this._snappingManagerResult.snappingManager}get test(){}};e([t({constructOnly:!0})],u.prototype,"view",void 0),e([t()],u.prototype,"updating",null),e([t()],u.prototype,"_snappingManager",null),e([t()],u.prototype,"_snappingManagerResult",void 0),u=e([i("esri.views.3d.analysis.Viewshed.ViewshedSnappingController")],u);export{u as ViewshedSnappingController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import i from"../../../../core/Accessor.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{cyclicalDegrees as n,Cyclical as o}from"../../../../core/Cyclical.js";import{handlesGroup as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{abortMaybe as l,destroyMaybe as p}from"../../../../core/maybe.js";import{after as h,throwIfAborted as u}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as c,initial as v}from"../../../../core/reactiveUtils.js";import{property as g,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{sub as f,len as b,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{tryProject as w}from"../../../../geometry/projectionUtils.js";import{viewingModeFromString as O}from"../../../ViewingMode.js";import{viewshedToolManipulatorConfiguration as V}from"./ViewshedConfiguration.js";import{ViewshedFieldOfViewManipulation as y,isSideHorizontal as T,flipSide as D}from"./ViewshedFieldOfViewManipulation.js";import{ViewshedScaleOrientManipulation as H}from"./ViewshedScaleOrientManipulation.js";import{ViewshedObserverManipulator as S}from"./viewshedToolManipulatorUtils.js";import{discRadiusSmall as C}from"../../interactive/editingTools/manipulations/config.js";import{MoveManipulation as j}from"../../interactive/editingTools/manipulations/MoveManipulation.js";import{resetProperties as F,sceneSnappingAtProjectedLocation as x,dragManipulatedObject as A}from"../../../interactive/dragEventPipeline.js";import{EditGeometryOperations as P}from"../../../interactive/editGeometry/EditGeometryOperations.js";const k=Symbol("dragHandles"),E=Symbol("hideManipulators"),z=Symbol("hideFoVManipulators"),U=Symbol("hideObserverManipulator");let R=class extends i{constructor(e){super(e),this._moveManipulation=null,this._observerManipulator=null,this._fieldOfViewManipulation=null,this._scaleOrientManipulation=null,this._forceHoveringTask=null,this._forceHoveringTestPromise=null,this._grabbing=!1,this.viewshedComputedData=null}initialize(){this._moveManipulation=this._createMoveManipulation(),this._fieldOfViewManipulation=new y({view:this.view,tool:this.parentTool}),this._scaleOrientManipulation=new H({view:this.view,tool:this.parentTool}),this._observerManipulator=new S(this.view,this.parentTool),this.addHandles([d(()=>this.elevationAlignedObserverRenderSpace,e=>{null!=e&&(this._moveManipulation.renderLocation=e,this._observerManipulator.renderLocation=e)},c),d(()=>this.viewshedComputedData?.heading,e=>{e&&(this._moveManipulation.angle=s(90-e))},v),d(()=>{const{viewshedComputedData:e}=this;return{viewshedComputedData:e,observer:this.elevationAlignedObserverRenderSpace}},({viewshedComputedData:e,observer:i},a)=>{this._grabbing&&i!==a?.observer||(this.removeHandles(k),e?.valid&&this.addHandles([this._buildObserverDragPipeline(e),this._buildFOVDragPipeline(e),this._buildScaleOrientDragPipeline(e)].filter(t),k))},v),d(()=>{const e=this.viewshedComputedData;return e?.valid?{viewshedCompData:e,target:e.elevationAlignedTargetRenderSpace,hFOV:e.horizontalFieldOfView,vFOV:e.verticalFieldOfView}:null},e=>{null!=e&&this._fieldOfViewManipulation.updateManipulatorsTransform(e.viewshedCompData)},v),d(()=>{const e=this.viewshedComputedData;return e?.valid?{viewshedCompData:e,hFOV:e.horizontalFieldOfView,vFOV:e.verticalFieldOfView,tilt:e.tilt}:null},e=>{null!=e&&this._fieldOfViewManipulation.updateManipulatorVisuals(e.viewshedCompData)},v),d(()=>{const e=this.analysisViewData.visible&&(this.viewshedComputedData?.valid??!1),i=this.parentTool.selectedViewshedComputedData===this.viewshedComputedData,{creating:t,isPlacingTarget:a}=this.parentTool;return{fovManipulationAvailable:e&&!a,nonFOVManipulationAvailable:e&&(!t||i)}},({fovManipulationAvailable:e,nonFOVManipulationAvailable:i})=>{this._moveManipulation.available=i,this._scaleOrientManipulation.available=i,this._observerManipulator.available=i,this._fieldOfViewManipulation.available=e},v),d(()=>{const e=this.viewshedComputedData;if(!e?.valid)return null;const{observer:i,target:t,verticalFieldOfView:a,horizontalFieldOfView:n}=e;return{viewshedCompData:e,observer:i,target:t,verticalFieldOfView:a,horizontalFieldOfView:n}},e=>{null!=e&&this._scaleOrientManipulation.updateManipulators(e.viewshedCompData)},v)]);const e=e=>{this.addHandles([e.events.on("focus-changed",()=>{const e=this._someManipulatorHovering();e&&this.parentTool.subToolHandles.forEach(({subTool:e})=>{e._resetHoveringTask()}),this._someManipulatorSelected()||e||(this._forceHoveringTask=a(async e=>{await(this._forceHoveringTestPromise??h(V.hoverTimeoutMilliseconds,e)),u(e),this._forceHoveringTask=null,this._updateManipulatorVisibility()}))}),e.events.on("grab-changed",i=>{this._grabbing="start"===i.action,"end"===i.action&&this.parentTool.updateInteractionVisualsVisibility(),this.parentTool.subToolHandles.forEach(({subTool:e})=>{e!==this&&e._setInteractive(!this._grabbing)}),this._setInteractive(i=>i.hasManipulator(e)||!this._grabbing)}),e.events.on("drag",e=>{"start"===e.action&&this.parentTool.updateInteractionVisualsVisibility()})])};this._forEachManipulator(e)}destroy(){this._forceHoveringTask=l(this._forceHoveringTask),this._moveManipulation=p(this._moveManipulation),this._fieldOfViewManipulation=p(this._fieldOfViewManipulation),this._scaleOrientManipulation=p(this._scaleOrientManipulation),this.parentTool.manipulators.remove(this._observerManipulator),this._observerManipulator=p(this._observerManipulator)}get updating(){return null!=this._forceHoveringTask&&!this._forceHoveringTask.finished}get viewshed(){return this.viewshedComputedData?.viewshed}get grabbing(){return this._grabbing}get observer(){return this.viewshed?.observer}set observer(e){const i=this.viewshed;null!=i&&(i.observer=e)}get elevationAlignedObserverRenderSpace(){return this.viewshedComputedData?.elevationAlignedObserverRenderSpace}get discManipulator(){return this._moveManipulation.xyManipulation.discManipulator}get moveInteractionState(){const{dragging:e,grabbing:i}=this._moveManipulation;return{dragging:e,grabbing:i}}get scaleOrientInteractionState(){const{dragging:e,grabbing:i}=this._scaleOrientManipulation;return{dragging:e,grabbing:i}}_setInteractive(e){const i="boolean"==typeof e;this._forEachManipulation(t=>t.interactive=i?e:e(t))}onManipulatorSelectionChanged(){if(this._updateManipulatorVisibility(),!this._someManipulatorSelected()){this.analysisViewData.selectedViewshed===this.viewshed&&(this.analysisViewData.selectedViewshed=null),this._resetHoveringTask()}}hasManipulator(e){let i=!1;return this._forEachManipulator(t=>{i=i||t===e}),i}_someManipulatorSelected(){return this._moveManipulation.selected||this._fieldOfViewManipulation.selected||this._scaleOrientManipulation.selected}_someManipulatorHovering(){return this._moveManipulation.hovering||this._fieldOfViewManipulation.hovering||this._scaleOrientManipulation.hovering}_createMoveManipulation(){return new j({view:this.view,tool:this.parentTool,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:C})}_buildObserverDragPipeline(e){const i={mode:"absolute-height",offset:0},t=e.observer;if(null==t)return null;const a=this.view.spatialReference;return this._moveManipulation.createDragPipeline((n,o,r,s,l)=>{s=s.next(F(this,["observer"]));const p=w(t,a),h=w(e.elevationAlignedObserver,a);if(null==p||null==h)return{steps:r,cancel:s};const u=P.fromGeometry(p,O(this.view.viewingMode)),d=P.fromGeometry(h,O(this.view.viewingMode)),c=this.parentTool.createObserverMoveSnappingPipeline?.(n,d,l);if(null!=c){const{snappingStep:e,cancelSnapping:t}=c,{coordinateHelper:a}=d.data;s=s.next(t);return{steps:r.next(e=>({...e,snapOrigin:a.pointToVector(h)})).next(x(this.view,i)).next(...e).next(A({operations:u})).next(e=>(this.observer=u.data.geometry,e)),cancel:s}}return{steps:r.next(A({operations:u})).next(e=>(this.observer=u.data.geometry,e)),cancel:s}},i,a,void 0)}_buildFOVDragPipeline(e){let i=0,t=0;return this._fieldOfViewManipulation.createDragPipeline((a,o,r)=>{if(null==e)return{steps:o,cancel:r};const s=e.viewshed;let l=null;r=r.next(F(s,["horizontalFieldOfView","verticalFieldOfView"]));return{steps:o.next(a=>{"start"===a.action&&(l=null,i=e.horizontalFieldOfView,t=e.verticalFieldOfView);const o=a.deltaAngle;if(null==l&&0!==o){const e="bottom"===a.side||"left"===a.side?o>0:o<0;l=T(a.side)?0===i&&e||360===i&&!e:0===t&&e}const r=l?D(a.side):a.side;let p=0;switch(r){case"left":p=i/2-o;break;case"right":p=i/2+o;break;case"top":p=t+2*o;break;case"bottom":p=t-2*o}return T(r)?(p=n.normalize(p),p=p>270?0:p>180?180:p,s.horizontalFieldOfView=2*p):s.verticalFieldOfView=p,a}),cancel:r}},e)}_buildScaleOrientDragPipeline(e){let i=0,t=0;const a=(i,t)=>(a,n,o)=>{if(null==e)return{steps:n,cancel:o};const r=e.viewshed;return o=o.next(F(r,[i])),{steps:n=n.next(t(r,e)),cancel:o}};return r([this._scaleOrientManipulation.createHeadingDragPipeline(a("heading",(i,a)=>a=>("start"===a.action&&(t=e.heading),i.heading=n.normalize(t+a.deltaAngle),a)),e),this._scaleOrientManipulation.createTiltDragPipeline(a("tilt",(t,a)=>a=>{"start"===a.action&&(i=e.tilt);let n=i+a.deltaAngle;return n<-90?n=180:n>270&&(n=0),t.tilt=G.clamp(n),a}),e),this._scaleOrientManipulation.createDistanceDragPipeline(a("farDistance",(e,i)=>t=>{const a=f(I,t.renderEnd,i.elevationAlignedObserverRenderSpace),n=b(a)*i.metersPerUnit,o=M(a,i.targetDirection)<0?V.scaleOrientMinDistance:n;return e.farDistance=o,t}),e)])}_updateManipulatorVisibility(){const e=this._someManipulatorSelected(),i=null!=this._forceHoveringTask||this._someManipulatorHovering(),t=this._fieldOfViewManipulation.hovering,a=this.parentTool.creating;let n=[];const o=e=>{n.push(e.disableDisplay())};e||!a&&i?this.removeHandles(E):(this._scaleOrientManipulation.forEachManipulator(o),this._moveManipulation.forEachManipulator(o),this.addHandles(n,E),n=[]),e||!a&&i||a&&t?this.removeHandles(z):(this._fieldOfViewManipulation.forEachManipulator(o),this.addHandles(n,z)),e||!a?this.removeHandles(U):this.addHandles(this._observerManipulator.disableDisplay(),U)}_resetHoveringTask(){this._forceHoveringTask=l(this._forceHoveringTask),this._updateManipulatorVisibility()}_forEachManipulator(e){this._forEachManipulation(i=>{i.forEachManipulator(e)}),e(this._observerManipulator)}_forEachManipulation(e){e(this._moveManipulation),e(this._fieldOfViewManipulation),e(this._scaleOrientManipulation)}get test(){return{moveManipulation:this._moveManipulation,fieldOfViewManipulation:this._fieldOfViewManipulation,scaleOrientManipulation:this._scaleOrientManipulation,viewshedComputedData:this.viewshedComputedData,setHoveringTimeoutPromise:e=>{this._forceHoveringTestPromise=e}}}};e([g({constructOnly:!0})],R.prototype,"analysis",void 0),e([g({constructOnly:!0})],R.prototype,"analysisViewData",void 0),e([g({constructOnly:!0})],R.prototype,"parentTool",void 0),e([g({constructOnly:!0,nonNullable:!0})],R.prototype,"view",void 0),e([g()],R.prototype,"_forceHoveringTask",void 0),e([g()],R.prototype,"updating",null),e([g()],R.prototype,"viewshed",null),e([g()],R.prototype,"_grabbing",void 0),e([g()],R.prototype,"grabbing",null),e([g()],R.prototype,"viewshedComputedData",void 0),e([g()],R.prototype,"observer",null),e([g()],R.prototype,"elevationAlignedObserverRenderSpace",null),R=e([m("esri.views.3d.analysis.Viewshed.ViewshedSubTool")],R);const I=_(),G=new o(0,180);export{R as ViewshedSubTool};
2
+ import{__decorate as e}from"tslib";import i from"../../../../core/Accessor.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{cyclicalDegrees as n,Cyclical as o}from"../../../../core/Cyclical.js";import{handlesGroup as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{abortMaybe as l,destroyMaybe as p}from"../../../../core/maybe.js";import{after as h,throwIfAborted as u}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as c,initial as v}from"../../../../core/reactiveUtils.js";import{property as g,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{sub as f,len as b,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{tryProject as w}from"../../../../geometry/projectionUtils.js";import{viewshedToolManipulatorConfiguration as O}from"./ViewshedConfiguration.js";import{ViewshedFieldOfViewManipulation as V,isSideHorizontal as y,flipSide as T}from"./ViewshedFieldOfViewManipulation.js";import{ViewshedScaleOrientManipulation as D}from"./ViewshedScaleOrientManipulation.js";import{ViewshedObserverManipulator as H}from"./viewshedToolManipulatorUtils.js";import{discRadiusSmall as S}from"../../interactive/editingTools/manipulations/config.js";import{MoveManipulation as C}from"../../interactive/editingTools/manipulations/MoveManipulation.js";import{resetProperties as F,sceneSnappingAtProjectedLocation as j,dragManipulatedObject as x}from"../../../interactive/dragEventPipeline.js";import{EditGeometryOperations as A}from"../../../interactive/editGeometry/EditGeometryOperations.js";const P=Symbol("dragHandles"),k=Symbol("hideManipulators"),E=Symbol("hideFoVManipulators"),z=Symbol("hideObserverManipulator");let U=class extends i{constructor(e){super(e),this._moveManipulation=null,this._observerManipulator=null,this._fieldOfViewManipulation=null,this._scaleOrientManipulation=null,this._forceHoveringTask=null,this._forceHoveringTestPromise=null,this._grabbing=!1,this.viewshedComputedData=null}initialize(){this._moveManipulation=this._createMoveManipulation(),this._fieldOfViewManipulation=new V({view:this.view,tool:this.parentTool}),this._scaleOrientManipulation=new D({view:this.view,tool:this.parentTool}),this._observerManipulator=new H(this.view,this.parentTool),this.addHandles([d(()=>this.elevationAlignedObserverRenderSpace,e=>{null!=e&&(this._moveManipulation.renderLocation=e,this._observerManipulator.renderLocation=e)},c),d(()=>this.viewshedComputedData?.heading,e=>{e&&(this._moveManipulation.angle=s(90-e))},v),d(()=>{const{viewshedComputedData:e}=this;return{viewshedComputedData:e,observer:this.elevationAlignedObserverRenderSpace}},({viewshedComputedData:e,observer:i},a)=>{this._grabbing&&i!==a?.observer||(this.removeHandles(P),e?.valid&&this.addHandles([this._buildObserverDragPipeline(e),this._buildFOVDragPipeline(e),this._buildScaleOrientDragPipeline(e)].filter(t),P))},v),d(()=>{const e=this.viewshedComputedData;return e?.valid?{viewshedCompData:e,target:e.elevationAlignedTargetRenderSpace,hFOV:e.horizontalFieldOfView,vFOV:e.verticalFieldOfView}:null},e=>{null!=e&&this._fieldOfViewManipulation.updateManipulatorsTransform(e.viewshedCompData)},v),d(()=>{const e=this.viewshedComputedData;return e?.valid?{viewshedCompData:e,hFOV:e.horizontalFieldOfView,vFOV:e.verticalFieldOfView,tilt:e.tilt}:null},e=>{null!=e&&this._fieldOfViewManipulation.updateManipulatorVisuals(e.viewshedCompData)},v),d(()=>{const e=this.analysisViewData.visible&&(this.viewshedComputedData?.valid??!1),i=this.parentTool.selectedViewshedComputedData===this.viewshedComputedData,{creating:t,isPlacingTarget:a}=this.parentTool;return{fovManipulationAvailable:e&&!a,nonFOVManipulationAvailable:e&&(!t||i)}},({fovManipulationAvailable:e,nonFOVManipulationAvailable:i})=>{this._moveManipulation.available=i,this._scaleOrientManipulation.available=i,this._observerManipulator.available=i,this._fieldOfViewManipulation.available=e},v),d(()=>{const e=this.viewshedComputedData;if(!e?.valid)return null;const{observer:i,target:t,verticalFieldOfView:a,horizontalFieldOfView:n}=e;return{viewshedCompData:e,observer:i,target:t,verticalFieldOfView:a,horizontalFieldOfView:n}},e=>{null!=e&&this._scaleOrientManipulation.updateManipulators(e.viewshedCompData)},v)]);const e=e=>{this.addHandles([e.events.on("focus-changed",()=>{const e=this._someManipulatorHovering();e&&this.parentTool.subToolHandles.forEach(({subTool:e})=>{e._resetHoveringTask()}),this._someManipulatorSelected()||e||(this._forceHoveringTask=a(async e=>{await(this._forceHoveringTestPromise??h(O.hoverTimeoutMilliseconds,e)),u(e),this._forceHoveringTask=null,this._updateManipulatorVisibility()}))}),e.events.on("grab-changed",i=>{this._grabbing="start"===i.action,"end"===i.action&&this.parentTool.updateInteractionVisualsVisibility(),this.parentTool.subToolHandles.forEach(({subTool:e})=>{e!==this&&e._setInteractive(!this._grabbing)}),this._setInteractive(i=>i.hasManipulator(e)||!this._grabbing)}),e.events.on("drag",e=>{"start"===e.action&&this.parentTool.updateInteractionVisualsVisibility()})])};this._forEachManipulator(e)}destroy(){this._forceHoveringTask=l(this._forceHoveringTask),this._moveManipulation=p(this._moveManipulation),this._fieldOfViewManipulation=p(this._fieldOfViewManipulation),this._scaleOrientManipulation=p(this._scaleOrientManipulation),this.parentTool.manipulators.remove(this._observerManipulator),this._observerManipulator=p(this._observerManipulator)}get updating(){return null!=this._forceHoveringTask&&!this._forceHoveringTask.finished}get viewshed(){return this.viewshedComputedData?.viewshed}get grabbing(){return this._grabbing}get observer(){return this.viewshed?.observer}set observer(e){const i=this.viewshed;null!=i&&(i.observer=e)}get elevationAlignedObserverRenderSpace(){return this.viewshedComputedData?.elevationAlignedObserverRenderSpace}get discManipulator(){return this._moveManipulation.xyManipulation.discManipulator}get moveInteractionState(){const{dragging:e,grabbing:i}=this._moveManipulation;return{dragging:e,grabbing:i}}get scaleOrientInteractionState(){const{dragging:e,grabbing:i}=this._scaleOrientManipulation;return{dragging:e,grabbing:i}}_setInteractive(e){const i="boolean"==typeof e;this._forEachManipulation(t=>t.interactive=i?e:e(t))}onManipulatorSelectionChanged(){if(this._updateManipulatorVisibility(),!this._someManipulatorSelected()){this.analysisViewData.selectedViewshed===this.viewshed&&(this.analysisViewData.selectedViewshed=null),this._resetHoveringTask()}}hasManipulator(e){let i=!1;return this._forEachManipulator(t=>{i=i||t===e}),i}_someManipulatorSelected(){return this._moveManipulation.selected||this._fieldOfViewManipulation.selected||this._scaleOrientManipulation.selected}_someManipulatorHovering(){return this._moveManipulation.hovering||this._fieldOfViewManipulation.hovering||this._scaleOrientManipulation.hovering}_createMoveManipulation(){return new C({view:this.view,tool:this.parentTool,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:S})}_buildObserverDragPipeline(e){const{observer:i,effectiveElevationInfo:t}=e,a=this.view.spatialReference;return this._moveManipulation.createDragPipeline((e,n,o,r,s)=>{r=r.next(F(this,["observer"]));const l=w(i,a);if(null==l)return{steps:o,cancel:r};const p=A.fromGeometry(l,this.view.state.viewingMode),h=this.parentTool.createObserverMoveSnappingPipeline?.(e,s,t);if(null!=h){const{snappingStep:e,cancelSnapping:i}=h;return r=r.next(i),{steps:o=o.next(j(this.view,t)).next(...e).next(x({operations:p})).next(e=>(this.observer=p.data.geometry,e)),cancel:r}}return{steps:o=o.next(x({operations:p})).next(e=>(this.observer=p.data.geometry,e)),cancel:r}},t,a,void 0)}_buildFOVDragPipeline(e){let i=0,t=0;return this._fieldOfViewManipulation.createDragPipeline((a,o,r)=>{if(null==e)return{steps:o,cancel:r};const s=e.viewshed;let l=null;r=r.next(F(s,["horizontalFieldOfView","verticalFieldOfView"]));return{steps:o.next(a=>{"start"===a.action&&(l=null,i=e.horizontalFieldOfView,t=e.verticalFieldOfView);const o=a.deltaAngle;if(null==l&&0!==o){const e="bottom"===a.side||"left"===a.side?o>0:o<0;l=y(a.side)?0===i&&e||360===i&&!e:0===t&&e}const r=l?T(a.side):a.side;let p=0;switch(r){case"left":p=i/2-o;break;case"right":p=i/2+o;break;case"top":p=t+2*o;break;case"bottom":p=t-2*o}return y(r)?(p=n.normalize(p),p=p>270?0:p>180?180:p,s.horizontalFieldOfView=2*p):s.verticalFieldOfView=p,a}),cancel:r}},e)}_buildScaleOrientDragPipeline(e){let i=0,t=0;const a=(i,t)=>(a,n,o)=>{if(null==e)return{steps:n,cancel:o};const r=e.viewshed;return o=o.next(F(r,[i])),{steps:n=n.next(t(r,e)),cancel:o}};return r([this._scaleOrientManipulation.createHeadingDragPipeline(a("heading",(i,a)=>a=>("start"===a.action&&(t=e.heading),i.heading=n.normalize(t+a.deltaAngle),a)),e),this._scaleOrientManipulation.createTiltDragPipeline(a("tilt",(t,a)=>a=>{"start"===a.action&&(i=e.tilt);let n=i+a.deltaAngle;return n<-90?n=180:n>270&&(n=0),t.tilt=R.clamp(n),a}),e),this._scaleOrientManipulation.createDistanceDragPipeline(a("farDistance",(e,i)=>t=>{const a=f(I,t.renderEnd,i.elevationAlignedObserverRenderSpace),n=b(a)*i.metersPerUnit,o=M(a,i.targetDirection)<0?O.scaleOrientMinDistance:n;return e.farDistance=o,t}),e)])}_updateManipulatorVisibility(){const e=this._someManipulatorSelected(),i=null!=this._forceHoveringTask||this._someManipulatorHovering(),t=this._fieldOfViewManipulation.hovering,a=this.parentTool.creating;let n=[];const o=e=>{n.push(e.disableDisplay())};e||!a&&i?this.removeHandles(k):(this._scaleOrientManipulation.forEachManipulator(o),this._moveManipulation.forEachManipulator(o),this.addHandles(n,k),n=[]),e||!a&&i||a&&t?this.removeHandles(E):(this._fieldOfViewManipulation.forEachManipulator(o),this.addHandles(n,E)),e||!a?this.removeHandles(z):this.addHandles(this._observerManipulator.disableDisplay(),z)}_resetHoveringTask(){this._forceHoveringTask=l(this._forceHoveringTask),this._updateManipulatorVisibility()}_forEachManipulator(e){this._forEachManipulation(i=>{i.forEachManipulator(e)}),e(this._observerManipulator)}_forEachManipulation(e){e(this._moveManipulation),e(this._fieldOfViewManipulation),e(this._scaleOrientManipulation)}get test(){return{moveManipulation:this._moveManipulation,fieldOfViewManipulation:this._fieldOfViewManipulation,scaleOrientManipulation:this._scaleOrientManipulation,viewshedComputedData:this.viewshedComputedData,setHoveringTimeoutPromise:e=>{this._forceHoveringTestPromise=e}}}};e([g({constructOnly:!0})],U.prototype,"analysis",void 0),e([g({constructOnly:!0})],U.prototype,"analysisViewData",void 0),e([g({constructOnly:!0})],U.prototype,"parentTool",void 0),e([g({constructOnly:!0,nonNullable:!0})],U.prototype,"view",void 0),e([g()],U.prototype,"_forceHoveringTask",void 0),e([g()],U.prototype,"updating",null),e([g()],U.prototype,"viewshed",null),e([g()],U.prototype,"_grabbing",void 0),e([g()],U.prototype,"grabbing",null),e([g()],U.prototype,"viewshedComputedData",void 0),e([g()],U.prototype,"observer",null),e([g()],U.prototype,"elevationAlignedObserverRenderSpace",null),U=e([m("esri.views.3d.analysis.Viewshed.ViewshedSubTool")],U);const I=_(),R=new o(0,180);export{U as ViewshedSubTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as d,initial as h,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as E}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import V from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as A}from"../../../../../layers/graphics/dehydratedPoint.js";import{isVolumetricSymbol as D}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as G,createManipulatorOutlineMaterial as P,placeAtObject as k}from"../../manipulatorUtils.js";import{RenderObject as C}from"../../RenderObject.js";import{SegmentLabels3D as U}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as R}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as L,screenToRenderPlaneFromEvent as z,convertToMapCoordinates as F}from"../dragEventPipeline3D.js";import{orientation as B}from"../geometryUtils.js";import{canMoveZOperations as Z}from"../manipulatorUtils.js";import{Settings as W}from"../settings.js";import{createVisualElements as N}from"../visualElementUtils.js";import{discRadiusSmall as q}from"../manipulations/config.js";import{MoveManipulation as X}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as Y}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as K,createEdgeOffsetIntersectionPlane as J,createEdgeOffsetOperation as Q,edgeOffsetRotationMatrix as $,screenEdgeLengthSquared as ee,getDistanceInGeometrySR as te}from"./edgeOffsetUtils.js";import{createTooltipInfos as ie,connectTooltipToManipulatedObject as ne,getUpdatedTranslateObjectTooltipInfo as ae,getUpdatedEdgeOffsetTooltipInfo as oe}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as se}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as re}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as le,createSphereGeometry as pe}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as de}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as he,addMapDelta as ue,createManipulatorDragEventPipeline as ce,dragAtLocation as me,addScreenDelta as fe}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ge}from"../../../../interactive/keybindings.js";import{SnappingContext as _e}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as ve}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as Me,enterInputModeIfAvailable as be}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as xe}from"../../../../support/GeometryWorkerHandle.js";const ye=Symbol(),Oe=Symbol();let Ee=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new W({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new xe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ie(this._sketchOptions,e),this._vertexManipulatorMaterial=G(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=P(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=P(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=G(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=P(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=G(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=G(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=G(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=P(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=P(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=Me(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([d(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),d(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,we(t)&&(t.edgeManipulator.available=e)}),d(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),d(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},h),ne(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),d(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ge.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!be(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new U({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&a;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||n.push(s),i++);this._moveVertices(n,t);if(n.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(ye):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,ye)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&a.push(o);this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new Y({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new X({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&Z(t.operations,t.elevationInfo),snapToScene:!1,radius:X.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=ve({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new _e({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new R}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(d),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(he(this.view,e,t.graphic??void 0)).next(...p).next(ue()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),d(()=>t.visible,()=>this._updateMoveManipulationPosition(),h),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),d(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Oe),e&&this.addHandles(re({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Oe)},h)])}_createVisualElements(){const{object:e,view:t}=this,i=N({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof se?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,d=p/2,h=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=le(m,h,d,d,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=le(m,-h,d,d,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new C(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new C(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new C(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new C(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new T({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||D(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:j(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:He(a)}),_=new T({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:He(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),ce(g,this._createEdgeOffsetPipeline(v,t,n)),ce(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?K(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ee(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),s(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=J(this.view,e.manipulator.elevationAlignedLocation,Q(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?$(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ae,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(me(this.view,r)).next(L(this.view,r,t,s,e)).next(fe()).next(ue()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(me(this.view,n.elevationAlignedLocation)).next(r).next(z(this.view)).next(F(this.view,i.data.spatialReference)).next(ue()).next(je()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:s}=this,r=Q(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),d=J(a,e.manipulator.elevationAlignedLocation,r);let h;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),h=p(h)},c=this.events.on("undo",u);return h=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==d?(u(),null):{...e,operation:r,plane:d},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),s=new se({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([d(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=a()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<De){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<De){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!be(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(we).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=Q(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??K(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,s=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,te(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?s(e):n()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,s=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ie(s.manipulators.vertex);this._vertexManipulatorGeometry=pe(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=pe(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ie(s.manipulators.edge);this._edgeManipulatorGeometry=pe(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=pe(this._edgeManipulatorOutlineMaterial,t,16,16)}const d="point"===r||"mesh"===r?[]:[new C(this._vertexManipulatorGeometry.instantiate(),4|Te),new C(this._vertexManipulatorOutlineGeometry.instantiate(),5|Te),new C(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Te),new C(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new C(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new C(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&d.push(new C(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|Ge),new C(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Ge),new C(this._edgeManipulatorGeometry.instantiate(),5|Ge),new C(this._edgeManipulatorOutlineGeometry.instantiate(),5|Ge));const h=()=>new T({view:n,renderObjects:d,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:He(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:h,elevationInfo:t,selected:i})??null),u??=h(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=o(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=ce(u,(e,i,o,s)=>{let r=null;const{snappingStep:d,cancelSnapping:h}=ve({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new _e({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new R}),updatingHandles:this._updatingHandles,useZ:!1});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(h);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0;i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(me(n,u)).next(L(n,u,t,l,m)).next(he(n,t,m)).next(...d).next(ue()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Te}break}case"line":{e.state=Ge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||D(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,we(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Ve),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=A(r,l,p,t.data.spatialReference)}else x(Ae,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ae}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ae,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&Z(this._operations,o.elevationInfo),this._moveManipulation.angle=B(s),this._moveManipulation.radius=X.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&Z(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=Se(t,e):o&&(i=Se(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=q}0!==t&&i?(E(e,e,1/t),Ve.spatialReference=this._operations.data.spatialReference,Ve.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Ve),this._moveManipulation.elevationAlignedLocation=Ve):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?k(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n){e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===de.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===de.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=ae(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=oe(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?oe(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function je(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function Ie(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function Se(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function He(e){return new H({x:0,y:0,z:0,spatialReference:e})}function we(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],Ee.prototype,"_numGrabbing",void 0),e([g()],Ee.prototype,"_numDragging",void 0),e([g()],Ee.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],Ee.prototype,"_operations",null),e([g()],Ee.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],Ee.prototype,"tool",void 0),e([g()],Ee.prototype,"tooltip",void 0),e([g()],Ee.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],Ee.prototype,"updating",null),e([g()],Ee.prototype,"manipulators",null),e([g()],Ee.prototype,"view",null),e([g()],Ee.prototype,"object",null),e([g()],Ee.prototype,"enableZShape",null),e([g()],Ee.prototype,"enableDeleteVertices",null),e([g()],Ee.prototype,"enableZVertex",null),e([g()],Ee.prototype,"autoHideManipulators",null),e([g()],Ee.prototype,"enableMoveObject",null),e([g()],Ee.prototype,"enableMidpoints",null),e([g()],Ee.prototype,"enableEdgeOffset",null),e([g()],Ee.prototype,"_sketchOptions",null),e([g()],Ee.prototype,"_accentColor",null),e([g()],Ee.prototype,"_tooltipsContext",null),Ee=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],Ee);const Ve=A(0,0,void 0,V.WGS84),Ae=I(),De=1e-6,Te=16,Ge=32;export{Ee as ReshapeOperation};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as d,initial as h,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as j}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as E,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import{projectPoint as V}from"../../../../../geometry/projectionUtils.js";import T from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as A}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as G}from"../../../../../symbols/support/utils.js";import{Manipulator3D as P}from"../../Manipulator3D.js";import{createManipulatorMaterial as k,createManipulatorOutlineMaterial as C,placeAtObject as U}from"../../manipulatorUtils.js";import{RenderObject as R}from"../../RenderObject.js";import{SegmentLabels3D as L}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as F,screenToRenderPlaneFromEvent as B,convertToMapCoordinates as Z}from"../dragEventPipeline3D.js";import{orientation as W}from"../geometryUtils.js";import{canMoveZOperations as N}from"../manipulatorUtils.js";import{Settings as q}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as J}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as Q,createEdgeOffsetIntersectionPlane as $,createEdgeOffsetOperation as ee,edgeOffsetRotationMatrix as te,screenEdgeLengthSquared as ie,getDistanceInGeometrySR as ne}from"./edgeOffsetUtils.js";import{createTooltipInfos as ae,connectTooltipToManipulatedObject as oe,getUpdatedTranslateObjectTooltipInfo as se,getUpdatedEdgeOffsetTooltipInfo as re}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as pe}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as de,createSphereGeometry as he}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as ue}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as fe,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ve}from"../../../../interactive/keybindings.js";import{SnappingContext as Me}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as xe,enterInputModeIfAvailable as ye}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as Oe}from"../../../../support/GeometryWorkerHandle.js";const je=Symbol(),Ee=Symbol();let Ie=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new q({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new Oe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ae(this._sketchOptions,e),this._vertexManipulatorMaterial=k(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=C(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=k(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=C(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=k(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=k(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=k(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=C(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=xe(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([d(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),d(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Te(t)&&(t.edgeManipulator.available=e)}),d(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),d(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},h),oe(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),d(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}set snapToScene(e){this._moveManipulation&&(this._moveManipulation.snapToScene=e)}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ve.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!ye(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new L({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&a;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||n.push(s),i++);this._moveVertices(n,t);if(n.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(je):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,je)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&a.push(o);this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new J({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new K({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&N(t.operations,t.elevationInfo),snapToScene:i.snapToScene,radius:K.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:i.snapToScene});return r=r.next(e=>(this._onDragCancel(),e)).next(d),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(ce(this.view,e,t.graphic??void 0)).next(...p).next(me()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),d(()=>t.visible,()=>this._updateMoveManipulationPosition(),h),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),d(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Ee),e&&this.addHandles(pe({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Ee)},h)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,d=p/2,h=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=de(m,h,d,d,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=de(m,-h,d,d,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new R(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new P({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:E(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Ve(a)}),_=new P({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Ve(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),fe(g,this._createEdgeOffsetPipeline(v,t,n)),fe(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?Q(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ie(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),s(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=$(this.view,e.manipulator.elevationAlignedLocation,ee(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?te(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ae,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(ge(this.view,r)).next(F(this.view,r,t,s,e)).next(_e()).next(me()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(ge(this.view,n.elevationAlignedLocation)).next(r).next(B(this.view)).next(Z(this.view,i.data.spatialReference)).next(me()).next(Se()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:s}=this,r=ee(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),d=$(a,e.manipulator.elevationAlignedLocation,r);let h;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),h=p(h)},c=this.events.on("undo",u);return h=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==d?(u(),null):{...e,operation:r,plane:d},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),s=new le({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([d(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=a()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<Ge){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<Ge){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!ye(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Te).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=ee(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??Q(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,s=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,ne(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?s(e):n()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,s=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.vertex);this._vertexManipulatorGeometry=he(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=he(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.edge);this._edgeManipulatorGeometry=he(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=he(this._edgeManipulatorOutlineMaterial,t,16,16)}const d="point"===r||"mesh"===r?[]:[new R(this._vertexManipulatorGeometry.instantiate(),4|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate(),5|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Pe),new R(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&d.push(new R(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|ke),new R(this._edgeManipulatorGeometry.instantiate(),5|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate(),5|ke));const h=()=>new P({view:n,renderObjects:d,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Ve(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:h,elevationInfo:t,selected:i})??null),u??=h(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=o(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=fe(u,(e,i,o,s)=>{let r=null;const{snappingStep:d,cancelSnapping:h}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:this.tool.snapToScene});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(h);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0,f=this.tool.snapToScene?this._screenToSceneMapForVertexDrag(t,a,m):F(n,u,t,l,m);i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(ge(n,u)).next(f).next(ce(n,t,m)).next(...d).next(me()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_screenToSceneMapForVertexDrag(e,t,i){const{view:n}=this,{coordinateHelper:a,spatialReference:o}=t.data;let s=null;return t=>{if("start"===t.action&&(s=a.vectorToPoint(t.snapOrigin)),null==s)return null;const r=n.toMap(t.screenEnd,{exclude:i,excludeLabels:!0});return null==r?null:(r.z=A(r,n,e),V(r,r,o)?{...t,mapStart:s,mapEnd:r}:null)}}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Pe}break}case"line":{e.state=ke,e.selectable=!1,e.cursor="copy",e.collisionPriority=2;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Te(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,De),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=D(r,l,p,t.data.spatialReference)}else x(Ae,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ae}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ae,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&N(this._operations,o.elevationInfo),this._moveManipulation.angle=W(s),this._moveManipulation.radius=K.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&N(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=we(t,e):o&&(i=we(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=Y}0!==t&&i?(j(e,e,1/t),De.spatialReference=this._operations.data.spatialReference,De.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,De),this._moveManipulation.elevationAlignedLocation=De):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?U(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n){e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=se(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=re(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?re(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function Se(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function He(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function we(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Ve(e){return new H({x:0,y:0,z:0,spatialReference:e})}function Te(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],Ie.prototype,"_numGrabbing",void 0),e([g()],Ie.prototype,"_numDragging",void 0),e([g()],Ie.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],Ie.prototype,"_operations",null),e([g()],Ie.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],Ie.prototype,"tool",void 0),e([g()],Ie.prototype,"tooltip",void 0),e([g()],Ie.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],Ie.prototype,"updating",null),e([g()],Ie.prototype,"manipulators",null),e([g()],Ie.prototype,"view",null),e([g()],Ie.prototype,"object",null),e([g()],Ie.prototype,"enableZShape",null),e([g()],Ie.prototype,"enableDeleteVertices",null),e([g()],Ie.prototype,"enableZVertex",null),e([g()],Ie.prototype,"autoHideManipulators",null),e([g()],Ie.prototype,"enableMoveObject",null),e([g()],Ie.prototype,"enableMidpoints",null),e([g()],Ie.prototype,"enableEdgeOffset",null),e([g()],Ie.prototype,"_sketchOptions",null),e([g()],Ie.prototype,"_accentColor",null),e([g()],Ie.prototype,"_tooltipsContext",null),Ie=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],Ie);const De=D(0,0,void 0,T.WGS84),Ae=I(),Ge=1e-6,Pe=16,ke=32;export{Ie as ReshapeOperation};