@arcgis/core 5.2.0-next.144 → 5.2.0-next.146

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 (138) hide show
  1. package/analysis/AreaMeasurementAnalysis.d.ts +11 -1
  2. package/analysis/DirectLineMeasurementAnalysis.d.ts +11 -1
  3. package/analysis/DistanceMeasurementAnalysis.d.ts +8 -0
  4. package/arcade/featureSetUtils.js +1 -1
  5. package/arcgisGlobal.d.ts +5 -5
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/{1ede8666d804c553803e.js → 0b6941781e35ce0f7274.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{a0d459bdb91ee892d4b6.js → 116293b1ee788a89ce1e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/18f20fd43ec9ce03cef1.js +1 -0
  10. package/assets/esri/core/workers/chunks/{8959a825f5e1ce6f38ac.js → 1c65ab9ed611c322ce27.js} +1 -1
  11. package/assets/esri/core/workers/chunks/257910cca66dc5df465e.js +1 -0
  12. package/assets/esri/core/workers/chunks/2e096537a3a5555a4a93.js +1 -0
  13. package/assets/esri/core/workers/chunks/{8ba32d3a0df4a206ef1c.js → 392bcef780df52fb4cca.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{d4926545193414cf2f16.js → 4ed8655770a3e018e366.js} +1 -1
  15. package/assets/esri/core/workers/chunks/505227797bcf2a1d908d.js +1 -0
  16. package/assets/esri/core/workers/chunks/532a1b6ff9a7c950e325.js +1 -0
  17. package/assets/esri/core/workers/chunks/56a24061589f4a968818.js +1 -0
  18. package/assets/esri/core/workers/chunks/{5b3cfe95314a75a735c1.js → 588e677f33df86a595bf.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{25e6013e2c095629b236.js → 58c252289411b0d86473.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{1c0975c2dd1d0e2710bb.js → 6883a5c6883eccaddf64.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{f74e32d2ffe81778826b.js → 6c1d5577a17a5c8ccf39.js} +1 -1
  22. package/assets/esri/core/workers/chunks/6c83398cf586ecea0eb1.js +1 -0
  23. package/assets/esri/core/workers/chunks/{e521bb9ee2030245c3ce.js → 6f358116f79021ff9687.js} +1 -1
  24. package/assets/esri/core/workers/chunks/76196c414e48834f7b92.js +1 -0
  25. package/assets/esri/core/workers/chunks/{cbe6c0f32608cb504695.js → 776ae25a34352d3468bc.js} +1 -1
  26. package/assets/esri/core/workers/chunks/77ebacfdf8e57f2e03f1.js +1118 -0
  27. package/assets/esri/core/workers/chunks/794e5a67a88cb10c1a19.js +1 -0
  28. package/assets/esri/core/workers/chunks/943a0f140813ee4ab04a.js +1 -0
  29. package/assets/esri/core/workers/chunks/{fccbb902fe08448f91de.js → 9c1e69ac82e2bf746191.js} +1 -1
  30. package/assets/esri/core/workers/chunks/aba42885c5d6b2b5fe7f.js +1 -0
  31. package/assets/esri/core/workers/chunks/b61008f28b788f759e2a.js +1 -0
  32. package/assets/esri/core/workers/chunks/{402a82c77420254831bc.js → b7d77dd2abb255fd2e5a.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{8b54589f173259c1ba55.js → b8054adc45bca069b948.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ba48045a81acc4cda927.js +1 -0
  35. package/assets/esri/core/workers/chunks/d21257d2e2a37266c0f7.js +1 -0
  36. package/assets/esri/core/workers/chunks/d4f038e04c42aed588c1.js +1 -0
  37. package/assets/esri/core/workers/chunks/d90a3bfd45b5ed4092e0.js +1 -0
  38. package/assets/esri/core/workers/chunks/{43fc42405167a5537039.js → f095cf98940e3f95d51e.js} +1 -1
  39. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +0 -2
  40. package/assets/esri/themes/dark/main.css +1 -1
  41. package/assets/esri/themes/light/main.css +1 -1
  42. package/assets/esri/themes/light/view.css +1 -1
  43. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.en.json +1 -1
  44. package/{basemaps/BasemapCollection.d.ts → basemapGallery/BasemapGalleryModel.d.ts} +8 -8
  45. package/{basemaps/BasemapCollection.js → basemapGallery/BasemapGalleryModel.js} +1 -1
  46. package/{basemaps → basemapGallery}/BasemapsSource.d.ts +1 -1
  47. package/{basemaps → basemapGallery}/BasemapsSource.js +1 -1
  48. package/{basemaps → basemapGallery}/LocalBasemapsSource.d.ts +2 -2
  49. package/{basemaps → basemapGallery}/LocalBasemapsSource.js +1 -1
  50. package/{basemaps → basemapGallery}/PortalBasemapsSource.d.ts +2 -2
  51. package/{basemaps → basemapGallery}/PortalBasemapsSource.js +1 -1
  52. package/{basemaps → basemapGallery}/support/BasemapItem.d.ts +2 -2
  53. package/{basemaps → basemapGallery}/support/BasemapItem.js +1 -1
  54. package/{basemaps → basemapGallery}/types.d.ts +2 -2
  55. package/chunks/GlobalIllumination.glsl.js +4 -2
  56. package/chunks/GlobalIlluminationBlur.glsl.js +3 -5
  57. package/chunks/GlobalIlluminationUpscale.glsl.js +1 -1
  58. package/config.js +1 -1
  59. package/core/colorUtils.js +1 -1
  60. package/form/elements/inputs/DynamicChoiceInput.d.ts +35 -5
  61. package/kernel.js +1 -1
  62. package/layers/ParquetLayer.d.ts +9 -8
  63. package/layers/ParquetLayer.js +1 -1
  64. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  65. package/layers/graphics/transferFeatures.js +1 -1
  66. package/layers/raster/datasets/TIFFRaster.js +1 -1
  67. package/layers/support/ParquetPortalItemData.d.ts +2 -0
  68. package/layers/support/ParquetPortalItemData.js +1 -1
  69. package/layers/support/PortalItemData.d.ts +21 -0
  70. package/layers/support/parquetUtils.d.ts +1 -1
  71. package/layers/support/types.d.ts +1 -1
  72. package/package.json +2 -2
  73. package/symbols/cim/cimAnalyzer.js +1 -1
  74. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +4 -4
  75. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +4 -4
  76. package/views/2d/layers/features/sources/strategies/FeatureDrillDownTileLoadStrategy.js +1 -1
  77. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  78. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  79. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  80. package/views/3d/analysis/ViewshedAnalysisView3D.d.ts +3 -0
  81. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.d.ts +2 -1
  82. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  83. package/views/3d/layers/support/FeatureMemory.js +1 -1
  84. package/views/3d/layers/support/FeatureTile.js +1 -1
  85. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  86. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  87. package/views/3d/support/PBFDecoder.js +1 -1
  88. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadGlobalIllumination.glsl.js +16 -11
  89. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  90. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js +2 -2
  91. package/views/SceneView.d.ts +4 -10
  92. package/views/View.d.ts +4 -12
  93. package/views/interactive/options/SnappingOptions.d.ts +29 -12
  94. package/views/interactive/options/TooltipOptions.d.ts +9 -1
  95. package/views/interactive/options/ValueOptions.d.ts +9 -2
  96. package/views/interactive/options/ViewOptions.d.ts +82 -6
  97. package/views/interactive/support/Units.d.ts +1 -0
  98. package/widgets/BasemapGallery/BasemapGalleryViewModel.d.ts +2 -2
  99. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  100. package/widgets/BasemapGallery/support/BasemapGalleryItem.d.ts +3 -3
  101. package/widgets/BasemapGallery/support/LocalBasemapsSource.d.ts +2 -2
  102. package/widgets/BasemapGallery/support/PortalBasemapsSource.d.ts +2 -2
  103. package/widgets/BasemapGallery/types.d.ts +3 -3
  104. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  105. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  106. package/widgets/BatchAttributeForm/expressions/expressionUtils.js +1 -1
  107. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +6 -0
  108. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  109. package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
  110. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  111. package/widgets/BatchAttributeForm.js +1 -1
  112. package/widgets/Editor/EditorViewModel.d.ts +13 -8
  113. package/widgets/Editor.d.ts +9 -9
  114. package/widgets/FeatureForm.d.ts +2 -2
  115. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  116. package/widgets/Sketch/SketchViewModel.d.ts +13 -8
  117. package/widgets/Sketch.d.ts +9 -9
  118. package/assets/esri/core/workers/chunks/14a3808427deaaa85bf2.js +0 -1
  119. package/assets/esri/core/workers/chunks/1b551ef3d84d9c1e93f9.js +0 -1
  120. package/assets/esri/core/workers/chunks/260dcb79dfd0f981949f.js +0 -1
  121. package/assets/esri/core/workers/chunks/303676d1b10676c9cab4.js +0 -1
  122. package/assets/esri/core/workers/chunks/37a636f61cfe89c6bfd1.js +0 -1
  123. package/assets/esri/core/workers/chunks/4097edb2ad522dff50ce.js +0 -1
  124. package/assets/esri/core/workers/chunks/4a0216ee6382d9276f1c.js +0 -1
  125. package/assets/esri/core/workers/chunks/55766692b578e60dd70e.js +0 -1742
  126. package/assets/esri/core/workers/chunks/57970d43cdcc5cf57a30.js +0 -1
  127. package/assets/esri/core/workers/chunks/5fd099ca1024707387b2.js +0 -1
  128. package/assets/esri/core/workers/chunks/68e24fa3f564c2a5c9fd.js +0 -1
  129. package/assets/esri/core/workers/chunks/8e7a33cc1f83063043f2.js +0 -1
  130. package/assets/esri/core/workers/chunks/a23272a7a47a95f6ddea.js +0 -1
  131. package/assets/esri/core/workers/chunks/cbdebdfa5f2cded29d0d.js +0 -1
  132. package/assets/esri/core/workers/chunks/cfae60b9d2f2939e9c16.js +0 -1
  133. package/assets/esri/core/workers/chunks/d56780290e0218d3e9de.js +0 -1
  134. package/assets/esri/core/workers/chunks/de24fc414a3f243d675e.js +0 -1
  135. package/assets/esri/core/workers/chunks/e22d45aeef293a5ffb78.js +0 -1
  136. package/assets/esri/core/workers/chunks/ea746d9bbea170719a1c.js +0 -1
  137. package/assets/esri/core/workers/chunks/f0c0c02730fe0d948fc1.js +0 -1
  138. /package/{basemaps → basemapGallery}/support/basemapCompatibilityUtils.js +0 -0
@@ -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{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{snapshotLineOfSightTargetState as o,restoreLineOfSightTargetState as s}from"./LineOfSightAuthoringUtils.js";import{LineOfSightItemManipulatedObject3D as c}from"./LineOfSightItemManipulatedObject3D.js";import{LineOfSightItemTool as l}from"./LineOfSightItemTool.js";import{discRadiusSmall as u}from"../../interactive/editingTools/manipulations/config.js";import{MoveTool3D as d}from"../../interactive/editingTools/move/MoveTool3D.js";import{bindViewToolOptions as f}from"../../../interactive/options/bindViewToolOptions.js";import p from"../../../interactive/options/InteractiveToolOptions.js";const m=Symbol(`inactiveMoveManipulatorDisplay`);let h=class extends t{get visible(){return this._get(`visible`)??!0}set visible(e){this._set(`visible`,e),this._itemTool.visible=e,this._moveTool.visible=e}get manipulatorsInteractive(){return this._get(`manipulatorsInteractive`)??!0}set manipulatorsInteractive(e){this._set(`manipulatorsInteractive`,e),this._itemTool.manipulatorsInteractive=e}constructor(e){super(e),this._selectedItem=null,this._objectByItem=new Map,this._undoStack=[],this._redoStack=[],this._itemTool=new l({analysisViewData:e.analysisViewData,snappingManager:e.snappingManager,view:e.view}),this._moveTool=new d({enableVisualElements:!1,manipulatorRadius:u,snappingManager:e.snappingManager,toolOptions:new p,view:e.view})}initialize(){this.view.tools.add(this._itemTool),this.view.tools.add(this._moveTool),this._itemTool.visible=this.visible,this._moveTool.visible=this.visible,this._itemTool.manipulatorsInteractive=this.manipulatorsInteractive;let e=e=>{let t=e.at(0);t!=null&&this._itemTool.showInteractionVisuals(t)},t=()=>this._itemTool.hideInteractionVisuals();this.addHandles([f(this._moveTool.toolOptions,()=>this.view.options),n(()=>({observer:this.analysis.observer,targets:this.analysis.targets.toArray()}),({observer:e,targets:t})=>this._syncObjects(e,t),r),this._itemTool.events.on(`select-item`,({item:e})=>this._setSelectedItem(e)),this._itemTool.events.on(`selection-cleared`,()=>{if(this._moveTool.hasFocusedManipulators){let e=this._selectedItem==null?null:this._objectByItem.get(this._selectedItem);this._itemTool.selectObject(e)}else this._setSelectedItem(null)}),this._itemTool.events.on(`delete-item`,({target:e})=>this._deleteTarget(e)),this._itemTool.events.on(`record-undo`,({record:e})=>this._recordHistory(g([e]))),this._moveTool.events.on(`record-undo`,({updates:e})=>this._recordHistory(g(e))),this._moveTool.events.on(`hold`,({objects:t})=>e(t)),this._moveTool.events.on(`move-start`,({objects:t})=>e(t)),this._moveTool.events.on(`move-stop`,t),n(()=>({sphereGrabbed:this._itemTool.hasGrabbedManipulators,manipulators:this._moveTool.manipulators.toArray()}),({sphereGrabbed:e})=>{let t=[];e&&this._moveTool.manipulators.forEach(({manipulator:e})=>{t.push(e.disableDisplay())}),this.removeHandles(m),this.addHandles(t,m)},r),n(()=>this._moveTool.firstGrabbedManipulator,e=>{e??t()})])}destroy(){this.removeHandles(m),this.stop(),this.view.tools.remove(this._itemTool),this.view.tools.remove(this._moveTool),this._itemTool.destroy(),this._moveTool.destroy();for(let e of this._objectByItem.values())this.removeHandles(e),e.destroy();this._objectByItem.clear(),this._undoStack.length=0,this._redoStack.length=0}get active(){return this._itemTool.active||this._moveTool.active}get canRedo(){return this._redoStack.length>0}get canUndo(){return this._undoStack.length>0}get hasSelection(){return this._selectedItem!=null}get selectedItem(){return this._selectedItem}get updating(){return this._itemTool.updating||this._moveTool.updating}get laserLineVisualElement(){return this._itemTool.laserLineVisualElement}get verticalLineVisualElement(){return this._itemTool.verticalLineVisualElement}selectItem(e){return this._objectByItem.has(e)?(this._setSelectedItem(e),!0):!1}clearSelection(){return this.hasSelection?(this._setSelectedItem(null),!0):!1}deleteSelectedItem(){let e=this._selectedItem;if(e==null)return!1;let t=this.analysis.targets.find(t=>t===e);return t!=null&&this._deleteTarget(t)}getObserverManipulator(){let e=this.analysis.observer,t=e==null?null:this._itemTool.getManipulator(e);return t!=null&&_(t)?t:null}getTargetManipulator(e){let t=this._itemTool.getManipulator(e);return t!=null&&v(t)?t:null}hasManipulatorAt(e,t){return this._itemTool.hasManipulatorAt(e,t)}redo(){let e=this._redoStack.pop();e!=null&&(e.redo()?(this._undoStack.push(e),this._notifyHistoryChanged()):this._redoStack.push(e))}setEditableFlag(e,t){this._itemTool.setEditableFlag(e,t),this._moveTool.setEditableFlag(e,t)}stop(){(this.view.activeTool===this._itemTool||this.view.activeTool===this._moveTool)&&(this.view.activeTool=null),this._itemTool.hideInteractionVisuals(),this.snappingManager.doneSnapping(),this.clearSelection()}undo(){let e=this._undoStack.pop();e!=null&&(e.undo(),this._redoStack.push(e),this._notifyHistoryChanged())}_syncObjects(e,t){let n=new Set(e==null?t:[e,...t]);for(let[e,t]of this._objectByItem)n.has(e)||(this._selectedItem===e&&this._setSelectedItem(null),this.removeHandles(t),this._itemTool.removeObject(t),this._objectByItem.delete(e),t.destroy());e!=null&&this._ensureObject(e);for(let e of t)this._ensureObject(e);this._setSelectedItem(this._selectedItem)}_ensureObject(e){if(this._objectByItem.has(e))return;let t=new c({analysisViewData:this.analysisViewData,intersector:this.intersector,item:e,view:this.view});this._objectByItem.set(e,t),this._itemTool.addObject(t),this.addHandles(t.on(`modified-externally`,()=>{this._selectedItem===e&&this._setSelectedItem(e)}),t)}_setSelectedItem(e){let t=e==null?null:this._objectByItem.get(e);this._selectedItem=t==null?null:e,this._itemTool.selectObject(t),this._moveTool.objects.removeAll(),t!=null&&this._moveTool.objects.add(t),this._itemTool.interacting=this._selectedItem!=null}_deleteTarget(e){if(this.analysis.targets.length<=1)return!1;let t=this.analysis.targets.indexOf(e);if(t<0)return!1;let n=o(e),r=this._selectedItem===e;return this.analysis.targets.remove(e),this._recordHistory({undo:()=>{s(n,e),this.analysis.targets.add(e,Math.min(t,this.analysis.targets.length)),r&&this._setSelectedItem(e)},redo:()=>this.analysis.targets.includes(e)&&this.analysis.targets.length<=1?!1:(this.analysis.targets.remove(e),this._selectedItem===e&&this._setSelectedItem(null),!0)}),!0}_recordHistory(e){this._undoStack.push(e),this._redoStack.length=0,this._notifyHistoryChanged()}_notifyHistoryChanged(){this.notifyChange(`canUndo`),this.notifyChange(`canRedo`)}get testInfo(){return{moveTooltip:this._moveTool.tooltip}}};e([i({constructOnly:!0})],h.prototype,`analysisViewData`,void 0),e([i({constructOnly:!0})],h.prototype,`analysis`,void 0),e([i({constructOnly:!0})],h.prototype,`intersector`,void 0),e([i({constructOnly:!0})],h.prototype,`snappingManager`,void 0),e([i({constructOnly:!0})],h.prototype,`view`,void 0),e([i()],h.prototype,`visible`,null),e([i()],h.prototype,`manipulatorsInteractive`,null),e([i()],h.prototype,`_selectedItem`,void 0),e([i()],h.prototype,`active`,null),e([i()],h.prototype,`canRedo`,null),e([i()],h.prototype,`canUndo`,null),e([i()],h.prototype,`selectedItem`,null),e([i()],h.prototype,`updating`,null),h=e([a(`esri.views.3d.analysis.LineOfSight.LineOfSightEditTool`)],h);function g(e){return{undo:()=>{for(let t=e.length-1;t>=0;t--)e[t].undo(null)},redo:()=>{for(let t of e)t.redo(null);return!0}}}function _(e){return e.metadata.type===`observer`}function v(e){return e.metadata.type===`target`}export{h as LineOfSightEditTool};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{snapshotLineOfSightTargetState as o,restoreLineOfSightTargetState as s}from"./LineOfSightAuthoringUtils.js";import{LineOfSightItemManipulatedObject3D as c}from"./LineOfSightItemManipulatedObject3D.js";import{LineOfSightItemTool as l}from"./LineOfSightItemTool.js";import{discRadiusSmall as u}from"../../interactive/editingTools/manipulations/config.js";import{MoveTool3D as d}from"../../interactive/editingTools/move/MoveTool3D.js";import{bindViewToolOptions as f}from"../../../interactive/options/bindViewToolOptions.js";import p from"../../../interactive/options/InteractiveToolOptions.js";import{makeTooltip as m}from"../../../interactive/tooltip/tooltipCommonUtils.js";const h=Symbol(`inactiveMoveManipulatorDisplay`);let g=class extends t{get visible(){return this._get(`visible`)??!0}set visible(e){this._set(`visible`,e),this._itemTool.visible=e,this._moveTool.visible=e}get manipulatorsInteractive(){return this._get(`manipulatorsInteractive`)??!0}set manipulatorsInteractive(e){this._set(`manipulatorsInteractive`,e),this._itemTool.manipulatorsInteractive=e}constructor(e){super(e),this._selectedItem=null,this._objectByItem=new Map,this._undoStack=[],this._redoStack=[];let t=new p;this._tooltip=m(()=>({view:e.view,options:t.tooltips})),this._moveTool=new d({enableVisualElements:!1,manipulatorRadius:u,snappingManager:e.snappingManager,toolOptions:t,tooltip:this._tooltip,view:e.view}),this._itemTool=new l({analysisViewData:e.analysisViewData,snappingManager:e.snappingManager,tooltip:this._tooltip,view:e.view})}initialize(){this.view.tools.add(this._itemTool),this.view.tools.add(this._moveTool),this._itemTool.visible=this.visible,this._moveTool.visible=this.visible,this._itemTool.manipulatorsInteractive=this.manipulatorsInteractive;let e=e=>{let t=e.at(0);t!=null&&this._itemTool.showInteractionVisuals(t)},t=()=>this._itemTool.hideInteractionVisuals();this.addHandles([f(this._moveTool.toolOptions,()=>this.view.options),n(()=>({observer:this.analysis.observer,targets:this.analysis.targets.toArray()}),({observer:e,targets:t})=>this._syncObjects(e,t),r),this._itemTool.events.on(`select-item`,({item:e})=>this._setSelectedItem(e)),this._itemTool.events.on(`selection-cleared`,()=>{if(this._moveTool.hasFocusedManipulators){let e=this._selectedItem==null?null:this._objectByItem.get(this._selectedItem);this._itemTool.selectObject(e)}else this._setSelectedItem(null)}),this._itemTool.events.on(`delete-item`,({target:e})=>this._deleteTarget(e)),this._itemTool.events.on(`record-undo`,({record:e})=>this._recordHistory(_([e]))),this._moveTool.events.on(`record-undo`,({updates:e})=>this._recordHistory(_(e))),this._moveTool.events.on(`hold`,({objects:t})=>e(t)),this._moveTool.events.on(`move-start`,({objects:t})=>{this._itemTool.endDrag(),e(t)}),this._moveTool.events.on(`move-stop`,t),n(()=>({sphereGrabbed:this._itemTool.hasGrabbedManipulators,manipulators:this._moveTool.manipulators.toArray()}),({sphereGrabbed:e})=>{let t=[];e&&this._moveTool.manipulators.forEach(({manipulator:e})=>{t.push(e.disableDisplay())}),this.removeHandles(h),this.addHandles(t,h)},r),n(()=>this._moveTool.firstGrabbedManipulator,e=>{e??t()})])}destroy(){this.removeHandles(h),this.stop(),this.view.tools.remove(this._itemTool),this.view.tools.remove(this._moveTool),this._itemTool.destroy(),this._moveTool.destroy(),this._tooltip.destroy();for(let e of this._objectByItem.values())this.removeHandles(e),e.destroy();this._objectByItem.clear(),this._undoStack.length=0,this._redoStack.length=0}get active(){return this._itemTool.active||this._moveTool.active}get canRedo(){return this._redoStack.length>0}get canUndo(){return this._undoStack.length>0}get hasSelection(){return this._selectedItem!=null}get selectedItem(){return this._selectedItem}get updating(){return this._itemTool.updating||this._moveTool.updating}get laserLineVisualElement(){return this._itemTool.laserLineVisualElement}get verticalLineVisualElement(){return this._itemTool.verticalLineVisualElement}selectItem(e){return this._objectByItem.has(e)?(this._setSelectedItem(e),!0):!1}clearSelection(){return this.hasSelection?(this._setSelectedItem(null),!0):!1}deleteSelectedItem(){let e=this._selectedItem;if(e==null)return!1;let t=this.analysis.targets.find(t=>t===e);return t!=null&&this._deleteTarget(t)}getObserverManipulator(){let e=this.analysis.observer,t=e==null?null:this._itemTool.getManipulator(e);return t!=null&&v(t)?t:null}getTargetManipulator(e){let t=this._itemTool.getManipulator(e);return t!=null&&y(t)?t:null}hasManipulatorAt(e,t){return this._itemTool.hasManipulatorAt(e,t)}redo(){let e=this._redoStack.pop();e!=null&&(e.redo()?(this._undoStack.push(e),this._notifyHistoryChanged()):this._redoStack.push(e))}setEditableFlag(e,t){this._itemTool.setEditableFlag(e,t),this._moveTool.setEditableFlag(e,t)}stop(){(this.view.activeTool===this._itemTool||this.view.activeTool===this._moveTool)&&(this.view.activeTool=null),this._itemTool.hideInteractionVisuals(),this.snappingManager.doneSnapping(),this.clearSelection()}undo(){let e=this._undoStack.pop();e!=null&&(e.undo(),this._redoStack.push(e),this._notifyHistoryChanged())}_syncObjects(e,t){let n=new Set(e==null?t:[e,...t]);for(let[e,t]of this._objectByItem)n.has(e)||(this._selectedItem===e&&this._setSelectedItem(null),this.removeHandles(t),this._itemTool.removeObject(t),this._objectByItem.delete(e),t.destroy());e!=null&&this._ensureObject(e);for(let e of t)this._ensureObject(e);this._setSelectedItem(this._selectedItem)}_ensureObject(e){if(this._objectByItem.has(e))return;let t=new c({analysisViewData:this.analysisViewData,intersector:this.intersector,item:e,view:this.view});this._objectByItem.set(e,t),this._itemTool.addObject(t),this.addHandles(t.on(`modified-externally`,()=>{this._selectedItem===e&&this._setSelectedItem(e)}),t)}_setSelectedItem(e){let t=e==null?null:this._objectByItem.get(e);this._selectedItem=t==null?null:e,this._itemTool.selectObject(t),this._moveTool.objects.removeAll(),t!=null&&this._moveTool.objects.add(t),this._itemTool.interacting=this._selectedItem!=null}_deleteTarget(e){if(this.analysis.targets.length<=1)return!1;let t=this.analysis.targets.indexOf(e);if(t<0)return!1;let n=o(e),r=this._selectedItem===e;return this.analysis.targets.remove(e),this._recordHistory({undo:()=>{s(n,e),this.analysis.targets.add(e,Math.min(t,this.analysis.targets.length)),r&&this._setSelectedItem(e)},redo:()=>this.analysis.targets.includes(e)&&this.analysis.targets.length<=1?!1:(this.analysis.targets.remove(e),this._selectedItem===e&&this._setSelectedItem(null),!0)}),!0}_recordHistory(e){this._undoStack.push(e),this._redoStack.length=0,this._notifyHistoryChanged()}_notifyHistoryChanged(){this.notifyChange(`canUndo`),this.notifyChange(`canRedo`)}get testInfo(){return{moveTooltip:this._tooltip}}};e([i({constructOnly:!0})],g.prototype,`analysisViewData`,void 0),e([i({constructOnly:!0})],g.prototype,`analysis`,void 0),e([i({constructOnly:!0})],g.prototype,`intersector`,void 0),e([i({constructOnly:!0})],g.prototype,`snappingManager`,void 0),e([i({constructOnly:!0})],g.prototype,`view`,void 0),e([i()],g.prototype,`visible`,null),e([i()],g.prototype,`manipulatorsInteractive`,null),e([i()],g.prototype,`_selectedItem`,void 0),e([i()],g.prototype,`active`,null),e([i()],g.prototype,`canRedo`,null),e([i()],g.prototype,`canUndo`,null),e([i()],g.prototype,`selectedItem`,null),e([i()],g.prototype,`updating`,null),g=e([a(`esri.views.3d.analysis.LineOfSight.LineOfSightEditTool`)],g);function _(e){return{undo:()=>{for(let t=e.length-1;t>=0;t--)e[t].undo(null)},redo:()=>{for(let t of e)t.redo(null);return!0}}}function v(e){return e.metadata.type===`observer`}function y(e){return e.metadata.type===`target`}export{g as LineOfSightEditTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventEmitter as t}from"../../../../core/Evented.js";import{handlesGroup as n}from"../../../../core/handleUtils.js";import{destroyMaybe as r,removeMaybe as i}from"../../../../core/maybe.js";import a from"../../../../core/ReactiveMap.js";import{initial as o,watch as s,syncAndInitial as c}from"../../../../core/reactiveUtils.js";import{property as l,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{create as f,fromPoints as p}from"../../../../geometry/support/lineSegment.js";import{LineOfSightInteractionVisuals as m}from"./LineOfSightInteractionVisuals.js";import{LineOfSightObserverManipulator as h,LineOfSightTargetManipulator as g,LineOfSightTargetManipulatorState as _,getInteractiveLineOfSightTargetManipulatorState as v}from"./LineOfSightManipulators.js";import{SnappingVisualizer3D as y}from"../../interactive/SnappingVisualizer3D.js";import{screenToMapAtSceneSurface as b}from"../../interactive/editingTools/dragEventPipeline3D.js";import{connectTooltipToManipulatedObject as x}from"../../interactive/editingTools/tooltipUtils3D.js";import{mouseButtons as S}from"../../../input/mouseButtons.js";import{createManipulatorDragEventPipeline as C,dragAtLocation as w,sceneSnappingAtLocation as T,dragManipulatedObject as E}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as D}from"../../../interactive/InteractiveToolBase.js";import{bindViewToolOptions as O}from"../../../interactive/options/bindViewToolOptions.js";import k from"../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as A}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as M,enterInputModeIfAvailable as N}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as P}from"../../../interactive/tooltip/infos/MovePointTooltipInfo.js";const F=f(),I=Symbol(`inactiveManipulatorDisplay`);let L=class extends D{get _manipulatorsToHide(){let e=this._manipulatorByObject.values();return this.view.tools.some(e=>e.hasGrabbedManipulators)||e.some(e=>e.grabbing)?e.filter(e=>!e.grabbing).toArray():[]}constructor(e){super(e),this.events=new t,this.automaticManipulatorSelection=!1,this.removeIncompleteOnCancel=!1,this.interacting=!1,this.manipulatorsInteractive=!0,this._objectByItem=new Map,this._manipulatorByObject=new a,this._updatingHandles=new d,this._toolOptions=new k,this._interactionVisuals=null,this._grabbedManipulator=null,this._visualsManipulator=null,this._tooltipHandle=null,this._tooltipObject=null,this._tooltipUndoRecord=null,this._tooltipInfo=new P({toolOptions:this._toolOptions,viewType:`3d`})}initialize(){let{view:e}=this;this._tooltip=M(()=>({view:e,options:this._toolOptions.tooltips})),this._interactionVisuals=new m({view:e}),this.addHandles([O(this._toolOptions,()=>e.options),this._updatingHandles.add(()=>({analysisVisible:this.analysisViewData.visible,computations:this.analysisViewData.computations.toArray().map(e=>({isTargetVisible:e.computationResult.isTargetVisible,isValid:e.computationResult.isValid,target:e.target})),grabbedManipulator:this._grabbedManipulator,interacting:this.interacting,manipulatorsInteractive:this.manipulatorsInteractive,visible:this.visible}),()=>this._syncManipulators(),o),s(()=>this._manipulatorsToHide,e=>{let t=e.map(e=>e.disableDisplay());this.removeHandles(I),this.addHandles(t,I)},c),s(()=>this._tooltip.mode,e=>{e!==`input`&&this._grabbedManipulator==null&&this._disconnectTooltip()})]),this.finishToolCreation()}destroy(){this.removeHandles(I),this._disconnectTooltip(),this._tooltip=r(this._tooltip),this._interactionVisuals=r(this._interactionVisuals),this._updatingHandles.destroy(),this._objectByItem.clear(),this._manipulatorByObject.clear(),super.destroy()}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}get verticalLineVisualElement(){return this._interactionVisuals?.verticalLineVisualElement??null}showInteractionVisuals(e){this._visualsManipulator=this._manipulatorByObject.get(e),this._syncInteractionVisuals()}hideInteractionVisuals(){this._visualsManipulator=null,this._syncInteractionVisuals()}addObject(e){if(this._manipulatorByObject.has(e))return;let t=e.item.type===`observer`?new h(this.view,{deleting:!1,intersection:null,type:`observer`}):new g(this.view,{deleting:!1,target:e.item,type:`target`});t.cursor=`move`,this._objectByItem.set(e.item,e),this._manipulatorByObject.set(e,t),this.manipulators.add(t),this.addHandles(this._connectManipulator(e,t),e),this._syncManipulator(e,t)}removeObject(e){let t=this._manipulatorByObject.get(e);t!=null&&(this._grabbedManipulator===t&&(this._grabbedManipulator=null),this._tooltipObject===e&&this._disconnectTooltip(),this._visualsManipulator===t&&this.hideInteractionVisuals(),this.removeHandles(e),this.removeHandles(e),this._objectByItem.delete(e.item),this._manipulatorByObject.delete(e),this.manipulators.remove(t),t.destroy())}getManipulator(e){let t=this._objectByItem.get(e);return t==null?null:this._manipulatorByObject.get(t)}hasManipulatorAt(e,t){for(let n of this._manipulatorByObject.values())if(n.consumesClicks&&n.intersectionDistance(e,t)!=null)return!0;return!1}selectObject(e){this._tooltipObject!=null&&this._tooltipObject!==e&&this._disconnectTooltip();let t=!1;for(let[n,r]of this._manipulatorByObject){let i=n===e;r.selected=i,t||=i}return this._syncManipulators(),t}onInputEvent(e){e.type===`hold`&&this._grabbedManipulator!=null&&(this._visualsManipulator=this._grabbedManipulator,this._syncInteractionVisuals()),N(e,this._tooltip)}onManipulatorSelectionChanged(){[...this._manipulatorByObject.values()].some(e=>e.selected)||this.events.emit(`selection-cleared`)}_connectManipulator(e,t){let r=()=>this._syncManipulator(e,t);return n([e.on(`committed`,r),e.on(`modified-externally`,r),t.events.on(`immediate-click`,n=>{this.events.emit(`select-item`,{item:e.item}),n.button===S.Right&&t.metadata.type===`target`&&this.events.emit(`delete-item`,{target:t.metadata.target}),n.stopPropagation()}),t.events.on(`grab-changed`,({action:n})=>{n===`start`?(this.events.emit(`select-item`,{item:e.item}),this._grabbedManipulator=t,this._connectTooltip(e)):this._grabbedManipulator===t&&(this._grabbedManipulator=null,this.hideInteractionVisuals(),this._tooltip.mode!==`input`&&this._disconnectTooltip()),this._manipulatorByObject.set(e,t)}),t.events.on(`drag`,t=>{e.updateDragIntersection(t),t.action===`start`&&this.showInteractionVisuals(e)}),t.events.on(`location-update`,()=>this._syncInteractionVisuals()),this._createDragHandle(e,t)])}_createDragHandle(e,t){return C(t,(n,r,i,a)=>{let o=e.operations;if(o==null)return;let s=null,{cancelSnapping:c,snappingStep:l}=j({snappingContext:new A({editGeometryOperations:o,elevationInfo:e.elevationInfo,pointer:a,visualizer:new y}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!0});i.next(e=>(s?.undo(null),s=null,e)).next(c);let u=o.data.allVerticesUnordered.at(0);r.next(t=>(t.action===`start`&&(s=e.createUndoRecord()),{...t,snapOrigin:u?.pos})).next(w(this.view,t.elevationAlignedLocation)).next(b(this.view,o.data.geometry,e.elevationInfo,o.data.spatialReference)).next(T(this.view,e.elevationInfo)).next(...l).next(E(e)).next(e=>(e.action===`end`&&s!=null&&(this.events.emit(`record-undo`,{record:s}),s=null),e))})}_connectTooltip(e){this._disconnectTooltip(),this._tooltipObject=e,this._tooltipHandle=x(this._tooltip,e,()=>({activeTooltipInfo:this._tooltipInfo,onRecordUndo:e=>this.events.emit(`record-undo`,{record:e}),callbacks:{onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._tooltipUndoRecord=e.createUndoRecord()},onMove:()=>{},onMoveStop:()=>{this._tooltipUndoRecord!=null&&(this.events.emit(`record-undo`,{record:this._tooltipUndoRecord}),this._tooltipUndoRecord=null)},onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}},toolOptions:this._toolOptions}))}_disconnectTooltip(){this._tooltipHandle=i(this._tooltipHandle),this._tooltipObject=null,this._tooltipUndoRecord=null,this._tooltip.clear()}_syncManipulators(){for(let[e,t]of this._manipulatorByObject)this._syncManipulator(e,t);this._syncInteractionVisuals()}_syncManipulator(e,t){let n=e.origin;if(t.available=this.visible&&e.visible&&n!=null,t.interactive=this.manipulatorsInteractive&&(this._grabbedManipulator==null||this._grabbedManipulator===t),n!=null&&(t.elevationAlignedLocation=n),e.item.type!==`target`)return;let r=this.analysisViewData.computations.find(t=>t.target===e.item),i=r==null||!r.computationResult.isValid?_.undefined:r.computationResult.isTargetVisible?_.visible:_.occluded;t.state=this.interacting&&t.selected?v(i):i}_syncInteractionVisuals(){let e=this._interactionVisuals,t=this._visualsManipulator,n=this.visible&&this.analysisViewData.visible;if(e==null||t==null||!n){e?.hide();return}let r=[...this._manipulatorByObject.entries()].find(([e])=>e.item.type===`observer`)?.[1];if(r==null){e.hide();return}let i=t===r?null:p(r.renderLocation,t.renderLocation,F);e.update({target:t.renderLocation,lineVerticalPlaneSegment:i,visible:!0})}};e([l({constructOnly:!0})],L.prototype,`analysisViewData`,void 0),e([l({constructOnly:!0})],L.prototype,`snappingManager`,void 0),e([l({constructOnly:!0})],L.prototype,`view`,void 0),e([l()],L.prototype,`automaticManipulatorSelection`,void 0),e([l()],L.prototype,`removeIncompleteOnCancel`,void 0),e([l()],L.prototype,`interacting`,void 0),e([l()],L.prototype,`manipulatorsInteractive`,void 0),e([l()],L.prototype,`_grabbedManipulator`,void 0),e([l()],L.prototype,`_manipulatorsToHide`,null),e([l()],L.prototype,`updating`,null),L=e([u(`esri.views.3d.analysis.LineOfSight.LineOfSightItemTool`)],L);export{L as LineOfSightItemTool};
2
+ import{__decorate as e}from"tslib";import{EventEmitter as t}from"../../../../core/Evented.js";import{handlesGroup as n}from"../../../../core/handleUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import i from"../../../../core/ReactiveMap.js";import{initial as a,watch as o,syncAndInitial as s}from"../../../../core/reactiveUtils.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import{create as d,fromPoints as f}from"../../../../geometry/support/lineSegment.js";import{LineOfSightInteractionVisuals as p}from"./LineOfSightInteractionVisuals.js";import{LineOfSightObserverManipulator as m,LineOfSightTargetManipulator as h,LineOfSightTargetManipulatorState as g,getInteractiveLineOfSightTargetManipulatorState as _}from"./LineOfSightManipulators.js";import{SnappingVisualizer3D as v}from"../../interactive/SnappingVisualizer3D.js";import{screenToMapAtSceneSurface as y}from"../../interactive/editingTools/dragEventPipeline3D.js";import{mouseButtons as b}from"../../../input/mouseButtons.js";import{createManipulatorDragEventPipeline as x,dragAtLocation as S,sceneSnappingAtLocation as C,dragManipulatedObject as w}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as T}from"../../../interactive/InteractiveToolBase.js";import{SnappingContext as E}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{enterInputModeIfAvailable as O}from"../../../interactive/tooltip/tooltipCommonUtils.js";const k=d(),A=Symbol(`inactiveManipulatorDisplay`);let j=class extends T{get _manipulatorsToHide(){let e=this._manipulatorByObject.values();return this.view.tools.some(e=>e.hasGrabbedManipulators)||e.some(e=>e.grabbing)?e.filter(e=>!e.grabbing).toArray():[]}constructor(e){super(e),this.events=new t,this.automaticManipulatorSelection=!1,this.removeIncompleteOnCancel=!1,this.interacting=!1,this.manipulatorsInteractive=!0,this._objectByItem=new Map,this._manipulatorByObject=new i,this._updatingHandles=new u,this._interactionVisuals=null,this._grabbedManipulator=null,this._visualsManipulator=null}initialize(){let{view:e}=this;this._interactionVisuals=new p({view:e}),this.addHandles([this._updatingHandles.add(()=>({analysisVisible:this.analysisViewData.visible,computations:this.analysisViewData.computations.toArray().map(e=>({isTargetVisible:e.computationResult.isTargetVisible,isValid:e.computationResult.isValid,target:e.target})),grabbedManipulator:this._grabbedManipulator,interacting:this.interacting,manipulatorsInteractive:this.manipulatorsInteractive,visible:this.visible}),()=>this._syncManipulators(),a),o(()=>this._manipulatorsToHide,e=>{let t=e.map(e=>e.disableDisplay());this.removeHandles(A),this.addHandles(t,A)},s)]),this.finishToolCreation()}destroy(){this.removeHandles(A),this._interactionVisuals=r(this._interactionVisuals),this._updatingHandles.destroy(),this._objectByItem.clear(),this._manipulatorByObject.clear(),super.destroy()}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}get laserLineVisualElement(){return this._interactionVisuals?.laserLineVisualElement??null}get verticalLineVisualElement(){return this._interactionVisuals?.verticalLineVisualElement??null}showInteractionVisuals(e){this._visualsManipulator=this._manipulatorByObject.get(e),this._syncInteractionVisuals()}hideInteractionVisuals(){this._visualsManipulator=null,this._syncInteractionVisuals()}addObject(e){if(this._manipulatorByObject.has(e))return;let t=e.item.type===`observer`?new m(this.view,{deleting:!1,intersection:null,type:`observer`}):new h(this.view,{deleting:!1,target:e.item,type:`target`});t.cursor=`move`,this._objectByItem.set(e.item,e),this._manipulatorByObject.set(e,t),this.manipulators.add(t),this.addHandles(this._connectManipulator(e,t),e),this._syncManipulator(e,t)}removeObject(e){let t=this._manipulatorByObject.get(e);t!=null&&(this._grabbedManipulator===t&&(this._grabbedManipulator=null),this._visualsManipulator===t&&this.hideInteractionVisuals(),this.removeHandles(e),this.removeHandles(e),this._objectByItem.delete(e.item),this._manipulatorByObject.delete(e),this.manipulators.remove(t),t.destroy())}getManipulator(e){let t=this._objectByItem.get(e);return t==null?null:this._manipulatorByObject.get(t)}hasManipulatorAt(e,t){for(let n of this._manipulatorByObject.values())if(n.consumesClicks&&n.intersectionDistance(e,t)!=null)return!0;return!1}selectObject(e){let t=!1;for(let[n,r]of this._manipulatorByObject){let i=n===e;r.selected=i,t||=i}return this._syncManipulators(),t}onInputEvent(e){e.type===`hold`&&this._grabbedManipulator!=null&&(this._visualsManipulator=this._grabbedManipulator,this._syncInteractionVisuals()),O(e,this.tooltip)}onManipulatorSelectionChanged(){[...this._manipulatorByObject.values()].some(e=>e.selected)||this.events.emit(`selection-cleared`)}_connectManipulator(e,t){let r=()=>this._syncManipulator(e,t);return n([e.on(`committed`,r),e.on(`modified-externally`,r),t.events.on(`immediate-click`,n=>{this.events.emit(`select-item`,{item:e.item}),n.button===b.Right&&t.metadata.type===`target`&&this.events.emit(`delete-item`,{target:t.metadata.target}),n.stopPropagation()}),t.events.on(`grab-changed`,({action:n})=>{n===`start`?(this.events.emit(`select-item`,{item:e.item}),this._grabbedManipulator=t):this._grabbedManipulator===t&&(this._grabbedManipulator=null,this.hideInteractionVisuals()),this._manipulatorByObject.set(e,t)}),t.events.on(`drag`,t=>{e.updateDragIntersection(t),t.action===`start`&&this.showInteractionVisuals(e)}),t.events.on(`location-update`,()=>this._syncInteractionVisuals()),this._createDragHandle(e,t)])}_createDragHandle(e,t){return x(t,(n,r,i,a)=>{let o=e.operations;if(o==null)return;let s=null,{cancelSnapping:c,snappingStep:l}=D({snappingContext:new E({editGeometryOperations:o,elevationInfo:e.elevationInfo,pointer:a,visualizer:new v}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!0});i.next(e=>(s?.undo(null),s=null,e)).next(c);let u=o.data.allVerticesUnordered.at(0);r.next(t=>(t.action===`start`&&(s=e.createUndoRecord()),{...t,snapOrigin:u?.pos})).next(S(this.view,t.elevationAlignedLocation)).next(y(this.view,o.data.geometry,e.elevationInfo,o.data.spatialReference)).next(C(this.view,e.elevationInfo)).next(...l).next(w(e)).next(e=>(e.action===`end`&&s!=null&&(this.events.emit(`record-undo`,{record:s}),s=null),e))})}_syncManipulators(){for(let[e,t]of this._manipulatorByObject)this._syncManipulator(e,t);this._syncInteractionVisuals()}_syncManipulator(e,t){let n=e.origin;if(t.available=this.visible&&e.visible&&n!=null,t.interactive=this.manipulatorsInteractive&&(this._grabbedManipulator==null||this._grabbedManipulator===t),n!=null&&(t.elevationAlignedLocation=n),e.item.type!==`target`)return;let r=this.analysisViewData.computations.find(t=>t.target===e.item),i=r==null||!r.computationResult.isValid?g.undefined:r.computationResult.isTargetVisible?g.visible:g.occluded;t.state=this.interacting&&t.selected?_(i):i}_syncInteractionVisuals(){let e=this._interactionVisuals,t=this._visualsManipulator,n=this.visible&&this.analysisViewData.visible;if(e==null||t==null||!n){e?.hide();return}let r=[...this._manipulatorByObject.entries()].find(([e])=>e.item.type===`observer`)?.[1];if(r==null){e.hide();return}let i=t===r?null:f(r.renderLocation,t.renderLocation,k);e.update({target:t.renderLocation,lineVerticalPlaneSegment:i,visible:!0})}};e([c({constructOnly:!0})],j.prototype,`analysisViewData`,void 0),e([c({constructOnly:!0})],j.prototype,`snappingManager`,void 0),e([c({constructOnly:!0})],j.prototype,`view`,void 0),e([c({constructOnly:!0})],j.prototype,`tooltip`,void 0),e([c()],j.prototype,`automaticManipulatorSelection`,void 0),e([c()],j.prototype,`removeIncompleteOnCancel`,void 0),e([c()],j.prototype,`interacting`,void 0),e([c()],j.prototype,`manipulatorsInteractive`,void 0),e([c()],j.prototype,`_grabbedManipulator`,void 0),e([c()],j.prototype,`_manipulatorsToHide`,null),e([c()],j.prototype,`updating`,null),j=e([l(`esri.views.3d.analysis.LineOfSight.LineOfSightItemTool`)],j);export{j as LineOfSightItemTool};
@@ -14,6 +14,9 @@ import type { ViewshedPlacementOptions, ViewshedPlacementResult } from "./Viewsh
14
14
  * or to make existing viewsheds selectable and editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#interactive) property.
15
15
  * To select a viewshed, hover and click on its field-of-view manipulators.
16
16
  *
17
+ * Snapping, tooltips, display units, and input units used during interactive placement and editing are inherited from
18
+ * [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/).
19
+ *
17
20
  * The view for an analysis can be retrieved using [SceneView.whenAnalysisView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenAnalysisView)
18
21
  * similar to how layer views are retrieved for layers using [SceneView.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenLayerView).
19
22
  *
@@ -28,7 +28,8 @@ import type { VolumeMeasurementPlacementResult } from "./VolumeMeasurement/types
28
28
  * > **Things to consider:**
29
29
  * >
30
30
  * > - When using the "cut-fill" [VolumeMeasurementAnalysis.measureType](https://developers.arcgis.com/javascript/latest/references/core/analysis/VolumeMeasurementAnalysis/#measureType) in [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/VolumeMeasurementAnalysisView3D/#interactive) mode, hover over the shift manipulator, press `Tab` to activate the tooltip input mode, and enter the elevation of the target surface.
31
- * > - The cut-fill elevation tooltip is enabled by default and remains enabled independently of [ViewOptions.tooltips](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#tooltips). Support for this setting is planned for a future release.
31
+ * > - The cut-fill elevation tooltip remains enabled independently of [ViewOptions.tooltips](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#tooltips). Support for this setting is planned for a future release.
32
+ * > Its display and input units can still inherit [ViewOptions.displayUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#displayUnits) and [ViewOptions.inputUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#inputUnits).
32
33
  * > - Snapping is enabled by default. This can be temporarily disabled by holding the `CTRL` key.
33
34
  * > - Layer types currently supported for snapping are: [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), [GraphicsLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GraphicsLayer/) (except Mesh geometries),
34
35
  * > [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/), [WFSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/), [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/),
@@ -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}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Collection.js";import{EventEmitter as r}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{debounce as o}from"../../../../../core/promiseUtils.js";import{scale as s,zeroMeters as c}from"../../../../../core/quantity.js";import{watch as l,initial as u,syncAndInitial as d}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as m}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as ee}from"../../../../../core/support/UpdatingHandles.js";import te from"../../../../../geometry/Point.js";import{makeDehydratedPoint as h}from"../../../../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{orientation as _}from"../geometryUtils.js";import{manipulatedObjectGeometry as v,supportsElevationMode as y}from"../manipulatedObjectUtils.js";import{canMoveZOperations as b}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as x}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as S}from"../tooltipUtils3D.js";import{createVisualElements as C}from"../visualElementUtils.js";import{discRadius as ne}from"../manipulations/config.js";import{MoveManipulation as w}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as E}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as D}from"./isSupportedObject.js";import{OutlineVisualElement as O}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as k}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as A,resetManipulatedObjectMany as j}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as M}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as N}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import P from"../../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as F}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as I}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as L,enterInputModeIfAvailable as R}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as z}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as H}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as U}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as W}from"../../../../support/GeometryWorkerHandle.js";class G{constructor(e){this.objects=e,this.type=`move-start`}}class K{constructor(e,t,n){this.dx=e,this.dy=t,this.objects=n,this.type=`move`}}class q{constructor(e){this.objects=e,this.type=`move-stop`}}class J{constructor(e){this.objects=e,this.type=`hold`}}const Y=Symbol(`manipulators`),X=Symbol(`tooltips`),Z=Symbol(`move-manipulator-display`);let Q=class extends M{get _infos(){return Array.from(this._infosByType.values())}constructor(e){super(e),this._infosByType=new Map,this.events=new r,this.objects=new n,this.enableVisualElements=!0,this.enableZ=!0,this.manipulatorRadius=null,this.toolOptions=new P,this.type=`move-3d`,this._measurementWorker=new W({preloadGeodetic:!0}),this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new ee,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=o(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){let{view:e}=this;this.tooltip=L(()=>({view:e,options:this.toolOptions.tooltips})),this.addHandles(this._updatingHandles.addOnCollectionChange(()=>this.objects,e=>{e.removed.forEach(e=>this.removeHandles(e)),this._updateObjectInfos(e),this._setupObjectUpdateHandles(e.added),this._refreshManipulators(),this._connectTooltips()}));let t=this.objects.toArray();this._updateObjectInfos({added:t,removed:[]}),this._setupObjectUpdateHandles(t),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this.tooltip=a(this.tooltip),this._moveManipulation=a(this._moveManipulation),this._set(`view`,null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(e){if(this.destroyed||R(e,this.tooltip))return;let t=this.firstGrabbedManipulator;if(e.type===`hold`&&t!=null){let e=this._getActiveObjectInfos(this._infos,t).map(({object:e})=>e);this.events.emit(`hold`,new J(e))}return super.onInputEvent(e)}get updating(){return this._updatingHandles.updating||!!this.snappingManager?.updating}get _shouldShowMovePointTooltip(){let{objects:e}=this;if(e.length!==1)return!1;let t=v(e.at(0))?.type;return t===`point`||t===`mesh`}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:e,removed:t}){for(let t of e){if(D(t)!==0)continue;let e=new re(t);this._infosByType.set(t,e)}for(let e of t)this._infosByType.delete(e)}_setupObjectUpdateHandles(e){for(let t of e){let e=this._infosByType.get(t);this.addHandles(x(e.object),t),y(t)&&this.addHandles(l(()=>{let{mode:e,unit:n,offset:r}=t.elevationInfo;return[e,n,r]},()=>this._refreshManipulators()),t)}}_refreshManipulators(){if(this.removeHandles(Y),this.removeHandles(Z),this._moveManipulation=a(this._moveManipulation),this.manipulators.removeAll(),this._infosByType.size===0)return;let e=this._infos;this._createManipulators(e),this._createVisualElements(e),this._updateMoveManipulation(e)}_createManipulators(e){for(let t of e){let n=t.object;t.manipulationXY=new E({tool:this,view:this.view,object:n}),t.manipulationXY.forEachManipulator(e=>{this.addHandles([e.events.on(`immediate-click`,e=>{this.events.emit(`immediate-click`,{...e,object:n}),e.stopPropagation()}),e.events.on(`grab-changed`,({action:e})=>{e===`start`?this._showTooltip(0):this._hideTooltip(),this._updateMoveManipulatorDisplay()})],Y)}),this.addHandles(t.manipulationXY.createDragPipeline((t,n,r,i)=>this._buildDragEventPipeline(e,0,t,n,r,i)),Y)}this._createMoveManipulation(e)}_updateMoveManipulatorDisplay(){let e=this._infos.some(e=>e.manipulationXY?.grabbing);this._moveManipulation&&(this._moveManipulation.interactive=!e),this.removeHandles(Z),e&&this._moveManipulation&&this.addHandles(this._moveManipulation.hideManipulators(),Z)}_createMoveManipulation(e){let t=new w({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:this.manipulatorRadius??(e.length===1?w.radiusForSymbol(e[0].object.graphic?.symbol):ne)});this._moveManipulation=t,t.elevationInfo={mode:`absolute-height`,offset:0},t.forEachManipulator(e=>{this.addHandles(e.events.on(`immediate-click`,n=>{let r=this.objects.at(0);!t.zManipulation.hasManipulator(e)&&this.objects.length===1&&r&&this.events.emit(`immediate-click`,{...n,object:r}),n.stopPropagation()}),Y)});let n=e=>t=>{this.addHandles([t.events.on(`focus-changed`,({action:t})=>{t===`focus`?this._showTooltip(e):this._hideTooltip()}),t.events.on(`grab-changed`,()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=c)})],Y)};this._moveManipulation.xyManipulation.forEachManipulator(n(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(n(1)),this._moveManipulation.zManipulation.forEachManipulator(n(2));let r=()=>this._updateMoveManipulation(e);for(let t of e){this.addHandles([t.object.on(`committed`,r),this._updatingHandles.add(()=>t.object.visible,r)],Y);let n=Symbol();this.addHandles(this._updatingHandles.add(()=>t.object.isDraped,r=>{this._updateMoveManipulation(e),this.removeHandles(n),r&&this.addHandles(k({view:this.view,geometry:t.object.graphic?.geometry,elevationInfo:t.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(e)}),n)},u),Y),this.addHandles(i(()=>this.removeHandles(n)),Y)}let a=e[e.length-1];this.addHandles(a.object.on(`committed`,()=>this._updateMoveManipulationAngle(a)),Y);let{object:o}=a,{operations:s}=o;if(s){let n=o.graphic;this.addHandles(t.createDragPipeline((t,n,r,i,a)=>this._buildDragEventPipeline(e,t,n,r,i,a),o.elevationInfo,s.data.spatialReference,n),Y)}this._updateMoveManipulationAngle(a)}_createVisualElements(e){if(this.enableVisualElements)for(let t of e){let n=t.object,r=C({view:this.view,object:n,forEachManipulator:e=>{t.manipulationXY?.forEachManipulator(e),this._moveManipulation?.forEachManipulator(e)},onManipulatorsChanged:()=>i()});r!=null&&(t.geometryRepresentation=r.visualElement,t.geometryRepresentation instanceof O&&this.addHandles([t.geometryRepresentation.events.on(`attachment-origin-changed`,()=>{t.object.isDraped||this._updateMoveManipulation(e)}),this._updatingHandles.add(()=>t.object.isDraped,()=>this._updateMoveManipulation(e))],Y),this.addHandles(r,Y))}}_updateMoveManipulationAngle(e){this._moveManipulation&&(this._moveManipulation.angle=_(v(e.object)))}_updateMoveManipulation(e){let t=h(0,0,0,this.view.spatialReference),n=0,r=!1,i=this._moveManipulation;if(i){for(let i of e){if(!i.object.visible)continue;this.enableZ&&b(i.object.operations,i.object.elevationInfo)&&(r=!0);let e=i.geometryRepresentation instanceof O&&!i.object.isDraped?i.geometryRepresentation.attachmentOrigin:i.object.origin;if(e!=null){let{x:r,y:i,z:a}=e;t.x+=r,t.y+=i,a&&(t.z??=0,t.z+=a),n++}}n>0?(t.x/=n,t.y/=n,t.z??=0,t.z/=n,i.location=t,i.xyManipulation.available=!0,i.xyAxisManipulation.available=!0,i.zManipulation.available=r):i.available=!1}}_buildDragEventPipeline(e,t,n,r,i,a){let o=[],s=[],c=null,l=null,u=()=>{for(let e of o)e.dragging=!1;o.length=0,s.length=0,c=null,l=null,this._updateMoveManipulatorDisplay()};if(e.length===1&&t===0){let t=e[0].object;({steps:r,cancel:i}=this._buildSnappingPipelineSteps(t,t.elevationInfo,r,i,a))}return i=i.next(e=>l?.(e)).next(()=>(s.length&&this.events.emit(`move-stop`,new q(s)),this.destroyed||u(),null)),r=r.next(t=>{if(t.action===`start`){o.length=0,s.length=0;for(let t of this._getActiveObjectInfos(e,n))o.push(t),s.push(t.object),t.dragging=!0;if(s.length!==0&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),c=A(s),l=j(s),this._emitRecordUndo(),this.events.emit(`move-start`,new G(s)),this.destroyed))return null}return s.length===0?null:t}).next(e=>c?.(e)).next(e=>(this._updateMoveTooltip(t,e),e)).next(e=>{switch(e.action){case`start`:case`update`:if(e.translationX||e.translationY||e.translationZ){let t=this.view.toScreen(e.mapStart),n=this.view.toScreen(e.mapEnd);if(!t||!n)return null;let r=n.x-t.x,i=n.y-t.y;if(this.events.emit(`move`,new K(r,i,s)),this.destroyed)return null}break;case`end`:if(this.events.emit(`move-stop`,new q(s)),this.destroyed)return null;u()}return null}),{steps:r,cancel:i}}_getActiveObjectInfos(e,t){return e.filter(e=>!e.dragging&&(e.manipulationXY?.hasManipulator(t)||!e.manipulationXY?.grabbing))}_connectTooltips(){this.removeHandles(X);let e;if(this._shouldShowMovePointTooltip){let t=this.objects.at(0),{events:n}=this;this._movePointTooltipInfo??=new z({viewType:this.view.type,toolOptions:this.toolOptions});let r={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),n.emit(`move-start`,new G([t]))},onMove:()=>n.emit(`move`,new K(0,0,[t])),onMoveStop:()=>n.emit(`move-stop`,new q([t])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};e=S(this.tooltip,t,()=>({toolOptions:this.toolOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:r,onRecordUndo:e=>n.emit(`record-undo`,{updates:[e]})}))}else e=this._updatingHandles.add(()=>this.toolOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,e=>{this.tooltip.info=e},d);this.addHandles(e,X)}_showTooltip(e){this._shouldShowMovePointTooltip||this._updateMoveTooltip(e)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(e,t){if(this._shouldShowMovePointTooltip)return;let{toolOptions:n}=this;switch(e){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new B({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,(e,t)=>this._measurementWorker.autoDistance2DBetweenPoints($(e),$(t))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new V({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,async(e,n)=>s(await this._measurementWorker.autoDistance2DBetweenPoints($(e),$(n)),T(t))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new H({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,U))}this._latestTooltipInfo.toolOptions=n}async _updateMoveTooltipDistanceAsync(e,t,n){if(t!=null&&t.action!==`end`){let{mapStart:r,mapEnd:i}=t;e.distance=await n(r,i)??c}else e.distance=c}_emitRecordUndo(){let e=this.objects.toArray().map(e=>e.createUndoRecord?.()).filter(t);e.length>0&&this.events.emit(`record-undo`,{updates:e})}_buildSnappingPipelineSteps(e,t,n,r,i){let a=v(e);if(a==null||a.type!==`point`&&a.type!==`mesh`)return{steps:n,cancel:r};let o=(a.type===`point`?a:a.origin).clone(),s=new F({elevationInfo:t,pointer:i,editGeometryOperations:N.fromGeometry(o,this.view.state.viewingMode),visualizer:new g,excludeFeature:e.graphic}),c=this.snappingManager,{snappingStep:l,cancelSnapping:u}=I({snappingContext:s,snappingManager:c,updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(u),n=n.next(e=>{let t=s.coordinateHelper.pointToVector(o);return{...e,snapOrigin:t}}).next(...l),{steps:n,cancel:r}}get test(){}};e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`view`,void 0),e([f()],Q.prototype,`objects`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableVisualElements`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableZ`,void 0),e([f({constructOnly:!0})],Q.prototype,`manipulatorRadius`,void 0),e([f({constructOnly:!0,type:P})],Q.prototype,`toolOptions`,void 0),e([f({constructOnly:!0})],Q.prototype,`snappingManager`,void 0),e([f()],Q.prototype,`type`,void 0),e([f()],Q.prototype,`updating`,null),e([f()],Q.prototype,`_latestTooltipInfo`,void 0),e([f()],Q.prototype,`_shouldShowMovePointTooltip`,null),e([f()],Q.prototype,`activeTooltipInfo`,null),Q=e([p(`esri.views.3d.interactive.editingTools.move.MoveTool3D`)],Q);const $=m(te);class re{constructor(e){this.object=e,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{J as HoldEvent,K as MoveEvent,G as MoveStartEvent,q as MoveStopEvent,Q as MoveTool3D};
2
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Collection.js";import{EventEmitter as r}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{debounce as o}from"../../../../../core/promiseUtils.js";import{scale as s,zeroMeters as c}from"../../../../../core/quantity.js";import{watch as l,initial as u,syncAndInitial as d}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{ensureType as m}from"../../../../../core/accessorSupport/ensureType.js";import{UpdatingHandles as ee}from"../../../../../core/support/UpdatingHandles.js";import te from"../../../../../geometry/Point.js";import{makeDehydratedPoint as h}from"../../../../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{orientation as _}from"../geometryUtils.js";import{manipulatedObjectGeometry as v,supportsElevationMode as y}from"../manipulatedObjectUtils.js";import{canMoveZOperations as b}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as x}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as S}from"../tooltipUtils3D.js";import{createVisualElements as C}from"../visualElementUtils.js";import{discRadius as ne}from"../manipulations/config.js";import{MoveManipulation as w}from"../manipulations/MoveManipulation.js";import{axisConstrainedDragSign as T}from"../manipulations/moveUtils.js";import{MoveXYObjectManipulation as E}from"../manipulations/MoveXYObjectManipulation.js";import{isSupportedObject as D}from"./isSupportedObject.js";import{OutlineVisualElement as O}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as k}from"../../../support/elevationUpdateUtils.js";import{dragManipulatedObjectMany as A,resetManipulatedObjectMany as j}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as M}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as N}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import P from"../../../../interactive/options/InteractiveToolOptions.js";import{SnappingContext as F}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as I}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as L,enterInputModeIfAvailable as R}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as z}from"../../../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateXYTooltipInfo as V}from"../../../../interactive/tooltip/infos/TranslateXYTooltipInfo.js";import{TranslateZTooltipInfo as H}from"../../../../interactive/tooltip/infos/TranslateZTooltipInfo.js";import{verticalSignedDistanceBetweenPoints as U}from"../../../../support/euclideanLengthMeasurementUtils.js";import{GeometryWorkerHandle as W}from"../../../../support/GeometryWorkerHandle.js";class G{constructor(e){this.objects=e,this.type=`move-start`}}class K{constructor(e,t,n){this.dx=e,this.dy=t,this.objects=n,this.type=`move`}}class q{constructor(e){this.objects=e,this.type=`move-stop`}}class J{constructor(e){this.objects=e,this.type=`hold`}}const Y=Symbol(`manipulators`),X=Symbol(`tooltips`),Z=Symbol(`move-manipulator-display`);let Q=class extends M{get _infos(){return Array.from(this._infosByType.values())}constructor(e){super(e),this._infosByType=new Map,this.events=new r,this.objects=new n,this.enableVisualElements=!0,this.enableZ=!0,this.manipulatorRadius=null,this.toolOptions=new P,this.type=`move-3d`,this._measurementWorker=new W({preloadGeodetic:!0}),this._ownedTooltip=null,this._latestTooltipInfo=null,this._translateTooltipInfo=null,this._translateXYTooltipInfo=null,this._translateZTooltipInfo=null,this._updatingHandles=new ee,this._moveManipulation=null,this._updateMoveTooltipDistanceDebounced=o(this._updateMoveTooltipDistanceAsync.bind(this))}initialize(){let{view:e}=this;this.tooltip??=this._ownedTooltip=L(()=>({view:e,options:this.toolOptions.tooltips})),this.addHandles(this._updatingHandles.addOnCollectionChange(()=>this.objects,e=>{e.removed.forEach(e=>this.removeHandles(e)),this._updateObjectInfos(e),this._setupObjectUpdateHandles(e.added),this._refreshManipulators(),this._connectTooltips()}));let t=this.objects.toArray();this._updateObjectInfos({added:t,removed:[]}),this._setupObjectUpdateHandles(t),this._refreshManipulators(),this._connectTooltips(),this.finishToolCreation()}destroy(){this._ownedTooltip=a(this._ownedTooltip),this._moveManipulation=a(this._moveManipulation),this._set(`view`,null),this._updatingHandles.destroy(),this._measurementWorker.destroy()}onInputEvent(e){if(this.destroyed||R(e,this.tooltip))return;let t=this.firstGrabbedManipulator;if(e.type===`hold`&&t!=null){let e=this._getActiveObjectInfos(this._infos,t).map(({object:e})=>e);this.events.emit(`hold`,new J(e))}return super.onInputEvent(e)}get updating(){return this._updatingHandles.updating||!!this.snappingManager?.updating}get _shouldShowMovePointTooltip(){let{objects:e}=this;if(e.length!==1)return!1;let t=v(e.at(0))?.type;return t===`point`||t===`mesh`}get activeTooltipInfo(){return this._shouldShowMovePointTooltip?this._movePointTooltipInfo:this._latestTooltipInfo}reset(){}_updateObjectInfos({added:e,removed:t}){for(let t of e){if(D(t)!==0)continue;let e=new re(t);this._infosByType.set(t,e)}for(let e of t)this._infosByType.delete(e)}_setupObjectUpdateHandles(e){for(let t of e){let e=this._infosByType.get(t);this.addHandles(x(e.object),t),y(t)&&this.addHandles(l(()=>{let{mode:e,unit:n,offset:r}=t.elevationInfo;return[e,n,r]},()=>this._refreshManipulators()),t)}}_refreshManipulators(){if(this.removeHandles(Y),this.removeHandles(Z),this._moveManipulation=a(this._moveManipulation),this.manipulators.removeAll(),this._infosByType.size===0)return;let e=this._infos;this._createManipulators(e),this._createVisualElements(e),this._updateMoveManipulation(e)}_createManipulators(e){for(let t of e){let n=t.object;t.manipulationXY=new E({tool:this,view:this.view,object:n}),t.manipulationXY.forEachManipulator(e=>{this.addHandles([e.events.on(`immediate-click`,e=>{this.events.emit(`immediate-click`,{...e,object:n}),e.stopPropagation()}),e.events.on(`grab-changed`,({action:e})=>{e===`start`?this._showTooltip(0):this._hideTooltip(),this._updateMoveManipulatorDisplay()})],Y)}),this.addHandles(t.manipulationXY.createDragPipeline((t,n,r,i)=>this._buildDragEventPipeline(e,0,t,n,r,i)),Y)}this._createMoveManipulation(e)}_updateMoveManipulatorDisplay(){let e=this._infos.some(e=>e.manipulationXY?.grabbing);this._moveManipulation&&(this._moveManipulation.interactive=!e),this.removeHandles(Z),e&&this._moveManipulation&&this.addHandles(this._moveManipulation.hideManipulators(),Z)}_createMoveManipulation(e){let t=new w({tool:this,view:this.view,snapToScene:!1,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:!0,radius:this.manipulatorRadius??(e.length===1?w.radiusForSymbol(e[0].object.graphic?.symbol):ne)});this._moveManipulation=t,t.elevationInfo={mode:`absolute-height`,offset:0},t.forEachManipulator(e=>{this.addHandles(e.events.on(`immediate-click`,n=>{let r=this.objects.at(0);!t.zManipulation.hasManipulator(e)&&this.objects.length===1&&r&&this.events.emit(`immediate-click`,{...n,object:r}),n.stopPropagation()}),Y)});let n=e=>t=>{this.addHandles([t.events.on(`focus-changed`,({action:t})=>{t===`focus`?this._showTooltip(e):this._hideTooltip()}),t.events.on(`grab-changed`,()=>{this._latestTooltipInfo&&(this._latestTooltipInfo.distance=c)})],Y)};this._moveManipulation.xyManipulation.forEachManipulator(n(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(n(1)),this._moveManipulation.zManipulation.forEachManipulator(n(2));let r=()=>this._updateMoveManipulation(e);for(let t of e){this.addHandles([t.object.on(`committed`,r),this._updatingHandles.add(()=>t.object.visible,r)],Y);let n=Symbol();this.addHandles(this._updatingHandles.add(()=>t.object.isDraped,r=>{this._updateMoveManipulation(e),this.removeHandles(n),r&&this.addHandles(k({view:this.view,geometry:t.object.graphic?.geometry,elevationInfo:t.object.elevationInfo,onElevationChanges:()=>this._updateMoveManipulation(e)}),n)},u),Y),this.addHandles(i(()=>this.removeHandles(n)),Y)}let a=e[e.length-1];this.addHandles(a.object.on(`committed`,()=>this._updateMoveManipulationAngle(a)),Y);let{object:o}=a,{operations:s}=o;if(s){let n=o.graphic;this.addHandles(t.createDragPipeline((t,n,r,i,a)=>this._buildDragEventPipeline(e,t,n,r,i,a),o.elevationInfo,s.data.spatialReference,n),Y)}this._updateMoveManipulationAngle(a)}_createVisualElements(e){if(this.enableVisualElements)for(let t of e){let n=t.object,r=C({view:this.view,object:n,forEachManipulator:e=>{t.manipulationXY?.forEachManipulator(e),this._moveManipulation?.forEachManipulator(e)},onManipulatorsChanged:()=>i()});r!=null&&(t.geometryRepresentation=r.visualElement,t.geometryRepresentation instanceof O&&this.addHandles([t.geometryRepresentation.events.on(`attachment-origin-changed`,()=>{t.object.isDraped||this._updateMoveManipulation(e)}),this._updatingHandles.add(()=>t.object.isDraped,()=>this._updateMoveManipulation(e))],Y),this.addHandles(r,Y))}}_updateMoveManipulationAngle(e){this._moveManipulation&&(this._moveManipulation.angle=_(v(e.object)))}_updateMoveManipulation(e){let t=h(0,0,0,this.view.spatialReference),n=0,r=!1,i=this._moveManipulation;if(i){for(let i of e){if(!i.object.visible)continue;this.enableZ&&b(i.object.operations,i.object.elevationInfo)&&(r=!0);let e=i.geometryRepresentation instanceof O&&!i.object.isDraped?i.geometryRepresentation.attachmentOrigin:i.object.origin;if(e!=null){let{x:r,y:i,z:a}=e;t.x+=r,t.y+=i,a&&(t.z??=0,t.z+=a),n++}}n>0?(t.x/=n,t.y/=n,t.z??=0,t.z/=n,i.location=t,i.xyManipulation.available=!0,i.xyAxisManipulation.available=!0,i.zManipulation.available=r):i.available=!1}}_buildDragEventPipeline(e,t,n,r,i,a){let o=[],s=[],c=null,l=null,u=()=>{for(let e of o)e.dragging=!1;o.length=0,s.length=0,c=null,l=null,this._updateMoveManipulatorDisplay()};if(e.length===1&&t===0){let t=e[0].object;({steps:r,cancel:i}=this._buildSnappingPipelineSteps(t,t.elevationInfo,r,i,a))}return i=i.next(e=>l?.(e)).next(()=>(s.length&&this.events.emit(`move-stop`,new q(s)),this.destroyed||u(),null)),r=r.next(t=>{if(t.action===`start`){o.length=0,s.length=0;for(let t of this._getActiveObjectInfos(e,n))o.push(t),s.push(t.object),t.dragging=!0;if(s.length!==0&&(this._moveManipulation&&(this._moveManipulation.interactive=!1),c=A(s),l=j(s),this._emitRecordUndo(),this.events.emit(`move-start`,new G(s)),this.destroyed))return null}return s.length===0?null:t}).next(e=>c?.(e)).next(e=>(this._updateMoveTooltip(t,e),e)).next(e=>{switch(e.action){case`start`:case`update`:if(e.translationX||e.translationY||e.translationZ){let t=this.view.toScreen(e.mapStart),n=this.view.toScreen(e.mapEnd);if(!t||!n)return null;let r=n.x-t.x,i=n.y-t.y;if(this.events.emit(`move`,new K(r,i,s)),this.destroyed)return null}break;case`end`:if(this.events.emit(`move-stop`,new q(s)),this.destroyed)return null;u()}return null}),{steps:r,cancel:i}}_getActiveObjectInfos(e,t){return e.filter(e=>!e.dragging&&(e.manipulationXY?.hasManipulator(t)||!e.manipulationXY?.grabbing))}_connectTooltips(){this.removeHandles(X);let e;if(this._shouldShowMovePointTooltip){let t=this.objects.at(0),{events:n}=this;this._movePointTooltipInfo??=new z({viewType:this.view.type,toolOptions:this.toolOptions});let r={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),n.emit(`move-start`,new G([t]))},onMove:()=>n.emit(`move`,new K(0,0,[t])),onMoveStop:()=>n.emit(`move-stop`,new q([t])),onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}};e=S(this.tooltip,t,()=>({toolOptions:this.toolOptions,activeTooltipInfo:this._movePointTooltipInfo,callbacks:r,onRecordUndo:e=>n.emit(`record-undo`,{updates:[e]})}))}else e=this._updatingHandles.add(()=>this.toolOptions.tooltips.effectiveEnabled?this._latestTooltipInfo:null,e=>{this.tooltip.info=e},d);this.addHandles(e,X)}_showTooltip(e){this._shouldShowMovePointTooltip||this._updateMoveTooltip(e)}_hideTooltip(){this._shouldShowMovePointTooltip||(this.tooltip?.clear(),this._latestTooltipInfo=null)}_updateMoveTooltip(e,t){if(this._shouldShowMovePointTooltip)return;let{toolOptions:n}=this;switch(e){case 0:this._latestTooltipInfo=this._translateTooltipInfo??=new B({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,(e,t)=>this._measurementWorker.autoDistance2DBetweenPoints($(e),$(t))));break;case 1:this._latestTooltipInfo=this._translateXYTooltipInfo??=new V({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,async(e,n)=>s(await this._measurementWorker.autoDistance2DBetweenPoints($(e),$(n)),T(t))));break;case 2:this._latestTooltipInfo=this._translateZTooltipInfo??=new H({toolOptions:n}),this._updatingHandles.consumePromise(this._updateMoveTooltipDistanceDebounced(this._latestTooltipInfo,t,U))}this._latestTooltipInfo.toolOptions=n}async _updateMoveTooltipDistanceAsync(e,t,n){if(t!=null&&t.action!==`end`){let{mapStart:r,mapEnd:i}=t;e.distance=await n(r,i)??c}else e.distance=c}_emitRecordUndo(){let e=this.objects.toArray().map(e=>e.createUndoRecord?.()).filter(t);e.length>0&&this.events.emit(`record-undo`,{updates:e})}_buildSnappingPipelineSteps(e,t,n,r,i){let a=v(e);if(a==null||a.type!==`point`&&a.type!==`mesh`)return{steps:n,cancel:r};let o=(a.type===`point`?a:a.origin).clone(),s=new F({elevationInfo:t,pointer:i,editGeometryOperations:N.fromGeometry(o,this.view.state.viewingMode),visualizer:new g,excludeFeature:e.graphic}),c=this.snappingManager,{snappingStep:l,cancelSnapping:u}=I({snappingContext:s,snappingManager:c,updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(u),n=n.next(e=>{let t=s.coordinateHelper.pointToVector(o);return{...e,snapOrigin:t}}).next(...l),{steps:n,cancel:r}}get test(){}};e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`view`,void 0),e([f()],Q.prototype,`objects`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableVisualElements`,void 0),e([f({constructOnly:!0,nonNullable:!0})],Q.prototype,`enableZ`,void 0),e([f({constructOnly:!0})],Q.prototype,`manipulatorRadius`,void 0),e([f({constructOnly:!0,type:P})],Q.prototype,`toolOptions`,void 0),e([f({constructOnly:!0})],Q.prototype,`snappingManager`,void 0),e([f()],Q.prototype,`type`,void 0),e([f()],Q.prototype,`updating`,null),e([f()],Q.prototype,`tooltip`,void 0),e([f()],Q.prototype,`_ownedTooltip`,void 0),e([f()],Q.prototype,`_latestTooltipInfo`,void 0),e([f()],Q.prototype,`_shouldShowMovePointTooltip`,null),e([f()],Q.prototype,`activeTooltipInfo`,null),Q=e([p(`esri.views.3d.interactive.editingTools.move.MoveTool3D`)],Q);const $=m(te);class re{constructor(e){this.object=e,this.geometryRepresentation=null,this.manipulationXY=null,this.dragging=!1}}export{J as HoldEvent,K as MoveEvent,G as MoveStartEvent,q as MoveStopEvent,Q as MoveTool3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../../../../core/has.js";import{estimateAttributesMemory as e}from"../../../../core/memoryEstimations.js";import{signal as t}from"../../../../core/signal.js";import{estimateGeometryMemory as n}from"../../../../layers/graphics/dehydratedFeatures.js";class r{constructor(){this._payloads=new Map,this._usedMemory=t(0),this._duplicatedMemory=t(0),this._referenceCount=t(0)}get usedMemory(){return this._usedMemory.value}get usedMemoryPerFeature(){return this._referenceCount.value>0?this._duplicatedMemory.value/this._referenceCount.value:0}ref(t){this._duplicatedMemory.value+=this._refPayload(t.geometry,n)+this._refPayload(t.attributes,e),this._referenceCount.value++}unref(e){this._duplicatedMemory.value-=this._unrefPayload(e.geometry)+this._unrefPayload(e.attributes),this._referenceCount.value--}_refPayload(e,t){if(e==null)return 0;let n=this._payloads.get(e);if(n)return n.count++,n.size;let r=t(e);return this._payloads.set(e,new i(r)),this._usedMemory.value+=r,r}_unrefPayload(e){if(e==null)return 0;let t=this._payloads.get(e);return--t.count===0&&(this._payloads.delete(e),this._usedMemory.value-=t.size),t.size}get test(){}}class i{constructor(e){this.size=e,this.count=1}}export{r as FeatureMemory};
2
+ import"../../../../core/has.js";import{getOrCreateMapValue as e}from"../../../../core/MapUtils.js";import{estimateAttributesMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{estimateGeometryMemory as r}from"../../../../layers/graphics/dehydratedFeatures.js";class i{constructor(e=()=>void 0){this._getGeometryKey=e,this._payloads=new Map,this._geometries=new Map,this._usedMemory=n(0),this._duplicatedMemory=n(0),this._referenceCount=n(0)}findGeometry(e,t){if(e===void 0)return;let n=this._geometries.get(e);if(n){for(let e of n)if(t(e))return e}}get usedMemory(){return this._usedMemory.value}get usedMemoryPerFeature(){return this._referenceCount.value>0?this._duplicatedMemory.value/this._referenceCount.value:0}ref(n,i,a=!0){let o;a&&n.geometry&&!this._payloads.has(n.geometry)&&(o=this._getGeometryKey(n.geometry,i),o!==void 0&&e(this._geometries,o,()=>new Set).add(n.geometry)),this._duplicatedMemory.value+=this._refPayload(n.geometry,r,o)+this._refPayload(n.attributes,t),this._referenceCount.value++}unref(e){let t=e.geometry,n=t&&this._payloads.get(t);if(t&&n?.count===1&&n.geometryKey!==void 0){let e=this._geometries.get(n.geometryKey);e.delete(t),e.size===0&&this._geometries.delete(n.geometryKey)}this._duplicatedMemory.value-=this._unrefPayload(e.geometry)+this._unrefPayload(e.attributes),this._referenceCount.value--}_refPayload(e,t,n){if(e==null)return 0;let r=this._payloads.get(e);if(r)return r.count++,r.size;let i=t(e);return this._payloads.set(e,new a(i,n)),this._usedMemory.value+=i,i}_unrefPayload(e){if(e==null)return 0;let t=this._payloads.get(e);return--t.count===0&&(this._payloads.delete(e),this._usedMemory.value-=t.size),t.size}get test(){}}class a{constructor(e,t){this.size=e,this.geometryKey=t,this.count=1}}export{i as FeatureMemory};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{shuffle as e}from"../../../../core/arrayUtils.js";import{baseObjectMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{create as r,diameter as i}from"../../../../geometry/support/aaBoundingBox.js";import{create as a,fromExtent as o,intersects as s,copy as c,positiveInfinity as l,intersection as u}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as d,estimateSize as f,getObjectId as p,computeAABB as m}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as h}from"../graphics/graphicUtils.js";import{SampledGeometryMaxDistanceRatio as g}from"./SampledGeometryMaxDistanceRatio.js";class _{constructor(e,t){this.descriptor=e,this._memory=t,this._numVertices=0,this.exceededTransferLimit=n(!1),this._fetchFailed=n(!1),this._sorted=!1,this._numFeatures=n(v),this._emptyFeatureRatio=n(0),this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=n(0),this._featureLimit=n(0),this._fetchStatus=0,this.fetchInformation=n(``),this.fetchingResolution=this.displayingResolution=e.resolution}get featuresMissing(){return this.fetchFailed||(this.hasPreciseFeatureCount?this._featuresLength.value<this.numFeatures:this.exceededTransferLimit.value)}get showsAllFeatures(){return!this.fetchFailed&&this.displayingFeatures!=null&&(this.hasPreciseFeatureCount?this.displayingFeatures.length===this.numFeatures:!this.exceededTransferLimit.value)}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(e){this._fetchFailed.value=e}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(e){this._displayingFeatures=e,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){let e=this.isFetched&&this.featuresMissing;return!this.filtered&&(e||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(e){this._featureLimit.value=e}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get availableFields(){return this._availableFields}setFeatures(e,t,n,r){this._replaceFeatures(e),this._availableFields=n,this._featuresLength.value=e?.length??0,this._sorted=!1,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._missingAttributes=r,e&&e.length>0?(this._emptyFeatureRatio.value=t/(e.length+t),this._numVertices=e.reduce((e,t)=>e+d(t.geometry),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){let e=this._features.reduce((e,{geometry:t})=>Math.max(e,h(t)??0),0);return Math.floor(e/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures.value:this._features?this._featuresLength.value:0}set numFeatures(e){this._numFeatures.value=e}get hasPreciseFeatureCount(){return this._numFeatures.value>v}get needsFeatureCount(){return this._numFeatures.value===v}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateEstimates(),this._estimatedSize}get sampledDensityEstimate(){return this._sampledDensityEstimate}updateEstimates(){if(this._estimatedSize<0||this._sampledDensityEstimate<0){this._estimatedSize=0,this._sampledDensityEstimate=0;let e=Math.floor(Math.sqrt(S));if(this._features){let t=null,n=new g(S,w*this.fetchingResolution),r=this._features.length;for(let i=0;i<r;++i){let a=this._features[i],o=f(a);if(this._estimatedSize+=o,!n.done){let o=r-i,s=Math.ceil(o/Math.max(1,Math.floor(Math.sqrt(n.numRemainingSamples))));if(i%s===0){let r=Math.max(Math.floor(n.numRemainingSamples/o),e);n.sampleGeometry(a.geometry,t,r)}}t=a.geometry}this._sampledDensityEstimate=n.numSamples>=C?n.ratio:0}return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=0}requestRefetch(){this._fetchStatus=1}startFetch(){this._fetchStatus=this.needsRefetch?3:2}fetchDone(e){this._fetchStatus=e}get isFetching(){return this._fetchStatus===2||this._fetchStatus===3}get isRefetching(){return this._fetchStatus===3}get needsFetch(){return this._fetchStatus===0||this._fetchStatus===1}get needsRefetch(){return this._fetchStatus===1}get isFetched(){return this._fetchStatus===4||this._fetchStatus===5}isFullyFetched(e){return!!this.features&&(this.features.length>=e||this.fetchStatus===5)}resetFetching(){this._fetchStatus=+!!this.isRefetching}get needsDisplayUpdate(){return!!this._features&&!x(this._features,this.displayingFeatures,this.featureLimit)}intersects(e){return e==null||!this.descriptor.extent||(o(e,T),s(this.descriptor.extent,T))}intersectionIncludingBorrowed(e,t){let n=this.extentIncludingBorrowedFeatures==null?this.descriptor.extent:this.extentIncludingBorrowedFeatures;return!e&&!n?(c(t,l),t):(e==null?c(t,n):(o(e,t),u(t,n,t)),t)}_shuffle(t){this._features?.sort((e,n)=>p(e,t)-p(n,t)),e(this._features,16438)}_sortBySize(e){this._features?.sort((t,n)=>i(m(n.geometry,E))-i(m(t.geometry,E))||p(t,e)-p(n,e))}reduceFeatures(e,t,n,r){if(e<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*e),this.featureLimit>this._features.length&&this._fetchStatus===4&&this._features.length>0&&(this._fetchStatus=1,i=!0),!this._sorted&&e<1&&(r===1?this._shuffle(n):this._sortBySize(n),this._sorted=!0);let a=Math.max(this.featureLimit,Math.ceil(t*this.numFeatures));if(this._features.length>a){for(let e=a;e<this._features.length;e++)this._memory.unref(this._features[e]);this._features.length=this._featuresLength.value=a,this._estimatedSize=-1,this.exceededTransferLimit.value=!1,this._fetchStatus===5&&(this._fetchStatus=4)}return i}get cache(){return new b(this,this._features,this._numFeatures.value,this._emptyFeatureRatio.value)}set cache(e){this._replaceFeatures(e.features),this.requestController=null,this._availableFields=e.availableFields,this._featuresLength.value=e.features?.length??0,this._numFeatures.value=e.numFeatures,this._emptyFeatureRatio.value=e.emptyFeatureRatio,this._fetchStatus=e.fetchStatus,this.exceededTransferLimit.value=e.exceededTransferLimit,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this.fetchInformation.value=e.fetchInformation}_replaceFeatures(e){for(let t of e??[])this._memory.ref(t);for(let e of this._features??[])this._memory.unref(e);this._features=e}}const v=-1,y=-2;class b{constructor(e,n,r,i){this.features=n,this.numFeatures=r,this.emptyFeatureRatio=i,this.usedMemory=t+e.estimatedSize,this.resolution=e.displayingResolution,this.availableFields=e.availableFields,this.fetchStatus=e.fetchStatus,this.exceededTransferLimit=e.exceededTransferLimit.value,this.fetchInformation=e.fetchInformation.value}}function x(e,t,n){if(t==null||e==null||n!==t.length||n>e.length)return!1;for(let r=0;r<n;++r)if(e[r]!==t[r])return!1;return!0}const S=150,C=100,w=2,T=a(),E=r();export{_ as FeatureTile,b as FeatureTileCacheItem,y as failedFeatureCount};
2
+ import{shuffle as e}from"../../../../core/arrayUtils.js";import{baseObjectMemory as t}from"../../../../core/memoryEstimations.js";import{signal as n}from"../../../../core/signal.js";import{create as r,diameter as i}from"../../../../geometry/support/aaBoundingBox.js";import{create as a,fromExtent as o,intersects as s,copy as c,positiveInfinity as l,intersection as u}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as d,estimateSize as f,getObjectId as p,computeAABB as m}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as h}from"../graphics/graphicUtils.js";import{SampledGeometryMaxDistanceRatio as g}from"./SampledGeometryMaxDistanceRatio.js";class _{constructor(e,t){this.descriptor=e,this._memory=t,this._numVertices=0,this.exceededTransferLimit=n(!1),this._fetchFailed=n(!1),this._sorted=!1,this._numFeatures=n(v),this._emptyFeatureRatio=n(0),this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=n(0),this._featureLimit=n(0),this._fetchStatus=0,this.fetchInformation=n(``),this.fetchingResolution=this.displayingResolution=e.resolution}get featuresMissing(){return this.fetchFailed||(this.hasPreciseFeatureCount?this._featuresLength.value<this.numFeatures:this.exceededTransferLimit.value)}get showsAllFeatures(){return!this.fetchFailed&&this.displayingFeatures!=null&&(this.hasPreciseFeatureCount?this.displayingFeatures.length===this.numFeatures:!this.exceededTransferLimit.value)}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(e){this._fetchFailed.value=e}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(e){this._displayingFeatures=e,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){let e=this.isFetched&&this.featuresMissing;return!this.filtered&&(e||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(e){this._featureLimit.value=e}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get availableFields(){return this._availableFields}setFeatures(e,t,n,r,i=this.fetchingResolution,a=!0){this._replaceFeatures(e,i,a),this._availableFields=n,this._featuresLength.value=e?.length??0,this._sorted=!1,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this._missingAttributes=r,e&&e.length>0?(this._emptyFeatureRatio.value=t/(e.length+t),this._numVertices=e.reduce((e,t)=>e+d(t.geometry),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){let e=this._features.reduce((e,{geometry:t})=>Math.max(e,h(t)??0),0);return Math.floor(e/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures.value:this._features?this._featuresLength.value:0}set numFeatures(e){this._numFeatures.value=e}get hasPreciseFeatureCount(){return this._numFeatures.value>v}get needsFeatureCount(){return this._numFeatures.value===v}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateEstimates(),this._estimatedSize}get sampledDensityEstimate(){return this._sampledDensityEstimate}updateEstimates(){if(this._estimatedSize<0||this._sampledDensityEstimate<0){this._estimatedSize=0,this._sampledDensityEstimate=0;let e=Math.floor(Math.sqrt(S));if(this._features){let t=null,n=new g(S,w*this.fetchingResolution),r=this._features.length;for(let i=0;i<r;++i){let a=this._features[i],o=f(a);if(this._estimatedSize+=o,!n.done){let o=r-i,s=Math.ceil(o/Math.max(1,Math.floor(Math.sqrt(n.numRemainingSamples))));if(i%s===0){let r=Math.max(Math.floor(n.numRemainingSamples/o),e);n.sampleGeometry(a.geometry,t,r)}}t=a.geometry}this._sampledDensityEstimate=n.numSamples>=C?n.ratio:0}return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=0}requestRefetch(){this._fetchStatus=1}startFetch(){this._fetchStatus=this.needsRefetch?3:2}fetchDone(e){this._fetchStatus=e}get isFetching(){return this._fetchStatus===2||this._fetchStatus===3}get isRefetching(){return this._fetchStatus===3}get needsFetch(){return this._fetchStatus===0||this._fetchStatus===1}get needsRefetch(){return this._fetchStatus===1}get isFetched(){return this._fetchStatus===4||this._fetchStatus===5}isFullyFetched(e){return!!this.features&&(this.features.length>=e||this.fetchStatus===5)}resetFetching(){this._fetchStatus=+!!this.isRefetching}get needsDisplayUpdate(){return!!this._features&&!x(this._features,this.displayingFeatures,this.featureLimit)}intersects(e){return e==null||!this.descriptor.extent||(o(e,T),s(this.descriptor.extent,T))}intersectionIncludingBorrowed(e,t){let n=this.extentIncludingBorrowedFeatures==null?this.descriptor.extent:this.extentIncludingBorrowedFeatures;return!e&&!n?(c(t,l),t):(e==null?c(t,n):(o(e,t),u(t,n,t)),t)}_shuffle(t){this._features?.sort((e,n)=>p(e,t)-p(n,t)),e(this._features,16438)}_sortBySize(e){this._features?.sort((t,n)=>i(m(n.geometry,E))-i(m(t.geometry,E))||p(t,e)-p(n,e))}reduceFeatures(e,t,n,r){if(e<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*e),this.featureLimit>this._features.length&&this._fetchStatus===4&&this._features.length>0&&(this._fetchStatus=1,i=!0),!this._sorted&&e<1&&(r===1?this._shuffle(n):this._sortBySize(n),this._sorted=!0);let a=Math.max(this.featureLimit,Math.ceil(t*this.numFeatures));if(this._features.length>a){for(let e=a;e<this._features.length;e++)this._memory.unref(this._features[e]);this._features.length=this._featuresLength.value=a,this._estimatedSize=-1,this.exceededTransferLimit.value=!1,this._fetchStatus===5&&(this._fetchStatus=4)}return i}get cache(){return new b(this,this._features,this._numFeatures.value,this._emptyFeatureRatio.value)}set cache(e){this._replaceFeatures(e.features,e.resolution),this.requestController=null,this._availableFields=e.availableFields,this._featuresLength.value=e.features?.length??0,this._numFeatures.value=e.numFeatures,this._emptyFeatureRatio.value=e.emptyFeatureRatio,this._fetchStatus=e.fetchStatus,this.exceededTransferLimit.value=e.exceededTransferLimit,this._estimatedSize=-1,this._sampledDensityEstimate=-1,this.fetchInformation.value=e.fetchInformation}_replaceFeatures(e,t,n=!0){for(let r of e??[])this._memory.ref(r,t,n);for(let e of this._features??[])this._memory.unref(e);this._features=e}}const v=-1,y=-2;class b{constructor(e,n,r,i){this.features=n,this.numFeatures=r,this.emptyFeatureRatio=i,this.usedMemory=t+e.estimatedSize,this.resolution=e.displayingResolution,this.availableFields=e.availableFields,this.fetchStatus=e.fetchStatus,this.exceededTransferLimit=e.exceededTransferLimit.value,this.fetchInformation=e.fetchInformation.value}}function x(e,t,n){if(t==null||e==null||n!==t.length||n>e.length)return!1;for(let r=0;r<n;++r)if(e[r]!==t[r])return!1;return!0}const S=150,C=100,w=2,T=a(),E=r();export{_ as FeatureTile,b as FeatureTileCacheItem,y as failedFeatureCount};
@@ -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{filterInPlace as n}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as o}from"../../../../core/promiseUtils.js";import s from"../../../../core/ReactiveMap.js";import{on as c,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as u}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as f}from"../../../../core/sql.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{getEpsilon as h}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as g,equals as _,clone as v,expand as y,toExtent as b,width as x,height as S}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as C,hasVertices as w,computeAABR as T}from"../../../../layers/graphics/dehydratedFeatures.js";import E from"../../../../rest/support/QuantizationParameters.js";import D from"../../../../rest/support/Query.js";import{FeatureMemory as O}from"./FeatureMemory.js";import{MultiFeatureReference as k,SingleFeatureReference as A}from"./featureReference.js";import{failedFeatureCount as j,FeatureTile as M}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as N,virtualSnapshotTileId as P}from"./FeatureTileDescriptor.js";import{tilesAreRelated as F}from"../../terrain/tileUtils.js";import{ImmediateTask as I,TaskPriority as L}from"../../../support/Scheduler.js";let R=class extends t{set maximumNumberOfFeatures(e){e||=1/0;let t=this._get(`maximumNumberOfFeatures`);e===t||e<1||(this._set(`maximumNumberOfFeatures`,e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set(`memoryFactor`,e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set(`lodFactor`,e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&this.context.query.queryFeatureCount!=null}set useTileCount(e){this._useTileCount=e,this.notifyChange(`useTileCount`)}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get usedMemory(){return this._memory.usedMemory}get usedMemoryPerFeature(){return this._memory.usedMemoryPerFeature}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(let e of this._featureTiles.values())if(!this.hasFullGeometries&&e.emptyFeatureRatio!==0||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){return!this._supportsResolution||this.tileDescriptors?.some(z)||!this.context.capabilities.supportsQuantization&&this.context.geometryType!==`polyline`}set filterExtent(e){if(e!=null&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference)){r.getLogger(this).error(`#filterExtent=`,`extent needs to be in the same spatial reference as the tiling scheme`);return}let t=this._get(`filterExtent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`filterExtent`,n),this._reclip(n,t)}_updateTileZQuantization(e){if(this.context.viewingMode===1){let t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:[],removes:[]},adds:[],removes:[]},this._featureTiles=new s,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._memory=new O,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this.snappingComplexityExceeded=!0,this._isFetching=!1;let t=e.context;this._frameTask=t.scheduler?.registerTask(L.FEATURE_TILE_FETCHER,this)??I,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?k:A,this._objectIdField=t.objectIdField}initialize(){this.addHandles([c(()=>this.tileDescriptors,`change`,()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),l(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){let e=this._featureTiles.get(N);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(let t of this._featureTiles.values()){let n=t.missingAttributes?.get(e);if(n!=null)return n}}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{t.displayingFeatures!=null&&t.displayingFeatures.length!==0&&(e==null?e=new Set(t.availableFields):e.forEach(n=>{t.availableFields?.has(n)||e.delete(n)}))}),e??new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());let t=this._pendingEdits;t.count++;let n=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e&&(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e))).then(e=>(--t.count===0&&(this._pendingEdits===t&&(this._pendingEdits=null),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=n,this._updated(),n}_applyEditsDeleteFeatures(e){if(e.length===0)return;let t=this.context.globalIdField,n=t&&this.availableFields.has(t),i=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:o})=>{(!e||e<0)&&t&&o&&(n||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(o,a,t)),e!=null&&e>=0&&i.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;let t=e.features.filter(e=>!i.has(C(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,n){if(e==null)return null;let r=this.features.find(t=>t.attributes?.[n]===e);return r?C(r,t):null}async _applyEditsAddUpdateFeatures(e,t,n){let{objectIdField:i,globalIdField:a}=this.context,o=a&&this.availableFields.has(a),s=new Set,c=new Set;for(let t of e){let e=t.objectId;e!=null&&s.add(e)}for(let{objectId:e,globalId:n}of t){let t=e;(t==null||t<0)&&a&&(o||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),t=this._objectIdFromGlobalId(n,i,a)),t!=null&&t>=0&&(s.add(t),c.add(t))}if(s.size===0)return;let l=[];this._featureTiles.forEach(e=>{let t=this._applyEditsAddUpdateTile(e,s,c,n);l.push(t)}),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,n,r){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;let i=this._createQuery(e);i.resultType=void 0,i.cacheHint=!1,i.objectIds=Array.from(t);let a=await this._queryFeatures(i,r),o=null;if(n.size>0){let t=e.features.filter(e=>!n.has(C(e,this._objectIdField)));t.length!==e.features.length&&(o=t)}if(a.features.length>0){o||=e.features.slice();for(let e of a.features)o.push(e)}o&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,o.length)),this._applyEditsTileUpdated(),e.setFeatures(o,0,G(e.availableFields,a.fields),K(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:Z})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){let t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;let n=this._featureTilesArray;if(this._markTilesNotAlive(n),!e.run(()=>this._addTiles(n,e))||!e.run(()=>this._filterExtentTiles(n,e))||!e.run(()=>this._removeTiles(n,e))||e.done){this._setDirty();return}let r=this._sortTiles(n);(!e.run(()=>this._showTiles(r,e))||!e.run(()=>this._fetchTiles(r,e))||!e.run(()=>this._updateMemoryEstimates(r,e)))&&this._setDirty(),this._updated(),this.updating||(this._updateMaximumNumberOfFeaturesExceeded(),this._updateSnappingComplexityExceeded(r))}_updateSnappingComplexityExceeded(e){let t=ee;for(let n of e){if(z(n)||t<=0)break;if(!B(n)&&(t--,n.sampledDensityEstimate>$)){this.snappingComplexityExceeded=!0;return}}this.snappingComplexityExceeded=this._featureTiles.size===0}_markTilesNotAlive(e){for(let t of e)t.alive=!1}_addTiles(e,t){return this._suspended||!this.tileDescriptors?!1:(this.tileDescriptors.forEach(n=>{let r=this._featureTiles.get(n.id);r?r.alive=!0:t.done||(e.push(this._addTile(n)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(let n of e){if(t.done)break;n.alive&&(n.filtered=!n.intersects(this.filterExtent),n.filtered&&(this._clearTile(n),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let n=e.length-1;n>=0&&!t.done;n--){let r=e[n];r.alive||(this._removeTile(r),n!==e.length-1&&(e[n]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){let n=this._updateRatio(e),r=e=>{let t=this._fullRatio<1?n(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();let{numFeatures:r,fetchingResolution:i,descriptor:a,isFetched:o}=e;return this._supportsResolution&&r>0&&i!==a.resolution&&o&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(let n of e)if(!t.run(()=>r(n))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let n=!1;for(let r of e){if(!r.needsFetch)continue;let e=this.context.memoryCache==null?null:this.context.memoryCache.pop(r.id);if(e?.resolution===r.displayingResolution){r.cache=e,r.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress();continue}if(this._needsNumFeatures(r)){let e=new AbortController,i=this._fetchTileCount(r,e.signal);this._handleRequest(r,i,e,()=>r.resetFetching(),()=>r.numFeatures=j),n=!0,t.madeProgress()}if(t.done)return!0}if(n)return t.hasProgressed;for(let n of e){if(!n.needsFetch)continue;let e=new AbortController,i=this._fetchTile(n,e.signal);if(this._handleRequest(n,i,e,e=>n.fetchDone(e),e=>{n.fetchFailed=!0,this.context.logFetchError(r.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;let n=[];this._featureTiles.forEach(r=>{r.displayingFeatures!=null&&r.displayingFeatures.length!==0&&(r.intersectionIncludingBorrowed(t,J),r.intersectionIncludingBorrowed(e,Y),_(J,Y)||n.push(r))}),this._refreshDisplayingFeatures(n),this._updated()}_refreshDisplayingFeatures(e){let t=new Set,n=this._changes.updates;for(let r of e)if(r.displayingFeatures!=null)for(let e of r.displayingFeatures){let r=C(e,this._objectIdField);if(t.has(r))continue;t.add(r);let i=this._displayingFeatureReferences.get(r).feature;n.removes.push(i),n.adds.push(i)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set(`dataUpdating`,!1),this.updating){let t=0,n=0,r=0,i=0,a=0,o=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++n,e.isFetching&&e.hasPreciseFeatureCount){let t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),n=e.displayingFeatures==null?0:e.displayingFeatures.length*o;a+=t-n}e.needsFetch?++i:e.numFeatures>0&&(++r,t+=e.numFeatures)}),i+=e;let s=0,c=0;t?(c=t,s=Math.min(i*t/r,t)):(c=n,s=i),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set(`updatingTotal`,c),this._set(`updatingRemaining`,s),this._set(`expectedFeatureDiff`,a)}else this._set(`updatingTotal`,0),this._set(`updatingRemaining`,0),this._set(`expectedFeatureDiff`,0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(let{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e){this._set(`maximumNumberOfFeaturesExceeded`,!0);return}this._set(`maximumNumberOfFeaturesExceeded`,!1)}_updateRatio(e){let t=H(e),n=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0])),r=0,i=0;for(let t of e){let e=t.numFeatures;r+=e,i+=e*n(t)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/r),this._farRatio=this.maximumNumberOfFeatures/i,this._scheduleUpdated(),n}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;let t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){let t=new M(e,this._memory);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){let t=e.displayingResolution;this._featureTiles.forEach(n=>{if(n.displayingFeatures!=null&&e!==n&&F(e.descriptor.lij,n.descriptor.lij)){e.displayingFeatures??=[],e.descriptor.extent&&n.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=v(e.descriptor.extent),y(e.extentIncludingBorrowedFeatures,n.descriptor.extent,e.extentIncludingBorrowedFeatures));for(let r of n.displayingFeatures){e.displayingFeatures.push(r),this._memory.ref(r);let n=this._displayingFeatureReferences.get(C(r,this._objectIdField));n.ref(this._memory,n.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(4):e.requestFetch()}_cancelFetchTile(e){let t=e.requestController;t!=null&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){e.fetchFailed=!1;let n=this._maximumFeaturesForTile(e);if(n<=0)return(!e.hasPreciseFeatureCount||e.numFeatures!==0)&&(e.fetchFailed=!0),U(e),e.fetchInformation.value=`Empty tile`,4;let r=this._getMaxRecordCount(e),i=Math.ceil(n/r);if(e.fetchingResolution=e.descriptor.resolution,V(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=n&&i>D.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);let a=this._createQuery(e);if(a.maxRecordCountFactor=i,e.isRefetching&&e.features&&e.features.length>0){let t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/r);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${n} features`;let{features:s,exceededTransferLimit:c,fields:l,missingAttributes:u}=await this._queryFeatures(a,t),d=c||a.maxRecordCountFactor>=D.MAX_MAX_RECORD_COUNT_FACTOR||n===this._totalFeaturesForTile(e)?5:4,f=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!c;let t=this._removeEmptyFeatures(s,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${s.length}/${n} features`,e.setFeatures(s,t,W(l),K(void 0,u)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>n?1:d},t);return o(t),this._invalidateCounts(),f}async _fetchPagedTile(e,t){let n=0,r=0,i,a=0,s=this._maximumFeaturesForTile(e)-a,c=this._getMaxRecordCount(e),l=null,u;for(;;){let d=this._createQuery(e),f=this._setPagingParameters(d,n,s,c);e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${s} features`;let{features:p,exceededTransferLimit:m,fields:h,missingAttributes:g}=await this._queryFeatures(d,t);if(await this._frameTask.schedule(()=>{f&&(n+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!m,i=i?.concat(p)??p,l=G(l,h),u=K(u,g),e.setFeatures(i,r,l,u),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),o(t),s=this._maximumFeaturesForTile(e)-(i?.length??0),!f||!m||s<=0)return m?4:5}}_createFeatureCountQuery(e){let t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){let t=this.context.createQuery();if(t.resultType=this._resultType(e),!V(e)&&e.descriptor.extent&&this.context.tilingScheme&&(t.geometry=b(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),t.resultType!==`tile`&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),B(e)){let{highlightIds:e}=this.context;e&&e.length>q&&r.getLogger(this).warn(`highlight-too-many-features`,`highlight is limited to ${q} features on large layers configured with a display filter to avoid performance issues`),t.objectIds=e?.slice(0,q)}else!z(e)&&this.context.effectiveDisplayFilter&&(t.where=f(t.where,this.context.effectiveDisplayFilter.where));return t}_setPagingParameters(e,t,n,r){return this.context.capabilities.supportsPagination?(e.start=t,n>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(n/r),e.num=Math.min(e.maxRecordCountFactor*r,n)):e.num=Math.min(r),!0):!1}_getEffectiveTileResolution(e){if(V(e)||!this._supportsResolution)return null;let t=this.context.viewingMode===1&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&this.context.geometryType!==`point`}_setResolutionParams(e,t){let n=this._getEffectiveTileResolution(t);n!=null&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new E({mode:`view`,originPosition:`upper-left`,tolerance:n,extent:this.context.fullExtent}):this.context.geometryType===`polyline`&&(e.maxAllowableOffset=n))}_removeEmptyFeatures(e,t){let r=e.length;if(t&&this._supportsResolution){let r=t*(1+h());n(e,({geometry:e})=>!e||!w(e)?!1:(T(e,X),x(X)>r||S(X)>r))}else n(e,({geometry:e})=>w(e));return r-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!z(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case`tile`:if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case`standard`:if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||q}_resultType(e){if(this.context.capabilities.supportsResultType)return z(e)?`standard`:`tile`}get _reduceMode(){let e=this.context.geometryType;return e===`polygon`||e===`polyline`?0:1}_handleRequest(e,t,n,r,i){e.startFetch(),e.requestController=n;let o=!1;t.then(t=>{e.requestController=null,r(t)}).catch(t=>{e.requestController===n&&(e.requestController=null,e.fetchDone(4)),a(t)?o=!0:i(t)}).then(()=>{o||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles(`scheduleUpdated`)||this.addHandles(u(()=>{this.removeHandles(`scheduleUpdated`),this._updated()}),`scheduleUpdated`)}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;let t=e.features;if(e.featureLimit===0||!t){let t=e.displayingFeatures!=null&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}let n=e.fetchingResolution,{adds:r,updates:i}=this._changes,a=Math.min(e.featureLimit,t.length);for(let e=0;e<a;++e){let a=t[e],o=C(a,this._objectIdField),s=this._displayingFeatureReferences.get(o);if(this._memory.ref(a),s){let{oldVersion:e,newVersion:t}=s.ref(this._memory,a,n);e!==t&&(e&&i.removes.push(e),t&&i.adds.push(t))}else this._displayingFeatureReferences.set(o,new this.FeatureReferenceClass(a,n,this._memory)),r.push(a);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(e.displayingFeatures==null)return;let{updates:t,removes:n}=this._changes;for(let r of e.displayingFeatures){this._memory.unref(r);let i=C(r,this._objectIdField),a=this._displayingFeatureReferences.get(i);if(!a)continue;let{oldVersion:o,newVersion:s}=a.unref(this._memory,e.displayingResolution);this._numDisplayingFeatureReferences--,o!==s&&(s==null?(this._displayingFeatureReferences.delete(i),o&&n.push(o)):(t.adds.push(s),o&&t.removes.push(o)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get(`dataUpdating`)||this._set(`dataUpdating`,!0)}_applyChanges(){let e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);let t=this._changes.adds,n=this._changes.removes,r=Math.min(t.length,n.length),i=0;for(;i<r;){let e=Math.min(i+Q,r);this._notifyDataUpdating(),this.features.addMany(t.slice(i,e)),this.features.removeMany(n.slice(i,e)),i=e}t.length>r&&(this._notifyDataUpdating(),this.features.addMany(i===0?t:t.slice(i))),n.length>r&&(this._notifyDataUpdating(),this.features.removeMany(i===0?n:n.slice(i))),t.length=0,n.length=0}_clearTile(e){this._hideTile(e),e.features&&this.context.memoryCache!=null&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange(`totalVertices`),this.notifyChange(`totalFeatures`)}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return this._featureTiles.values().reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){let t=this._totalFeaturesForTile(e),n=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*n/(1-e.emptyFeatureRatio)),t)}get test(){}};e([p({constructOnly:!0})],R.prototype,`features`,void 0),e([p({constructOnly:!0})],R.prototype,`context`,void 0),e([p()],R.prototype,`tileDescriptors`,void 0),e([p({value:1/0})],R.prototype,`maximumNumberOfFeatures`,null),e([p({value:1})],R.prototype,`memoryFactor`,null),e([p({value:1})],R.prototype,`lodFactor`,null),e([p()],R.prototype,`useTileCount`,null),e([p({readOnly:!0})],R.prototype,`updating`,null),e([p({readOnly:!0})],R.prototype,`dataUpdating`,void 0),e([p({readOnly:!0})],R.prototype,`updatingTotal`,void 0),e([p({readOnly:!0})],R.prototype,`updatingRemaining`,void 0),e([p({readOnly:!0})],R.prototype,`expectedFeatureDiff`,void 0),e([p()],R.prototype,`usedMemory`,null),e([p()],R.prototype,`usedMemoryPerFeature`,null),e([p({readOnly:!0})],R.prototype,`maximumNumberOfFeaturesExceeded`,void 0),e([p({readOnly:!0})],R.prototype,`totalVertices`,null),e([p({readOnly:!0})],R.prototype,`totalFeatures`,null),e([p({readOnly:!0})],R.prototype,`showsAllFeatures`,null),e([p({readOnly:!0})],R.prototype,`hasFullGeometries`,null),e([p()],R.prototype,`filterExtent`,null),e([p()],R.prototype,`_dirty`,void 0),e([p()],R.prototype,`_suspended`,void 0),e([p()],R.prototype,`_pendingEdits`,void 0),e([p()],R.prototype,`_applyEditsTilesUpdated`,void 0),e([p()],R.prototype,`_paused`,null),e([p()],R.prototype,`snappingComplexityExceeded`,void 0),e([p()],R.prototype,`_isFetching`,void 0),R=e([m(`esri.views.3d.layers.support.FeatureTileFetcher3D`)],R);function z(e){return e.id===P}function B(e){return e.id===N}function V(e){return z(e)||B(e)}function H(e){let t=0;for(let n of e)n.features&&n.features.length>0&&n.alive&&(t=Math.max(t,n.descriptor.lij[0]));return t}function U(e){e.setFeatures([],0,null,void 0)}function W(e){return e==null?new Set:new Set(e.map(e=>e.name))}function G(e,t){if(e==null||t==null)return W(t);let n=new Set;for(let{name:r}of t)e.has(r)&&n.add(r);return n}function K(e,t){if(!t?.length)return e;e??=new Map;let n=()=>new Set;for(let{objectId:r,attribute:a}of t)i(e,r,n).add(a);return e}const q=2e3,J=g(),Y=g(),X=g(),Z=6e5,Q=200,$=.95,ee=10;export{R as FeatureTileFetcher3D};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{filterInPlace as n}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as o}from"../../../../core/promiseUtils.js";import s from"../../../../core/ReactiveMap.js";import{on as c,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as u}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as f}from"../../../../core/sql.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{getEpsilon as h}from"../../../../core/libs/gl-matrix-2/math/common.js";import{create as g,equals as _,clone as v,expand as y,toExtent as b,width as x,height as S}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as C,hasVertices as w,computeAABR as T}from"../../../../layers/graphics/dehydratedFeatures.js";import{geometryKey as E,transferGeometryKey as D,identicalTransferGeometry as O,completeDehydratedFeatureFromTransfer as k}from"../../../../layers/graphics/transferFeatures.js";import A from"../../../../rest/support/QuantizationParameters.js";import j from"../../../../rest/support/Query.js";import{FeatureMemory as M}from"./FeatureMemory.js";import{MultiFeatureReference as ee,SingleFeatureReference as te}from"./featureReference.js";import{failedFeatureCount as N,FeatureTile as P}from"./FeatureTile.js";import{virtualDisplayFilterHighlightTileId as F,virtualSnapshotTileId as I}from"./FeatureTileDescriptor.js";import{tilesAreRelated as L}from"../../terrain/tileUtils.js";import{ImmediateTask as R,TaskPriority as z}from"../../../support/Scheduler.js";let B=class extends t{set maximumNumberOfFeatures(e){e||=1/0;let t=this._get(`maximumNumberOfFeatures`);e===t||e<1||(this._set(`maximumNumberOfFeatures`,e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set(`memoryFactor`,e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set(`lodFactor`,e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&this.context.query.queryFeatureCount!=null}set useTileCount(e){this._useTileCount=e,this.notifyChange(`useTileCount`)}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get readyToRun(){return this._dirty}get usedMemory(){return this._memory.usedMemory}get usedMemoryPerFeature(){return this._memory.usedMemoryPerFeature}get totalVertices(){let e=0;return this._featureTiles.forEach(t=>e+=t.numVertices),e}get totalFeatures(){let e=0;return this._featureTiles.forEach(t=>e+=t.numFeatures),e}get showsAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(let e of this._featureTiles.values())if(!this.hasFullGeometries&&e.emptyFeatureRatio!==0||!e.showsAllFeatures)return!1;return!0}get hasFullGeometries(){return!this._supportsResolution||this.tileDescriptors?.some(V)||!this.context.capabilities.supportsQuantization&&this.context.geometryType!==`polyline`}set filterExtent(e){if(e!=null&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference)){r.getLogger(this).error(`#filterExtent=`,`extent needs to be in the same spatial reference as the tiling scheme`);return}let t=this._get(`filterExtent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`filterExtent`,n),this._reclip(n,t)}_updateTileZQuantization(e){if(this.context.viewingMode===1){let t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:[],removes:[]},adds:[],removes:[]},this._featureTiles=new s,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._memory=new M(E),this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this.snappingComplexityExceeded=!0,this._isFetching=!1;let t=e.context;this._frameTask=t.scheduler?.registerTask(z.FEATURE_TILE_FETCHER,this)??R,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?ee:te,this._objectIdField=t.objectIdField}initialize(){this.addHandles([c(()=>this.tileDescriptors,`change`,()=>this._setDirty(),{onListenerAdd:()=>this._setDirty(),onListenerRemove:()=>this._setDirty()}),l(()=>this._tileZQuantization,()=>this.refetch())]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._removeTile(e)}),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach(e=>{this._cancelFetchTile(e),this._resetFetchTile(e)}),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._setDirty()}refetchDisplayFilterHighlightTile(){let e=this._featureTiles.get(F);e&&(this._cancelFetchTile(e),this._resetFetchTile(e),this._setDirty())}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(let t of this._featureTiles.values()){let n=t.missingAttributes?.get(e);if(n!=null)return n}}_pause(){this._paused&&(this._featureTiles.forEach(e=>this._cancelFetchTile(e)),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach(t=>{t.displayingFeatures!=null&&t.displayingFeatures.length!==0&&(e==null?e=new Set(t.availableFields):e.forEach(n=>{t.availableFields?.has(n)||e.delete(n)}))}),e??new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());let t=this._pendingEdits;t.count++;let n=t.edits.then(()=>e.result.catch(e=>{if(a(e))throw e;return null}).then(e=>e&&(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then(()=>e))).then(e=>(--t.count===0&&(this._pendingEdits===t&&(this._pendingEdits=null),this.context.memoryCache!=null&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)));return t.edits=n,this._updated(),n}_applyEditsDeleteFeatures(e){if(e.length===0)return;let t=this.context.globalIdField,n=t&&this.availableFields.has(t),i=new Set,a=this._objectIdField;e.forEach(({objectId:e,globalId:o})=>{(!e||e<0)&&t&&o&&(n||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(o,a,t)),e!=null&&e>=0&&i.add(e)}),this._featureTiles.forEach(e=>{if(!e.features)return;let t=e.features.filter(e=>!i.has(C(e,this._objectIdField)));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())})}_objectIdFromGlobalId(e,t,n){if(e==null)return null;let r=this.features.find(t=>t.attributes?.[n]===e);return r?C(r,t):null}async _applyEditsAddUpdateFeatures(e,t,n){let{objectIdField:i,globalIdField:a}=this.context,o=a&&this.availableFields.has(a),s=new Set,c=new Set;for(let t of e){let e=t.objectId;e!=null&&s.add(e)}for(let{objectId:e,globalId:n}of t){let t=e;(t==null||t<0)&&a&&(o||r.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),t=this._objectIdFromGlobalId(n,i,a)),t!=null&&t>=0&&(s.add(t),c.add(t))}if(s.size===0)return;let l=[];this._featureTiles.forEach(e=>{let t=this._applyEditsAddUpdateTile(e,s,c,n);l.push(t)}),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,n,r){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;let i=this._createQuery(e);i.resultType=void 0,i.cacheHint=!1,i.objectIds=Array.from(t);let a=await this.context.query.queryFeaturesDehydrated(i,{signal:r,timeout:$}),o=null;if(n.size>0){let t=e.features.filter(e=>!n.has(C(e,this._objectIdField)));t.length!==e.features.length&&(o=t)}if(a.features.length>0){o||=e.features.slice();for(let e of a.features)o.push(e)}o&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,o.length)),this._applyEditsTileUpdated(),e.setFeatures(o,0,q(e.availableFields,a.fields),J(e.missingAttributes,a.missingAttributes),void 0,!1),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t,n){return this.context.query.queryFeaturesDehydrated(e,{signal:n,timeout:$,completeFeatureFromTransfer:(e,n,r)=>{let i=D(e.geometry,n,t),a=this._memory.findGeometry(i,t=>O(e.geometry,n,t));a?e.geometry=a:k(e,n,r)}})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){let t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;let n=this._featureTilesArray;if(this._markTilesNotAlive(n),!e.run(()=>this._addTiles(n,e))||!e.run(()=>this._filterExtentTiles(n,e))||!e.run(()=>this._removeTiles(n,e))||e.done){this._setDirty();return}let r=this._sortTiles(n);(!e.run(()=>this._showTiles(r,e))||!e.run(()=>this._fetchTiles(r,e))||!e.run(()=>this._updateMemoryEstimates(r,e)))&&this._setDirty(),this._updated(),this.updating||(this._updateMaximumNumberOfFeaturesExceeded(),this._updateSnappingComplexityExceeded(r))}_updateSnappingComplexityExceeded(e){let t=ie;for(let n of e){if(V(n)||t<=0)break;if(!H(n)&&(t--,n.sampledDensityEstimate>re)){this.snappingComplexityExceeded=!0;return}}this.snappingComplexityExceeded=this._featureTiles.size===0}_markTilesNotAlive(e){for(let t of e)t.alive=!1}_addTiles(e,t){return this._suspended||!this.tileDescriptors?!1:(this.tileDescriptors.forEach(n=>{let r=this._featureTiles.get(n.id);r?r.alive=!0:t.done||(e.push(this._addTile(n)),t.madeProgress())}),t.hasProgressed)}_filterExtentTiles(e,t){for(let n of e){if(t.done)break;n.alive&&(n.filtered=!n.intersects(this.filterExtent),n.filtered&&(this._clearTile(n),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let n=e.length-1;n>=0&&!t.done;n--){let r=e[n];r.alive||(this._removeTile(r),n!==e.length-1&&(e[n]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority),e}_showTiles(e,t){let n=this._updateRatio(e),r=e=>{let t=this._fullRatio<1?n(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();let{numFeatures:r,fetchingResolution:i,descriptor:a,isFetched:o}=e;return this._supportsResolution&&r>0&&i!==a.resolution&&o&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(let n of e)if(!t.run(()=>r(n))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let n=!1;for(let r of e){if(!r.needsFetch)continue;let e=this.context.memoryCache==null?null:this.context.memoryCache.pop(r.id);if(e?.resolution===r.displayingResolution){r.cache=e,r.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress();continue}if(this._needsNumFeatures(r)){let e=new AbortController,i=this._fetchTileCount(r,e.signal);this._handleRequest(r,i,e,()=>r.resetFetching(),()=>r.numFeatures=N),n=!0,t.madeProgress()}if(t.done)return!0}if(n)return t.hasProgressed;for(let n of e){if(!n.needsFetch)continue;let e=new AbortController,i=this._fetchTile(n,e.signal);if(this._handleRequest(n,i,e,e=>n.fetchDone(e),e=>{n.fetchFailed=!0,this.context.logFetchError(r.getLogger(this),e)}),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some(e=>!t.run(()=>e.updateEstimates())&&(this._setDirty(),!0)),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;let n=[];this._featureTiles.forEach(r=>{r.displayingFeatures!=null&&r.displayingFeatures.length!==0&&(r.intersectionIncludingBorrowed(t,X),r.intersectionIncludingBorrowed(e,Z),_(X,Z)||n.push(r))}),this._refreshDisplayingFeatures(n),this._updated()}_refreshDisplayingFeatures(e){let t=new Set,n=this._changes.updates;for(let r of e)if(r.displayingFeatures!=null)for(let e of r.displayingFeatures){let r=C(e,this._objectIdField);if(t.has(r))continue;t.add(r);let i=this._displayingFeatureReferences.get(r).feature;n.removes.push(i),n.adds.push(i)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach(t=>t.isFetching?++e:0),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set(`dataUpdating`,!1),this.updating){let t=0,n=0,r=0,i=0,a=0,o=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach(e=>{if(++n,e.isFetching&&e.hasPreciseFeatureCount){let t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),n=e.displayingFeatures==null?0:e.displayingFeatures.length*o;a+=t-n}e.needsFetch?++i:e.numFeatures>0&&(++r,t+=e.numFeatures)}),i+=e;let s=0,c=0;t?(c=t,s=Math.min(i*t/r,t)):(c=n,s=i),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set(`updatingTotal`,c),this._set(`updatingRemaining`,s),this._set(`expectedFeatureDiff`,a)}else this._set(`updatingTotal`,0),this._set(`updatingRemaining`,0),this._set(`expectedFeatureDiff`,0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(let{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e){this._set(`maximumNumberOfFeaturesExceeded`,!0);return}this._set(`maximumNumberOfFeaturesExceeded`,!1)}_updateRatio(e){let t=W(e),n=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0])),r=0,i=0;for(let t of e){let e=t.numFeatures;r+=e,i+=e*n(t)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/r),this._farRatio=this.maximumNumberOfFeatures/i,this._scheduleUpdated(),n}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach(e=>{if(!e.featuresMissing)return;let t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))}),this._setDirty())}_addTile(e){let t=new P(e,this._memory);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){let t=e.displayingResolution;this._featureTiles.forEach(n=>{if(n.displayingFeatures!=null&&e!==n&&L(e.descriptor.lij,n.descriptor.lij)){e.displayingFeatures??=[],e.descriptor.extent&&n.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=v(e.descriptor.extent),y(e.extentIncludingBorrowedFeatures,n.descriptor.extent,e.extentIncludingBorrowedFeatures));for(let r of n.displayingFeatures){e.displayingFeatures.push(r),this._memory.ref(r);let n=this._displayingFeatureReferences.get(C(r,this._objectIdField));n.ref(this._memory,n.feature,t),this._numDisplayingFeatureReferences++}}})}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(4):e.requestFetch()}_cancelFetchTile(e){let t=e.requestController;t!=null&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t}),this._updateRatio(this._featureTilesArray)}async _fetchTile(e,t){e.fetchFailed=!1;let n=this._maximumFeaturesForTile(e);if(n<=0)return(!e.hasPreciseFeatureCount||e.numFeatures!==0)&&(e.fetchFailed=!0),G(e),e.fetchInformation.value=`Empty tile`,4;let r=this._getMaxRecordCount(e),i=Math.ceil(n/r);if(e.fetchingResolution=e.descriptor.resolution,U(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=n&&i>j.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);let a=this._createQuery(e);if(a.maxRecordCountFactor=i,e.isRefetching&&e.features&&e.features.length>0){let t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/r);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}e.fetchInformation.value=`Single fetch\n${n} features`;let{features:s,exceededTransferLimit:c,fields:l,missingAttributes:u}=await this._queryFeatures(a,e.fetchingResolution,t),d=c||a.maxRecordCountFactor>=j.MAX_MAX_RECORD_COUNT_FACTOR||n===this._totalFeaturesForTile(e)?5:4,f=await this._frameTask.schedule(()=>{e.exceededTransferLimit.value=!!c;let t=this._removeEmptyFeatures(s,this._getEffectiveTileResolution(e));return e.fetchInformation.value=`Single fetch\n${s.length}/${n} features`,e.setFeatures(s,t,K(l),J(void 0,u)),this._updateTileZQuantization(e),this._maximumFeaturesForTile(e)>n?1:d},t);return o(t),this._invalidateCounts(),f}async _fetchPagedTile(e,t){let n=0,r=0,i,a=0,s=this._maximumFeaturesForTile(e)-a,c=this._getMaxRecordCount(e),l=null,u;for(;;){let d=this._createQuery(e),f=this._setPagingParameters(d,n,s,c);e.fetchInformation.value=`Paged fetch\n${e.features?.length}/${s} features`;let{features:p,exceededTransferLimit:m,fields:h,missingAttributes:g}=await this._queryFeatures(d,e.fetchingResolution,t);if(await this._frameTask.schedule(()=>{f&&(n+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p,this._getEffectiveTileResolution(e)),e.exceededTransferLimit.value=!!m,i=i?.concat(p)??p,l=q(l,h),u=J(u,g),e.setFeatures(i,r,l,u),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()},t),o(t),s=this._maximumFeaturesForTile(e)-(i?.length??0),!f||!m||s<=0)return m?4:5}}_createFeatureCountQuery(e){let t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){let t=this.context.createQuery();if(t.resultType=this._resultType(e),!U(e)&&e.descriptor.extent&&this.context.tilingScheme&&(t.geometry=b(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),t.resultType!==`tile`&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),H(e)){let{highlightIds:e}=this.context;e&&e.length>Y&&r.getLogger(this).warn(`highlight-too-many-features`,`highlight is limited to ${Y} features on large layers configured with a display filter to avoid performance issues`),t.objectIds=e?.slice(0,Y)}else!V(e)&&this.context.effectiveDisplayFilter&&(t.where=f(t.where,this.context.effectiveDisplayFilter.where));return t}_setPagingParameters(e,t,n,r){return this.context.capabilities.supportsPagination?(e.start=t,n>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(n/r),e.num=Math.min(e.maxRecordCountFactor*r,n)):e.num=Math.min(r),!0):!1}_getEffectiveTileResolution(e){if(U(e)||!this._supportsResolution)return null;let t=this.context.viewingMode===1&&this.context.tilingScheme?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&this.context.geometryType!==`point`}_setResolutionParams(e,t){let n=this._getEffectiveTileResolution(t);n!=null&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new A({mode:`view`,originPosition:`upper-left`,tolerance:n,extent:this.context.fullExtent}):this.context.geometryType===`polyline`&&(e.maxAllowableOffset=n))}_removeEmptyFeatures(e,t){let r=e.length;if(t&&this._supportsResolution){let r=t*(1+h());n(e,({geometry:e})=>!e||!w(e)?!1:(T(e,Q),x(Q)>r||S(Q)>r))}else n(e,({geometry:e})=>w(e));return r-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!V(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case`tile`:if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case`standard`:if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||Y}_resultType(e){if(this.context.capabilities.supportsResultType)return V(e)?`standard`:`tile`}get _reduceMode(){let e=this.context.geometryType;return e===`polygon`||e===`polyline`?0:1}_handleRequest(e,t,n,r,i){e.startFetch(),e.requestController=n;let o=!1;t.then(t=>{e.requestController=null,r(t)}).catch(t=>{e.requestController===n&&(e.requestController=null,e.fetchDone(4)),a(t)?o=!0:i(t)}).then(()=>{o||this._setDirty(),this._scheduleUpdated()})}_scheduleUpdated(){this.hasHandles(`scheduleUpdated`)||this.addHandles(u(()=>{this.removeHandles(`scheduleUpdated`),this._updated()}),`scheduleUpdated`)}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;let t=e.features;if(e.featureLimit===0||!t){let t=e.displayingFeatures!=null&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}let n=e.fetchingResolution,{adds:r,updates:i}=this._changes,a=Math.min(e.featureLimit,t.length);for(let e=0;e<a;++e){let a=t[e],o=C(a,this._objectIdField),s=this._displayingFeatureReferences.get(o);if(this._memory.ref(a),s){let{oldVersion:e,newVersion:t}=s.ref(this._memory,a,n);e!==t&&(e&&i.removes.push(e),t&&i.adds.push(t))}else this._displayingFeatureReferences.set(o,new this.FeatureReferenceClass(a,n,this._memory)),r.push(a);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(e.displayingFeatures==null)return;let{updates:t,removes:n}=this._changes;for(let r of e.displayingFeatures){this._memory.unref(r);let i=C(r,this._objectIdField),a=this._displayingFeatureReferences.get(i);if(!a)continue;let{oldVersion:o,newVersion:s}=a.unref(this._memory,e.displayingResolution);this._numDisplayingFeatureReferences--,o!==s&&(s==null?(this._displayingFeatureReferences.delete(i),o&&n.push(o)):(t.adds.push(s),o&&t.removes.push(o)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get(`dataUpdating`)||this._set(`dataUpdating`,!0)}_applyChanges(){let e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);let t=this._changes.adds,n=this._changes.removes,r=Math.min(t.length,n.length),i=0;for(;i<r;){let e=Math.min(i+ne,r);this._notifyDataUpdating(),this.features.addMany(t.slice(i,e)),this.features.removeMany(n.slice(i,e)),i=e}t.length>r&&(this._notifyDataUpdating(),this.features.addMany(i===0?t:t.slice(i))),n.length>r&&(this._notifyDataUpdating(),this.features.removeMany(i===0?n:n.slice(i))),t.length=0,n.length=0}_clearTile(e){this._hideTile(e),e.features&&this.context.memoryCache!=null&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange(`totalVertices`),this.notifyChange(`totalFeatures`)}get _featureTilesArray(){return Array.from(this._featureTiles.values())}get featureTiles(){return this._featureTiles}get storedFeatures(){return this._featureTilesArray.reduce((e,t)=>e+(t.features?t.features.length:0),0)}get missingTiles(){return this._featureTiles.values().reduce((e,t)=>e+(t.needsFetch||t.isFetching?1:0),0)}_totalFeaturesForTile(e){return e.hasPreciseFeatureCount?e.numFeatures:this.maximumNumberOfFeatures}_maximumFeaturesForTile(e){let t=this._totalFeaturesForTile(e),n=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(t*n/(1-e.emptyFeatureRatio)),t)}get test(){}};e([p({constructOnly:!0})],B.prototype,`features`,void 0),e([p({constructOnly:!0})],B.prototype,`context`,void 0),e([p()],B.prototype,`tileDescriptors`,void 0),e([p({value:1/0})],B.prototype,`maximumNumberOfFeatures`,null),e([p({value:1})],B.prototype,`memoryFactor`,null),e([p({value:1})],B.prototype,`lodFactor`,null),e([p()],B.prototype,`useTileCount`,null),e([p({readOnly:!0})],B.prototype,`updating`,null),e([p({readOnly:!0})],B.prototype,`dataUpdating`,void 0),e([p({readOnly:!0})],B.prototype,`updatingTotal`,void 0),e([p({readOnly:!0})],B.prototype,`updatingRemaining`,void 0),e([p({readOnly:!0})],B.prototype,`expectedFeatureDiff`,void 0),e([p()],B.prototype,`usedMemory`,null),e([p()],B.prototype,`usedMemoryPerFeature`,null),e([p({readOnly:!0})],B.prototype,`maximumNumberOfFeaturesExceeded`,void 0),e([p({readOnly:!0})],B.prototype,`totalVertices`,null),e([p({readOnly:!0})],B.prototype,`totalFeatures`,null),e([p({readOnly:!0})],B.prototype,`showsAllFeatures`,null),e([p({readOnly:!0})],B.prototype,`hasFullGeometries`,null),e([p()],B.prototype,`filterExtent`,null),e([p()],B.prototype,`_dirty`,void 0),e([p()],B.prototype,`_suspended`,void 0),e([p()],B.prototype,`_pendingEdits`,void 0),e([p()],B.prototype,`_applyEditsTilesUpdated`,void 0),e([p()],B.prototype,`_paused`,null),e([p()],B.prototype,`snappingComplexityExceeded`,void 0),e([p()],B.prototype,`_isFetching`,void 0),B=e([m(`esri.views.3d.layers.support.FeatureTileFetcher3D`)],B);function V(e){return e.id===I}function H(e){return e.id===F}function U(e){return V(e)||H(e)}function W(e){let t=0;for(let n of e)n.features&&n.features.length>0&&n.alive&&(t=Math.max(t,n.descriptor.lij[0]));return t}function G(e){e.setFeatures([],0,null,void 0)}function K(e){return e==null?new Set:new Set(e.map(e=>e.name))}function q(e,t){if(e==null||t==null)return K(t);let n=new Set;for(let{name:r}of t)e.has(r)&&n.add(r);return n}function J(e,t){if(!t?.length)return e;e??=new Map;let n=()=>new Set;for(let{objectId:r,attribute:a}of t)i(e,r,n).add(a);return e}const Y=2e3,X=g(),Z=g(),Q=g(),$=6e5,ne=200,re=.95,ie=10;export{B as FeatureTileFetcher3D};
@@ -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 n from"../../../../core/Error.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,createAbortError as a}from"../../../../core/promiseUtils.js";import{difference as o}from"../../../../core/SetUtils.js";import{parseWhereClause as s}from"../../../../core/sql.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fromFeatureSetJSON as u}from"../../../../layers/graphics/dehydratedFeatures.js";import{canConvertSqlRelativeTime as d,sqlRelativeTimeToAbsolute as f}from"../../../../layers/support/relativeTimeQueryUtils.js";import{queueAutoPriority as p}from"../../../../request/queue.js";import{runQuery as m,executeQuery as h,executeQueryForCount as g}from"../../../../rest/query/operations/query.js";import{PBFDecoder as _}from"../../support/PBFDecoder.js";let v=class extends t{constructor(e){super(e)}get implicitFields(){if(!this.layer.outFields?.includes(`*`))return new Set;let e=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return o(t,e)}async queryFeaturesDehydrated(e,t){let{layer:n}=this,r=n.capabilities,o=r?.query?.supportsFormatPBF,c=n.parsedUrl,l=d(e.where)?await f(n.fieldsIndex,e.where,r.query.relativeTimeBinWindow):e.where,p=e.where;l!==e.where&&(e=e.clone(),e.where=l);let g;if(o){this._decoder??=new _(this.controller);let r={sourceSpatialReference:n.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S};g=await m(c,e,`pbf`,this._createRequestOptions(t)).then(e=>(i(t),this._decoder==null?Promise.reject(a()):this._decoder.invoke({buffer:e,options:r},t.signal)))}else g=await h(c,e,n.spatialReference,this._createRequestOptions(t)).then(e=>u(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S}));if(p&&e.where!==p){let e=await this.controller.schedule(()=>s(p,this.layer.fieldsIndex),t.signal);g.features=await this.controller.schedule(()=>g.features.filter(t=>e.testFeatureCompiled(t)),t.signal)}return g}queryFeatureCount(e,t){return g(this.layer.parsedUrl,e,this._createRequestOptions(t))}destroy(){this._decoder=r(this._decoder)}_createRequestOptions(e){return{...p,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([c({constructOnly:!0})],v.prototype,`layer`,void 0),e([c({constructOnly:!0})],v.prototype,`layerView`,void 0),e([c({constructOnly:!0})],v.prototype,`controller`,void 0),e([c({readOnly:!0})],v.prototype,`implicitFields`,null),v=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D`)],v);let y=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.queryFeatures(e,t)}};e([c({constructOnly:!0})],y.prototype,`layer`,void 0),y=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D`)],y);let b=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.source.queryFeaturesJSON(e,t).then(u,n=>{if(n&&n.name===`query-features-json:unsupported`)return this.layer.queryFeatures(e,t);throw n})}queryFeatureCount(e,t){return this.layer.queryFeatureCount(e,t)}};e([c({constructOnly:!0})],b.prototype,`layer`,void 0),b=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D`)],b);function x(e,t){let{layer:r}=e;switch(r.type){case`feature`:switch(r.source.type){case`feature-layer`:return new v({layer:r,layerView:e,controller:t});case`memory`:return new b({layer:r});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:case`ogc-feature`:case`parquet`:break;default:r.source.type}break;case`catalog-footprint`:return new v({layer:r,layerView:e,controller:t});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:return new b({layer:r});case`ogc-feature`:return new y({layer:r})}throw new n(`feature-layer:unsupported`,`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}const S=1024;export{x as createFeatureTileQuery3D};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import n from"../../../../core/Error.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,createAbortError as a}from"../../../../core/promiseUtils.js";import{difference as o}from"../../../../core/SetUtils.js";import{parseWhereClause as s}from"../../../../core/sql.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fromFeatureSetJSON as u}from"../../../../layers/graphics/dehydratedFeatures.js";import{canConvertSqlRelativeTime as d,sqlRelativeTimeToAbsolute as f}from"../../../../layers/support/relativeTimeQueryUtils.js";import{queueAutoPriority as p}from"../../../../request/queue.js";import{runQuery as m,executeQuery as h,executeQueryForCount as g}from"../../../../rest/query/operations/query.js";import{PBFDecoder as _}from"../../support/PBFDecoder.js";let v=class extends t{constructor(e){super(e)}get implicitFields(){if(!this.layer.outFields?.includes(`*`))return new Set;let e=new Set(this.layerView.requiredFields),t=new Set(this.layerView.availableFields);return o(t,e)}async queryFeaturesDehydrated(e,t){let{layer:n}=this,r=n.capabilities,o=r?.query?.supportsFormatPBF,c=n.parsedUrl,l=d(e.where)?await f(n.fieldsIndex,e.where,r.query.relativeTimeBinWindow):e.where,p=e.where;l!==e.where&&(e=e.clone(),e.where=l);let g;if(o){this._decoder??=new _(this.controller);let r={sourceSpatialReference:n.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S};g=await m(c,e,`pbf`,this._createRequestOptions(t)).then(e=>(i(t),this._decoder==null?Promise.reject(a()):this._decoder.invoke({buffer:e,options:r},t.completeFeatureFromTransfer,t.signal)))}else g=await h(c,e,n.spatialReference,this._createRequestOptions(t)).then(e=>u(e,{maxStringAttributeFields:this.implicitFields,maxStringAttributeLength:S}));if(p&&e.where!==p){let e=await this.controller.schedule(()=>s(p,this.layer.fieldsIndex),t.signal);g.features=await this.controller.schedule(()=>g.features.filter(t=>e.testFeatureCompiled(t)),t.signal)}return g}queryFeatureCount(e,t){return g(this.layer.parsedUrl,e,this._createRequestOptions(t))}destroy(){this._decoder=r(this._decoder)}_createRequestOptions(e){return{...p,...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([c({constructOnly:!0})],v.prototype,`layer`,void 0),e([c({constructOnly:!0})],v.prototype,`layerView`,void 0),e([c({constructOnly:!0})],v.prototype,`controller`,void 0),e([c({readOnly:!0})],v.prototype,`implicitFields`,null),v=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D`)],v);let y=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.queryFeatures(e,t)}};e([c({constructOnly:!0})],y.prototype,`layer`,void 0),y=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileOGCServiceQuery3D`)],y);let b=class extends t{constructor(e){super(e)}queryFeaturesDehydrated(e,t){return this.layer.source.queryFeaturesJSON(e,t).then(u,n=>{if(n&&n.name===`query-features-json:unsupported`)return this.layer.queryFeatures(e,t);throw n})}queryFeatureCount(e,t){return this.layer.queryFeatureCount(e,t)}};e([c({constructOnly:!0})],b.prototype,`layer`,void 0),b=e([l(`esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D`)],b);function x(e,t){let{layer:r}=e;switch(r.type){case`feature`:switch(r.source.type){case`feature-layer`:return new v({layer:r,layerView:e,controller:t});case`memory`:return new b({layer:r});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:case`ogc-feature`:case`parquet`:break;default:r.source.type}break;case`catalog-footprint`:return new v({layer:r,layerView:e,controller:t});case`csv`:case`geojson`:case`oriented-imagery`:case`wfs`:return new b({layer:r});case`ogc-feature`:return new y({layer:r})}throw new n(`feature-layer:unsupported`,`Unsupported Feature layer type ${e.layer.type}:${e.layer.source.type}`)}const S=1024;export{x as createFeatureTileQuery3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{generateUID as t}from"../../../core/uid.js";import{WorkerHandle as n}from"../../../core/workers/WorkerHandle.js";import r from"../../../geometry/SpatialReference.js";import{toDehydratedGeometry as i}from"../../../layers/graphics/transferFeatures.js";import a from"../../../layers/support/Field.js";class o{constructor(e){this._controller=e,this._abortController=new AbortController,this._handle=new s((t,n)=>e.schedule(t,n))}destroy(){this._abortController.abort(),this._handle.destroy()}async invoke(n,o){if(o=AbortSignal.any([o,this._abortController.signal]),e(o),!n.buffer||n.buffer.byteLength===0)return null;n.options.sourceSpatialReference&&n.options.sourceSpatialReference instanceof r&&(n.options={...n.options,sourceSpatialReference:n.options.sourceSpatialReference.toJSON()});let{featureSet:s,coordinates:c,queryGeometry:l,queryCoordinates:u}=await this._handle.invoke(n,o);return await this._controller.scheduleGenerator(function*(e){let n=r.fromJSON(s.spatialReference),o=[];for(let t=0;t<s.fields.length;++t)o.push(a.fromJSON(s.fields[t])),e.madeProgress()&&(e=yield);let d=s.features;for(let r=0;r<d.length;++r){let a=d[r];a.geometry=i(a.geometry,c[r],n),a.uid=t(),a.centroid&&(a.centroid.spatialReference=n),c[r]=null,e.madeProgress()&&(e=yield)}return Object.assign(s,{spatialReference:n,fields:o,queryGeometry:i(l,u,n)})},o)}}class s extends n{constructor(e){super(`PBFDecoderWorker`,`parseFeatureQuery`,{parseFeatureQuery:e=>[e.buffer]},e)}}export{o as PBFDecoder};
2
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{generateUID as t}from"../../../core/uid.js";import{WorkerHandle as n}from"../../../core/workers/WorkerHandle.js";import r from"../../../geometry/SpatialReference.js";import{completeDehydratedGeometryFromTransfer as i,completeDehydratedFeatureFromTransfer as a}from"../../../layers/graphics/transferFeatures.js";import o from"../../../layers/support/Field.js";class s{constructor(e){this._controller=e,this._abortController=new AbortController,this._handle=new c((t,n)=>e.schedule(t,n))}destroy(){this._abortController.abort(),this._handle.destroy()}async invoke(n,s,c){if(c=AbortSignal.any([c,this._abortController.signal]),e(c),!n.buffer||n.buffer.byteLength===0)return null;n.options.sourceSpatialReference&&n.options.sourceSpatialReference instanceof r&&(n.options={...n.options,sourceSpatialReference:n.options.sourceSpatialReference.toJSON()});let{featureSet:l,coordinates:u,queryGeometry:d,queryCoordinates:f}=await this._handle.invoke(n,c);return await this._controller.scheduleGenerator(function*(e){let n=r.fromJSON(l.spatialReference),c=[];for(let t=0;t<l.fields.length;++t)c.push(o.fromJSON(l.fields[t])),e.madeProgress()&&(e=yield);let p=l.features,m=[],h=s??a;for(let r=0;r<p.length;++r){let i=p[r],a=u[r];h(i,a,n),i.uid=t(),i.centroid&&(i.centroid.spatialReference=n),m.push(i),p[r]=null,u[r]=null,e.madeProgress()&&(e=yield)}return i(d,f,n),Object.assign(l,{spatialReference:n,fields:c,features:m,queryGeometry:d})},c)}}class c extends n{constructor(e){super(`PBFDecoderWorker`,`parseFeatureQuery`,{parseFeatureQuery:e=>[e.buffer]},e)}}export{s as PBFDecoder};
@@ -1,24 +1,29 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{BooleanBindUniform as e}from"../../shaderModules/BooleanBindUniform.js";import{glsl as t}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as n}from"../../shaderModules/Texture2DBindUniform.js";import{blurSizePixels as r}from"../../../effects/globalIllumination/GlobalIllumination.js";function i(i,a){a.receiveGlobalIllumination?(i.uniforms.add(new e(`hasGlobalIlluminationTexture`,e=>e.globalIllumination!=null),new n(`globalIlluminationTexture`,e=>e.globalIllumination?.getTexture())),i.constants.add(`blurSizePixelsInverse`,`float`,1/r),i.code.add(t`vec3 readGlobalIlluminationOcclusionInverse() {
2
+ import{BooleanBindUniform as e}from"../../shaderModules/BooleanBindUniform.js";import{glsl as t}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as n}from"../../shaderModules/Texture2DBindUniform.js";function r(r,i){i.receiveGlobalIllumination?(r.uniforms.add(new e(`hasGlobalIlluminationTexture`,e=>e.globalIllumination!=null),new n(`globalIlluminationTexture`,e=>e.globalIllumination?.getTexture())),r.constants.add(`globalIlluminationEmissionNoiseThreshold`,`float`,.01),r.code.add(t`vec3 readGlobalIlluminationOcclusionInverse() {
3
3
  if (!hasGlobalIlluminationTexture) {
4
4
  return vec3(1.0);
5
5
  }
6
- ivec2 texel = ivec2(gl_FragCoord.xy * blurSizePixelsInverse);
6
+ ivec2 texel = ivec2(gl_FragCoord.xy);
7
7
  return vec3(texelFetch(globalIlluminationTexture, texel, 0).a);
8
8
  }
9
9
  vec3 readGlobalIlluminationOcclusion() {
10
10
  return 1.0 - readGlobalIlluminationOcclusionInverse();
11
11
  }
12
- vec4 readGlobalIlluminationEmissionInverse() {
13
- if (!hasGlobalIlluminationTexture) {
14
- return vec4(1.0);
12
+ vec3 suppressBlackNoise(vec3 color) {
13
+ float peak = max(color.r, max(color.g, color.b));
14
+ if (peak <= globalIlluminationEmissionNoiseThreshold) {
15
+ return vec3(0.0);
15
16
  }
16
- ivec2 texel = ivec2(gl_FragCoord.xy * blurSizePixelsInverse);
17
- return 1.0 - vec4(texelFetch(globalIlluminationTexture, texel, 0).rgb, 0.0);
17
+ float correctedPeak = (peak - globalIlluminationEmissionNoiseThreshold) / (1.0 - globalIlluminationEmissionNoiseThreshold);
18
+ return color * (correctedPeak / peak);
18
19
  }
19
20
  vec4 readGlobalIlluminationEmission() {
20
- return max((1.0 - readGlobalIlluminationEmissionInverse() - 0.01) / 0.99, 0.0);
21
- }`)):i.code.add(t`vec3 readGlobalIlluminationOcclusionInverse() { return vec3(1.0); }
21
+ if (!hasGlobalIlluminationTexture) {
22
+ return vec4(0.0);
23
+ }
24
+ ivec2 texel = ivec2(gl_FragCoord.xy);
25
+ vec3 color = texelFetch(globalIlluminationTexture, texel, 0).rgb;
26
+ return vec4(suppressBlackNoise(color), 0.0);
27
+ }`)):r.code.add(t`vec3 readGlobalIlluminationOcclusionInverse() { return vec3(1.0); }
22
28
  vec3 readGlobalIlluminationOcclusion() { return vec3(0.0); }
23
- vec4 readGlobalIlluminationEmissionInverse() { return vec4(1.0); }
24
- vec4 readGlobalIlluminationEmission() { return vec4(0.0); }`)}export{i as ReadGlobalIllumination};
29
+ vec4 readGlobalIlluminationEmission() { return vec4(0.0); }`)}export{r as ReadGlobalIllumination};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{waitRender as i}from"../../../../../core/scheduling.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_W as s,ZEROS as c}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{AmbientIllumination as u}from"../AmbientIllumination.js";import{G as d}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as f}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as p}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as m}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as h}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as g}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as _}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as v,ColorAttachment1 as y}from"../../../../webgl/enums.js";const b=1;let x=class extends u{constructor(e){super(e),this._passParameters=new d,this._drawParameters=new f,this._drawParametersUpscale=new g,this._configuration=new h,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._lowQualityResolutionScale=.35,this._maxFrames=256}initialize(){this.addHandles(n(()=>this._mode,e=>{e===0?this._disable():this._enable()},r))}destroy(){this._lastOutput=t(this._lastOutput)}_disable(){super._disable(),this._resetAccumulation(),this._passParameters.temporalSampleFrame=0}get hasHighQuality(){return this._mode===2}resetAccumulation(){!this._isGlobalIlluminationUpdate&&(this._passParameters.accumulatedFrames>100||!this._configuration.hasEmission)&&this._resetAccumulation()}_resetAccumulation(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get isAccumulating(){return this.enabled&&this._passParameters.accumulatedFrames<this._maxFrames}precompile(){this.techniques.getCompiled(_)}render(e){let t=this.bindParameters.frameRendererTarget===1;if(this._passParameters.accumulatedFrames>=this._maxFrames&&!t)return this._lastOutput?.retain(),this._lastOutput;let n=e.find(({name:e})=>e===`normals`),r=n?.getTexture(),i=n?.getTexture(v);return!r||!i||this._mode===0?this._emptyOutput:(this._configuration.hasEmission=!!this.bindParameters.reprojection.lastFrameEmission,t?this._renderScreenshot(r,i):this._renderInteractive(r,i))}_renderScreenshot(e,t){let n=this._emptyOutput,r=this._passParameters.accumulatedFrames,i=this._passParameters.temporalSampleFrame;this._passParameters.accumulatedFrames=0,this._passParameters.temporalSampleFrame=0;let a=this.techniques.get(m,this._configuration),o=this.techniques.get(p);for(;this._passParameters.accumulatedFrames<this._maxFrames;){this._passParameters.globalIllumination=n.getTexture(),this._passParameters.globalIlluminationWeights=n.getTexture(y);let r=this._renderAccumulationFrame(e,t,a,o);++this._passParameters.accumulatedFrames,n.release(),n=r}return this._passParameters.globalIllumination=null,this._passParameters.globalIlluminationWeights=null,this._passParameters.accumulatedFrames=r,this._passParameters.temporalSampleFrame=i,n}_renderInteractive(e,t){if(!this._canRender)return this._requestRender(),this._emptyOutput;let n=this._mode===1?this._lowQualityResolutionScale:1,r=this.techniques.getCompiled(m,this._configuration),i=this.techniques.getCompiled(p),a=n<1,o=a?this.techniques.getCompiled(_):null;if(!r||!i||a&&!o)return this._requestRender(),this._emptyOutput;let s=this._renderAccumulationFrame(e,t,r,i,o,n);return++this._passParameters.accumulatedFrames,this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),this._storeOutput(s),s}_renderAccumulationFrame(e,t,n,r,i,a=1){let s=this.bindParameters,c=this.renderingContext,{camera:u}=s;this._passParameters.normalTexture=e,this._passParameters.depthTexture=t,this._passParameters.projScale=1/u.computeScreenPixelSizeAtDistance(1),this._passParameters.resolutionScale=a,this._passParameters.glowBoost=this._glowBoost;let{fullWidth:d,fullHeight:f}=u,p=Math.max(1,Math.floor(d*a)),m=Math.max(1,Math.floor(f*a)),h=this.fboCache.acquire(p,m,`global illumination input`).acquireColor(y,2);c.bindFramebuffer(h.fbo),c.setViewport(0,0,p,m),c.bindTechnique(n,s,this._passParameters,this._drawParameters),c.screen.draw();let g=Math.max(1,Math.round(p/1)),_=Math.max(1,Math.round(m/1)),v=this.fboCache.acquire(g,_,`global illumination blur horizontal`);c.bindFramebuffer(v.fbo);let b=h.obtainAttachment(y);this._drawParameters.texture=h.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,0,1/m),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),h.release();let x=this.fboCache.acquire(g,_,i?`global illumination blur vertical`:l.AMBIENT_ILLUMINATION);c.bindFramebuffer(x.fbo),c.setViewport(0,0,g,_),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParameters.texture=v.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,1/g,0),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),v.release(),x.attachColor(b,y),b.release();let S=x;return i&&(S=this.fboCache.acquire(d,f,l.AMBIENT_ILLUMINATION).acquireColor(y,2),c.bindFramebuffer(S.fbo),c.setViewport(0,0,d,f),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParametersUpscale.colorTexture=x.getTexture(),this._drawParametersUpscale.weightTexture=x.getTexture(y),c.bindTechnique(i,s,this._passParameters,this._drawParametersUpscale),c.screen.draw(),x.release()),c.setViewport4fv(u.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,S}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){let e=this.renderingContext,{fullWidth:t,fullHeight:n}=this.bindParameters.camera,r=this.fboCache.acquire(t,n,l.AMBIENT_ILLUMINATION).acquireColor(y,2);return e.bindFramebuffer(r.fbo),e.setViewport(0,0,t,n),e.clearBuffer(0,s),e.clearBuffer(1,c),r}get _canRender(){let{reprojection:e,hasEmission:t,globalIllumination:n}=this.bindParameters;return!!e.lastFrameColor&&(!t||!!e.lastFrameEmission)&&!!e.lastFrameDepth&&!!n}get _glowBoost(){let e=this.view.environment.lighting.glow;return e==null?0:2+3*e.intensity}get _mode(){return this._useGlobalIllumination?this.view.stage.renderer.isFeatureEnabled(10)?2:1:0}get test(){let e=this;return{get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},passParameters:this._passParameters,configuration:this._configuration,get mode(){return e._mode},async restartAccumulation(){e.produces!==`disabled`&&(e._disable(),await i(),e._enable())}}}};x=e([a(`esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination`)],x);export{x as GlobalIllumination,b as blurSizePixels};
2
+ import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{waitRender as i}from"../../../../../core/scheduling.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_W as s,ZEROS as c}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{AmbientIllumination as u}from"../AmbientIllumination.js";import{G as d}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as f}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as p}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as m}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as h}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as g}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as _}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as v,ColorAttachment1 as y}from"../../../../webgl/enums.js";let b=class extends u{constructor(e){super(e),this._passParameters=new d,this._drawParameters=new f,this._drawParametersUpscale=new g,this._configuration=new h,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._lowQualityResolutionScale=.35,this._maxFrames=256}initialize(){this.addHandles(n(()=>this._mode,e=>{e===0?this._disable():this._enable()},r))}destroy(){this._lastOutput=t(this._lastOutput)}_disable(){super._disable(),this._resetAccumulation(),this._passParameters.temporalSampleFrame=0}get hasHighQuality(){return this._mode===2}resetAccumulation(){!this._isGlobalIlluminationUpdate&&(this._passParameters.accumulatedFrames>100||!this._configuration.hasEmission)&&this._resetAccumulation()}_resetAccumulation(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get isAccumulating(){return this.enabled&&this._passParameters.accumulatedFrames<this._maxFrames}precompile(){this.techniques.getCompiled(_)}render(e){let t=this.bindParameters.frameRendererTarget===1;if(this._passParameters.accumulatedFrames>=this._maxFrames&&!t)return this._lastOutput?.retain(),this._lastOutput;let n=e.find(({name:e})=>e===`normals`),r=n?.getTexture(),i=n?.getTexture(v);return!r||!i||this._mode===0?this._emptyOutput:(this._configuration.hasEmission=!!this.bindParameters.reprojection.lastFrameEmission,t?this._renderScreenshot(r,i):this._renderInteractive(r,i))}_renderScreenshot(e,t){let n=this._emptyOutput,r=this._passParameters.accumulatedFrames,i=this._passParameters.temporalSampleFrame;this._passParameters.accumulatedFrames=0,this._passParameters.temporalSampleFrame=0;let a=this.techniques.get(m,this._configuration),o=this.techniques.get(p);for(;this._passParameters.accumulatedFrames<this._maxFrames;){this._passParameters.globalIllumination=n.getTexture(),this._passParameters.globalIlluminationWeights=n.getTexture(y);let r=this._renderAccumulationFrame(e,t,a,o);++this._passParameters.accumulatedFrames,n.release(),n=r}return this._passParameters.globalIllumination=null,this._passParameters.globalIlluminationWeights=null,this._passParameters.accumulatedFrames=r,this._passParameters.temporalSampleFrame=i,n}_renderInteractive(e,t){if(!this._canRender)return this._requestRender(),this._emptyOutput;let n=this._mode===1?this._lowQualityResolutionScale:1,r=this.techniques.getCompiled(m,this._configuration),i=this.techniques.getCompiled(p),a=n<1,o=a?this.techniques.getCompiled(_):null;if(!r||!i||a&&!o)return this._requestRender(),this._emptyOutput;let s=this._renderAccumulationFrame(e,t,r,i,o,n);return++this._passParameters.accumulatedFrames,this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),this._storeOutput(s),s}_renderAccumulationFrame(e,t,n,r,i,a=1){let s=this.bindParameters,c=this.renderingContext,{camera:u}=s;this._passParameters.normalTexture=e,this._passParameters.depthTexture=t,this._passParameters.projScale=1/u.computeScreenPixelSizeAtDistance(1),this._passParameters.resolutionScale=a,this._passParameters.glowBoost=this._glowBoost;let{fullWidth:d,fullHeight:f}=u,p=Math.max(1,Math.floor(d*a)),m=Math.max(1,Math.floor(f*a)),h=this.fboCache.acquire(p,m,`global illumination input`).acquireColor(y,2);c.bindFramebuffer(h.fbo),c.setViewport(0,0,p,m),c.bindTechnique(n,s,this._passParameters,this._drawParameters),c.screen.draw();let g=Math.max(1,Math.round(p)),_=Math.max(1,Math.round(m)),v=this.fboCache.acquire(g,_,`global illumination blur horizontal`);c.bindFramebuffer(v.fbo);let b=h.obtainAttachment(y);this._drawParameters.texture=h.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,0,1/m),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),h.release();let x=this.fboCache.acquire(g,_,i?`global illumination blur vertical`:l.AMBIENT_ILLUMINATION);c.bindFramebuffer(x.fbo),c.setViewport(0,0,g,_),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParameters.texture=v.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,1/g,0),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),v.release(),x.attachColor(b,y),b.release();let S=x;return i&&(S=this.fboCache.acquire(d,f,l.AMBIENT_ILLUMINATION).acquireColor(y,2),c.bindFramebuffer(S.fbo),c.setViewport(0,0,d,f),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParametersUpscale.colorTexture=x.getTexture(),this._drawParametersUpscale.weightTexture=x.getTexture(y),c.bindTechnique(i,s,this._passParameters,this._drawParametersUpscale),c.screen.draw(),x.release()),c.setViewport4fv(u.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,S}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){let e=this.renderingContext,{fullWidth:t,fullHeight:n}=this.bindParameters.camera,r=this.fboCache.acquire(t,n,l.AMBIENT_ILLUMINATION).acquireColor(y,2);return e.bindFramebuffer(r.fbo),e.setViewport(0,0,t,n),e.clearBuffer(0,s),e.clearBuffer(1,c),r}get _canRender(){let{reprojection:e,hasEmission:t,globalIllumination:n}=this.bindParameters;return!!e.lastFrameColor&&(!t||!!e.lastFrameEmission)&&!!e.lastFrameDepth&&!!n}get _glowBoost(){let e=this.view.environment.lighting.glow;return e==null?0:2+3*e.intensity}get _mode(){return this._useGlobalIllumination?this.view.stage.renderer.isFeatureEnabled(10)?2:1:0}get test(){let e=this;return{get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},passParameters:this._passParameters,configuration:this._configuration,get mode(){return e._mode},async restartAccumulation(){e.produces!==`disabled`&&(e._disable(),await i(),e._enable())}}}};b=e([a(`esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination`)],b);export{b as GlobalIllumination};
@@ -1,7 +1,7 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import{glsl as e}from"../../core/shaderModules/glsl.js";function t(t){t.code.add(e`
3
- vec3 quantizeGlobalIlluminationColor(vec3 color) {
4
- vec3 clampedColor = clamp(color, vec3(0.0), vec3(1.0));
3
+ vec4 quantizeGlobalIlluminationColor(vec4 color) {
4
+ vec4 clampedColor = clamp(color, vec4(0.0), vec4(1.0));
5
5
  return floor(clampedColor * ${e.float(255)} + 0.5) * ${e.float(1/255)};
6
6
  }
7
7
  `)}export{t as GlobalIlluminationColorQuantization};
@@ -300,16 +300,13 @@ export interface SceneViewProperties extends ViewProperties, DOMContainerPropert
300
300
  */
301
301
  floors?: ReadonlyArrayOrCollection<string>;
302
302
  /**
303
- * Configures snapping, tooltips, and measurement units for supported components and analyses configured to inherit these options from the view.
304
- *
305
- * Snapping is enabled by default. Tooltips are disabled by default.
303
+ * Configures snapping, tooltips, display units, and input units for supported components, view models, and analyses.
304
+ * See [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) for supported options, exceptions, and opt-in requirements.
306
305
  *
307
306
  * > [!IMPORTANT]
308
307
  * >
309
308
  * > These options are not saved in a [WebScene](https://developers.arcgis.com/javascript/latest/references/core/WebScene/).
310
309
  *
311
- * See [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) for details.
312
- *
313
310
  * @beta
314
311
  * @since 5.2
315
312
  */
@@ -1117,16 +1114,13 @@ export default class SceneView extends SceneViewSuperclass {
1117
1114
  */
1118
1115
  get groundView(): GroundView;
1119
1116
  /**
1120
- * Configures snapping, tooltips, and measurement units for supported components and analyses configured to inherit these options from the view.
1121
- *
1122
- * Snapping is enabled by default. Tooltips are disabled by default.
1117
+ * Configures snapping, tooltips, display units, and input units for supported components, view models, and analyses.
1118
+ * See [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) for supported options, exceptions, and opt-in requirements.
1123
1119
  *
1124
1120
  * > [!IMPORTANT]
1125
1121
  * >
1126
1122
  * > These options are not saved in a [WebScene](https://developers.arcgis.com/javascript/latest/references/core/WebScene/).
1127
1123
  *
1128
- * See [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) for details.
1129
- *
1130
1124
  * @beta
1131
1125
  * @since 5.2
1132
1126
  */