@arcgis/core 5.0.0-next.33 → 5.0.0-next.35

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 (220) hide show
  1. package/applications/Components/SketchTooltipControls.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f8a5b26e0231244972d8.js → 032444974011118127d7.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{9252854b512237b6a0ef.js → 0446562aee0639c61485.js} +1 -1
  5. package/assets/esri/core/workers/chunks/15c1a48e8cd2a8882d85.js +1 -0
  6. package/assets/esri/core/workers/chunks/{1dd867fa7c58c06b79ea.js → 1bacdd17e199e22b5cd1.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{b56c07c0b43cb1999070.js → 1fa55d4c4b092a98bdd7.js} +1 -1
  8. package/assets/esri/core/workers/chunks/234ffd08c2be03a0b9fe.js +1 -0
  9. package/assets/esri/core/workers/chunks/32d32d3c3b38a215d20d.js +1 -0
  10. package/assets/esri/core/workers/chunks/{e7f4d135ef9665de1468.js → 33431e8131f6017de2f9.js} +1 -1
  11. package/assets/esri/core/workers/chunks/36130910ba141f34531b.js +1 -0
  12. package/assets/esri/core/workers/chunks/{096e5f94eaa226814569.js → 4356274cfa477eb6d749.js} +1 -1
  13. package/assets/esri/core/workers/chunks/48d1a443b324753921de.js +1 -0
  14. package/assets/esri/core/workers/chunks/{3c1e50c3505e5e7c946a.js → 4d5591c1b4ef37075921.js} +1 -1
  15. package/assets/esri/core/workers/chunks/4f4d51181ae7db9fbe6d.js +1 -0
  16. package/assets/esri/core/workers/chunks/{d21ae4980741be98f948.js → 59889855d23baec1adf9.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{fee942ef802a162e0248.js → 5dc0d853c21ccb6054c7.js} +1 -1
  18. package/assets/esri/core/workers/chunks/5f9e64f00329cb646f0c.js +1 -0
  19. package/assets/esri/core/workers/chunks/{d786b17cc9062b1450ac.js → 726a797f5df7eeee0b3d.js} +1 -1
  20. package/assets/esri/core/workers/chunks/768d9b6eaba7bfa18dde.js +1 -0
  21. package/assets/esri/core/workers/chunks/{a4b7ba8aec109beb5b4d.js → 7d3e665613927904ba4f.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{a2cee5ac0d4df0108425.js → 82cc758bddd9f8397b9f.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{433d249c35c56bf15806.js → 97650ee3d0eecb69ccbb.js} +3 -3
  24. package/assets/esri/core/workers/chunks/{866a608d489bf56bc371.js → a372d9af43ade7c6314c.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{add17e95f47e6904bf6d.js → a59dab47a58695c639da.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{f441fc74451330384fb0.js → abb05a903440d97a6a74.js} +1 -1
  27. package/assets/esri/core/workers/chunks/ad138b989c2c7a1168ac.js +1 -0
  28. package/assets/esri/core/workers/chunks/{5baef729beef0199c3d9.js → b536fdb655ad293d9024.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{1d4ea8db272655c0608c.js → c7c721de93bc8688e13c.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{446f76356fc116204ec3.js → c8d2cce4a426c72ab173.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{14feb12826e0c8ba7fb8.js → d14bd320f72d8e8a0ad8.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{4b6a44c6265c8959abd8.js → d3db7244fac7398cc700.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{7aa730e5ac7b268e3c98.js → dd34d56caafa38d4b8e4.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ef5b13ee3362763c1096.js +1 -0
  35. package/assets/esri/core/workers/chunks/{2a17991923abc64c84c6.js → f55328aabf84770c8e6a.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{e32fc0b2c6530d28ce85.js → fa01d1813fa78034526e.js} +1 -1
  37. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  38. package/chunks/ComponentShader.glsl.js +19 -21
  39. package/chunks/Laserlines.glsl.js +1 -1
  40. package/chunks/Terrain.glsl.js +9 -11
  41. package/chunks/boundedPlane.js +1 -1
  42. package/chunks/cameraUtilsSpherical.js +1 -1
  43. package/chunks/lyr3DMain.js +1 -1
  44. package/chunks/vec32.js +1 -1
  45. package/config.js +1 -1
  46. package/core/deprecate.js +1 -1
  47. package/core/has.js +1 -1
  48. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  49. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  50. package/core/workers/registry.js +1 -1
  51. package/geometry/geometryEngineJSON.js +1 -1
  52. package/geometry/operators/integrateOperator.js +1 -1
  53. package/geometry/support/buffer/BufferView.js +1 -1
  54. package/geometry/support/coordsUtils.js +1 -1
  55. package/geometry/support/curves/curveUtils.js +1 -1
  56. package/geometry/support/curves/interpolateCurve.js +5 -0
  57. package/geometry/support/lineSegment.js +1 -1
  58. package/geometry/support/meshUtils/Metadata.js +1 -1
  59. package/geometry/support/meshUtils/merge.js +1 -1
  60. package/geometry/support/sphere.js +1 -1
  61. package/geometry/support/vector.js +1 -1
  62. package/interfaces.d.ts +71 -445
  63. package/intl/locale.js +1 -1
  64. package/kernel.js +1 -1
  65. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  66. package/layers/SceneLayer.js +1 -1
  67. package/layers/VoxelWasmPerSceneView.js +1 -1
  68. package/layers/graphics/data/QueryEngine.js +1 -1
  69. package/layers/graphics/data/QueryEngineResult.js +1 -1
  70. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  71. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  72. package/layers/support/layerOriginUtils.js +1 -1
  73. package/layers/voxel/VoxelVolume.js +1 -1
  74. package/package.json +3 -3
  75. package/request/config.js +1 -1
  76. package/request/process.js +1 -1
  77. package/smartMapping/statistics/support/statsWorker.js +1 -1
  78. package/support/revision.js +1 -1
  79. package/views/2d/interactive/SegmentLabels2D.js +5 -0
  80. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  81. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  82. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  83. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  84. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  85. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  86. package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
  87. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  88. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  89. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  90. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  91. package/views/3d/camera/constraintUtils/distance.js +1 -1
  92. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  93. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  94. package/views/3d/environment/CloudsParameters.js +1 -1
  95. package/views/3d/environment/EnvironmentManager.js +1 -1
  96. package/views/3d/environment/MarsAtmosphere.js +1 -1
  97. package/views/3d/interactive/SegmentLabels3D.js +1 -1
  98. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  99. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  100. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  101. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  102. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  103. package/views/3d/layers/I3SMeshView3D.js +1 -1
  104. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  105. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  106. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  107. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  108. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  109. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  110. package/views/3d/state/Frustum.js +1 -1
  111. package/views/3d/state/controllers/FovController.js +1 -1
  112. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  113. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  114. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  115. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  116. package/views/3d/support/cameraUtils.js +1 -1
  117. package/views/3d/support/intersectionUtils.js +1 -1
  118. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  119. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  120. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  121. package/views/3d/support/viewpointUtils.js +1 -1
  122. package/views/3d/terrain/OverlayManager.js +1 -1
  123. package/views/3d/terrain/PatchRenderData.js +1 -1
  124. package/views/3d/terrain/SphericalPatch.js +1 -1
  125. package/views/3d/terrain/Tile.js +1 -1
  126. package/views/3d/webgl/RenderCamera.js +1 -1
  127. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  128. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +63 -0
  129. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  130. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +5 -0
  131. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  132. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  133. package/views/3d/webgl-engine/collections/Component/Material/{shader/DecodeSymbolColor.glsl.js → DecodeSymbolColor.glsl.js} +1 -1
  134. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  135. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +8 -8
  136. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +7 -12
  137. package/views/3d/webgl-engine/core/shaderModules/Texture2DUintDrawUniform.js +5 -0
  138. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  139. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  140. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  141. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  143. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +1 -1
  144. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  145. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  146. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  147. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  148. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  149. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  150. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  151. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  152. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  153. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  154. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  155. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  157. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  158. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  159. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  160. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +18 -18
  161. package/views/Attribution.js +1 -1
  162. package/views/SelectionManager.js +1 -1
  163. package/views/draw/support/Reshape.js +1 -1
  164. package/views/interactive/GraphicManipulator.js +1 -1
  165. package/views/interactive/SegmentLabels.js +1 -1
  166. package/views/interactive/coordinateHelper.js +1 -1
  167. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  168. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  169. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  170. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  171. package/views/interactive/sketch/constraints.js +1 -1
  172. package/views/interactive/sketch/normalizedPoint.js +1 -1
  173. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  174. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  175. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  176. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  177. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  178. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  179. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  180. package/views/support/geometry3dUtils.js +1 -1
  181. package/views/support/selectionUtils.js +1 -1
  182. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  183. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  184. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  185. package/widgets/BuildingExplorer.js +1 -1
  186. package/widgets/Editor/EditorViewModel.js +1 -1
  187. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  188. package/widgets/Editor/Upload.js +1 -1
  189. package/widgets/Editor/components/Settings.js +1 -1
  190. package/widgets/Editor/support/SketchController.js +1 -1
  191. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  192. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  193. package/widgets/ShadowCast/DiscreteOptions.js +1 -1
  194. package/widgets/ShadowCast/DurationOptions.js +1 -1
  195. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  196. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  197. package/widgets/ShadowCast.js +1 -1
  198. package/widgets/Sketch/SketchViewModel.js +1 -1
  199. package/widgets/Sketch.js +1 -1
  200. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  201. package/widgets/support/SketchTooltipControls.js +1 -1
  202. package/assets/esri/core/workers/chunks/08957e462d06c4dc8ab5.js +0 -1
  203. package/assets/esri/core/workers/chunks/22d66d1c8dfccdbbcf30.js +0 -1
  204. package/assets/esri/core/workers/chunks/484cd728dd17b8dc1f72.js +0 -1
  205. package/assets/esri/core/workers/chunks/6c8f5a56e94fdbe6a4a5.js +0 -1
  206. package/assets/esri/core/workers/chunks/745fc2b89fd7d816f2e0.js +0 -1
  207. package/assets/esri/core/workers/chunks/79c7391f00a55e7bcf6b.js +0 -1
  208. package/assets/esri/core/workers/chunks/7f8b85de079614b9c336.js +0 -1
  209. package/assets/esri/core/workers/chunks/c2596f48b37092dd566c.js +0 -1
  210. package/assets/esri/core/workers/chunks/c6cc3db057da49755d15.js +0 -1
  211. package/assets/esri/core/workers/chunks/d6d03f22c91f528b97e5.js +0 -1
  212. package/assets/esri/core/workers/chunks/ea5bf896acfcc3106bf5.js +0 -1
  213. package/assets/esri/core/workers/chunks/f3127bdf28a1d9b8db27.js +0 -1
  214. package/chunks/geometryEngineJSON.js +0 -5
  215. package/geometry/geometryEngineAsync.d.ts +0 -39
  216. package/geometry/geometryEngineAsync.js +0 -5
  217. package/geometry/geometryEngineWorker.js +0 -5
  218. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +0 -57
  219. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentDataConstants.js +0 -5
  220. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{createArea as t}from"../../core/quantity.js";import{areaUnitFromSpatialReference as o}from"../../core/units.js";import{e as r}from"../../chunks/earcut.js";import{h as n,c as e,E as s}from"../../chunks/vec32.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as c}from"../../geometry/projection/projectVectorToVector.js";import{fromPoints as f,wrap as u,getNormal as l,projectPointLocal as m}from"../../geometry/support/plane.js";import{areaPoints2d as p}from"../../geometry/support/triangle.js";import{computeEuclideanMeasurementSR as a}from"./measurementUtils.js";function g(t,o=k()){return j(t,o)}function h(t,o=k()){return j(t,o,!1)}function j(r,g,h=r.hasZ){const j=a(r.spatialReference),k=o(j);if(null==k)return null;const x=(t,o)=>!(o.length<2)&&(n(t,o[0],o[1],h&&o[2]||0),!0);let C=0;for(const t of r.rings){const o=t.length;if(o<3)continue;const{positionsWorldCoords:a}=g;for(;a.length<o;)a.push(i());const h=y,k=n(d,0,0,0),R=1/o;for(let n=0;n<o;n++){if(!x(h,t[n]))return null;if(!c(h,r.spatialReference,a[n],j))return null;e(k,k,a[n],R)}const V=f(a[0],a[1],k,u());if(0===s(l(V)))continue;for(let t=0;t<o;t++)m(V,k,a[t],a[t]);const W=v(a);for(let t=0;t<W.length;t+=3)C+=p(a[W[t]],a[W[t+1]],a[W[t+2]])}return t(C,k)}const y=i(),d=i();function k(){return{positionsWorldCoords:[]}}function v(t){return r(x(t),[],2)}function x(t){const o=new Float64Array(2*t.length);for(let r=0;r<t.length;++r){const n=t[r],e=2*r;o[e]=n[0],o[e+1]=n[1]}return o}export{j as computeEuclideanPlanarArea,k as createEuclideanPlanarAreaCache,h as euclideanHorizontalPlanarArea,g as euclideanPlanarArea,v as triangulate};
5
+ import{createArea as t}from"../../core/quantity.js";import{areaUnitFromSpatialReference as o}from"../../core/units.js";import{e as r}from"../../chunks/earcut.js";import{h as n,c as e,F as s}from"../../chunks/vec32.js";import{create as i}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as c}from"../../geometry/projection/projectVectorToVector.js";import{fromPoints as f,wrap as u,getNormal as l,projectPointLocal as m}from"../../geometry/support/plane.js";import{areaPoints2d as p}from"../../geometry/support/triangle.js";import{computeEuclideanMeasurementSR as a}from"./measurementUtils.js";function g(t,o=k()){return j(t,o)}function h(t,o=k()){return j(t,o,!1)}function j(r,g,h=r.hasZ){const j=a(r.spatialReference),k=o(j);if(null==k)return null;const x=(t,o)=>!(o.length<2)&&(n(t,o[0],o[1],h&&o[2]||0),!0);let C=0;for(const t of r.rings){const o=t.length;if(o<3)continue;const{positionsWorldCoords:a}=g;for(;a.length<o;)a.push(i());const h=y,k=n(d,0,0,0),F=1/o;for(let n=0;n<o;n++){if(!x(h,t[n]))return null;if(!c(h,r.spatialReference,a[n],j))return null;e(k,k,a[n],F)}const R=f(a[0],a[1],k,u());if(0===s(l(R)))continue;for(let t=0;t<o;t++)m(R,k,a[t],a[t]);const V=v(a);for(let t=0;t<V.length;t+=3)C+=p(a[V[t]],a[V[t+1]],a[V[t+2]])}return t(C,k)}const y=i(),d=i();function k(){return{positionsWorldCoords:[]}}function v(t){return r(x(t),[],2)}function x(t){const o=new Float64Array(2*t.length);for(let r=0;r<t.length;++r){const n=t[r],e=2*r;o[e]=n[0],o[e+1]=n[1]}return o}export{j as computeEuclideanPlanarArea,k as createEuclideanPlanarAreaCache,h as euclideanHorizontalPlanarArea,g as euclideanPlanarArea,v as triangulate};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{createLength as n}from"../../core/quantity.js";import{verticalLengthUnitFromSpatialReference as t,lengthUnitFromSpatialReference as e}from"../../core/units.js";import{C as r,h as l}from"../../chunks/vec32.js";import{create as u}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as i}from"../../geometry/projection/projectVectorToVector.js";import{equals as o}from"../../geometry/support/spatialReferenceUtils.js";import{computeEuclideanMeasurementSR as c}from"./measurementUtils.js";function s(n){return f(n,0)}function a(n){return f(n,1)}function f(t,r){const{hasZ:l,spatialReference:u}=t,i=c(u);let o=0;const s=e(i);if(null==s)return null;const a=0===r?Z:j;for(const n of t.paths){if(n.length<2)continue;const t=n.length-1;for(let e=0;e<t;++e){const t=n[e];b[0]=t[0],b[1]=t[1],b[2]=l?t[2]:0;const r=n[e+1];S[0]=r[0],S[1]=r[1],S[2]=l?r[2]:0;const i=a(b,S,u);if(null==i)return null;o+=i.value}}return n(o,s)}function p(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,x(b,S,e)):null}function h(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,Z(b,S,e)):null}function m(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,j(b,S,e)):null}function z(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,d(b,S,e)):null}function y(n){return null!=n?R(n.hasZ?n.z:0,n.spatialReference):null}function R(e,r){const l=t(r);return null!=l?n(e??0,l):null}function x(t,e,r){const l=g(t,e,r);return null!=l?{direct:n(l.direct,l.unit),horizontal:n(l.horizontal,l.unit),vertical:n(l.vertical,l.unit)}:null}function Z(t,e,r){const l=g(t,e,r,0);return null!=l?n(l.direct,l.unit):null}function j(t,e,r){const l=g(t,e,r,1);return null!=l?n(l.horizontal,l.unit):null}function v(t,e,r){const l=g(t,e,r,2);return null!=l?n(Math.abs(l.verticalSigned),l.unit):null}function d(t,e,r){const l=g(t,e,r,2);return null!=l?n(l.verticalSigned,l.unit):null}function g(n,t,u,o){const s=c(u),a=e(s);if(null==a)return null;const f=t[2]-n[2];if(2===o)return{verticalSigned:f,unit:a};if(!i(n,u,M,s)||!i(t,u,U,s))return null;if(0===o){return{direct:r(U,M),unit:a}}if(l(V,n[0],n[1],t[2]),!i(V,u,V,s))return null;const p=r(V,U);if(1===o)return{horizontal:p,unit:a};return{direct:r(U,M),horizontal:p,vertical:Math.abs(f),unit:a}}const b=u(),S=u(),M=u(),U=u(),V=u();export{y as elevationFromPoint,R as elevationFromZ,Z as euclideanDirectDistance,h as euclideanDirectDistanceBetweenPoints,x as euclideanDistance,p as euclideanDistanceBetweenPoints,j as euclideanHorizontalDistance,m as euclideanHorizontalDistanceBetweenPoints,a as euclideanHorizontalLength,s as euclideanLength,v as verticalDistance,d as verticalSignedDistance,z as verticalSignedDistanceBetweenPoints};
5
+ import{createLength as n}from"../../core/quantity.js";import{verticalLengthUnitFromSpatialReference as t,lengthUnitFromSpatialReference as e}from"../../core/units.js";import{D as r,h as l}from"../../chunks/vec32.js";import{create as u}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectVectorToVector as i}from"../../geometry/projection/projectVectorToVector.js";import{equals as o}from"../../geometry/support/spatialReferenceUtils.js";import{computeEuclideanMeasurementSR as c}from"./measurementUtils.js";function s(n){return f(n,0)}function a(n){return f(n,1)}function f(t,r){const{hasZ:l,spatialReference:u}=t,i=c(u);let o=0;const s=e(i);if(null==s)return null;const a=0===r?Z:j;for(const n of t.paths){if(n.length<2)continue;const t=n.length-1;for(let e=0;e<t;++e){const t=n[e];b[0]=t[0],b[1]=t[1],b[2]=l?t[2]:0;const r=n[e+1];S[0]=r[0],S[1]=r[1],S[2]=l?r[2]:0;const i=a(b,S,u);if(null==i)return null;o+=i.value}}return n(o,s)}function p(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,x(b,S,e)):null}function h(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,Z(b,S,e)):null}function m(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,j(b,S,e)):null}function z(n,t){const{spatialReference:e}=n;return o(e,t.spatialReference)?(b[0]=n.x,b[1]=n.y,b[2]=n.hasZ?n.z:0,S[0]=t.x,S[1]=t.y,S[2]=t.hasZ?t.z:0,d(b,S,e)):null}function y(n){return null!=n?R(n.hasZ?n.z:0,n.spatialReference):null}function R(e,r){const l=t(r);return null!=l?n(e??0,l):null}function x(t,e,r){const l=g(t,e,r);return null!=l?{direct:n(l.direct,l.unit),horizontal:n(l.horizontal,l.unit),vertical:n(l.vertical,l.unit)}:null}function Z(t,e,r){const l=g(t,e,r,0);return null!=l?n(l.direct,l.unit):null}function j(t,e,r){const l=g(t,e,r,1);return null!=l?n(l.horizontal,l.unit):null}function v(t,e,r){const l=g(t,e,r,2);return null!=l?n(Math.abs(l.verticalSigned),l.unit):null}function d(t,e,r){const l=g(t,e,r,2);return null!=l?n(l.verticalSigned,l.unit):null}function g(n,t,u,o){const s=c(u),a=e(s);if(null==a)return null;const f=t[2]-n[2];if(2===o)return{verticalSigned:f,unit:a};if(!i(n,u,M,s)||!i(t,u,U,s))return null;if(0===o){return{direct:r(U,M),unit:a}}if(l(V,n[0],n[1],t[2]),!i(V,u,V,s))return null;const p=r(V,U);if(1===o)return{horizontal:p,unit:a};return{direct:r(U,M),horizontal:p,vertical:Math.abs(f),unit:a}}const b=u(),S=u(),M=u(),U=u(),V=u();export{y as elevationFromPoint,R as elevationFromZ,Z as euclideanDirectDistance,h as euclideanDirectDistanceBetweenPoints,x as euclideanDistance,p as euclideanDistanceBetweenPoints,j as euclideanHorizontalDistance,m as euclideanHorizontalDistanceBetweenPoints,a as euclideanHorizontalLength,s as euclideanLength,v as verticalDistance,d as verticalSignedDistance,z as verticalSignedDistanceBetweenPoints};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,length as r,scaleAndAdd as s,sub as e,dot as o,squaredLength as c,lerp as i,set as u,distance as a,squaredDistance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as h}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{a as d,g as l,c as y,h as b,f as j,w as M,e as g,d as x,C as q,H as v}from"../../chunks/vec32.js";import{create as U,clone as k}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as w}from"../../core/libs/gl-matrix-2/math/common.js";import{fromPositionAndNormal as C,create as L,distance as A,intersectLine as H,isPointInside as P}from"../../geometry/support/plane.js";import{tangentFrame as z}from"../3d/support/mathUtils.js";import{intersectLineLikeAndCircle as B}from"./geometry2dUtils.js";function D({start:t,end:r,type:e},i,u){const a=[],f=n(rt,r,t),m=n(st,t,i),h=c(f),d=2*o(f,m),l=d*d-4*h*(c(m)-u*u);if(0===l){const n=-d/(2*h);(0===e||n>=0)&&a.push(s(p(),t,f,n))}else if(l>0){const n=Math.sqrt(l),r=(-d+n)/(2*h);(0===e||r>=0)&&a.push(s(p(),t,f,r));const o=(-d-n)/(2*h);(0===e||o>=0)&&a.push(s(p(),t,f,o))}return a}function E(t,r){const s=t.start,c=t.end,i=n(rt,c,s),u=b(ot,-i[1],i[0],0),a=r.start,f=r.end,p=d(ct,f,a),m=l(p,u),h=b(it,s[0],s[1],0),j=d(ut,h,a),M=l(j,u),g=w();if(Math.abs(m)<g)return Math.abs(M),[];const x=y(at,a,p,M/m);if(0===r.type){const t=d(ft,x,a);if(l(t,p)<-g)return[]}if(1===t.type){const t=e(st,x,s);if(o(t,i)<-g)return[]}return[k(x)]}function F(t,n){return V(Y(mt,n[2],t),n)}function G(t,n){const r=0;return T(Y(mt,r,t),Y(ht,r,n)).map(([t,n])=>m(t,n))}function I(t,n,r){return O(t,Y(mt,t[2],n),r)}function J(t,n){return Q(Y(mt,t[2],n),t)}function K(t,e,o,c=U()){const i=n(rt,t,e),u=r(i);return s(c,e,i,0===u?1:o/u),c[2]=t[2],c}function N(t,n,r){return a(t,n)-r}function O(t,{start:n,end:r,type:s},e=U()){const o=d(et,t,n),c=d(ot,r,n),i=l(o,c)/l(c,c);return y(e,n,c,0===s?Math.max(i,0):i)}function Q({start:t,end:n,type:r},s){const e=d(et,s,t),o=d(ot,n,t);if(0===r&&l(o,e)<-w())return q(t,s);const c=j(ct,o,e);return v(c)/v(o)}const R=(()=>{const t=U(),n=U(),r=U();return({start:s,end:e},{center:o,radius:c,normal:i,slicePlane:a})=>{const f=C(o,i,pt);if($(A(f,s),0)&&$(A(f,e),0)){z(i,t,n);const f=(s,e)=>(g(r,e,o),u(s,l(r,t),l(r,n)),s),p=B({start:f(rt,s),end:f(st,e),type:1},h,c),m=[];for(const[r,s]of p){const e=x(U(),o);y(e,e,t,r),y(e,e,n,s),a&&!tt(a,e)||m.push(e)}return m}const p=U();return H(f,s,e,p)?!$(q(p,o),c)||a&&!tt(a,p)?[]:[p]:[]}})();function S({start:t,end:r,type:s},e,i){const u=[],a=g(et,r,t),f=n(st,t,e),p=c(a),m=2*o(a,f),h=m*m-4*p*(c(f)-i*i);if(0===h){const n=-m/(2*p);(1===s||n>=0)&&u.push(y(U(),t,a,n))}else if(h>0){const n=Math.sqrt(h),r=(-m+n)/(2*p);(1===s||r>=0)&&u.push(y(U(),t,a,r));const e=(-m-n)/(2*p);(1===s||e>=0)&&u.push(y(U(),t,a,e))}return u}function T(t,n){const r=t.start,s=t.end,e=n.start,o=n.end,c=d(et,s,r),i=d(ot,o,e),u=d(ct,e,r),a=j(it,c,i);if(!$(l(u,a),0))return[];const f=M(a);if($(f,0))return[];const p=j(ut,u,i),m=l(p,a)/f,h=y(at,r,c,m);if(0===t.type){const t=d(ft,h,r);if(l(c,t)<-w())return[]}if(0===n.type){const t=d(ft,h,e);if(l(i,t)<-w())return[]}return[k(h)]}function V({start:t,end:n,type:r},s){const e=d(et,s,t),o=d(ot,n,t),c=j(ct,o,e),i=M(c)/M(o),u=w();if(i<u)switch(r){case 1:return[k(s)];case 0:return l(o,e)<-u?[]:[k(s)]}return[]}function W(t,n,r){return $(f(r,t),n*n)?[k(r)]:[]}function X(t,n,r,s){const[e,o]=t,[c,u]=r,a=c-e,f=u-o,p=a*a+f*f,h=Math.sqrt(p);if(h>n+s)return[];if(h<Math.abs(n-s))return[];if($(h,0)&&$(n,s))return[];const d=(n*n-s*s+p)/(2*h),l=Math.sqrt(n*n-d*d),y=l*f/h,b=l*a/h,[j,M]=i(rt,t,r,d/h);return $(y,b)?[m(j,M)]:[m(j+y,M-b),m(j-y,M+b)]}function Y(t,n,{start:r,end:s,type:e}){return b(t.start,r[0],r[1],n),b(t.end,s[0],s[1],n),t.type=nt[e],t}function Z(t,n){return $(t[2],n[2])}function $(n,r){return t(Math.abs(n-r),0,w())}function _(t,n){return n.filter(n=>tt(t,n))}function tt(t,n){return P(t,n)}const nt={0:1,1:0},rt=p(),st=p(),et=U(),ot=U(),ct=U(),it=U(),ut=U(),at=U(),ft=U(),pt=L(),mt={start:U(),end:U(),type:1},ht={start:U(),end:U(),type:1};export{V as intersectLineAndPoint,R as intersectLineLikeAndCircle,S as intersectLineLikeAndVerticalCylinder,T as intersectLineLikes,W as intersectVerticalCylinderAndPoint,X as intersectVerticalCylinders,E as intersectVerticalPlaneAndLineLike,F as intersectVerticalPlaneAndPoint,D as intersectVerticalPlaneAndVerticalCylinder,G as intersectVerticalPlanes,$ as isClose,tt as isPointInsidePlane,Q as pointToLineLikeDistance,N as pointToVerticalCylinderDistance,J as pointToVerticalPlaneDistance,_ as pointsInsidePlane,O as projectPointToLineLike,K as projectPointToVerticalCylinder,I as projectPointToVerticalPlane,Z as vectorsHaveCloseZ};
5
+ import{floatEqualAbsolute as t}from"../../core/mathUtils.js";import{subtract as n,length as r,scaleAndAdd as s,sub as e,dot as o,squaredLength as c,lerp as i,set as u,distance as a,squaredDistance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p,fromValues as m,ZEROS as h}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{a as d,g as l,c as y,h as b,f as j,w as M,e as g,d as x,D as q,B as v}from"../../chunks/vec32.js";import{create as U,clone as k}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as w}from"../../core/libs/gl-matrix-2/math/common.js";import{fromPositionAndNormal as L,create as A,distance as B,intersectLine as C,isPointInside as D}from"../../geometry/support/plane.js";import{tangentFrame as P}from"../3d/support/mathUtils.js";import{intersectLineLikeAndCircle as z}from"./geometry2dUtils.js";function E({start:t,end:r,type:e},i,u){const a=[],f=n(rt,r,t),m=n(st,t,i),h=c(f),d=2*o(f,m),l=d*d-4*h*(c(m)-u*u);if(0===l){const n=-d/(2*h);(0===e||n>=0)&&a.push(s(p(),t,f,n))}else if(l>0){const n=Math.sqrt(l),r=(-d+n)/(2*h);(0===e||r>=0)&&a.push(s(p(),t,f,r));const o=(-d-n)/(2*h);(0===e||o>=0)&&a.push(s(p(),t,f,o))}return a}function F(t,r){const s=t.start,c=t.end,i=n(rt,c,s),u=b(ot,-i[1],i[0],0),a=r.start,f=r.end,p=d(ct,f,a),m=l(p,u),h=b(it,s[0],s[1],0),j=d(ut,h,a),M=l(j,u),g=w();if(Math.abs(m)<g)return Math.abs(M),[];const x=y(at,a,p,M/m);if(0===r.type){const t=d(ft,x,a);if(l(t,p)<-g)return[]}if(1===t.type){const t=e(st,x,s);if(o(t,i)<-g)return[]}return[k(x)]}function G(t,n){return V(Y(mt,n[2],t),n)}function H(t,n){const r=0;return T(Y(mt,r,t),Y(ht,r,n)).map(([t,n])=>m(t,n))}function I(t,n,r){return O(t,Y(mt,t[2],n),r)}function J(t,n){return Q(Y(mt,t[2],n),t)}function K(t,e,o,c=U()){const i=n(rt,t,e),u=r(i);return s(c,e,i,0===u?1:o/u),c[2]=t[2],c}function N(t,n,r){return a(t,n)-r}function O(t,{start:n,end:r,type:s},e=U()){const o=d(et,t,n),c=d(ot,r,n),i=l(o,c)/l(c,c);return y(e,n,c,0===s?Math.max(i,0):i)}function Q({start:t,end:n,type:r},s){const e=d(et,s,t),o=d(ot,n,t);if(0===r&&l(o,e)<-w())return q(t,s);const c=j(ct,o,e);return v(c)/v(o)}const R=(()=>{const t=U(),n=U(),r=U();return({start:s,end:e},{center:o,radius:c,normal:i,slicePlane:a})=>{const f=L(o,i,pt);if($(B(f,s),0)&&$(B(f,e),0)){P(i,t,n);const f=(s,e)=>(g(r,e,o),u(s,l(r,t),l(r,n)),s),p=z({start:f(rt,s),end:f(st,e),type:1},h,c),m=[];for(const[r,s]of p){const e=x(U(),o);y(e,e,t,r),y(e,e,n,s),a&&!tt(a,e)||m.push(e)}return m}const p=U();return C(f,s,e,p)?!$(q(p,o),c)||a&&!tt(a,p)?[]:[p]:[]}})();function S({start:t,end:r,type:s},e,i){const u=[],a=g(et,r,t),f=n(st,t,e),p=c(a),m=2*o(a,f),h=m*m-4*p*(c(f)-i*i);if(0===h){const n=-m/(2*p);(1===s||n>=0)&&u.push(y(U(),t,a,n))}else if(h>0){const n=Math.sqrt(h),r=(-m+n)/(2*p);(1===s||r>=0)&&u.push(y(U(),t,a,r));const e=(-m-n)/(2*p);(1===s||e>=0)&&u.push(y(U(),t,a,e))}return u}function T(t,n){const r=t.start,s=t.end,e=n.start,o=n.end,c=d(et,s,r),i=d(ot,o,e),u=d(ct,e,r),a=j(it,c,i);if(!$(l(u,a),0))return[];const f=M(a);if($(f,0))return[];const p=j(ut,u,i),m=l(p,a)/f,h=y(at,r,c,m);if(0===t.type){const t=d(ft,h,r);if(l(c,t)<-w())return[]}if(0===n.type){const t=d(ft,h,e);if(l(i,t)<-w())return[]}return[k(h)]}function V({start:t,end:n,type:r},s){const e=d(et,s,t),o=d(ot,n,t),c=j(ct,o,e),i=M(c)/M(o),u=w();if(i<u)switch(r){case 1:return[k(s)];case 0:return l(o,e)<-u?[]:[k(s)]}return[]}function W(t,n,r){return $(f(r,t),n*n)?[k(r)]:[]}function X(t,n,r,s){const[e,o]=t,[c,u]=r,a=c-e,f=u-o,p=a*a+f*f,h=Math.sqrt(p);if(h>n+s)return[];if(h<Math.abs(n-s))return[];if($(h,0)&&$(n,s))return[];const d=(n*n-s*s+p)/(2*h),l=Math.sqrt(n*n-d*d),y=l*f/h,b=l*a/h,[j,M]=i(rt,t,r,d/h);return $(y,b)?[m(j,M)]:[m(j+y,M-b),m(j-y,M+b)]}function Y(t,n,{start:r,end:s,type:e}){return b(t.start,r[0],r[1],n),b(t.end,s[0],s[1],n),t.type=nt[e],t}function Z(t,n){return $(t[2],n[2])}function $(n,r){return t(Math.abs(n-r),0,w())}function _(t,n){return n.filter(n=>tt(t,n))}function tt(t,n){return D(t,n)}const nt={0:1,1:0},rt=p(),st=p(),et=U(),ot=U(),ct=U(),it=U(),ut=U(),at=U(),ft=U(),pt=A(),mt={start:U(),end:U(),type:1},ht={start:U(),end:U(),type:1};export{V as intersectLineAndPoint,R as intersectLineLikeAndCircle,S as intersectLineLikeAndVerticalCylinder,T as intersectLineLikes,W as intersectVerticalCylinderAndPoint,X as intersectVerticalCylinders,F as intersectVerticalPlaneAndLineLike,G as intersectVerticalPlaneAndPoint,E as intersectVerticalPlaneAndVerticalCylinder,H as intersectVerticalPlanes,$ as isClose,tt as isPointInsidePlane,Q as pointToLineLikeDistance,N as pointToVerticalCylinderDistance,J as pointToVerticalPlaneDistance,_ as pointsInsidePlane,O as projectPointToLineLike,K as projectPointToVerticalCylinder,I as projectPointToVerticalPlane,Z as vectorsHaveCloseZ};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- function e(e){return!(null==e||"object"!=typeof e||!("createQuery"in e)||!e.createQuery)}export{e as isSelectableLayer};
5
+ function e(e){return!(null==e||"object"!=typeof e||!("createQuery"in e)||!e.createQuery)}export{e as isISelectableLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as o,cast as c,subclass as h}from"../../core/accessorSupport/decorators.js";import d from"../../popup/support/AttachmentsOrderByInfo.js";import l from"../../rest/query/support/AttachmentInfo.js";import p from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const u={editing:!1,operations:{add:!0,update:!0,delete:!0}},f=a.ofType(l);let y=class extends i{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.attachmentKeywords=null,this.attachmentTypes=null,this.capabilities={...u},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new f,this.fileInfos=new a,this.graphic=null,this.mode="view",this.orderByFields=null,this.filesEnabled=!1,this.addHandles(r(()=>this.graphic,()=>this._graphicChanged(),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...u,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}get supportsTypeWildcard(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsTypeWildcard||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e,orderByFields:i,attachmentTypes:a,attachmentKeywords:r,supportsTypeWildcard:s}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const o=this._getObjectId();if("number"!=typeof o)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const c=i?.map(t=>`${t.field} ${"descending"===t.order?"DESC":"ASC"}`),h=new p({objectIds:[o],returnMetadata:!0,orderByFields:c,attachmentTypes:s?a?.filter(Boolean).map(t=>`${t}/*`):void 0,keywords:r}),d=[],l=t.queryAttachments(h).then(t=>t[o]||d).catch(()=>d);this._getAttachmentsPromise=l,this.notifyChange("state");const m=await l;return e.destroyAll(),m.length&&e.addMany(m),this._getAttachmentsPromise=null,this.notifyChange("state"),m}async addAttachment(t,e=this.graphic){const{_attachmentLayer:i,attachmentInfos:a,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!i||"function"!=typeof i.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=i.addAttachment(e,t).then(t=>this._queryAttachment(t.objectId,e)),o=await s;return a.add(o),o}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:i,graphic:a,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!a)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(a,[t.id]).then(()=>t),o=await s;return i.remove(o),o.destroy(),o}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:i,attachmentInfos:a,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const o=a.indexOf(e);if(!i||"function"!=typeof i.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const c=i.updateAttachment(r,e.id,t).then(t=>this._queryAttachment(t.objectId)),h=await c;return a.splice(o,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map(t=>this.addAttachment(t.form))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const i={file:t,form:e};return this.fileInfos.add(i),i}updateFile(t,e,i=this.activeFileInfo){if(!t||!e||!i)return null;const a=this.fileInfos.indexOf(i);return a>-1&&this.fileInfos.splice(a,1,{file:t,form:e}),this.fileInfos.items[a]}deleteFile(t){const e=this.fileInfos.find(e=>e.file===t);return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:i}=this;if(!t||!i?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const a=this._getObjectId(e);if("number"!=typeof a)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new p({objectIds:[a],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return i.queryAttachments(r).then(t=>t[a][0])}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch(()=>this.attachmentInfos.destroyAll()))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([o({type:[String]})],y.prototype,"attachmentKeywords",void 0),t([o({type:[["application","audio","image","model","text","video"]]})],y.prototype,"attachmentTypes",void 0),t([o()],y.prototype,"capabilities",void 0),t([c("capabilities")],y.prototype,"castCapabilities",null),t([o()],y.prototype,"activeAttachmentInfo",void 0),t([o()],y.prototype,"activeFileInfo",void 0),t([o({readOnly:!0,type:f})],y.prototype,"attachmentInfos",void 0),t([o()],y.prototype,"fileInfos",void 0),t([o({type:e})],y.prototype,"graphic",void 0),t([o()],y.prototype,"mode",void 0),t([o({type:[d]})],y.prototype,"orderByFields",void 0),t([o({readOnly:!0})],y.prototype,"state",null),t([o()],y.prototype,"filesEnabled",void 0),t([o({readOnly:!0})],y.prototype,"supportsResizeAttachments",null),t([o({readOnly:!0})],y.prototype,"supportsTypeWildcard",null),y=t([h("esri.widgets.Attachments.AttachmentsViewModel")],y);export{y as default};
5
+ import{__decorate as t}from"tslib";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as o,cast as c,subclass as h}from"../../core/accessorSupport/decorators.js";import d from"../../popup/support/AttachmentsOrderByInfo.js";import l from"../../rest/query/support/AttachmentInfo.js";import p from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const u={editing:!1,operations:{add:!0,update:!0,delete:!0}},f=a.ofType(l);let y=class extends i{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.attachmentKeywords=null,this.attachmentTypes=null,this.capabilities={...u},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new f,this.fileInfos=new a,this.graphic=null,this.mode="view",this.orderByFields=null,this.filesEnabled=!1,this.addHandles(r(()=>this.graphic,()=>this._graphicChanged(),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...u,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.sourceLayer??t.layer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}get supportsTypeWildcard(){const{graphic:t}=this;if(!t)return!1;const e=t.sourceLayer??t.layer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsTypeWildcard||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e,orderByFields:i,attachmentTypes:a,attachmentKeywords:r,supportsTypeWildcard:s}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const o=this._getObjectId();if("number"!=typeof o)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const c=i?.map(t=>`${t.field} ${"descending"===t.order?"DESC":"ASC"}`),h=new p({objectIds:[o],returnMetadata:!0,orderByFields:c,attachmentTypes:s?a?.filter(Boolean).map(t=>`${t}/*`):void 0,keywords:r}),d=[],l=t.queryAttachments(h).then(t=>t[o]||d).catch(()=>d);this._getAttachmentsPromise=l,this.notifyChange("state");const m=await l;return e.destroyAll(),m.length&&e.addMany(m),this._getAttachmentsPromise=null,this.notifyChange("state"),m}async addAttachment(t,e=this.graphic){const{_attachmentLayer:i,attachmentInfos:a,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!i||"function"!=typeof i.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=i.addAttachment(e,t).then(t=>this._queryAttachment(t.objectId,e)),o=await s;return a.add(o),o}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:i,graphic:a,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!a)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(a,[t.id]).then(()=>t),o=await s;return i.remove(o),o.destroy(),o}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:i,attachmentInfos:a,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const o=a.indexOf(e);if(!i||"function"!=typeof i.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const c=i.updateAttachment(r,e.id,t).then(t=>this._queryAttachment(t.objectId)),h=await c;return a.splice(o,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map(t=>this.addAttachment(t.form))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const i={file:t,form:e};return this.fileInfos.add(i),i}updateFile(t,e,i=this.activeFileInfo){if(!t||!e||!i)return null;const a=this.fileInfos.indexOf(i);return a>-1&&this.fileInfos.splice(a,1,{file:t,form:e}),this.fileInfos.items[a]}deleteFile(t){const e=this.fileInfos.find(e=>e.file===t);return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:i}=this;if(!t||!i?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const a=this._getObjectId(e);if("number"!=typeof a)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new p({objectIds:[a],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return i.queryAttachments(r).then(t=>t[a][0])}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch(()=>this.attachmentInfos.destroyAll()))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([o({type:[String]})],y.prototype,"attachmentKeywords",void 0),t([o({type:[["application","audio","image","model","text","video"]]})],y.prototype,"attachmentTypes",void 0),t([o()],y.prototype,"capabilities",void 0),t([c("capabilities")],y.prototype,"castCapabilities",null),t([o()],y.prototype,"activeAttachmentInfo",void 0),t([o()],y.prototype,"activeFileInfo",void 0),t([o({readOnly:!0,type:f})],y.prototype,"attachmentInfos",void 0),t([o()],y.prototype,"fileInfos",void 0),t([o({type:e})],y.prototype,"graphic",void 0),t([o()],y.prototype,"mode",void 0),t([o({type:[d]})],y.prototype,"orderByFields",void 0),t([o({readOnly:!0})],y.prototype,"state",null),t([o()],y.prototype,"filesEnabled",void 0),t([o({readOnly:!0})],y.prototype,"supportsResizeAttachments",null),t([o({readOnly:!0})],y.prototype,"supportsTypeWildcard",null),y=t([h("esri.widgets.Attachments.AttachmentsViewModel")],y);export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import s from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import r from"../../core/Logger.js";import{isAbortError as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as a}from"../../core/reactiveUtils.js";import{property as n,subclass as p}from"../../core/accessorSupport/decorators.js";import d from"../../layers/BuildingSceneLayer.js";import y from"../../layers/support/BuildingFilter.js";import h from"./BuildingDisciplinesViewModel.js";import c from"./BuildingLevel.js";import u from"./BuildingPhase.js";import{showFullModel as m}from"./support/buildingLayerUtils.js";import{setFilterOnLayers as g,getFilterBlockSolid as f,getFilterBlockXRay as v,generateFilterId as j}from"./support/filterUtils.js";import{createLoadLayersFunction as _}from"./support/layerUtils.js";let w=class extends t{constructor(e){super(e),this.view=null,this.state="disabled",this.level=new c,this.phase=new u,this.disciplines=new h,this._loadLayers=_(),this.layers=new s}initialize(){this.addHandles([this.layers.on("change",()=>this._onLayersChange()),o(()=>({state:this.state,layers:this.layers,filter:this._filter}),({state:e,layers:t,filter:s})=>{"ready"===e&&g(t,s)},{initial:!0})]),this._onLayersChange()}destroy(){this.level.destroyed||this.level.destroy(),this.phase.destroyed||this.phase.destroy(),this.disciplines.destroyed||this.disciplines.destroy()}get isSupported(){return"3d"===this.view?.type}get layers(){return this._get("layers")}set layers(e){const t=e.filter(e=>e instanceof d);t.length!==e.length&&r.getLogger(this).error("Some layers are not BuildingSceneLayers but only BuildingSceneLayers can be passed to the widget."),this._set("layers",i(t,this._get("layers")))}get _filter(){const e=this.level.filterExpressions,t=this.phase.filterExpressions,s=[],i=f([e.solid,t.solid]);null!=i&&s.push(i);const r=v([e.xRay,t.xRay]);return null!=r&&s.push(r),0===s.length?null:new y({id:j(),name:"Building Explorer Filter",filterBlocks:s})}async _onLayersChange(){const e=this.layers;if(this.level.layers=e,this.phase.layers=e,this.disciplines.layers=e,0!==e.length){this._set("state","loading");try{await this._loadLayers(e),await Promise.all([a(()=>"ready"===this.level.state),a(()=>"ready"===this.phase.state),a(()=>"ready"===this.disciplines.state)]),e.forEach(m),this._set("state","ready")}catch(t){l(t)||this._set("state","failed")}}else this._set("state","disabled")}};e([n({value:null})],w.prototype,"view",void 0),e([n()],w.prototype,"isSupported",null),e([n({type:s,nonNullable:!0})],w.prototype,"layers",null),e([n({readOnly:!0})],w.prototype,"state",void 0),e([n({readOnly:!0,type:c})],w.prototype,"level",void 0),e([n({readOnly:!0,type:u})],w.prototype,"phase",void 0),e([n({readOnly:!0,type:h})],w.prototype,"disciplines",void 0),e([n()],w.prototype,"_filter",null),w=e([p("esri.widgets.BuildingExplorer.BuildingExplorerViewModel")],w);const L=w;export{L as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import s from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as r}from"../../core/deprecate.js";import l from"../../core/Logger.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{watch as a,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p,subclass as d}from"../../core/accessorSupport/decorators.js";import y from"../../layers/BuildingSceneLayer.js";import h from"../../layers/support/BuildingFilter.js";import c from"./BuildingDisciplinesViewModel.js";import u from"./BuildingLevel.js";import g from"./BuildingPhase.js";import{showFullModel as m}from"./support/buildingLayerUtils.js";import{setFilterOnLayers as f,getFilterBlockSolid as v,getFilterBlockXRay as w,generateFilterId as j}from"./support/filterUtils.js";import{createLoadLayersFunction as _}from"./support/layerUtils.js";let L=class extends t{constructor(e){super(e),this.view=null,this.state="disabled",this.level=new u({isDefaultViewModel:!0}),this.phase=new g({isDefaultViewModel:!0}),this.disciplines=new c,this._loadLayers=_(),e?.isDefaultViewModel||r(l.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"}),this.layers=new s}normalizeCtorArgs(e){const{isDefaultViewModel:t,...s}=e??{};return s}initialize(){this.addHandles([this.layers.on("change",()=>this._onLayersChange()),a(()=>({state:this.state,layers:this.layers,filter:this._filter}),({state:e,layers:t,filter:s})=>{"ready"===e&&f(t,s)},{initial:!0})]),this._onLayersChange()}destroy(){this.level.destroyed||this.level.destroy(),this.phase.destroyed||this.phase.destroy(),this.disciplines.destroyed||this.disciplines.destroy()}get isSupported(){return"3d"===this.view?.type}get layers(){return this._get("layers")}set layers(e){const t=e.filter(e=>e instanceof y);t.length!==e.length&&l.getLogger(this).error("Some layers are not BuildingSceneLayers but only BuildingSceneLayers can be passed to the widget."),this._set("layers",i(t,this._get("layers")))}get _filter(){const e=this.level.filterExpressions,t=this.phase.filterExpressions,s=[],i=v([e.solid,t.solid]);null!=i&&s.push(i);const r=w([e.xRay,t.xRay]);return null!=r&&s.push(r),0===s.length?null:new h({id:j(),name:"Building Explorer Filter",filterBlocks:s})}async _onLayersChange(){const e=this.layers;if(this.level.layers=e,this.phase.layers=e,this.disciplines.layers=e,0!==e.length){this._set("state","loading");try{await this._loadLayers(e),await Promise.all([n(()=>"ready"===this.level.state),n(()=>"ready"===this.phase.state),n(()=>"ready"===this.disciplines.state)]),e.forEach(m),this._set("state","ready")}catch(t){o(t)||this._set("state","failed")}}else this._set("state","disabled")}};e([p({value:null})],L.prototype,"view",void 0),e([p()],L.prototype,"isSupported",null),e([p({type:s,nonNullable:!0})],L.prototype,"layers",null),e([p({readOnly:!0})],L.prototype,"state",void 0),e([p({readOnly:!0,type:u})],L.prototype,"level",void 0),e([p({readOnly:!0,type:g})],L.prototype,"phase",void 0),e([p({readOnly:!0,type:c})],L.prototype,"disciplines",void 0),e([p()],L.prototype,"_filter",null),L=e([d("esri.widgets.BuildingExplorer.BuildingExplorerViewModel")],L);const B=L;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{binaryIndexOf as l}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as a}from"../../core/collectionUtils.js";import{isAbortError as i}from"../../core/promiseUtils.js";import{property as r,subclass as o}from"../../core/accessorSupport/decorators.js";import{createLoadLayersFunction as n}from"./support/layerUtils.js";import{getDomainInfo as u,getValidNumber as d,getMin as h,getMax as y}from"./support/validation.js";let p=class extends t{constructor(e){super(e),this.state="disabled",this._valueBeforeReady=null,this._domainInfo=u([]),this._loadLayers=n(),this.layers=new s}initialize(){this.addHandles(this.layers.on("change",()=>this._onLayersChange())),this._onLayersChange()}destroy(){this._set("state","disabled")}get enabled(){return this.allowedValues.length>0&&this._get("enabled")}set enabled(e){e!==this.enabled&&this.allowedValues.length>0&&this._set("enabled",e)}get value(){return("ready"===this.state?this._get("value"):this._valueBeforeReady)??0}set value(e){if("ready"!==this.state)return void(this._valueBeforeReady=e);if(e===this.value)return;const t=d(e,this);null!=t&&this._set("value",t)}get min(){return h(this.allowedValues)}get max(){return y(this.allowedValues)}get allowedValues(){return this._domainInfo.allowedValues}set allowedValues(e){null==e?this._clearOverride("allowedValues"):this._override("allowedValues",e);const t=d(this.value,this);null!=t&&(this.value=t)}get hasNext(){if(!this.enabled)return!0;const e=this._valueIndex;return e>=0&&e<this.allowedValues.length-1}get hasPrevious(){return!this.enabled||this._valueIndex>0}set layers(e){const t=this._get("layers");this._set("layers",a(e,t))}get filterExpressions(){return{solid:null,xRay:null}}get _valueIndex(){return l(this.allowedValues,this.value)}select(e){if("ready"!==this.state)return void(this._valueBeforeReady=e);null!=d(e,this)&&(this.enabled=!0,this.value=e)}clear(){"ready"===this.state?this.enabled=!1:this._valueBeforeReady=null}next(){const{state:e,allowedValues:t,enabled:l,hasNext:s,_valueIndex:a}=this;if("ready"===e||null==this._valueBeforeReady){if(0!==t.length)return l?void(s&&(this.value=t[a+1])):(this.enabled=!0,void(this.value=t[0]))}else this._valueBeforeReady++}previous(){const{state:e,allowedValues:t,enabled:l,hasPrevious:s,_valueIndex:a}=this;if("ready"===e||null==this._valueBeforeReady){if(0!==t.length)return l?void(s&&(this.value=t[a-1])):(this.enabled=!0,void(this.value=t[t.length-1]))}else this._valueBeforeReady++}getValueLabel(e){return 0===this.layers.length?null:this._domainInfo.fieldValueMap.get(e)??null}async _onLayersChange(){if(this._set("state","loading"),this._domainInfo=u([]),0!==this.layers.length)try{await this._loadLayers(this.layers),this._setup()}catch(e){i(e)||this._set("state","failed")}}};e([r({value:!1,nonNullable:!0})],p.prototype,"enabled",null),e([r({nonNullable:!0})],p.prototype,"value",null),e([r({readOnly:!0})],p.prototype,"min",null),e([r({readOnly:!0})],p.prototype,"max",null),e([r()],p.prototype,"allowedValues",null),e([r({readOnly:!0})],p.prototype,"hasNext",null),e([r({readOnly:!0})],p.prototype,"hasPrevious",null),e([r({type:s,nonNullable:!0})],p.prototype,"layers",null),e([r({nonNullable:!0})],p.prototype,"state",void 0),e([r()],p.prototype,"_valueBeforeReady",void 0),e([r({readOnly:!0})],p.prototype,"_valueIndex",null),e([r()],p.prototype,"_domainInfo",void 0),p=e([o("esri.widgets.BuildingExplorer.BuildingNumericFilterViewModel")],p);const v=p;export{v as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{binaryIndexOf as l}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import{referenceSetter as a}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as r}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{property as n,subclass as u}from"../../core/accessorSupport/decorators.js";import{createLoadLayersFunction as d}from"./support/layerUtils.js";import{getDomainInfo as h,getValidNumber as y,getMin as p,getMax as v}from"./support/validation.js";let f=class extends t{constructor(e){super(e),this.state="disabled",this._valueBeforeReady=null,this._domainInfo=h([]),this._loadLayers=d(),e?.isDefaultViewModel||r(i.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"}),this.layers=new s}normalizeCtorArgs(e){const{isDefaultViewModel:t,...l}=e??{};return l}initialize(){this.addHandles(this.layers.on("change",()=>this._onLayersChange())),this._onLayersChange()}destroy(){this._set("state","disabled")}get enabled(){return this.allowedValues.length>0&&this._get("enabled")}set enabled(e){e!==this.enabled&&this.allowedValues.length>0&&this._set("enabled",e)}get value(){return("ready"===this.state?this._get("value"):this._valueBeforeReady)??0}set value(e){if("ready"!==this.state)return void(this._valueBeforeReady=e);if(e===this.value)return;const t=y(e,this);null!=t&&this._set("value",t)}get min(){return p(this.allowedValues)}get max(){return v(this.allowedValues)}get allowedValues(){return this._domainInfo.allowedValues}set allowedValues(e){null==e?this._clearOverride("allowedValues"):this._override("allowedValues",e);const t=y(this.value,this);null!=t&&(this.value=t)}get hasNext(){if(!this.enabled)return!0;const e=this._valueIndex;return e>=0&&e<this.allowedValues.length-1}get hasPrevious(){return!this.enabled||this._valueIndex>0}set layers(e){const t=this._get("layers");this._set("layers",a(e,t))}get filterExpressions(){return{solid:null,xRay:null}}get _valueIndex(){return l(this.allowedValues,this.value)}select(e){if("ready"!==this.state)return void(this._valueBeforeReady=e);null!=y(e,this)&&(this.enabled=!0,this.value=e)}clear(){"ready"===this.state?this.enabled=!1:this._valueBeforeReady=null}next(){const{state:e,allowedValues:t,enabled:l,hasNext:s,_valueIndex:a}=this;if("ready"===e||null==this._valueBeforeReady){if(0!==t.length)return l?void(s&&(this.value=t[a+1])):(this.enabled=!0,void(this.value=t[0]))}else this._valueBeforeReady++}previous(){const{state:e,allowedValues:t,enabled:l,hasPrevious:s,_valueIndex:a}=this;if("ready"===e||null==this._valueBeforeReady){if(0!==t.length)return l?void(s&&(this.value=t[a-1])):(this.enabled=!0,void(this.value=t[t.length-1]))}else this._valueBeforeReady++}getValueLabel(e){return 0===this.layers.length?null:this._domainInfo.fieldValueMap.get(e)??null}async _onLayersChange(){if(this._set("state","loading"),this._domainInfo=h([]),0!==this.layers.length)try{await this._loadLayers(this.layers),this._setup()}catch(e){o(e)||this._set("state","failed")}}};e([n({value:!1,nonNullable:!0})],f.prototype,"enabled",null),e([n({nonNullable:!0})],f.prototype,"value",null),e([n({readOnly:!0})],f.prototype,"min",null),e([n({readOnly:!0})],f.prototype,"max",null),e([n()],f.prototype,"allowedValues",null),e([n({readOnly:!0})],f.prototype,"hasNext",null),e([n({readOnly:!0})],f.prototype,"hasPrevious",null),e([n({type:s,nonNullable:!0})],f.prototype,"layers",null),e([n({nonNullable:!0})],f.prototype,"state",void 0),e([n()],f.prototype,"_valueBeforeReady",void 0),e([n({readOnly:!0})],f.prototype,"_valueIndex",null),e([n()],f.prototype,"_domainInfo",void 0),f=e([u("esri.widgets.BuildingExplorer.BuildingNumericFilterViewModel")],f);const g=f;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{property as i,cast as s,subclass as t}from"../core/accessorSupport/decorators.js";import l from"./Widget.js";import r from"./BuildingExplorer/BuildingExplorerViewModel.js";import{css as o}from"./BuildingExplorer/css.js";import n from"./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js";import a from"./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js";import d from"./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js";import{loadCalciteComponents as p}from"./support/componentsUtils.js";import{globalCss as c}from"./support/globalCss.js";import{Heading as g}from"./support/Heading.js";import{messageBundle as u,tsx as m,classes as h}from"./support/widget.js";const v={levels:!0,phases:!0,disciplines:!0};let y=class extends l{constructor(e,i){super(e,i),this._defaultViewModel=new r,this.viewModel=this._defaultViewModel,this.visibleElements={...v},this.headingLevel=3,this.messages=null,this.messagesCommon=null,this.toggleSiblingsVisibility=!1}loadDependencies(){return p({loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}_castVisibleElements(e){return{...v,...e}}get icon(){return"organization"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}render(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return m("div",{"aria-label":this.messages.widgetLabel,class:h(c.widget,o.base,c.panel,{[c.widgetDisabled]:i}),key:this},this._renderContent())}_renderContent(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return m("p",{class:o.panelError},i.unsupported);if(!e.layers.length)return m("p",{class:o.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return m("div",{class:o.content,key:"content"},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return m("p",{class:o.panelError},i.failed);default:return null}}_renderLoadingIndicator(){const e=this.messagesCommon.loading;return m("div",{"aria-label":e,class:o.loadingContainer,key:"loading-container",role:"presentation",title:e},m("calcite-loader",{label:e,type:"indeterminate"}))}_renderLevelPickerSection(){const e=this.viewModel.level,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.levels||!i||!s)return null;const t=this.messages?.level;return m("div",{class:h(o.section,o.levels),key:"levels"},m(g,{level:this.headingLevel},t?.title),m(a,{messages:t,vm:e}))}_renderPhasePickerSection(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return m("div",{class:h(o.section,o.phases),key:"phases"},m(g,{level:this.headingLevel},t.title),m(d,{messages:t,vm:e}))}_renderDisciplinesSection(){const e=this.viewModel.disciplines,i="ready"===e.state,s=e.root.hasChildren;if(!this.visibleElements.disciplines||!i||!s)return null;const t=this.messages?.disciplines;return m("div",{class:h(o.section,o.disciplines),key:"disciplines"},m(g,{level:this.headingLevel},t.title),m(n,{messages:t,toggleSiblingsVisibility:this.toggleSiblingsVisibility,vm:e}))}};e([i({type:r})],y.prototype,"viewModel",void 0),e([i()],y.prototype,"view",null),e([i()],y.prototype,"layers",null),e([i()],y.prototype,"visibleElements",void 0),e([s("visibleElements")],y.prototype,"_castVisibleElements",null),e([i()],y.prototype,"headingLevel",void 0),e([i()],y.prototype,"icon",null),e([i()],y.prototype,"label",null),e([i(),u("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],y.prototype,"messages",void 0),e([i(),u("esri/t9n/common")],y.prototype,"messagesCommon",void 0),e([i({nonNullable:!0})],y.prototype,"toggleSiblingsVisibility",void 0),e([i()],y.prototype,"uiStrings",void 0),y=e([t("esri.widgets.BuildingExplorer")],y);const w=y;export{w as default};
5
+ import{__decorate as e}from"tslib";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{property as t,cast as l,subclass as r}from"../core/accessorSupport/decorators.js";import o from"./Widget.js";import n from"./BuildingExplorer/BuildingExplorerViewModel.js";import{css as a}from"./BuildingExplorer/css.js";import d from"./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js";import p from"./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js";import c from"./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{Heading as m}from"./support/Heading.js";import{messageBundle as h,tsx as v,classes as y}from"./support/widget.js";const w={levels:!0,phases:!0,disciplines:!0};let b=class extends o{constructor(e,t){super(e,t),this._defaultViewModel=new n({isDefaultViewModel:!0}),this.viewModel=this._defaultViewModel,this.visibleElements={...w},this.headingLevel=3,this.messages=null,this.messagesCommon=null,this.toggleSiblingsVisibility=!1,i(s.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"})}loadDependencies(){return g({loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}_castVisibleElements(e){return{...w,...e}}get icon(){return"organization"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}render(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return v("div",{"aria-label":this.messages.widgetLabel,class:y(u.widget,a.base,u.panel,{[u.widgetDisabled]:i}),key:this},this._renderContent())}_renderContent(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return v("p",{class:a.panelError},i.unsupported);if(!e.layers.length)return v("p",{class:a.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return v("div",{class:a.content,key:"content"},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return v("p",{class:a.panelError},i.failed);default:return null}}_renderLoadingIndicator(){const e=this.messagesCommon.loading;return v("div",{"aria-label":e,class:a.loadingContainer,key:"loading-container",role:"presentation",title:e},v("calcite-loader",{label:e,type:"indeterminate"}))}_renderLevelPickerSection(){const e=this.viewModel.level,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.levels||!i||!s)return null;const t=this.messages?.level;return v("div",{class:y(a.section,a.levels),key:"levels"},v(m,{level:this.headingLevel},t?.title),v(p,{messages:t,vm:e}))}_renderPhasePickerSection(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return v("div",{class:y(a.section,a.phases),key:"phases"},v(m,{level:this.headingLevel},t.title),v(c,{messages:t,vm:e}))}_renderDisciplinesSection(){const e=this.viewModel.disciplines,i="ready"===e.state,s=e.root.hasChildren;if(!this.visibleElements.disciplines||!i||!s)return null;const t=this.messages?.disciplines;return v("div",{class:y(a.section,a.disciplines),key:"disciplines"},v(m,{level:this.headingLevel},t.title),v(d,{messages:t,toggleSiblingsVisibility:this.toggleSiblingsVisibility,vm:e}))}};e([t({type:n})],b.prototype,"viewModel",void 0),e([t()],b.prototype,"view",null),e([t()],b.prototype,"layers",null),e([t()],b.prototype,"visibleElements",void 0),e([l("visibleElements")],b.prototype,"_castVisibleElements",null),e([t()],b.prototype,"headingLevel",void 0),e([t()],b.prototype,"icon",null),e([t()],b.prototype,"label",null),e([t(),h("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],b.prototype,"messages",void 0),e([t(),h("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([t({nonNullable:!0})],b.prototype,"toggleSiblingsVisibility",void 0),e([t()],b.prototype,"uiStrings",void 0),b=e([r("esri.widgets.BuildingExplorer")],b);const f=b;export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import d from"../../core/Logger.js";import{destroyMaybe as c,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W,subclass as M}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as I}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,isSubtypeGroupLayer as S,getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import U from"../../views/SelectionManager.js";import C from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import j from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as R}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import H from"./CreateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as x,isCreateFeaturesWorkflow as G,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isMergeFeaturesWorkflow as N,isSplitFeatureWorkflow as Q,isUpdateWorkflow as z,isFeatureFormViewModel as Z,findEditorItemForLayerOrThrow as $,toFeatureInfos as J,fetchFullFeaturesByObjectId as K,fetchFullFeatures as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{assertViewNot3D as ie,MultipleSourceLayersError as re,InsufficientFeatureCountError as oe,MissingOriginLayerError as ae,assertMergeWorkflowCapabilities as se,FetchFullFeatureError as ne,assertSplitWorkflowCapabilities as le}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as de}from"../FeatureTemplates/featureTemplatesUtils.js";import ce from"../FeatureTemplates/FeatureTemplatesViewModel.js";import pe from"../Sketch/SketchViewModel.js";import he from"../Spinner/SpinnerViewModel.js";import{goTo as ue}from"../support/goToUtils.js";import{isFeatureItem as we,isLayerItem as fe}from"../support/SelectionList/selectionListUtils.js";import me from"../support/SelectionList/SelectionListViewModel.js";import ye from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ge(e,t){return e?.find(e=>e.layer===t)}let ke=class extends s{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new ce({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new pe({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new me,this.selectionManager=new U,this.selectionToolbarViewModel=new ye({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new C,this.snappingOptions=new j({attributeRulesEnabled:!0}),this.spinnerViewModel=new he,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:r}=i.data;r.removeAll(),e&&r.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=x(t),r=`sketch-${e.type}`;this.emit(r,{type:r,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=c(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new O({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return G(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.fullFeatures.length:N(e)?e.data.features.length:Q(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&z(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return Z(e)?e:null}get formViewModel(){return this.activeWorkflow?.formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&Z(e.formViewModel)){const{associatedLayer:t,associationId:i}=e.formViewModel;if(t||null!=i)return"viewing-associated-features"}if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?$(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ie(this,"merge-features");const i=Array.isArray(e)?J(e):[e];if(i.length>1)throw new re;if(0===i.length||i[0].objectIds.length<2)throw new oe(2);const o=i[0],a=o.layer;if(!a)throw new ae;const s=$(this.editorItems,a);se(s);const l=this._createUpdatingResolver(),d=new AbortController;this.addHandles(n(d));try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const e=await K(o.objectIds,a,this.view?.spatialReference,d.signal);if(e.length!==o.objectIds.length)throw new ne;let i;if(t.keyFeature){const r=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===r)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(c){this._logErrorAndCancelWorkflow(c)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),ie(this,"split-feature");const i=T(e);if(!i)throw new ae;const o=$(this.editorItems,i);le(o);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const o=await X([e],i,this.view?.spatialReference,s.signal);if(1!==o.length)throw new ne;const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(o),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?J(e):[e];if(t.length>1)throw new re;const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;if(z(e))return e.deleteActiveFeatures();this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:r}=this;if(!i)return;const o=void 0,a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?ue(i,a.geometry,o):ue(i,a,o);else{const e=r?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ue(i,e.map(e=>e.geometry).filter(t),o):e&&ue(i,e,o)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){we(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){we(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):fe(e)&&await this._startUpdateWorkflowWithLayerItem(e,t)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),o=i.allTables.toArray().filter(e=>E(e)||S(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...o.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...r.reverse(),...o.reverse()].filter(e=>I(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const r=[],o=[],a=[],{layerInfos:s}=this;for(const l of i){const t=ge(s,l),i=await ee(e,l).catch(()=>null);(t?r:i?o:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...o,...a];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const r=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push(de(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return H.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const o=e.url?await A(e.url):null,a={returnServiceEditsOption:(!o||!L(o))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const o=await ee(i,e).catch(()=>null);return r=await e.applyEdits(t,a),o&&await _(()=>!o.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return m(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:r}=e,o=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(o)throw o.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=$(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,o="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,o&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),r=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let o;if(null!=r&&""!==r){const e=J(i);if(e.length>1)throw new re;if(o=e[0],!o)throw new oe("merge"===t?2:1)}else o={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(o):"merge"===t&&await this.startMergeFeaturesWorkflow(o)}};e([W()],ke.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ke.prototype,"_queuedSelectionTool",void 0),e([W()],ke.prototype,"_snappingManager",void 0),e([W()],ke.prototype,"_selectionSources",null),e([W()],ke.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ke.prototype,"activeWorkflow",void 0),e([W()],ke.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ke.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ke.prototype,"canCreate",null),e([W()],ke.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ke.prototype,"canUpdate",null),e([W()],ke.prototype,"canUpdateVisible",null),e([W()],ke.prototype,"featureTemplatesLayers",null),e([W()],ke.prototype,"editorItems",void 0),e([W()],ke.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ke.prototype,"failures",void 0),e([W()],ke.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:P})],ke.prototype,"attachmentsViewModel",void 0),e([W()],ke.prototype,"featureFormViewModel",null),e([W()],ke.prototype,"formViewModel",null),e([W()],ke.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:ce})],ke.prototype,"featureTemplatesViewModel",void 0),e([W()],ke.prototype,"labelOptions",null),e([W()],ke.prototype,"layerInfos",void 0),e([W()],ke.prototype,"ownSketchViewModel",void 0),e([W()],ke.prototype,"selectionListViewModel",void 0),e([W()],ke.prototype,"selectionManager",void 0),e([W()],ke.prototype,"selectionToolbarViewModel",void 0),e([W()],ke.prototype,"sketchOptions",void 0),e([W()],ke.prototype,"sketchViewModel",null),e([W({type:j,nonNullable:!0})],ke.prototype,"snappingOptions",void 0),e([W()],ke.prototype,"spinnerViewModel",void 0),e([W()],ke.prototype,"state",null),e([W({readOnly:!0})],ke.prototype,"syncing",null),e([W()],ke.prototype,"updating",null),e([W()],ke.prototype,"tooltipOptions",null),e([W()],ke.prototype,"valueOptions",null),e([W()],ke.prototype,"view",null),e([W()],ke.prototype,"canZoomTo",null),e([W()],ke.prototype,"pageStack",void 0),e([W()],ke.prototype,"showDiscardEditsPrompt",void 0),e([W()],ke.prototype,"_candidateCommitted",void 0),e([W()],ke.prototype,"page",null),e([W()],ke.prototype,"featureFormDisabled",null),e([W()],ke.prototype,"featureFormHasAssociation",null),e([W()],ke.prototype,"canGoBack",null),e([W()],ke.prototype,"shouldShowDeleteButton",null),e([W()],ke.prototype,"hasPendingEdits",null),e([W()],ke.prototype,"snappingManager",null),ke=e([M("esri.widgets.Editor.EditorViewModel")],ke);const ve=ke;export{ve as default};
5
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import d from"../../core/Logger.js";import{destroyMaybe as c,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W,subclass as M}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as b}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as T}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as I}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,isSubtypeGroupLayer as S,getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import U from"../../views/SelectionManager.js";import C from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as O}from"../../views/interactive/snapping/SnappingManager.js";import j from"../../views/interactive/snapping/SnappingOptions.js";import{isISelectableLayer as R}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import H from"./CreateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as x,isCreateFeaturesWorkflow as G,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isMergeFeaturesWorkflow as N,isSplitFeatureWorkflow as Q,isUpdateWorkflow as z,isFeatureFormViewModel as Z,findEditorItemForLayerOrThrow as $,toFeatureInfos as J,fetchFullFeaturesByObjectId as K,fetchFullFeatures as X,findEditorItemForLayer as Y,whenEditorLayerView as ee}from"./workflowUtils.js";import te from"./support/EditorItem.js";import{assertViewNot3D as ie,MultipleSourceLayersError as re,InsufficientFeatureCountError as oe,MissingOriginLayerError as ae,assertMergeWorkflowCapabilities as se,FetchFullFeatureError as ne,assertSplitWorkflowCapabilities as le}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as de}from"../FeatureTemplates/featureTemplatesUtils.js";import ce from"../FeatureTemplates/FeatureTemplatesViewModel.js";import pe from"../Sketch/SketchViewModel.js";import he from"../Spinner/SpinnerViewModel.js";import{goTo as ue}from"../support/goToUtils.js";import{isFeatureItem as we,isLayerItem as fe}from"../support/SelectionList/selectionListUtils.js";import me from"../support/SelectionList/SelectionListViewModel.js";import ye from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ge(e,t){return e?.find(e=>e.layer===t)}let ke=class extends s{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new b,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new ce({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new pe({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new me,this.selectionManager=new U,this.selectionToolbarViewModel=new ye({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new C,this.snappingOptions=new j({attributeRulesEnabled:!0}),this.spinnerViewModel=new he,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:r}=i.data;r.removeAll(),e&&r.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter(e=>!!t?.includes(e.layer));return[t,r,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.highlightEnabled=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);await this.startCreateFeaturesWorkflowAtFeatureCreation(r)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=x(t),r=`sketch-${e.type}`;this.emit(r,{type:r,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=c(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new O({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)R(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return G(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.fullFeatures.length:N(e)?e.data.features.length:Q(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&z(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return Z(e)?e:null}get formViewModel(){return this.activeWorkflow?.formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&Z(e.formViewModel)){const{associatedLayer:t,associationId:i}=e.formViewModel;if(t||null!=i)return"viewing-associated-features"}if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?$(this.editorItems,i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new a("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ie(this,"merge-features");const i=Array.isArray(e)?J(e):[e];if(i.length>1)throw new re;if(0===i.length||i[0].objectIds.length<2)throw new oe(2);const o=i[0],a=o.layer;if(!a)throw new ae;const s=$(this.editorItems,a);se(s);const l=this._createUpdatingResolver(),d=new AbortController;this.addHandles(n(d));try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const e=await K(o.objectIds,a,this.view?.spatialReference,d.signal);if(e.length!==o.objectIds.length)throw new ne;let i;if(t.keyFeature){const r=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===r)??t.keyFeature}const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(c){this._logErrorAndCancelWorkflow(c)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),ie(this,"split-feature");const i=T(e);if(!i)throw new ae;const o=$(this.editorItems,i);le(o);const a=this._createUpdatingResolver(),s=new AbortController;this.addHandles(n(s));try{await this._cancelWorkflow();const o=await X([e],i,this.view?.spatialReference,s.signal);if(1!==o.length)throw new ne;const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r(o),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{a.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?J(e):[e];if(t.length>1)throw new re;const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.selectionToolbarViewModel.cancel();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new r([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)throw new a("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new a("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;if(z(e))return e.deleteActiveFeatures();this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}itemHasInvalidFormTemplate(e){return null!=e&&!0===Y(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:r}=this;if(!i)return;const o=void 0,a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?ue(i,a.geometry,o):ue(i,a,o);else{const e=r?.updateGraphics?.toArray();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ue(i,e.map(e=>e.geometry).filter(t),o):e&&ue(i,e,o)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){we(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){we(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):fe(e)&&await this._startUpdateWorkflowWithLayerItem(e,t)}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),o=i.allTables.toArray().filter(e=>E(e)||S(e));return await Promise.allSettled([...r.flatMap(e=>this._getLayerLoadPromise(e)),...o.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...r.reverse(),...o.reverse()].filter(e=>I(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const r=[],o=[],a=[],{layerInfos:s}=this;for(const l of i){const t=ge(s,l),i=await ee(e,l).catch(()=>null);(t?r:i?o:a).push(new te({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...r,...o,...a];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const r=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push(de(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return H.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new a("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(r=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,r)),r}async _applyEdits(e,t,i){let r=null;const o=e.url?await A(e.url):null,a={returnServiceEditsOption:(!o||!L(o))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const o=await ee(i,e).catch(()=>null);return r=await e.applyEdits(t,a),o&&await _(()=>!o.updating),r}),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation(async()=>r=await e.applyEdits(t,i)),r}_destroyWorkflowOnCommit(e){return m(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:r}=e,o=t.find(e=>!!e.error)||r.find(e=>!!e.error)||i.find(e=>!!e.error);if(o)throw o.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=$(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new a(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,o="ready"===this.state,a=1===i.length;if(this._queuedSelectionTool=void 0,o&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),r=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let o;if(null!=r&&""!==r){const e=J(i);if(e.length>1)throw new re;if(o=e[0],!o)throw new oe("merge"===t?2:1)}else o={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(o):"merge"===t&&await this.startMergeFeaturesWorkflow(o)}};e([W()],ke.prototype,"_featureTemplatesLayersAndTables",null),e([W()],ke.prototype,"_queuedSelectionTool",void 0),e([W()],ke.prototype,"_snappingManager",void 0),e([W()],ke.prototype,"_selectionSources",null),e([W()],ke.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],ke.prototype,"activeWorkflow",void 0),e([W()],ke.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],ke.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],ke.prototype,"canCreate",null),e([W()],ke.prototype,"canCreateVisible",null),e([W({readOnly:!0})],ke.prototype,"canUpdate",null),e([W()],ke.prototype,"canUpdateVisible",null),e([W()],ke.prototype,"featureTemplatesLayers",null),e([W()],ke.prototype,"editorItems",void 0),e([W()],ke.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],ke.prototype,"failures",void 0),e([W()],ke.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:P})],ke.prototype,"attachmentsViewModel",void 0),e([W()],ke.prototype,"featureFormViewModel",null),e([W()],ke.prototype,"formViewModel",null),e([W()],ke.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:ce})],ke.prototype,"featureTemplatesViewModel",void 0),e([W()],ke.prototype,"labelOptions",null),e([W()],ke.prototype,"layerInfos",void 0),e([W()],ke.prototype,"ownSketchViewModel",void 0),e([W()],ke.prototype,"selectionListViewModel",void 0),e([W()],ke.prototype,"selectionManager",void 0),e([W()],ke.prototype,"selectionToolbarViewModel",void 0),e([W()],ke.prototype,"sketchOptions",void 0),e([W()],ke.prototype,"sketchViewModel",null),e([W({type:j,nonNullable:!0})],ke.prototype,"snappingOptions",void 0),e([W()],ke.prototype,"spinnerViewModel",void 0),e([W()],ke.prototype,"state",null),e([W({readOnly:!0})],ke.prototype,"syncing",null),e([W()],ke.prototype,"updating",null),e([W()],ke.prototype,"tooltipOptions",null),e([W()],ke.prototype,"valueOptions",null),e([W()],ke.prototype,"view",null),e([W()],ke.prototype,"canZoomTo",null),e([W()],ke.prototype,"pageStack",void 0),e([W()],ke.prototype,"showDiscardEditsPrompt",void 0),e([W()],ke.prototype,"_candidateCommitted",void 0),e([W()],ke.prototype,"page",null),e([W()],ke.prototype,"featureFormDisabled",null),e([W()],ke.prototype,"featureFormHasAssociation",null),e([W()],ke.prototype,"canGoBack",null),e([W()],ke.prototype,"shouldShowDeleteButton",null),e([W()],ke.prototype,"hasPendingEdits",null),e([W()],ke.prototype,"snappingManager",null),ke=e([M("esri.widgets.Editor.EditorViewModel")],ke);const ve=ke;export{ve as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a}from"../../core/reactiveUtils.js";import{property as o,subclass as r}from"../../core/accessorSupport/decorators.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import _ from"../Sketch/SketchViewModel.js";var g;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=g=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}async commit(){this.removeHandles(V.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),a(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:a}=this,{edits:o,viewModel:r}=i,l=o.feature,{view:h}=r,d=p(l),n=await w({feature:l,featureClone:a,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(o.updateAttributes(t),o.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:a}=e,o=e.edits.feature,{capabilities:r,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!r.update.geometry||a)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new _({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:d});return this._sketchLayer=n,this._sketchViewModel=c,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(c)}),V.sketchViewModel),await u(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await m(n,d,o,t)]),{enter:async()=>{this.hasHandles(V.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([V.sketchGraphics]),viewModel:c}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new g({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([o()],v.prototype,"_layerViewEditSession",void 0),e([o()],v.prototype,"_sketchGraphicClone",void 0),e([o()],v.prototype,"_sketchLayer",void 0),e([o()],v.prototype,"_sketchViewModel",void 0),v=g=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a}from"../../core/reactiveUtils.js";import{property as o,subclass as r}from"../../core/accessorSupport/decorators.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as u,updateGraphicSymbolWhenRequired as w,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import g from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}async commit(){this.removeHandles(V.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),a(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:a}=this,{edits:o,viewModel:r}=i,l=o.feature,{view:h}=r,d=p(l),n=await u({feature:l,featureClone:a,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(o.updateAttributes(t),o.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:a}=e,o=e.edits.feature,{capabilities:r,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!r.update.geometry||a)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c={reshapeOptions:{enableCreateCurveFromStraightEdge:h.capabilities?.query.supportsTrueCurve}},p=new g({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:c,view:d});return this._sketchLayer=n,this._sketchViewModel=p,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(p)}),V.sketchViewModel),await w(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await m(n,d,o,t)]),{enter:async()=>{this.hasHandles(V.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([V.sketchGraphics]),viewModel:p}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([o()],v.prototype,"_layerViewEditSession",void 0),e([o()],v.prototype,"_sketchGraphicClone",void 0),e([o()],v.prototype,"_sketchLayer",void 0),e([o()],v.prototype,"_sketchViewModel",void 0),v=_=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import{createTask as t}from"../../core/asyncUtils.js";import o from"../../core/Error.js";import{on as s}from"../../core/events.js";import has from"../../core/has.js";import{throwIfAborted as i,createResolver as a}from"../../core/promiseUtils.js";import{property as l,subclass as n}from"../../core/accessorSupport/decorators.js";import p from"../../geometry/Point.js";import{projectWithZConversion as c}from"../../geometry/projectionUtils.js";import{equalsWithProjectionEngine as u}from"../../geometry/support/spatialReferenceUtils.js";import{uploadProgressWeights as f}from"../../layers/graphics/sources/support/uploadProgressWeights.js";import{getSupportedExtensions as d}from"../../layers/support/infoFor3D.js";import{makeProgressManager as m,estimatedTransferTime as h}from"../../support/progressUtils.js";let y=class extends r{constructor(){super(...arguments),this.files=[],this.progress=0,this._uploadTask=null,this._layer=null}destroy(){this.cancel(),this.files=[],this._layer=null,this._uploadTask=null}get state(){const e=this._uploadTask;return e&&0!==this.files.length?e.finished?e.error?"error":"success":"pending":"default"}get result(){return this._uploadTask?.value??null}get error(){return this._uploadTask?.error??null}uploadTo(e){this.cancel(),this.files=[],this._layer=e,this._uploadTask=t(async r=>{const t=await v(e);i(r),this.progress=0,this.files=t;const s=m(f.upload,e=>{this.progress=e},"Upload.uploadTo");if(0===t.length)return null;i(r);const a=await e.extractAndFilterFiles(t);i(r),a.length>0&&(this.files=a);const l=await e.convertMesh(a,{signal:r,onProgress:s.makeOnProgress("createFromFiles")});if(i(r),!l)throw new o("editor:upload","could not upload or convert model");const n=a.reduce((e,r)=>e+r.size,0),p=s.simulate("loadMesh",h(n));try{await l.load()}finally{p.remove()}if(!has("disable-feature:georeferenced-uploads")&&l.metadata.georeferenced){if(await u(e.spatialReference,l.origin?.spatialReference))return{type:"georeferenced",mesh:l};if(await w(l,e.spatialReference))return{type:"georeferenced-reprojected",mesh:l}}return l.spatialReference=e.spatialReference,l.vertexSpace.origin=[0,0,0],{type:"non-georeferenced",mesh:l}})}retry(){this._layer&&this.uploadTo(this._layer)}cancel(){this._uploadTask?.abort()}};e([l()],y.prototype,"files",void 0),e([l()],y.prototype,"progress",void 0),e([l()],y.prototype,"state",null),e([l()],y.prototype,"result",null),e([l()],y.prototype,"error",null),e([l()],y.prototype,"_uploadTask",void 0),e([l()],y.prototype,"_layer",void 0),y=e([n("esri.widgets.Editor.Upload")],y);let g=null;async function v(e){const{resolve:r,promise:t}=a(),o=document.createElement("input");o.type="file",o.multiple=!1,o.accept=[...d(e.infoFor3D),".zip"].join(","),o.style.display="none",document.body.appendChild(o);const i=s(o,"change",()=>r(o.files?Array.from(o.files):[]));return g?g(o):o.click(),t.finally(()=>{i.remove(),o.remove()})}function j(e,r){g=t=>{r?.(),Promise.resolve().then(()=>e).then(e=>{if(!g)return;const r=new DataTransfer;e.forEach(e=>r.items.add(e)),t.files=r.files,t.dispatchEvent(new Event("change"))})}}function _(){g=null}async function w(e,r){if(!e.vertexSpace.origin)return!1;const[t,o,s]=e.vertexSpace.origin,i=new p({x:t,y:o,z:s,spatialReference:e.spatialReference}),a=await c(i,r);return!!a&&(e.vertexSpace.origin=[a.x,a.y,a.z??0],e.spatialReference=r,!0)}export{y as Upload,_ as clearPromptForFilesStub,j as stubFilePickerToSelect};
5
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{on as s}from"../../core/events.js";import{throwIfAborted as i,createResolver as l}from"../../core/promiseUtils.js";import{property as n,subclass as a}from"../../core/accessorSupport/decorators.js";import{equalsWithProjectionEngine as p}from"../../geometry/support/spatialReferenceUtils.js";import{uploadProgressWeights as c}from"../../layers/graphics/sources/support/uploadProgressWeights.js";import{getSupportedExtensions as u}from"../../layers/support/infoFor3D.js";import{makeProgressManager as d,estimatedTransferTime as f}from"../../support/progressUtils.js";let h=class extends r{constructor(){super(...arguments),this.files=[],this.progress=0,this._uploadTask=null,this._layer=null}destroy(){this.cancel(),this.files=[],this._layer=null,this._uploadTask=null}get state(){const e=this._uploadTask;return e&&0!==this.files.length?e.finished?e.error?"error":"success":"pending":"default"}get result(){return this._uploadTask?.value??null}get error(){return this._uploadTask?.error??null}uploadTo(e){this.cancel(),this.files=[],this._layer=e,this._uploadTask=o(async r=>{const o=await y(e);i(r),this.progress=0,this.files=o;const s=d(c.upload,e=>{this.progress=e},"Upload.uploadTo");if(0===o.length)return null;i(r);const l=await e.extractAndFilterFiles(o);i(r),l.length>0&&(this.files=l);const{mesh:n,georeferenceInfo:a}=await e.convertMesh(l,{signal:r,onProgress:s.makeOnProgress("createFromFiles")});if(i(r),!n)throw new t("editor:upload","could not upload or convert model");const u=l.reduce((e,r)=>e+r.size,0),h=s.simulate("loadMesh",f(u));try{await n.load()}finally{h.remove()}if(a){return{type:!await p(e.spatialReference,a.origin.spatialReference)?"georeferenced-reprojected":"georeferenced",mesh:n}}return{type:"non-georeferenced",mesh:n}})}retry(){this._layer&&this.uploadTo(this._layer)}cancel(){this._uploadTask?.abort()}};e([n()],h.prototype,"files",void 0),e([n()],h.prototype,"progress",void 0),e([n()],h.prototype,"state",null),e([n()],h.prototype,"result",null),e([n()],h.prototype,"error",null),e([n()],h.prototype,"_uploadTask",void 0),e([n()],h.prototype,"_layer",void 0),h=e([a("esri.widgets.Editor.Upload")],h);let m=null;async function y(e){const{resolve:r,promise:o}=l(),t=document.createElement("input");t.type="file",t.multiple=!1,t.accept=[...u(e.infoFor3D),".zip"].join(","),t.style.display="none",document.body.appendChild(t);const i=s(t,"change",()=>r(t.files?Array.from(t.files):[]));return m?m(t):t.click(),o.finally(()=>{i.remove(),t.remove()})}function g(e,r){m=o=>{r?.(),Promise.resolve().then(()=>e).then(e=>{if(!m)return;const r=new DataTransfer;e.forEach(e=>r.items.add(e)),o.files=r.files,o.dispatchEvent(new Event("change"))})}}function v(){m=null}export{h as Upload,v as clearPromptForFilesStub,g as stubFilePickerToSelect};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import e from"../../support/SketchTooltipControls.js";import o from"../../support/SnappingControls.js";import{tsx as i}from"../../support/widget.js";import s from"../../support/SketchTooltipControls/VisibleElements.js";import n from"../../support/SnappingControls/VisibleElements.js";const p={settingsContainer:"esri-editor__settings"},r=()=>t({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item")});function c({editorViewModel:t,messagesCommon:r,visibleElements:c}){const{snappingOptions:a,sketchOptions:l,view:m,snappingManager:g}=t,d=[],u={directionModePicker:c.directionModePicker,labelsToggle:c.labelsToggle,tooltipsToggle:c.tooltipsToggle};return Object.values(u).includes(!0)&&d.push(i(e,{sketchOptions:l,viewType:m?.type,visibleElements:new s(u)})),c.snappingControls&&d.push(i(o,{afterCreate:t=>t.layerListOpen=!1,snappingManager:g,snappingOptions:a,view:m,visibleElements:c.snappingControlsElements??new n})),0===d.length?null:i("calcite-accordion",{appearance:"transparent",class:p.settingsContainer,key:"settings"},i("calcite-accordion-item",{"data-testid":"settings",heading:r.settings,iconStart:"gear"},d))}export{c as Settings,p as css,r as loadSettingsComponents};
5
+ import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import e from"../../support/SketchTooltipControls.js";import o from"../../support/SnappingControls.js";import{tsx as s}from"../../support/widget.js";import i from"../../support/SketchTooltipControls/VisibleElements.js";import n from"../../support/SnappingControls/VisibleElements.js";const p={settingsContainer:"esri-editor__settings"},r=()=>t({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item")});function c({editorViewModel:t,messagesCommon:r,visibleElements:c}){const{snappingOptions:a,sketchOptions:l,view:m,snappingManager:g}=t,d=[],u={directionModePicker:c.directionModePicker,labelsToggle:c.labelsToggle,tooltipsToggle:c.tooltipsToggle};return Object.values(u).includes(!0)&&d.push(s(e,{sketchOptions:l,visibleElements:new i(u)})),c.snappingControls&&d.push(s(o,{afterCreate:t=>t.layerListOpen=!1,snappingManager:g,snappingOptions:a,view:m,visibleElements:c.snappingControlsElements??new n})),0===d.length?null:s("calcite-accordion",{appearance:"transparent",class:p.settingsContainer,key:"settings"},s("calcite-accordion-item",{"data-testid":"settings",heading:r.settings,iconStart:"gear"},d))}export{c as Settings,p as css,r as loadSettingsComponents};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import{whenOnce as o,watch as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import h from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as u,updateGraphicSymbolWhenRequired as y,setVisualVariablesAndElevationInfoForUpdate as m,swapForEditingSession as v,visualVariableInteractiveUpdate as _,getSizeVariableAttribute as g,getRotationVariableAttribute as w}from"../workflowUtils.js";import f from"../../Sketch/SketchViewModel.js";const b=Symbol();let k=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new h,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._nextUpdateSubset=[],this._sketchGraphicsMap=new r,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=u(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get sketchGraphics(){return Array.from(this._sketchGraphicsMap.values())}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphicsMap.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(y(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:r,_sketchLayer:n,sourceLayer:l,view:p,viewModel:c,_webStyleCache:d}=this,h=e.map(e=>r.get(e)).filter(i),u={};this._completeCurrentOperation();let v=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await m({graphic:h[0],sketchLayer:n,sketchViewModel:c,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(u.enableRotation=null!=i.rotation,u.enableScaling=null!=i.size,v=async e=>{const s=e.graphics[0];_(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(y(s,d,"2d"===p.type?p.scale:null)))}))}else u.tool="move";const g=()=>c.update(h,u),w=c.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void g();const e=new AbortController,t=s(e);return this.addHandles(t,b),void this._updatingHandles.addPromise(o(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await g())}))}const n=e.map(e=>{const t=r.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),v?.(a)});await g(),this._nextUpdateSubset=this.features,this.addHandles(w,b),c.addHandles(w)}_completeCurrentOperation(){this.removeHandles(b),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,M(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,view:i,_webStyleCache:s}=this,r=Array.from(e.entries()),o=new f({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:i});this.viewModel=o;const l=a(e=>Promise.all(r.map(([,t])=>y(t,s,e))));await l("2d"===i.type?i.scale:null),"2d"===i.type&&this.addHandles(n(()=>i.scale,e=>l(e))),this.addHandles(await Promise.all(r.map(([e,s])=>v(t,i,e,s))))}};function M({rotation:e,size:t},i){return{rotation:e?w(e,i.rotation):null,size:t?g(t,i.size):null}}e([l()],k.prototype,"features",void 0),e([l()],k.prototype,"onGeometriesUpdated",void 0),e([l()],k.prototype,"onVisualVariableAttributesUpdated",void 0),e([l()],k.prototype,"sketchGraphics",null),e([l()],k.prototype,"sketchOptions",void 0),e([l()],k.prototype,"snappingManager",void 0),e([l()],k.prototype,"sourceLayer",void 0),e([l()],k.prototype,"updating",null),e([l()],k.prototype,"view",void 0),e([l()],k.prototype,"viewModel",void 0),e([l()],k.prototype,"_nextUpdateSubset",void 0),e([l()],k.prototype,"_sketchGraphicsMap",void 0),e([l()],k.prototype,"_sketchLayer",void 0),e([l()],k.prototype,"_visualVariablesForLayer",void 0),k=e([p("esri.widgets.Editor.support.SketchController")],k);export{k as SketchController};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import{whenOnce as o,watch as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import h from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as u,updateGraphicSymbolWhenRequired as y,setVisualVariablesAndElevationInfoForUpdate as m,swapForEditingSession as v,visualVariableInteractiveUpdate as g,getSizeVariableAttribute as _,getRotationVariableAttribute as b}from"../workflowUtils.js";import w from"../../Sketch/SketchViewModel.js";const f=Symbol();let k=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new h,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._nextUpdateSubset=[],this._sketchGraphicsMap=new r,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=u(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get sketchGraphics(){return Array.from(this._sketchGraphicsMap.values())}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphicsMap.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(y(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:r,_sketchLayer:n,sourceLayer:l,view:p,viewModel:c,_webStyleCache:d}=this,h=e.map(e=>r.get(e)).filter(i),u={};this._completeCurrentOperation();let v=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await m({graphic:h[0],sketchLayer:n,sketchViewModel:c,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(u.enableRotation=null!=i.rotation,u.enableScaling=null!=i.size,v=async e=>{const s=e.graphics[0];g(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(y(s,d,"2d"===p.type?p.scale:null)))}))}else u.tool="move";const _=()=>c.update(h,u),b=c.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void _();const e=new AbortController,t=s(e);return this.addHandles(t,f),void this._updatingHandles.addPromise(o(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await _())}))}const n=e.map(e=>{const t=r.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),v?.(a)});await _(),this._nextUpdateSubset=this.features,this.addHandles(b,f),c.addHandles(b)}_completeCurrentOperation(){this.removeHandles(f),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,S(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,sourceLayer:i,view:s,_webStyleCache:r}=this,o=Array.from(e.entries()),l=new w({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:i.capabilities?.query.supportsTrueCurve}},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:s});this.viewModel=l;const p=a(e=>Promise.all(o.map(([,t])=>y(t,r,e))));await p("2d"===s.type?s.scale:null),"2d"===s.type&&this.addHandles(n(()=>s.scale,e=>p(e))),this.addHandles(await Promise.all(o.map(([e,i])=>v(t,s,e,i))))}};function S({rotation:e,size:t},i){return{rotation:e?b(e,i.rotation):null,size:t?_(t,i.size):null}}e([l()],k.prototype,"features",void 0),e([l()],k.prototype,"onGeometriesUpdated",void 0),e([l()],k.prototype,"onVisualVariableAttributesUpdated",void 0),e([l()],k.prototype,"sketchGraphics",null),e([l()],k.prototype,"sketchOptions",void 0),e([l()],k.prototype,"snappingManager",void 0),e([l()],k.prototype,"sourceLayer",void 0),e([l()],k.prototype,"updating",null),e([l()],k.prototype,"view",void 0),e([l()],k.prototype,"viewModel",void 0),e([l()],k.prototype,"_nextUpdateSubset",void 0),e([l()],k.prototype,"_sketchGraphicsMap",void 0),e([l()],k.prototype,"_sketchLayer",void 0),e([l()],k.prototype,"_visualVariablesForLayer",void 0),k=e([p("esri.widgets.Editor.support.SketchController")],k);export{k as SketchController};