@arcgis/core 4.31.0-next.20240821 → 4.31.0-next.20240823

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 (376) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{24e38b7d1e9984a1472e.js → 033032715c3b04e0fc7d.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{cfc93bbd35cc4bfde7c0.js → 045336db17aae6eef68f.js} +1 -1
  4. package/assets/esri/core/workers/chunks/04de7b2937d5ca7c23e2.js +1 -0
  5. package/assets/esri/core/workers/chunks/12a4b3706162872c2b41.js +769 -0
  6. package/assets/esri/core/workers/chunks/142b1336533fa2ac470b.js +47 -0
  7. package/assets/esri/core/workers/chunks/185e596f86767c22f951.js +1 -0
  8. package/assets/esri/core/workers/chunks/{cd8d595d577b74817623.js → 1a4b3820136fb615b730.js} +1 -1
  9. package/assets/esri/core/workers/chunks/29b157b41dfa16da886b.js +1 -0
  10. package/assets/esri/core/workers/chunks/300b57846114fedd12be.js +1 -0
  11. package/assets/esri/core/workers/chunks/{3f75b7ed24b440b4508a.js → 3d5f37c2f355260e6dc6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a9eba26d62b62592cee1.js → 42861d54a336146753d8.js} +1 -1
  13. package/assets/esri/core/workers/chunks/4c8deac4bf72a5e2597a.js +1 -0
  14. package/assets/esri/core/workers/chunks/52107d450c55450f5c04.js +274 -0
  15. package/assets/esri/core/workers/chunks/6d54222301b6d819c904.js +1 -0
  16. package/assets/esri/core/workers/chunks/{eb0f180ed20af220a82e.js → 6ddece9cd94b60efe3d7.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{566844774388a031fd74.js → 7125cff7fd288ff7bd5f.js} +1 -1
  18. package/assets/esri/core/workers/chunks/74de734a20b4cd2d7efb.js +1 -0
  19. package/assets/esri/core/workers/chunks/7712a23dc68220edaa64.js +1 -0
  20. package/assets/esri/core/workers/chunks/{ea561b2460e634a643fc.js → 7f35380809e7de99c302.js} +1 -1
  21. package/assets/esri/core/workers/chunks/7f3d49b667e9b46449e7.js +1 -0
  22. package/assets/esri/core/workers/chunks/8a2faf12938e811a9fc9.js +1 -0
  23. package/assets/esri/core/workers/chunks/{796c64b9caa1303e26ed.js → 8af503fa88c1668872eb.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{e2a6f77c05d0818e3f74.js → 8e42ce8305cefba5debc.js} +1 -1
  25. package/assets/esri/core/workers/chunks/93169e55e472fec4bc50.js +1 -0
  26. package/assets/esri/core/workers/chunks/985c1f42aab564008c0d.js +1 -0
  27. package/assets/esri/core/workers/chunks/9a32d9d720cb81abfba2.js +1 -0
  28. package/assets/esri/core/workers/chunks/b171d57b4d0142f687d0.js +1 -0
  29. package/assets/esri/core/workers/chunks/d5e376893cd47605a438.js +1 -0
  30. package/assets/esri/core/workers/chunks/df9daac7ea581e9e5ca4.js +1 -0
  31. package/assets/esri/core/workers/chunks/f11ae249cc8e995bbccc.js +1 -0
  32. package/assets/esri/core/workers/chunks/{65d8011cf756b066cade.js → f218316de8b4635653b2.js} +1 -1
  33. package/assets/esri/libs/linkchartlayout/lclayout.wasm +0 -0
  34. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  35. package/assets/esri/themes/base/_core.scss +2 -0
  36. package/assets/esri/themes/base/widgets/_Grid.scss +0 -8
  37. package/assets/esri/themes/base/widgets/_GridControls.scss +86 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +13 -15
  39. package/assets/esri/themes/dark/main.css +1 -1
  40. package/assets/esri/themes/light/main.css +1 -1
  41. package/assets/esri/themes/light/view.css +1 -1
  42. package/assets/esri/widgets/Print/t9n/Print.json +1 -1
  43. package/assets/esri/widgets/Print/t9n/Print_ar.json +1 -1
  44. package/assets/esri/widgets/Print/t9n/Print_bg.json +1 -1
  45. package/assets/esri/widgets/Print/t9n/Print_bs.json +1 -1
  46. package/assets/esri/widgets/Print/t9n/Print_ca.json +1 -1
  47. package/assets/esri/widgets/Print/t9n/Print_cs.json +1 -1
  48. package/assets/esri/widgets/Print/t9n/Print_da.json +1 -1
  49. package/assets/esri/widgets/Print/t9n/Print_de.json +1 -1
  50. package/assets/esri/widgets/Print/t9n/Print_el.json +1 -1
  51. package/assets/esri/widgets/Print/t9n/Print_en.json +1 -1
  52. package/assets/esri/widgets/Print/t9n/Print_es.json +1 -1
  53. package/assets/esri/widgets/Print/t9n/Print_et.json +1 -1
  54. package/assets/esri/widgets/Print/t9n/Print_fi.json +1 -1
  55. package/assets/esri/widgets/Print/t9n/Print_fr.json +1 -1
  56. package/assets/esri/widgets/Print/t9n/Print_he.json +1 -1
  57. package/assets/esri/widgets/Print/t9n/Print_hr.json +1 -1
  58. package/assets/esri/widgets/Print/t9n/Print_hu.json +1 -1
  59. package/assets/esri/widgets/Print/t9n/Print_id.json +1 -1
  60. package/assets/esri/widgets/Print/t9n/Print_it.json +1 -1
  61. package/assets/esri/widgets/Print/t9n/Print_ja.json +1 -1
  62. package/assets/esri/widgets/Print/t9n/Print_ko.json +1 -1
  63. package/assets/esri/widgets/Print/t9n/Print_lt.json +1 -1
  64. package/assets/esri/widgets/Print/t9n/Print_lv.json +1 -1
  65. package/assets/esri/widgets/Print/t9n/Print_nb.json +1 -1
  66. package/assets/esri/widgets/Print/t9n/Print_nl.json +1 -1
  67. package/assets/esri/widgets/Print/t9n/Print_pl.json +1 -1
  68. package/assets/esri/widgets/Print/t9n/Print_pt-BR.json +1 -1
  69. package/assets/esri/widgets/Print/t9n/Print_pt-PT.json +1 -1
  70. package/assets/esri/widgets/Print/t9n/Print_ro.json +1 -1
  71. package/assets/esri/widgets/Print/t9n/Print_ru.json +1 -1
  72. package/assets/esri/widgets/Print/t9n/Print_sk.json +1 -1
  73. package/assets/esri/widgets/Print/t9n/Print_sl.json +1 -1
  74. package/assets/esri/widgets/Print/t9n/Print_sr.json +1 -1
  75. package/assets/esri/widgets/Print/t9n/Print_sv.json +1 -1
  76. package/assets/esri/widgets/Print/t9n/Print_th.json +1 -1
  77. package/assets/esri/widgets/Print/t9n/Print_tr.json +1 -1
  78. package/assets/esri/widgets/Print/t9n/Print_uk.json +1 -1
  79. package/assets/esri/widgets/Print/t9n/Print_vi.json +1 -1
  80. package/assets/esri/widgets/Print/t9n/Print_zh-CN.json +1 -1
  81. package/assets/esri/widgets/Print/t9n/Print_zh-HK.json +1 -1
  82. package/assets/esri/widgets/Print/t9n/Print_zh-TW.json +1 -1
  83. package/assets/esri/widgets/support/GridControls/t9n/GridControls.json +1 -0
  84. package/assets/esri/widgets/support/GridControls/t9n/GridControls_en.json +1 -0
  85. package/chunks/CloudsComposition.glsl.js +3 -3
  86. package/chunks/ComponentShader.glsl.js +53 -61
  87. package/chunks/DefaultMaterial.glsl.js +1 -1
  88. package/chunks/FocusAreaColor.glsl.js +12 -0
  89. package/chunks/FocusAreaMask.glsl.js +5 -0
  90. package/chunks/Laserlines.glsl.js +1 -1
  91. package/chunks/Path.glsl.js +22 -17
  92. package/chunks/PointRenderer.glsl.js +3 -3
  93. package/chunks/Precipitation.glsl.js +1 -1
  94. package/chunks/Terrain.glsl.js +1 -1
  95. package/chunks/WaterSurface.glsl.js +18 -18
  96. package/chunks/boundedPlane.js +1 -1
  97. package/chunks/cameraUtilsPlanar.js +1 -1
  98. package/chunks/cameraUtilsSpherical.js +1 -1
  99. package/chunks/sphere.js +1 -1
  100. package/chunks/terrainUtilsPlanar.js +1 -1
  101. package/chunks/vec32.js +1 -1
  102. package/chunks/vxlLayer.js +1 -1
  103. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  104. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  105. package/core/mathUtils.js +1 -1
  106. package/core/perspectiveUtils.js +1 -1
  107. package/exports/csv.js +1 -1
  108. package/geometry/operators/support/converterAPI.js +1 -1
  109. package/geometry/projection/localLinearScaleFactors.js +1 -1
  110. package/geometry/support/buffer/internals/Vec3.js +1 -1
  111. package/geometry/support/clipRay.js +1 -1
  112. package/geometry/support/coordinateSystem.js +1 -1
  113. package/geometry/support/frustum.js +1 -1
  114. package/geometry/support/heightModelInfoUtils.js +1 -1
  115. package/geometry/support/lineSegment.js +1 -1
  116. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  117. package/geometry/support/meshUtils/rotate.js +1 -1
  118. package/geometry/support/meshUtils/scale.js +1 -1
  119. package/geometry/support/plane.js +1 -1
  120. package/geometry/support/polygonUtils.js +1 -1
  121. package/geometry/support/ray.js +1 -1
  122. package/geometry/support/sphere.js +1 -1
  123. package/geometry/support/sphereUtils.js +5 -0
  124. package/geometry/support/triangle.js +1 -1
  125. package/geometry/support/vector.js +1 -1
  126. package/interfaces.d.ts +68 -9
  127. package/layers/FocusAreaLayer.js +5 -0
  128. package/layers/VoxelLayer.js +1 -1
  129. package/layers/VoxelWasmPerSceneView.js +1 -1
  130. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  131. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  132. package/layers/video/VideoCameraSensorModel.js +1 -1
  133. package/package.json +1 -1
  134. package/support/revision.js +1 -1
  135. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  136. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  137. package/symbols/support/Symbol3DMaterial.js +1 -1
  138. package/views/2d/engine/webgl/AFeatureTile.js +1 -1
  139. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  140. package/views/2d/grid/GridView2D.js +1 -1
  141. package/views/2d/grid/constants.js +5 -0
  142. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  143. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  144. package/views/2d/layerViewModuleImportUtils.js +1 -1
  145. package/views/2d/support/highlightGroupUtils.js +1 -1
  146. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  147. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  148. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  149. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  150. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  151. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  152. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  153. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  154. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  155. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  156. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  157. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  158. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  159. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  160. package/views/3d/analysis/Viewshed/viewshedToolUtils.js +1 -1
  161. package/views/3d/analysis/support/measurementUtils.js +1 -1
  162. package/views/3d/animation/pointToPoint/Animation.js +1 -1
  163. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  164. package/views/3d/camera/constraintUtils/common.js +1 -1
  165. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  166. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  167. package/views/3d/camera/intersectionUtils.js +1 -1
  168. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  169. package/views/3d/environment/CloudsComposition.glsl.js +1 -1
  170. package/views/3d/environment/CloudsParameters.js +1 -1
  171. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  172. package/views/3d/environment/Fog.js +1 -1
  173. package/views/3d/environment/MarsAtmosphere.js +1 -1
  174. package/views/3d/interactive/Manipulator3D.js +1 -1
  175. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  176. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  177. package/views/3d/interactive/editingTools/lineObjectVisualElementUtils.js +1 -1
  178. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  179. package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
  180. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  181. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  182. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  183. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  184. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  185. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  186. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  187. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  188. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  189. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  190. package/views/3d/layerViewModuleImportUtils.js +1 -1
  191. package/views/3d/layers/FocusAreaLayerView3D.js +5 -0
  192. package/views/3d/layers/I3SMeshView3D.js +1 -1
  193. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  194. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  195. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  196. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  197. package/views/3d/layers/VoxelGraphic.js +5 -0
  198. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  200. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  205. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  206. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  207. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  208. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  209. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  210. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  211. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  212. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  213. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  214. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  215. package/views/3d/layers/i3s/LoDUtil.js +1 -1
  216. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  217. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  218. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  219. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  220. package/views/3d/layers/support/uvUtils.js +1 -1
  221. package/views/3d/state/NearFarHeuristic.js +1 -1
  222. package/views/3d/state/ViewStateManager.js +1 -1
  223. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  224. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  225. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  226. package/views/3d/state/controllers/RotateController.js +1 -1
  227. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  228. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  229. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  230. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  231. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  232. package/views/3d/state/utils/navigationUtils.js +1 -1
  233. package/views/3d/state/utils/viewUtils.js +1 -1
  234. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  235. package/views/3d/support/cameraUtilsInternal.js +1 -1
  236. package/views/3d/support/geometryUtils/ray.js +1 -1
  237. package/views/3d/support/intersectionUtils.js +1 -1
  238. package/views/3d/support/mathUtils.js +1 -1
  239. package/views/3d/support/orientedBoundingBox.js +1 -1
  240. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  241. package/views/3d/support/sunUtils.js +1 -1
  242. package/views/3d/support/viewpointUtils.js +1 -1
  243. package/views/3d/terrain/OverlayRenderer.js +1 -1
  244. package/views/3d/terrain/PatchRenderData.js +1 -1
  245. package/views/3d/terrain/SphericalPatch.js +1 -1
  246. package/views/3d/terrain/TerrainRenderer.js +1 -1
  247. package/views/3d/terrain/TerrainSurface.js +1 -1
  248. package/views/3d/terrain/Tile.js +1 -1
  249. package/views/3d/terrain/isTerrainSurfaceLayer.js +1 -1
  250. package/views/3d/webgl/RenderCamera.js +1 -1
  251. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  252. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  253. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  254. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  255. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  256. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  257. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  258. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  259. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  260. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +1 -1
  261. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +1 -1
  262. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +2 -6
  263. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +2 -2
  264. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js +13 -0
  265. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +1 -1
  266. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +11 -13
  267. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +4 -4
  268. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +1 -4
  269. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +3 -3
  270. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +1 -1
  271. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +2 -2
  272. package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +1 -1
  273. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  274. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorRenderNodeTechnique.js +5 -0
  275. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskRenderNodeTechnique.js +5 -0
  276. package/views/3d/webgl-engine/effects/focusArea/FocusAreaParameters.js +5 -0
  277. package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNode.js +5 -0
  278. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  279. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  280. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  281. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  282. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  283. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  284. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  285. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  286. package/views/3d/webgl-engine/lib/Path.js +1 -1
  287. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  288. package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
  289. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  290. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  291. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  292. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  293. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  294. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  295. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  296. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  297. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  298. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  299. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  300. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  301. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  302. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  303. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  304. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  305. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  306. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  307. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  308. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  309. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  310. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  311. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  312. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +5 -0
  313. package/views/3d/webgl-engine/shaders/FocusAreaMask.glsl.js +5 -0
  314. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  315. package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
  316. package/views/draw/support/helpMessageUtils3d.js +1 -1
  317. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  318. package/views/input/gamepad/GamepadSource.js +1 -1
  319. package/views/interactive/coordinateHelper.js +1 -1
  320. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  321. package/views/interactive/sketch/constraints.js +1 -1
  322. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  323. package/views/interactive/snapping/GridSnappingEngine.js +5 -0
  324. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  325. package/views/interactive/snapping/SnappingOptions.js +1 -1
  326. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  327. package/views/interactive/snapping/snappingUtils.js +1 -1
  328. package/views/navigation/PanPlanarMomentumEstimator.js +1 -1
  329. package/views/support/angularMeasurementUtils.js +1 -1
  330. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  331. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  332. package/views/support/geometry3dUtils.js +1 -1
  333. package/webscene/Slide.js +1 -1
  334. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  335. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  336. package/widgets/Feature/FeatureMedia.js +1 -1
  337. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  338. package/widgets/FeatureTable/Grid/Column.js +1 -1
  339. package/widgets/FeatureTable.js +1 -1
  340. package/widgets/GridControls/GridControlsViewModel.d.ts +4 -0
  341. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  342. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  343. package/widgets/Print/CustomTemplate.js +1 -1
  344. package/widgets/Print/PrintViewModel.js +1 -1
  345. package/widgets/Print/TemplateOptions.js +1 -1
  346. package/widgets/Print/utils.js +5 -0
  347. package/widgets/Print.js +1 -1
  348. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  349. package/widgets/support/GridControls/GridControlsViewModel.d.ts +4 -0
  350. package/widgets/support/GridControls/GridControlsViewModel.js +5 -0
  351. package/widgets/support/GridControls/VisibleElements.js +5 -0
  352. package/widgets/support/GridControls/gridUtils.js +5 -0
  353. package/widgets/support/GridControls.d.ts +4 -0
  354. package/widgets/support/GridControls.js +5 -0
  355. package/widgets/support/exportUtils.js +1 -1
  356. package/assets/esri/core/workers/chunks/14dc47896456e3c66b24.js +0 -1
  357. package/assets/esri/core/workers/chunks/2e88af8ab1e2713e7655.js +0 -1
  358. package/assets/esri/core/workers/chunks/3b204e75b613bcfbc8b9.js +0 -1
  359. package/assets/esri/core/workers/chunks/3e57f493d5a9d7aa7a48.js +0 -1
  360. package/assets/esri/core/workers/chunks/4e5ae81c612543130d9a.js +0 -1
  361. package/assets/esri/core/workers/chunks/4e746f8fca1d932dd684.js +0 -1
  362. package/assets/esri/core/workers/chunks/544eec13338b2d71680f.js +0 -1
  363. package/assets/esri/core/workers/chunks/5e7e12863cbed07451d0.js +0 -1
  364. package/assets/esri/core/workers/chunks/6c129767cda74aa672e0.js +0 -1
  365. package/assets/esri/core/workers/chunks/6f7c2d02fbd29870f6ee.js +0 -1
  366. package/assets/esri/core/workers/chunks/7802e70422f4151b95bc.js +0 -1
  367. package/assets/esri/core/workers/chunks/920557db2bd107a3c579.js +0 -1
  368. package/assets/esri/core/workers/chunks/9443b9ec03f25c723c2c.js +0 -47
  369. package/assets/esri/core/workers/chunks/991295637f51e8207efe.js +0 -1
  370. package/assets/esri/core/workers/chunks/ace8b6351ed35b03499b.js +0 -1
  371. package/assets/esri/core/workers/chunks/b1e4896acfae0bf9a9a8.js +0 -1
  372. package/assets/esri/core/workers/chunks/ca12b1c470e67ca7b30e.js +0 -1
  373. package/assets/esri/core/workers/chunks/cd9f48dcee2a1fc261ed.js +0 -774
  374. package/assets/esri/core/workers/chunks/d3626c01d2569d84e01e.js +0 -1
  375. package/assets/esri/core/workers/chunks/e5474bcde5b8fa037b56.js +0 -278
  376. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +0 -31
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",c={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let a=class extends t.EventedAccessor{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:o}=e,{formatFunction:n}=this,i=r.sanitize(o);if(n&&t){const{index:e,item:{feature:o}}=t;return n({column:this,feature:o,index:e,value:i})}return i},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,o=this.createHeaderContent();this.removeCellContent(t),t.appendChild(o)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:o})=>{const n=this.getCellValue(o),i=this.cellValueFormatFunction({column:t,rowData:o,value:n});let r=null;r=i instanceof HTMLElement?i:s(this.messagesURIUtils,i),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([o((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),o((()=>this.hidden),(()=>this.closeMenu())),o((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)})),o((()=>this.effectiveLabel),(e=>{const{sortElement:t}=this;t&&t.textContent!==e&&(t.setAttribute("title",e),t.textContent=e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:o,iconClass:n,label:i,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:n,iconStart:o,selected:s,textContent:i,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],o=this.visibleElements?.columnMenuItems;if(!1!==o?.sortAscending){const o=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(o)}if(!1!==o?.sortDescending){const o=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(o)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:o}=this,n=!!o?.open,i=this.createCalciteAction({icon:o?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=o?.maxItems??4,s.placement="top-end",s.overlayPositioning="fixed",s.scale=o?.scale??"m",n&&(s.open=n,this._menuIsOpen=!0),s.appendChild(i),s.addEventListener("calciteDropdownOpen",(()=>this._menuIsOpen=!0)),s.addEventListener("calciteDropdownClose",(()=>this._menuIsOpen=!1)),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=o?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:o,initialSortPriority:n}=this,i=document.createElement("vaadin-grid-sorter");return i.classList.add(c.sorter),i.setAttribute("path",o),i.setAttribute("title",e),i.textContent=e,t&&i.setAttribute("direction",t),null!=n&&(i._initialOrder=n),i.addEventListener("direction-changed",(()=>{this.direction!==i.direction&&this._set("direction",i.direction)})),i}createCalciteAction(e){const t=document.createElement("calcite-action"),{className:o,disabled:n,icon:i,label:s,scale:r,slot:l,text:c,textEnabled:a,onclick:d}=e;return t.className=o??"",t.disabled=!!n,t.icon=i??"",t.label=s??"",t.scale=r??"s",t.slot=l??"",t.text=t.title=c??"",t.textEnabled=!!a,t.onclick=d??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:o,className:n,disabled:i,iconEnd:s,iconFlipRtl:r,loading:l,onclick:c,scale:a,textContent:d}=e;return t.className=n??"",t.scale=a??"s",t.appearance=o??"transparent",t.disabled=!!i,t.iconEnd=s??"",r&&(t.iconFlipRtl=r),t.loading=!!l,t.textContent=t.title=d??"",t.onclick=c??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:o,hidden:n,iconClass:i,iconStart:s,textContent:r,onclick:l,selected:a}=e,d=r??"";if(i&&!s){const e=document.createElement("span"),o=document.createElement("span");o.classList.add(c.headerMenuIcon,i),e.textContent=e.title=d,e.insertBefore(o,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!o,t.hidden="function"==typeof n?n():!!n,t.selected=!!a,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:o,scale:n,textLabel:i}=e,s=document.createElement("calcite-icon"),r=i??t;return s.icon=o,s.scale=n??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,o=document.createElement("div");if(o.classList.add(c.headerContent),t&&o.appendChild(t),this.sortable)o.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(c.headerLabel);const n=t.appendChild(document.createElement("span"));n.textContent=e,n.setAttribute("title",e),o.appendChild(t)}return this.menuIsVisible&&o.appendChild(this.menu),o}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}};e([n()],a.prototype,"_menuIsOpen",void 0),e([n()],a.prototype,"autoWidth",void 0),e([n()],a.prototype,"cellValueFormatFunction",void 0),e([n()],a.prototype,"customMenuItems",null),e([n()],a.prototype,"defaultMenuItems",null),e([n()],a.prototype,"direction",void 0),e([n()],a.prototype,"effectiveLabel",null),e([n({constructOnly:!0})],a.prototype,"fieldName",void 0),e([n()],a.prototype,"flexGrow",void 0),e([n()],a.prototype,"footerRenderFunction",void 0),e([n()],a.prototype,"formatFunction",void 0),e([n()],a.prototype,"frozen",void 0),e([n()],a.prototype,"frozenToEnd",void 0),e([n()],a.prototype,"grid",void 0),e([n()],a.prototype,"iconNode",null),e([n()],a.prototype,"invalid",null),e([n()],a.prototype,"headerRenderFunction",void 0),e([n()],a.prototype,"hidden",void 0),e([n()],a.prototype,"icon",void 0),e([n({constructOnly:!0})],a.prototype,"initialSortPriority",void 0),e([n()],a.prototype,"label",void 0),e([n()],a.prototype,"menu",null),e([n()],a.prototype,"menuItems",null),e([n()],a.prototype,"menuConfig",void 0),e([n()],a.prototype,"menuIsOpen",null),e([n()],a.prototype,"menuIsVisible",null),e([n()],a.prototype,"messages",void 0),e([n()],a.prototype,"messagesCommon",void 0),e([n()],a.prototype,"messagesURIUtils",void 0),e([n()],a.prototype,"renderFunction",void 0),e([n()],a.prototype,"resizable",void 0),e([n()],a.prototype,"sortable",void 0),e([n({readOnly:!0})],a.prototype,"sortElement",void 0),e([n()],a.prototype,"store",void 0),e([n()],a.prototype,"textAlign",void 0),e([n()],a.prototype,"textWrap",void 0),e([n()],a.prototype,"timeZone",void 0),e([n()],a.prototype,"timeZoneName",void 0),e([n()],a.prototype,"visibleElements",void 0),e([n()],a.prototype,"width",void 0),a=e([i("esri.widgets.FeatureTable.Grid.Column")],a);const d=a;export{d as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Evented.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{autoLink as s}from"../../support/uriUtils.js";import{renderingSanitizer as r}from"../../support/widgetUtils.js";const l="esri-column",a={sorter:`${l}__sorter`,headerContent:`${l}__header-content`,headerLabel:`${l}__header-label`,headerMenuIcon:`${l}__header-menu-icon`};let c=class extends t.EventedAccessor{constructor(e){super(e),this._menuIsOpen=!1,this.autoWidth=!1,this.cellValueFormatFunction=e=>{const{rowData:t,value:n}=e,{formatFunction:o}=this,i=r.sanitize(n);if(o&&t){const{index:e,item:{feature:n}}=t;return o({column:this,feature:n,index:e,value:i})}return i},this.direction=null,this.fieldName=null,this.flexGrow=1,this.footerRenderFunction=null,this.formatFunction=null,this.frozen=!1,this.frozenToEnd=!1,this.grid=null,this.headerRenderFunction=e=>{const{root:t}=e,n=this.createHeaderContent();this.removeCellContent(t),t.appendChild(n)},this.hidden=!1,this.icon=null,this.initialSortPriority=null,this.label=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.renderFunction=({root:e,column:t,rowData:n})=>{const o=this.getCellValue(n),i=this.cellValueFormatFunction({column:t,rowData:n,value:o});let r=null;r=i instanceof HTMLElement?i:s(this.messagesURIUtils,i),this.removeCellContent(e),r instanceof HTMLElement?e.appendChild(r):null!=r&&(e.innerHTML=r.toString())},this.resizable=!0,this.sortable=!1,this.store=null,this.textAlign="start",this.textWrap=!1,this.timeZone=null,this.timeZoneName=null,this.visibleElements=null,this.width=200}initialize(){const{fieldName:e}=this;this._set("sortElement",this.createSortElement()),this.sortElement.setAttribute("path",e),this.addHandles([n((()=>this.direction),(e=>{const{sortElement:t}=this;this.sortable&&t&&(e?this.sortElement.direction!==e&&t.setAttribute("direction",e):t.removeAttribute("direction"))})),n((()=>this.hidden),(()=>this.closeMenu())),n((()=>this.fieldName),(e=>{const{sortElement:t}=this;t&&t.path!==e&&t.setAttribute("path",e)})),n((()=>this.effectiveLabel),(e=>{const{sortElement:t}=this;t&&t.textContent!==e&&(t.setAttribute("title",e),t.textContent=e)}))])}get customMenuItems(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:n,iconClass:o,label:i,selected:s,clickFunction:r})=>this.createCalciteDropdownItem({disabled:e,hidden:t,iconClass:o,iconStart:n,selected:s,textContent:i,onclick:e=>r(e)})))??[]}get defaultMenuItems(){if(!this.sortable)return[];const e=this.messages,t=[],n=this.visibleElements?.columnMenuItems;if(!1!==n?.sortAscending){const n=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:e?.sortAsc,onclick:()=>this.direction="asc"});t.push(n)}if(!1!==n?.sortDescending){const n=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:e?.sortDesc,onclick:()=>this.direction="desc"});t.push(n)}return t}get effectiveLabel(){return r.sanitize(this.label||this.fieldName)}get iconNode(){const{icon:e}=this;return e?this.createCalciteIcon({icon:e}):null}set invalid(e){this._set("invalid",e),this.grid?.generateCellPartNames()}get menu(){const{customMenuItems:e,defaultMenuItems:t,menuConfig:n}=this,o=!!n?.open,i=this.createCalciteAction({icon:n?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),s=document.createElement("calcite-dropdown");if(s.maxItems=n?.maxItems??4,s.placement="top-end",s.overlayPositioning="fixed",s.scale=n?.scale??"m",o&&(s.open=o,this._menuIsOpen=!0),s.appendChild(i),s.addEventListener("calciteDropdownOpen",(()=>this._menuIsOpen=!0)),s.addEventListener("calciteDropdownClose",(()=>this._menuIsOpen=!1)),s.onkeydown=this._stopPropagationOnSelect,s.addEventListener("mousewheel",(e=>{e.stopPropagation()})),t.length){const e=s.appendChild(document.createElement("calcite-dropdown-group"));e.selectionMode="none",e.append(...t)}if(e.length){const t=s.appendChild(document.createElement("calcite-dropdown-group"));t.selectionMode=n?.selectionMode??"none",t.append(...e)}return s}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1===this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(e){return e?.item.feature.attributes?.[this.fieldName]}createSortElement(){const{effectiveLabel:e,direction:t,fieldName:n,initialSortPriority:o}=this,i=document.createElement("vaadin-grid-sorter");return i.classList.add(a.sorter),i.setAttribute("path",n),i.setAttribute("title",e),i.textContent=e,t&&i.setAttribute("direction",t),null!=o&&(i._initialOrder=o),i.addEventListener("direction-changed",(()=>{this.direction!==i.direction&&this._set("direction",i.direction)})),i}createCalciteAction(e){const t=document.createElement("calcite-action"),{appearance:n,className:o,disabled:i,icon:s,label:r,scale:l,slot:a,text:c,textEnabled:d,onclick:p}=e;return t.appearance=n??"transparent",t.className=o??"",t.disabled=!!i,t.icon=s??"",t.label=r??"",t.scale=l??"s",t.slot=a??"",t.text=t.title=c??"",t.textEnabled=!!d,t.onclick=p??null,t}createCalciteButton(e){const t=document.createElement("calcite-button"),{appearance:n,className:o,disabled:i,iconEnd:s,iconFlipRtl:r,loading:l,onclick:a,scale:c,textContent:d}=e;return t.className=o??"",t.scale=c??"s",t.appearance=n??"transparent",t.disabled=!!i,t.iconEnd=s??"",r&&(t.iconFlipRtl=r),t.loading=!!l,t.textContent=t.title=d??"",t.onclick=a??null,t}createCalciteDropdownItem(e){const t=document.createElement("calcite-dropdown-item"),{disabled:n,hidden:o,iconClass:i,iconStart:s,textContent:r,onclick:l,selected:c}=e,d=r??"";if(i&&!s){const e=document.createElement("span"),n=document.createElement("span");n.classList.add(a.headerMenuIcon,i),e.textContent=e.title=d,e.insertBefore(n,e.firstChild),t.appendChild(e)}else t.iconStart=s??"",t.textContent=t.title=d;return t.disabled=!!n,t.hidden="function"==typeof o?o():!!o,t.selected=!!c,l&&(t.addEventListener("calciteDropdownItemSelect",l),t.onkeydown=this._stopPropagationOnSelect),t}createCalciteIcon(e){const{effectiveLabel:t}=this,{icon:n,scale:o,textLabel:i}=e,s=document.createElement("calcite-icon"),r=i??t;return s.icon=n,s.scale=o??"s",s.textLabel=r,s.title=r,s}createHeaderContent(){const{effectiveLabel:e,iconNode:t}=this,n=document.createElement("div");if(n.classList.add(a.headerContent),t&&n.appendChild(t),this.sortable)n.appendChild(this.sortElement);else if(""!==e){const t=document.createElement("div");t.classList.add(a.headerLabel);const o=t.appendChild(document.createElement("span"));o.textContent=e,o.setAttribute("title",e),n.appendChild(t)}return this.menuIsVisible&&n.appendChild(this.menu),n}removeCellContent(e){if(e&&e.firstChild)try{for(;e?.firstChild;)e?.removeChild(e.firstChild)}catch(t){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}_stopPropagationOnSelect(e){"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}};e([o()],c.prototype,"_menuIsOpen",void 0),e([o()],c.prototype,"autoWidth",void 0),e([o()],c.prototype,"cellValueFormatFunction",void 0),e([o()],c.prototype,"customMenuItems",null),e([o()],c.prototype,"defaultMenuItems",null),e([o()],c.prototype,"direction",void 0),e([o()],c.prototype,"effectiveLabel",null),e([o({constructOnly:!0})],c.prototype,"fieldName",void 0),e([o()],c.prototype,"flexGrow",void 0),e([o()],c.prototype,"footerRenderFunction",void 0),e([o()],c.prototype,"formatFunction",void 0),e([o()],c.prototype,"frozen",void 0),e([o()],c.prototype,"frozenToEnd",void 0),e([o()],c.prototype,"grid",void 0),e([o()],c.prototype,"iconNode",null),e([o()],c.prototype,"invalid",null),e([o()],c.prototype,"headerRenderFunction",void 0),e([o()],c.prototype,"hidden",void 0),e([o()],c.prototype,"icon",void 0),e([o({constructOnly:!0})],c.prototype,"initialSortPriority",void 0),e([o()],c.prototype,"label",void 0),e([o()],c.prototype,"menu",null),e([o()],c.prototype,"menuItems",null),e([o()],c.prototype,"menuConfig",void 0),e([o()],c.prototype,"menuIsOpen",null),e([o()],c.prototype,"menuIsVisible",null),e([o()],c.prototype,"messages",void 0),e([o()],c.prototype,"messagesCommon",void 0),e([o()],c.prototype,"messagesURIUtils",void 0),e([o()],c.prototype,"renderFunction",void 0),e([o()],c.prototype,"resizable",void 0),e([o()],c.prototype,"sortable",void 0),e([o({readOnly:!0})],c.prototype,"sortElement",void 0),e([o()],c.prototype,"store",void 0),e([o()],c.prototype,"textAlign",void 0),e([o()],c.prototype,"textWrap",void 0),e([o()],c.prototype,"timeZone",void 0),e([o()],c.prototype,"timeZoneName",void 0),e([o()],c.prototype,"visibleElements",void 0),e([o()],c.prototype,"width",void 0),c=e([i("esri.widgets.FeatureTable.Grid.Column")],c);const d=c;export{d 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/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{watch as l,sync as o,initial as s,on as n}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as d}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as c,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import p from"./Widget.js";import m from"./FeatureTable/ColumnMenuVisibleElements.js";import u from"./FeatureTable/FeatureTableViewModel.js";import g from"./FeatureTable/VisibleElements.js";import b from"./FeatureTable/support/FieldColumnTemplate.js";import w from"./FeatureTable/support/TableTemplate.js";import{isIFeatureTableSupportedLayer as v,uniqueColumnNames as y,isIFeatureTableSupportedLayerWithAttachments as f,isMapImageLayer as _}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as M}from"./support/componentsUtils.js";import{globalCss as T}from"./support/globalCss.js";import{Heading as S}from"./support/Heading.js";import{renderingSanitizer as C}from"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as R}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";var x;const j="esri-feature-table",F=`${j}__prompt`,k={base:j,content:`${j}__content`,menuPopover:`${j}__menu-popover`,layerDropdownMenu:`${j}__layer-switcher-menu`,tableContainer:`${j}__table-container`,tableNavigation:`${j}__table-navigation`,expanded:`${j}__expanded`,collapsed:`${j}__collapsed`,promptContainer:F,promptHeader:`${F}__header`,promptHeading:`${F}__header__heading`,promptMessage:`${F}__message`,promptDivider:`${F}__divider`,promptActions:`${F}__actions`},V={clearSelection:"clear-selection",exportToCSV:"file-csv",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let D=x=class extends p{constructor(e,t){super(e,t),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.relatedTables=new i,this.tableParent=null,this.title=null,this.viewModel=new u,this.visibleElements=new g,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([l((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),l((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),o),l((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),s),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),l((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return M({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),option:()=>import("@esri/calcite-components/dist/components/calcite-option.js"),select:()=>import("@esri/calcite-components/dist/components/calcite-select.js")})}destroy(){this._drainRelatedTables(),this._clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?C.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(v):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTable(){return this.relatedTable||this}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:s}=this;if(o)return C.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return A(t.header,{title:C.sanitize(e.title),count:s,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this._effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!v(e)||h(e)||t.has(e)||t.add(e)},l=e=>{d(e)||"catalog-footprint"===e.type||(c(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):_(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?e.sublayers?.forEach(i):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this._showAllTablesEnabled)}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this._drainRelatedTables(),this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}exportSelectionToCSV(){this.viewModel.exportSelectionToCSV()}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}toggleAllRelatedTables(e){const t=this.relatedTable;this._showAllTablesEnabled=e,t&&(e?this._enterShowAllView(t):this._exitShowAllView(t))}zoomToSelection(){this._effectiveTable.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return R("div",{bind:this,class:this.classes(k.base,T.widget)},R("calcite-panel",{bind:this,class:k.content,closable:t.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===o&&!this._effectiveLayers?.length,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?R("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),this._renderTables()),e?R("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{allRelatedTablesVisible:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(k.base,e?k.expanded:k.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return R("div",{class:k.tableContainer},R("calcite-panel",{overlayPositioning:"fixed"},R("div",null,[n?R("div",{class:s},t?.render(),this._renderPagination()):void 0,...r.map((e=>{const t=i.indexOf(e);return R("div",{class:s,key:`related-${t}`},e.render())})),,])))}return[R("div",{class:k.tableContainer},t?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return R("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.target.startItem-1)})}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=R("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?R("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return R("div",{class:`${k.promptContainer}--${i}`},R("div",{class:k.promptHeader},R("calcite-icon",{icon:"exclamation-mark-triangle"}),R(S,{class:k.promptHeading,level:2},e)),R("div",{class:k.promptMessage},t),R("div",{class:k.promptDivider}),R("div",{class:k.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=A(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return R("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:V.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:V.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:V.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:V.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:V.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:V.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:V.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveTable:t,_effectiveVisibleElements:i,id:l,messages:o}=this,s=t.columns.toArray(),n=o?.toggleColumns,r=`${l}__toggle-columns-action`,a=[R("calcite-action",{afterCreate:t=>e.set(l,t),afterRemoved:()=>e.delete(l),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},i.tooltips?R("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return t.menuConfig?.disabled||a.push(R("calcite-popover",{autoClose:!0,class:k.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(l)},R("calcite-list",{filterEnabled:!0,filterPlaceholder:o.toggleColumns,selectionMode:"multiple"},...s.map((e=>{const i="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:t,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:t,items:i})}))))),a}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:s,fieldName:n,hidden:r}=t;return R("calcite-list-item",{key:`toggle-columns__item-${n}`,label:s,open:!(!l?.length||r)||void 0,selected:!r,value:n,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return R("div",{class:k.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},R("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},R("calcite-action",{icon:"layers",slot:"trigger",text:e,title:e}),R("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return R("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(this._effectiveTable,e),this._createRelatedTable(e))}_renderRelatedTableNavigationBar(){const{messages:e}=this,t=e.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return R("div",{class:k.tableNavigation,key:"table-nav"},R("calcite-action",{icon:"move-up",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTables(),text:t,title:t}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),R("div",null,R("calcite-label",{layout:"inline"},e.showAllTables,R("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.toggleAllRelatedTables(!!e.target.checked)}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return R("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([y.action,y.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([y.action,y.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new b({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new g({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new m({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([y.action,y.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([y.action,y.attachments]))}_collapseRelatedTable(e,t){const{relatedLayer:l,feature:o,relationshipId:s}=t,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,d=o.getObjectId()??o.attributes[r],c=e===this,{close:h,columnMenus:p,header:u,layerDropdown:b,menu:v,menuItems:f,progress:_,tooltips:M}=e.visibleElements;e.set({highlightIds:new i([d]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new g({header:c&&u,progress:c&&_,columnMenus:p,close:h,layerDropdown:b,menu:v,menuItems:f,tooltips:M,selectionColumn:!1,columnMenuItems:new m({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([y.action,y.attachments]),e.scrollLeft()}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,paginationEnabled:i,pageSize:l,relatedTables:o,view:s,viewModel:r}=this,{layer:a,feature:d,relatedLayer:c,relationshipId:h}=e,p=d.getObjectId()??d.attributes[c.objectIdField],m=o.length,u=m?o.getItemAt(m-1):this;await a.load();const b=this.attachmentsEnabled&&f(a),w=new x({layer:a,attachmentsEnabled:b,editingEnabled:t,paginationEnabled:i,pageSize:l,relatedRecordsEnabled:!0,relationshipConfig:{objectId:p,relatedLayer:c,relationshipId:h},relationshipColumnConfigs:this._getRelationshipIdsToShow(a,h),tableParent:u,view:s,visibleElements:new g({header:!1,progress:!1}),showRelatedTableCallback:e=>{r.emit("show-related-table",e)}});w.addHandles([n((()=>u.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(w.highlightIds.removeAll(),w.relationshipConfig={objectId:t,relatedLayer:c,relationshipId:h})})),n((()=>u),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[c.objectIdField];null!=e&&u.highlightIds.add(e)}}))]),this.relatedTables.add(w),this.scheduleRender()}};e([r()],D.prototype,"_columnVisibilityActions",void 0),e([r()],D.prototype,"_effectiveDescription",null),e([r()],D.prototype,"_effectiveLayers",null),e([r()],D.prototype,"_effectiveTable",null),e([r()],D.prototype,"_effectiveTitle",null),e([r()],D.prototype,"_effectiveVisibleElements",null),e([r()],D.prototype,"_hasCustomMenuItems",null),e([r()],D.prototype,"_hasDefaultMenuItems",null),e([r()],D.prototype,"_prompt",void 0),e([r()],D.prototype,"_shouldShowMenu",null),e([r()],D.prototype,"_showAllTablesEnabled",void 0),e([r()],D.prototype,"_showClearSelectionAction",null),e([r()],D.prototype,"_showColumnsVisibilityAction",null),e([r()],D.prototype,"_showDeleteSelectionAction",null),e([r()],D.prototype,"_showExportSelectionToCSVAction",null),e([r()],D.prototype,"_showLayerDropdown",null),e([r()],D.prototype,"_showRefreshDataAction",null),e([r()],D.prototype,"_showSelectedRecordsShowSelectedAction",null),e([r()],D.prototype,"_showSelectedRecordsShowAllAction",null),e([r()],D.prototype,"_showZoomToSelectionAction",null),e([r()],D.prototype,"_viewLayers",null),e([r()],D.prototype,"actionColumnConfig",null),e([r({readOnly:!0})],D.prototype,"activeFilters",null),e([r({readOnly:!0})],D.prototype,"activeSortOrders",null),e([r({readOnly:!0})],D.prototype,"allRelatedTablesVisible",null),e([r()],D.prototype,"attachmentsEnabled",null),e([r()],D.prototype,"autoRefreshEnabled",null),e([r()],D.prototype,"columnPerformanceModeEnabled",null),e([r()],D.prototype,"columnReorderingEnabled",null),e([r({readOnly:!0})],D.prototype,"columns",null),e([r()],D.prototype,"description",void 0),e([r()],D.prototype,"disabled",void 0),e([r()],D.prototype,"editingEnabled",null),e([r()],D.prototype,"effectiveSize",null),e([r()],D.prototype,"filterGeometry",null),e([r()],D.prototype,"filterBySelectionEnabled",null),e([r({readOnly:!0})],D.prototype,"grid",null),e([r()],D.prototype,"hiddenFields",null),e([r()],D.prototype,"highlightEnabled",null),e([r()],D.prototype,"highlightIds",null),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"isQueryingOrSyncing",null),e([r()],D.prototype,"label",null),e([r()],D.prototype,"layer",null),e([r()],D.prototype,"layers",void 0),e([r()],D.prototype,"layerView",null),e([r()],D.prototype,"maxSize",null),e([r(),E("esri/widgets/FeatureTable/t9n/FeatureTable")],D.prototype,"messages",null),e([r(),E("esri/t9n/common")],D.prototype,"messagesCommon",null),e([r(),E("esri/widgets/support/t9n/uriUtils")],D.prototype,"messagesURIUtils",null),e([r()],D.prototype,"menuConfig",void 0),e([r()],D.prototype,"multipleSelectionEnabled",null),e([r()],D.prototype,"multiSortEnabled",null),e([r()],D.prototype,"objectIds",null),e([r()],D.prototype,"outFields",null),e([r()],D.prototype,"pageCount",null),e([r()],D.prototype,"pageIndex",null),e([r()],D.prototype,"pageSize",null),e([r()],D.prototype,"paginationEnabled",null),e([r()],D.prototype,"relatedRecordsEnabled",null),e([r()],D.prototype,"relatedTable",null),e([r()],D.prototype,"relatedTables",void 0),e([r()],D.prototype,"relationship",null),e([r()],D.prototype,"relationshipColumnConfigs",null),e([r()],D.prototype,"relationshipConfig",null),e([r()],D.prototype,"returnGeometryEnabled",null),e([r()],D.prototype,"returnMEnabled",null),e([r()],D.prototype,"returnZEnabled",null),e([r()],D.prototype,"rowHighlightIds",null),e([r()],D.prototype,"selectionSource",null),e([r()],D.prototype,"showRelatedTableCallback",null),e([r()],D.prototype,"size",null),e([r({readOnly:!0})],D.prototype,"state",null),e([r({constructOnly:!0})],D.prototype,"tableParent",void 0),e([r()],D.prototype,"tableTemplate",null),e([r()],D.prototype,"tableTemplateOverride",null),e([r()],D.prototype,"title",void 0),e([r()],D.prototype,"timeExtent",null),e([r()],D.prototype,"timeZone",null),e([r()],D.prototype,"view",null),e([r({type:u}),I(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],D.prototype,"viewModel",void 0),e([r({type:g,nonNullable:!0})],D.prototype,"visibleElements",void 0),e([r({type:g})],D.prototype,"visibleElementsOverride",void 0),D=x=e([a("esri.widgets.FeatureTable")],D);const O=D;export{O as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{watch as l,sync as o,initial as s,on as n}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as d}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as c,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import p from"./Widget.js";import m from"./FeatureTable/ColumnMenuVisibleElements.js";import u from"./FeatureTable/FeatureTableViewModel.js";import g from"./FeatureTable/VisibleElements.js";import b from"./FeatureTable/support/FieldColumnTemplate.js";import w from"./FeatureTable/support/TableTemplate.js";import{isIFeatureTableSupportedLayer as v,uniqueColumnNames as y,isIFeatureTableSupportedLayerWithAttachments as f,isMapImageLayer as _}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as M}from"./support/componentsUtils.js";import{globalCss as T}from"./support/globalCss.js";import{Heading as S}from"./support/Heading.js";import{renderingSanitizer as C}from"./support/widgetUtils.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as R}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";var x;const j="esri-feature-table",F=`${j}__prompt`,k={base:j,content:`${j}__content`,menuPopover:`${j}__menu-popover`,layerDropdownMenu:`${j}__layer-switcher-menu`,tableContainer:`${j}__table-container`,tableNavigation:`${j}__table-navigation`,expanded:`${j}__expanded`,collapsed:`${j}__collapsed`,promptContainer:F,promptHeader:`${F}__header`,promptHeading:`${F}__header__heading`,promptMessage:`${F}__message`,promptDivider:`${F}__divider`,promptActions:`${F}__actions`},V={clearSelection:"clear-selection",exportToCSV:"file-csv",delete:"trash",refresh:"refresh",showAll:"selection-x",showSelected:"selection-filter",zoomToSelection:"zoom-to-object"};let D=x=class extends p{constructor(e,t){super(e,t),this._columnVisibilityActions=new Map,this._prompt=null,this._showAllTablesEnabled=!1,this.description=null,this.disabled=!1,this.layers=null,this.menuConfig=null,this.relatedTables=new i,this.tableParent=null,this.title=null,this.viewModel=new u,this.visibleElements=new g,this.visibleElementsOverride=null,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([l((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),l((()=>({visibleElements:this._effectiveVisibleElements,items:this.columns.length})),(({visibleElements:e})=>{this.columns.forEach((t=>t.visibleElements=e)),this.refreshCellContent()}),o),l((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),s),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),l((()=>this.viewModel.state),(e=>{"disabled"===e&&this.relatedTables.length&&this._drainRelatedTables()}))])}loadDependencies(){return M({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination.js"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),option:()=>import("@esri/calcite-components/dist/components/calcite-option.js"),select:()=>import("@esri/calcite-components/dist/components/calcite-select.js")})}destroy(){this._drainRelatedTables(),this._clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?C.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(v):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTable(){return this.relatedTable||this}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:s}=this;if(o)return C.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return A(t.header,{title:C.sanitize(e.title),count:s,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this._effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!v(e)||h(e)||t.has(e)||t.add(e)},l=e=>{d(e)||"catalog-footprint"===e.type||(c(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):_(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?e.sublayers?.forEach(i):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this._showAllTablesEnabled)}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get grid(){return this.viewModel.grid}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this._drainRelatedTables(),this.viewModel.layer=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}exportSelectionToCSV(e){this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){this.relatedTables.forEach((async e=>await e.refresh())),await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}toggleAllRelatedTables(e){const t=this.relatedTable;this._showAllTablesEnabled=e,t&&(e?this._enterShowAllView(t):this._exitShowAllView(t))}zoomToSelection(){this._effectiveTable.viewModel.zoomToSelection()}render(){const{_prompt:e,_effectiveVisibleElements:t,isQueryingOrSyncing:i,menuConfig:l,state:o}=this;return R("div",{bind:this,class:this.classes(k.base,T.widget)},R("calcite-panel",{bind:this,class:k.content,closable:t.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===o&&!this._effectiveLayers?.length,heading:t.header?this._effectiveTitle:void 0,loading:"loading"===o,menuOpen:!!l?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.target.closed=!1,this.emit("close")}},t.progress?R("calcite-progress",{type:i?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderRelatedTableNavigationBar(),this._renderTables()),e?R("calcite-scrim",null,this._renderPrompt(e)):null)}_renderTables(){const{allRelatedTablesVisible:e,grid:t,relatedTables:i}=this;if(i.length){const l=i.toArray(),o=1===l.length,s=this.classes(k.base,e?k.expanded:k.collapsed),n=e||o,r=e?l:o?[l[0]]:l.slice(-2);return R("div",{class:k.tableContainer},R("calcite-panel",{overlayPositioning:"fixed"},R("div",null,[n?R("div",{class:s},t?.render(),this._renderPagination()):void 0,...r.map((e=>{const t=i.indexOf(e);return R("div",{class:s,key:`related-${t}`},e.render())})),,])))}return[R("div",{class:k.tableContainer},t?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return R("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.target.startItem-1)})}_clearPrompt(){this._prompt=null}_renderPrompt({title:e,message:t,context:i,actions:l}){const o=R("calcite-button",{appearance:"solid",key:"prompt-primary-button",kind:"danger"===i?"danger":"brand",onclick:l.primary.action,width:l.secondary?"half":"full"},l.primary.label),s=l.secondary?R("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:"danger"===i?"danger":"brand",onclick:l.secondary.action,width:"half"},l.secondary.label):null;return R("div",{class:`${k.promptContainer}--${i}`},R("div",{class:k.promptHeader},R("calcite-icon",{icon:"exclamation-mark-triangle"}),R(S,{class:k.promptHeading,level:2},e)),R("div",{class:k.promptMessage},t),R("div",{class:k.promptDivider}),R("div",{class:k.promptActions},s,o))}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=A(e.deleteSelectionCount,{count:this.highlightIds.length});this._prompt={title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this._clearPrompt()}}}}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this._clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:s}=e;if(!i)return R("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>s(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:V.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:V.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:V.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:V.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:V.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:V.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:V.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,_effectiveTable:t,_effectiveVisibleElements:i,id:l,messages:o}=this,s=t.columns.toArray(),n=o?.toggleColumns,r=`${l}__toggle-columns-action`,a=[R("calcite-action",{afterCreate:t=>e.set(l,t),afterRemoved:()=>e.delete(l),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:"show-column",id:r,slot:"header-actions-end",text:n},i.tooltips?R("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},n):null)];return t.menuConfig?.disabled||a.push(R("calcite-popover",{autoClose:!0,class:k.menuPopover,label:n,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:e.get(l)},R("calcite-list",{filterEnabled:!0,filterPlaceholder:o.toggleColumns,selectionMode:"multiple"},...s.map((e=>{const i="columns"in e&&e.columns?.length?e.columns.map((e=>this._renderColumnListItem({column:e,table:t,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:e,table:t,items:i})}))))),a}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:s,fieldName:n,hidden:r}=t;return R("calcite-list-item",{key:`toggle-columns__item-${n}`,label:s,open:!(!l?.length||r)||void 0,selected:!r,value:n,onCalciteListItemSelect:e=>{o||i.toggleColumnVisibility(e.target.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return R("div",{class:k.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},R("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},R("calcite-action",{icon:"layers",slot:"trigger",text:e,title:e}),R("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){return R("calcite-dropdown-item",{key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(this._effectiveTable,e),this._createRelatedTable(e))}_renderRelatedTableNavigationBar(){const{messages:e}=this,t=e.exitRelatedRecords;if(this.relatedTables.length&&!this.showRelatedTableCallback)return R("div",{class:k.tableNavigation,key:"table-nav"},R("calcite-action",{icon:"move-up",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTables(),text:t,title:t}),this.relatedTables.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),R("div",null,R("calcite-label",{layout:"inline"},e.showAllTables,R("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.toggleAllRelatedTables(!!e.target.checked)}))))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return R("calcite-action",{icon:"chevron-right",iconFlipRtl:!0,key:t,onclick:()=>this._drainRelatedTablesAboveIndex(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_drainRelatedTables(){this.relatedTables.drain((e=>!e.destroyed&&e.destroy())),this.set({_showAllTablesEnabled:!1,multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:null,visibleElementsOverride:null}),this.hiddenFields.removeMany([y.action,y.attachments])}_drainRelatedTablesAboveIndex(e){const t=this.relatedTables,i=t.filter(((t,i)=>i>e));i.forEach((e=>!e.destroyed&&e.destroy())),t.removeMany(i);const l=t.at(-1);if(!l?.layer||!l?.relationship)return;const{layer:o,relationship:s}=l;this._showAllTablesEnabled?this._enterShowAllView(l):l.set({multipleSelectionEnabled:!0,tableTemplateOverride:null,relationshipColumnConfigs:this._getRelationshipIdsToShow(o,s.id),visibleElementsOverride:null}),l.hiddenFields.removeMany([y.action,y.attachments])}_getRelatedTableMenuItemConfig(e,t,i){return t.fields.map((({alias:l,name:o})=>({selected:o===i,label:l||o,clickFunction:i=>{i.stopPropagation(),e.tableTemplateOverride=new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]})}})))}_createRelatedFieldColumnTemplate(e,t,i){return new b({fieldName:i,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._getRelatedTableMenuItemConfig(e,t,i)},resizable:!1})}_enterShowAllView(e){const t=e.layer;if(!t)return;const i=e===this,{visibleElements:l}=e,o=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,t,o)]}),visibleElementsOverride:new g({header:i&&l.header,progress:i&&l.progress,columnMenus:l.columnMenus,close:l.close,tooltips:l.tooltips,selectionColumn:!1,columnMenuItems:new m({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([y.action,y.attachments])}_exitShowAllView(e){const{layer:t,relationship:i}=e;t&&null!=i?.id&&(e.set({relationshipColumnConfigs:this._getRelationshipIdsToShow(t,i.id),tableTemplateOverride:null,visibleElementsOverride:null}),e.hiddenFields.removeMany([y.action,y.attachments]))}_collapseRelatedTable(e,t){const{relatedLayer:l,feature:o,relationshipId:s}=t,n=l.relationships?.find((({id:e})=>e===s)),{objectIdField:r}=l,a=l.displayField||n?.keyField||r,d=o.getObjectId()??o.attributes[r],c=e===this,{close:h,columnMenus:p,header:u,layerDropdown:b,menu:v,menuItems:f,progress:_,tooltips:M}=e.visibleElements;e.set({highlightIds:new i([d]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[{relationshipId:s,collapsed:!0}],tableTemplateOverride:new w({columnTemplates:[this._createRelatedFieldColumnTemplate(e,l,a)]}),visibleElementsOverride:new g({header:c&&u,progress:c&&_,columnMenus:p,close:h,layerDropdown:b,menu:v,menuItems:f,tooltips:M,selectionColumn:!1,columnMenuItems:new m({sortAscending:!1,sortDescending:!1})})}),e.hiddenFields.addMany([y.action,y.attachments]),e.scrollLeft()}_getRelationshipIdsToShow(e,t){return(e.relationships??[]).filter((e=>!(e.id===t&&"one-to-one"===e.cardinality))).map((({id:e})=>({relationshipId:e})))}async _createRelatedTable(e){const{editingEnabled:t,paginationEnabled:i,pageSize:l,relatedTables:o,view:s,viewModel:r}=this,{layer:a,feature:d,relatedLayer:c,relationshipId:h}=e,p=d.getObjectId()??d.attributes[c.objectIdField],m=o.length,u=m?o.getItemAt(m-1):this;await a.load();const b=this.attachmentsEnabled&&f(a),w=new x({layer:a,attachmentsEnabled:b,editingEnabled:t,paginationEnabled:i,pageSize:l,relatedRecordsEnabled:!0,relationshipConfig:{objectId:p,relatedLayer:c,relationshipId:h},relationshipColumnConfigs:this._getRelationshipIdsToShow(a,h),tableParent:u,view:s,visibleElements:new g({header:!1,progress:!1}),showRelatedTableCallback:e=>{r.emit("show-related-table",e)}});w.addHandles([n((()=>u.highlightIds),"change",(({added:e})=>{const t=e[0];null!=t&&(w.highlightIds.removeAll(),w.relationshipConfig={objectId:t,relatedLayer:c,relationshipId:h})})),n((()=>u),"cell-click",(e=>{const{feature:t}=e;if(t){const e=t.getObjectId()??t.attributes[c.objectIdField];null!=e&&u.highlightIds.add(e)}}))]),this.relatedTables.add(w),this.scheduleRender()}};e([r()],D.prototype,"_columnVisibilityActions",void 0),e([r()],D.prototype,"_effectiveDescription",null),e([r()],D.prototype,"_effectiveLayers",null),e([r()],D.prototype,"_effectiveTable",null),e([r()],D.prototype,"_effectiveTitle",null),e([r()],D.prototype,"_effectiveVisibleElements",null),e([r()],D.prototype,"_hasCustomMenuItems",null),e([r()],D.prototype,"_hasDefaultMenuItems",null),e([r()],D.prototype,"_prompt",void 0),e([r()],D.prototype,"_shouldShowMenu",null),e([r()],D.prototype,"_showAllTablesEnabled",void 0),e([r()],D.prototype,"_showClearSelectionAction",null),e([r()],D.prototype,"_showColumnsVisibilityAction",null),e([r()],D.prototype,"_showDeleteSelectionAction",null),e([r()],D.prototype,"_showExportSelectionToCSVAction",null),e([r()],D.prototype,"_showLayerDropdown",null),e([r()],D.prototype,"_showRefreshDataAction",null),e([r()],D.prototype,"_showSelectedRecordsShowSelectedAction",null),e([r()],D.prototype,"_showSelectedRecordsShowAllAction",null),e([r()],D.prototype,"_showZoomToSelectionAction",null),e([r()],D.prototype,"_viewLayers",null),e([r()],D.prototype,"actionColumnConfig",null),e([r({readOnly:!0})],D.prototype,"activeFilters",null),e([r({readOnly:!0})],D.prototype,"activeSortOrders",null),e([r({readOnly:!0})],D.prototype,"allRelatedTablesVisible",null),e([r()],D.prototype,"attachmentsEnabled",null),e([r()],D.prototype,"autoRefreshEnabled",null),e([r()],D.prototype,"columnPerformanceModeEnabled",null),e([r()],D.prototype,"columnReorderingEnabled",null),e([r({readOnly:!0})],D.prototype,"columns",null),e([r()],D.prototype,"description",void 0),e([r()],D.prototype,"disabled",void 0),e([r()],D.prototype,"editingEnabled",null),e([r()],D.prototype,"effectiveSize",null),e([r()],D.prototype,"filterGeometry",null),e([r()],D.prototype,"filterBySelectionEnabled",null),e([r({readOnly:!0})],D.prototype,"grid",null),e([r()],D.prototype,"hiddenFields",null),e([r()],D.prototype,"highlightEnabled",null),e([r()],D.prototype,"highlightIds",null),e([r()],D.prototype,"icon",null),e([r()],D.prototype,"isQueryingOrSyncing",null),e([r()],D.prototype,"label",null),e([r()],D.prototype,"layer",null),e([r()],D.prototype,"layers",void 0),e([r()],D.prototype,"layerView",null),e([r()],D.prototype,"maxSize",null),e([r(),E("esri/widgets/FeatureTable/t9n/FeatureTable")],D.prototype,"messages",null),e([r(),E("esri/t9n/common")],D.prototype,"messagesCommon",null),e([r(),E("esri/widgets/support/t9n/uriUtils")],D.prototype,"messagesURIUtils",null),e([r()],D.prototype,"menuConfig",void 0),e([r()],D.prototype,"multipleSelectionEnabled",null),e([r()],D.prototype,"multiSortEnabled",null),e([r()],D.prototype,"objectIds",null),e([r()],D.prototype,"outFields",null),e([r()],D.prototype,"pageCount",null),e([r()],D.prototype,"pageIndex",null),e([r()],D.prototype,"pageSize",null),e([r()],D.prototype,"paginationEnabled",null),e([r()],D.prototype,"relatedRecordsEnabled",null),e([r()],D.prototype,"relatedTable",null),e([r()],D.prototype,"relatedTables",void 0),e([r()],D.prototype,"relationship",null),e([r()],D.prototype,"relationshipColumnConfigs",null),e([r()],D.prototype,"relationshipConfig",null),e([r()],D.prototype,"returnGeometryEnabled",null),e([r()],D.prototype,"returnMEnabled",null),e([r()],D.prototype,"returnZEnabled",null),e([r()],D.prototype,"rowHighlightIds",null),e([r()],D.prototype,"selectionSource",null),e([r()],D.prototype,"showRelatedTableCallback",null),e([r()],D.prototype,"size",null),e([r({readOnly:!0})],D.prototype,"state",null),e([r({constructOnly:!0})],D.prototype,"tableParent",void 0),e([r()],D.prototype,"tableTemplate",null),e([r()],D.prototype,"tableTemplateOverride",null),e([r()],D.prototype,"title",void 0),e([r()],D.prototype,"timeExtent",null),e([r()],D.prototype,"timeZone",null),e([r()],D.prototype,"view",null),e([r({type:u}),I(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","show-related-table"])],D.prototype,"viewModel",void 0),e([r({type:g,nonNullable:!0})],D.prototype,"visibleElements",void 0),e([r({type:g})],D.prototype,"visibleElementsOverride",void 0),D=x=e([a("esri.widgets.FeatureTable")],D);const O=D;export{O as default};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ type GridControlsGridControlsViewModel = __esri.GridControlsGridControlsViewModel;
4
+ export default GridControlsGridControlsViewModel;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import H from"../PanoramicViewer.js";import{sectorsInOrder as D,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as $,activeSourcePointSymbol as q,sourcePointSymbol as J}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,scaleExtent as Y,isSceneView as Z,isGraphic as ee,calculateSegment as te,calculateDirection as ie}from"./utils.js";import re from"./components/ImageViewer.js";import oe from"../../geometry/Point.js";import se from"../../geometry/SpatialReference.js";import ae from"../../geometry/Polygon.js";const ne={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},le=new Set(["JPG","JPEG"]),he=/\.(\w+)$/,ce=e=>"FA"===e;let ue=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i,view:r}=this;if(r?.closePopup(),t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(o){g(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new re,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new H,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url,{origin:n,pathname:l,searchParams:h}=new URL(a);let c=s?l.match(he)?.[1]??"":e.datasetFormat;if(!c){const e=await K(a,{...t.options});e&&(c=e.split("/")[1]),c??="UNKNOWN FORMAT"}switch(i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(h),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break;case"panoramic":this._loading=!0;if(le.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,this._loading=!1,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new oe(d);let F=s;if(ce(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new oe({...h(e)?e.toJSON():e,spatialReference:se.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new oe(n,se.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(ne.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,T.WIDGET),ne.click),this.removeHandles(ne.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),ne.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),ne.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ne.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),ne.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e}=this,{imageSize:t,vfov:i,hfov:r,pitch:o,yaw:s}=this._panoramicViewer;return e&&t?[i,r,s,o]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{...v,equals:(e,t)=>r(e,t,c)}),ne.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?D.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),-999!==t&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[D[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new oe({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new oe({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new oe(n,se.WebMercator),symbol:$}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of D)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=te(t,n),l=ie(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=new ae({spatialReference:s[0].spatialReference});for(const{rings:u}of s)n.addRing(u[0]);const l=[];for(const{geometry:u}of o)n.contains(u)||l.push(u);n.addRing(l);const h=n.extent;let c;if(Y(h,2),this.footprintExtent=h,this.view?.supportsGround)try{c=await this.view.map.ground.createElevationSampler(h,i)}catch(d){g(d)||u.getLogger(this).error(d)}if(o[0].elevationSample=c,(c||o[0].attributes.elevationSource)&&h){const e=await k([t],{feature:o[0],footprintExtent:h,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Z(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const p=this._suitabilities.map((e=>e.feature));this.currentBestFeature=p[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:q,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:J,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(ee);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([_()],ue.prototype,"activeLayer",null),e([_({readOnly:!0})],ue.prototype,"activeViewer",null),e([_()],ue.prototype,"additionalFeatures",void 0),e([_()],ue.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],ue.prototype,"brightness",null),e([_({type:Number})],ue.prototype,"contrast",null),e([_()],ue.prototype,"coverageFrustums",void 0),e([_()],ue.prototype,"coveragePolygons",void 0),e([_()],ue.prototype,"currentBestFeature",void 0),e([_()],ue.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],ue.prototype,"determineWorkflowForFeature",void 0),e([_()],ue.prototype,"disabled",void 0),e([_()],ue.prototype,"displayMessage",void 0),e([_()],ue.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],ue.prototype,"featureCount",null),e([_()],ue.prototype,"features",void 0),e([_({readOnly:!0})],ue.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],ue.prototype,"imageLoaded",null),e([_()],ue.prototype,"imagePointsInView",null),e([_()],ue.prototype,"isAdditionalCoverageVisible",void 0),e([_()],ue.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],ue.prototype,"layer",void 0),e([_({type:Number})],ue.prototype,"localPort",void 0),e([_()],ue.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],ue.prototype,"mode",null),e([_()],ue.prototype,"navigatorCurrentBestFeature",void 0),e([_()],ue.prototype,"pointSources",void 0),e([_({readOnly:!0})],ue.prototype,"popupEnabled",null),e([_()],ue.prototype,"previousFeatureAngle",void 0),e([_()],ue.prototype,"referencePoint",null),e([_({readOnly:!0})],ue.prototype,"sectorData",null),e([_()],ue.prototype,"selectedPoint",void 0),e([_({type:Number})],ue.prototype,"sharpness",null),e([_()],ue.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],ue.prototype,"state",null),e([_({readOnly:!0})],ue.prototype,"thumbnails",null),e([_()],ue.prototype,"updateFootprint",void 0),e([_()],ue.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],ue.prototype,"view",null),e([_()],ue.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],ue.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],ue.prototype,"additionalCameraLocations",void 0),e([_()],ue.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],ue.prototype,"_fetchFeaturesController",void 0),e([_()],ue.prototype,"_highlightedFeatureHandle",void 0),e([_()],ue.prototype,"_imageViewer",void 0),e([_({type:t})],ue.prototype,"bestFeatureFootprint",void 0),e([_()],ue.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],ue.prototype,"_loading",void 0),e([_()],ue.prototype,"_overlays",void 0),e([_({readOnly:!0})],ue.prototype,"_overlaysView",null),e([_()],ue.prototype,"_panoramicViewer",void 0),e([_()],ue.prototype,"_referencePointOnGround",void 0),e([_()],ue.prototype,"_referencePointOnImage",void 0),e([_()],ue.prototype,"currentBestFeatureLocation",void 0),e([_()],ue.prototype,"_sectorData",void 0),e([_()],ue.prototype,"footprintExtent",void 0),ue=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ue);const pe=ue;export{pe as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{throwIfAborted as y,isAbortError as f,waitTick as v}from"../../core/promiseUtils.js";import{on as w,watch as F,syncAndInitial as _,initial as b}from"../../core/reactiveUtils.js";import{property as P}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as I}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import{isPolygon as S}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as V}from"../../geometry/support/webMercatorUtils.js";import O from"../../layers/GraphicsLayer.js";import{searchImages as k}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as j}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as A,computePolygonForInspection as B,resizePolygon as L,checkIfPolygonContainsSelectedPoint as M}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as G,transformPoints as T}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as R}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as E,convertPixelToHeadingPitch as H,convertHeadingPitchToSphereVertex as x}from"../../layers/orientedImagery/transformations/utils.js";import D from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as U}from"../../views/input/InputManager.js";import N from"../PanoramicViewer.js";import{sectorsInOrder as W,sectorsRadii as z}from"./constants.js";import{crossSymbol as $,crossSymbol3D as q,diamondSymbol as J,diamondSymbol3D as K,activeSourcePointSymbol as Q,sourcePointSymbol as X}from"./symbols.js";import{isNoAttachmentError as Y,getContentType as Z,isTifOrMrf as ee,scaleExtent as te,isSceneView as re,isGraphic as ie,calculateSegment as oe,calculateDirection as se}from"./utils.js";import ae from"./components/ImageViewer.js";import ne from"../../geometry/Point.js";import le from"../../geometry/SpatialReference.js";import he from"../../geometry/Polygon.js";const ce={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ue=new Set(["JPG","JPEG"]),pe=/\.(\w+)$/,de=e=>"FA"===e;let me=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:r,view:i}=this;if(i?.closePopup(),t&&r){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(o){f(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._highlightedFeatureHandle=null,this._imageViewer=new ae,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._overlays=new O({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new N,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:r,popupEnabled:i,layer:o,view:s}=this;if(s?.closePopup(),!(s&&r&&i&&o))return;const{attributes:a,geometry:n}=r,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ce.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,U.WIDGET),ce.click)},this._createImageClickHandle=()=>{this.removeHandles(ce.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:r}=this;if(!e||"none"===t||!r)return;r.clickAction="pixel-location";let i=null;const s=w((()=>r),"pixel-location",(e=>{this.plotReferencePointOnImage(e),i?.abort(),i=o((async t=>{const{currentBestFeature:i,footprintExtent:o}=this,{imageSize:s}=r;if(!(i&&e&&s&&o))return;const[a]=await R([e],{feature:i,footprintExtent:o,imageProperties:{width:s[0],height:s[1]},options:{signal:t}});y(t),a&&this.plotReferencePointOnGround(a)}))}));this.addHandles(s,ce.imageClick)},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new D({objectIds:[t]}),o=await e.queryAttachments(i,r),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._loadImage=async e=>{const{currentBestFeature:t,layer:r,mode:i}=this;if(this.clearGraphics(),!r||!t||"none"===i)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),g=d.spatialReference.isWGS84&&4!==p?.type?V(d):new ne(d);let v=s;if(de(s))try{v=await this._getImageSourceFromAttachment(r,c,e)}catch(w){if(f(w))return;return Y(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${c}`)):(u.getLogger(this).error(w,{[r.objectIdField]:c,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${c}`))}try{await this.loadImageFromSource(v,{imageRotation:m,options:e,pitch:h,yaw:n,mode:i,cameraLocation:g}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(w){f(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:r,imageRotation:i,options:o}=t,s="string"==typeof e,a=s?e:e.url,{origin:n,pathname:l,searchParams:h}=new URL(a);let c=s?l.match(pe)?.[1]??"":e.datasetFormat;if(!c){const e=await Z(a,{...t.options});e&&(c=e.split("/")[1]),c??="UNKNOWN FORMAT"}switch(r){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(h),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(o);break;case"panoramic":if(ue.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:r,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await E(s,e)-l),this._panoramicViewer.pitch=r??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=o((async t=>{const{pointerType:r,button:i,mapPoint:o}=e;if(("mouse"!==r||0===i)&&o)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(o,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,r)=>{if(await v(r),!e)return;const i=new ne({...h(e)?e.toJSON():e,spatialReference:le.WebMercator});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,this._crossSymbol=new t({geometry:i,symbol:$}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=H(e,i,o),n=x(s,a);this._crossSymbol=new t({geometry:new ne(n,le.WebMercator),symbol:q}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),b),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),b),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ce.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,c)}),ce.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:r,vfov:i,hfov:o,pitch:s,yaw:a}=this._panoramicViewer;return e&&r&&"image-loading"!==t?[i,o,a,s]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,r,i,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:r,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,c)}),ce.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:o}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=o)}),_)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:r}=this;switch(r){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return ee(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:r}=e;return 360===t||r?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?W.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(!this.isFulfilled())return"loading";if(this.isRejected())return"error";if(this._updatingHandles.updating)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const o=e.trim();return ee(o)?{url:o,objectId:t,rotation:(r??0)+(i??0)}:null})).filter(r)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const r=[],i=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=A(a);if(n=l.clone(),a.isInspection&&(n=B(a)),s&&(n=L(n,s)),M(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),-999!==t&&(r.push(l),h&&i.push(h))}})),{features:o,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[W[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(r))}async load(e){return this.addResolvingPromise(this._loadAdapter(e).catch((e=>{if(!f(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?V(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new ne({...e.toJSON()}),symbol:J}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const r=h(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:new ne({spatialReference:this._imageViewer.imageRenderer.spatialReference,...r}),symbol:J}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=H(e,i,o),n=x(s,a);this._referencePointOnImage=new t({geometry:new ne(n,le.WebMercator),symbol:K}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}async searchBestImage(e,t){try{const r=await k(e,t);r&&await this._processFeatureResponse(r,e.point,{signal:t?.signal})}catch(r){f(r)||(this.setMessage("imageLoadError","error",r.message),u.getLogger(this).error("error occurred while finding best image",r))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e,i=this.bestFeatureFootprint?.geometry,o=S(i)&&i.contains(t),s="mesh"===i?.type&&i?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,r);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const r=this.layer;if(r){const i={include:r},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,i);return this._processHitTestResults(r,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(r){if(f(r))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i}=this;if(!(e&&t&&r&&i))return void(this._sectorData=null);this._sectorData={};for(const l of W)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:r,featureIndex:o}=e,s=t/n*z[2],a=oe(t,n),l=se(r);if(!this._sectorData)return;const h=z[3]+s*Math.sin(r*Math.PI/180),c=z[3]+s*Math.cos(r*Math.PI/180);let u;const p=i.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-z[3],t=c-z[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:r,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,r){const{features:i}=e;if(!i?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(i,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=new he({spatialReference:s[0].spatialReference});for(const{rings:u}of s)n.addRing(u[0]);const l=[];for(const{geometry:u}of o)n.contains(u)||l.push(u);n.addRing(l);const h=n.extent;let c;if(te(h,2),this.footprintExtent=h,this.view?.supportsGround)try{c=await this.view.map.ground.createElevationSampler(h,r)}catch(p){f(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=c,(c||o[0].attributes.elevationSource)&&h){const e=await G([t],{feature:o[0],footprintExtent:h,options:r});if(e[0]){const r=e[0];t.elevation=r.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=j({features:o,selectedPoint:t,camera:re(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(i);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,r)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:r,currentBestFeature:i,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(i){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of r)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:Q,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:X,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-z[3],i=e.y-z[3],o=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(o)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),r=s}r===this.bestFeatureAngle?this.previousFeatureAngle=r:this.bestFeatureAngle=r,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,r,i){this.displayMessage={key:e,type:t,data:r,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:r,state:i}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!r||!t||"image-loaded"!==i)return;let o;try{o=await this.transformPoint(r,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){f(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:r,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const r=this.currentBestFeature,i=await T([e],{feature:r,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!i.length)return;return i[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:r,additionalCameraLocations:i,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...r,...i,this.bestFeatureCurrentFootprint,s].filter(ie);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:$.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([P()],me.prototype,"activeLayer",null),e([P({readOnly:!0})],me.prototype,"activeViewer",null),e([P()],me.prototype,"additionalFeatures",void 0),e([P()],me.prototype,"bestFeatureAngle",void 0),e([P({type:Number})],me.prototype,"brightness",null),e([P({type:Number})],me.prototype,"contrast",null),e([P()],me.prototype,"coverageFrustums",void 0),e([P()],me.prototype,"coveragePolygons",void 0),e([P()],me.prototype,"currentBestFeature",void 0),e([P()],me.prototype,"currentCoverageVisible",void 0),e([P({json:{write:!1}})],me.prototype,"determineWorkflowForFeature",void 0),e([P()],me.prototype,"disabled",void 0),e([P()],me.prototype,"displayMessage",void 0),e([P()],me.prototype,"drawFootprint",void 0),e([P({readOnly:!0})],me.prototype,"featureCount",null),e([P()],me.prototype,"features",void 0),e([P({readOnly:!0})],me.prototype,"imageGalleryEnabled",null),e([P({readOnly:!0})],me.prototype,"imageLoaded",null),e([P()],me.prototype,"imagePointsInView",null),e([P()],me.prototype,"isAdditionalCoverageVisible",void 0),e([P()],me.prototype,"isAdditionalPointSourcesVisible",void 0),e([P()],me.prototype,"layer",void 0),e([P({type:Number})],me.prototype,"localPort",void 0),e([P()],me.prototype,"mapImageConversionToolState",void 0),e([P({readOnly:!0,value:"none"})],me.prototype,"mode",null),e([P()],me.prototype,"navigatorCurrentBestFeature",void 0),e([P()],me.prototype,"pointSources",void 0),e([P({readOnly:!0})],me.prototype,"popupEnabled",null),e([P()],me.prototype,"previousFeatureAngle",void 0),e([P()],me.prototype,"referencePoint",null),e([P({readOnly:!0})],me.prototype,"sectorData",null),e([P()],me.prototype,"selectedPoint",void 0),e([P({type:Number})],me.prototype,"sharpness",null),e([P()],me.prototype,"shouldShowSelectedImage",void 0),e([P({readOnly:!0})],me.prototype,"state",null),e([P({readOnly:!0})],me.prototype,"thumbnails",null),e([P()],me.prototype,"updateFootprint",void 0),e([P()],me.prototype,"updateFootprintPanorama",void 0),e([P({value:null})],me.prototype,"view",null),e([P()],me.prototype,"_adapter",void 0),e([P({type:s.ofType(t)})],me.prototype,"additionalFootprints",void 0),e([P({type:s.ofType(t)})],me.prototype,"additionalCameraLocations",void 0),e([P()],me.prototype,"bestFeatureCurrentFootprint",void 0),e([P()],me.prototype,"_highlightedFeatureHandle",void 0),e([P()],me.prototype,"_imageViewer",void 0),e([P({type:t})],me.prototype,"bestFeatureFootprint",void 0),e([P()],me.prototype,"_initialCurrentCoverageUpdate",void 0),e([P()],me.prototype,"_overlays",void 0),e([P({readOnly:!0})],me.prototype,"_overlaysView",null),e([P()],me.prototype,"_panoramicViewer",void 0),e([P()],me.prototype,"_referencePointOnGround",void 0),e([P()],me.prototype,"_referencePointOnImage",void 0),e([P()],me.prototype,"currentBestFeatureLocation",void 0),e([P()],me.prototype,"_sectorData",void 0),e([P({readOnly:!0})],me.prototype,"_updatingHandles",void 0),e([P()],me.prototype,"footprintExtent",void 0),me=e([I("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],me);const ge=me;export{ge 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/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import"../../geometry.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as V}from"../../layers/orientedImagery/transformations/utils.js";import z from"../../views/SceneView.js";import R from"../Zoom.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import x from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as k,meshToGraphic as I,createImageSphere as F}from"./utils.js";import G from"../../geometry/SpatialReference.js";const A={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new w({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(A.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],A.navigation)},this._addHFOVHandles=()=>{this.removeHandles(A.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),A.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new x({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new R({viewModel:this._zoomViewModel});this.imageRenderer.ui.add(e,"top-left"),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.async((async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",t)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=V(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:G.WebMercator,meshVertex:e.mapPoint});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(t),!0},this._imageRenderer=new z({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:G.WebMercator,ui:{components:["attribution"]}})}initialize(){this.state="initialized",this.addHandles([g((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),u),g((()=>this.fov),(()=>{this._reloadCamera()}),u),g((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),u),g((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),u),_((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),u),g((()=>this.clickAction),(e=>{this.removeHandles(A.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],A.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return k(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return k(O,e/t)}get vfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadImageInternal(e,t){let i;this.state="image-loading";try{i=(await a(e,{responseType:"image",...t})).data}catch(o){throw c(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(i,t)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=d(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const{size:[i,o]}=this.imageRenderer;return this._imageGraphic=I(F(e)),this._graphics.add(this._imageGraphic),this.fov=k(S,i/o),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(M("panoramic-viewer"),j("PanoramicViewerViewModel","imageSource")))}};e([y()],L.prototype,"_graphics",void 0),e([y()],L.prototype,"_imageGraphic",void 0),e([y()],L.prototype,"_imageRenderer",void 0),e([y()],L.prototype,"_loadController",void 0),e([y()],L.prototype,"_map",void 0),e([y()],L.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],L.prototype,"autoLoad",void 0),e([y({type:t})],L.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([y({type:Number})],L.prototype,"fov",null),e([y({readOnly:!0})],L.prototype,"hfov",null),e([y({readOnly:!0})],L.prototype,"imageRenderer",null),e([y()],L.prototype,"imageSize",void 0),e([y()],L.prototype,"imageSource",void 0),e([y({readOnly:!0})],L.prototype,"maxHFOV",null),e([y({readOnly:!0})],L.prototype,"minHFOV",null),e([y({type:Number})],L.prototype,"pitch",void 0),e([y()],L.prototype,"state",void 0),e([y({readOnly:!0})],L.prototype,"vfov",null),e([y({type:Number})],L.prototype,"yaw",void 0),L=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const W=L;export{W as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import"../../geometry.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as z}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import V from"../Zoom.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";import G from"../../geometry/SpatialReference.js";const A={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new w({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(A.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],A.navigation)},this._addHFOVHandles=()=>{this.removeHandles(A.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),A.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=new V({viewModel:this._zoomViewModel});this.imageRenderer.ui.add(e,"top-left"),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.async((async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",t)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=z(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:G.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(t),!0},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:G.WebMercator,ui:{components:["attribution"]}})}initialize(){this.state="initialized",this.addHandles([g((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),u),g((()=>this.fov),(()=>{this._reloadCamera()}),u),g((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),u),g((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),u),_((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),u),g((()=>this.clickAction),(e=>{this.removeHandles(A.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],A.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return x(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return x(O,e/t)}get vfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadImageInternal(e,t){let i;this.state="image-loading";try{i=(await a(e,{responseType:"image",...t})).data}catch(o){throw c(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(i,t)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=d(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const{size:[i,o]}=this.imageRenderer;return this._imageGraphic=I(F(e)),this._graphics.add(this._imageGraphic),this.fov=x(S,i/o),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(M("panoramic-viewer"),j("PanoramicViewerViewModel","imageSource")))}};e([y()],L.prototype,"_graphics",void 0),e([y()],L.prototype,"_imageGraphic",void 0),e([y()],L.prototype,"_imageRenderer",void 0),e([y()],L.prototype,"_loadController",void 0),e([y()],L.prototype,"_map",void 0),e([y()],L.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],L.prototype,"autoLoad",void 0),e([y({type:t})],L.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([y({type:Number})],L.prototype,"fov",null),e([y({readOnly:!0})],L.prototype,"hfov",null),e([y({readOnly:!0})],L.prototype,"imageRenderer",null),e([y()],L.prototype,"imageSize",void 0),e([y()],L.prototype,"imageSource",void 0),e([y({readOnly:!0})],L.prototype,"maxHFOV",null),e([y({readOnly:!0})],L.prototype,"minHFOV",null),e([y({type:Number})],L.prototype,"pitch",void 0),e([y()],L.prototype,"state",void 0),e([y({readOnly:!0})],L.prototype,"vfov",null),e([y({type:Number})],L.prototype,"yaw",void 0),L=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const W=L;export{W 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/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import e from"../../portal/PortalItem.js";import{fromJSON as p}from"../../rest/support/fileFormat.js";import{fromJSON as l}from"../../rest/support/layoutTemplate.js";let i=class extends t{constructor(o){super(o),this.description=null,this.format=null,this.label=null,this.layout=null,this.layoutItem=null,this.layoutOptions=null,this.layoutTemplateInfo=null}};o([r()],i.prototype,"description",void 0),o([r({json:{read:p}})],i.prototype,"format",void 0),o([r()],i.prototype,"label",void 0),o([r({json:{read:l}})],i.prototype,"layout",void 0),o([r({type:e})],i.prototype,"layoutItem",void 0),o([r()],i.prototype,"layoutOptions",void 0),o([r()],i.prototype,"layoutTemplateInfo",void 0),i=o([s("esri.widgets.Print.CustomTemplate")],i);const a=i;export{a as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{id as o}from"../../kernel.js";import e from"../../core/Error.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import{createMD5Hash as s}from"../../core/MD5.js";import{isAbortError as a}from"../../core/promiseUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../portal/PortalItem.js";import{fromJSON as p}from"../../rest/support/fileFormat.js";import{fromJSON as u}from"../../rest/support/layoutTemplate.js";import{fetchLayoutTemplateInfos as m}from"./utils.js";let d=class extends r{constructor(t){super(t),this.description=null,this.format=null,this.state="not-loaded",this.label=null,this.layoutInfoTaskUrl=null,this.layout=null,this.layoutItem=null,this.layoutOptions=null,this.layoutTemplateInfo=null,this.type=null}get id(){return this.layoutItem?.id??`${this.layout}-${s(JSON.stringify(this.toJSON()))}`}get mapSurroundInfoOptions(){const t=this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos;if(!t)return null;const o={northArrow:[],scaleBar:[],legend:[]};for(const e of t)switch(e.type){case"CIMMarkerNorthArrow":o.northArrow.push(e);break;case"CIMScaleLine":o.scaleBar.push(e);break;case"CIMGroupElement":e.elements?.some((t=>"CIMScaleLine"===t.type))&&o.scaleBar.push(e);break;case"CIMLegend":o.legend.push(e)}return o}async fetchLayoutItemTemplateInfo(t){const{layoutItem:r}=this;if(r?.id&&!this.layoutTemplateInfo&&"loaded"!==this.state)try{this._set("state","loading");const s=this.layoutInfoTaskUrl;if(!s)throw new e("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:s});"public"!==r.access&&o&&await o.getCredential(s);const a={Layout_Item_ID:JSON.stringify({id:r.id})},i=(await m(s,a,t))[0];this._set("layoutTemplateInfo",i);const{hasLegend:l}=i.layoutOptions,n=this.mapSurroundInfoOptions?.northArrow.some((({visible:t})=>t))??!1,p=this.mapSurroundInfoOptions?.scaleBar.some((({visible:t})=>t))??!1;this._set("layoutOptions",{legend:l,northArrow:n,scaleBar:p}),this._set("state","loaded")}catch(s){this._set("state",a(s)?"not-loaded":"error")}}setLayoutTemplateInfo(t){this._set("layoutTemplateInfo",t),this._set("state","loaded")}};t([i({json:{write:!0}})],d.prototype,"description",void 0),t([i({json:{read:p,write:!0}})],d.prototype,"format",void 0),t([i({readOnly:!0})],d.prototype,"id",null),t([i({readOnly:!0})],d.prototype,"state",void 0),t([i({json:{write:!0}})],d.prototype,"label",void 0),t([i()],d.prototype,"layoutInfoTaskUrl",void 0),t([i({json:{read:u,write:!0}})],d.prototype,"layout",void 0),t([i({type:n,json:{write:!0}})],d.prototype,"layoutItem",void 0),t([i({readOnly:!0,json:{write:!0}})],d.prototype,"layoutOptions",void 0),t([i({readOnly:!0})],d.prototype,"layoutTemplateInfo",void 0),t([i({readOnly:!0})],d.prototype,"mapSurroundInfoOptions",null),t([i()],d.prototype,"type",void 0),d=t([l("esri.widgets.Print.CustomTemplate")],d);const y=d;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/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{id as e}from"../../kernel.js";import o from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import n from"../../core/Loadable.js";import{isAbortError as p}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{watch as u,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{unitType as d,convertUnit as y,getMetersPerUnitForSR as f,inchesPerMeter as v}from"../../core/unitUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as I,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as g}from"../../intl/locale.js";import O from"../../portal/Portal.js";import b from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as x}from"../../portal/support/urlUtils.js";import{execute as P,getTasks as S,getMode as j}from"../../rest/print.js";import{execute as L}from"../../rest/geoprocessor/execute.js";import{submitJob as E}from"../../rest/geoprocessor/submitJob.js";import{fromJSON as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/PrintParameters.js";import H from"../../rest/support/PrintTemplate.js";import{getExtent as F}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as D}from"../../views/input/InputManager.js";import A from"../../views/overlay/BoxOverlayItem.js";import M from"./CustomTemplate.js";import W from"./TemplateOptions.js";import N from"../../geometry/Extent.js";const z=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),V=/(\/GPServer\/).+/i,q=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),G=r.ofType(M);function R(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let o=I(Date.now(),_("short-date"));"ar"===g()&&(o="‏"+o),e.push({date:o})}}let J=class extends n{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._layoutToTemplateInfo=new m,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new G,this.defaultTemplates=new G,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.portal=O.getDefault(),this.portalTemplateIds=[],this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new W}initialize(){this.addHandles(u((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})))}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=l(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const o=t[e];if(o){const t=this.templateCustomTextElements?.[e];o.forEach((e=>{const[o]=Object.entries(e)[0];t?.forEach((t=>{const[i,r]=Object.entries(t)[0];o===i&&(e[o]=r)}))}))}})),Object.freeze(t)}get layoutTemplateInfo(){const t=this.templateOptions.layoutItem?.id??this.templateOptions.layout;return t?this._layoutToTemplateInfo.get(t):null}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}get layoutTemplateNorthArrowInfo(){return this.layoutTemplateInfo?.layoutOptions?.mapSurroundInfos?this.layoutTemplateInfo.layoutOptions.mapSurroundInfos.find((t=>"CIMMarkerNorthArrow"===t.type)):null}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:o,updateDelay:i}=this;if(!e)throw new s("print:view-required","view is not set");R(t);const r=this._getOverlayItem(),a=t.scalePreserved||!this.showPrintAreaEnabled?void 0:F(new N,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),l=new C({view:e,template:t,extent:a,extraParameters:o,updateDelay:i});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,l,{timeout:this.printTimeout})}catch(n){throw new s("print:export-error","An error occurred while exporting the web map.",{error:n})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:o,customTextElements:i,dpi:r,forceFeatureAttributes:a,format:l,height:n,includeTables:p,layout:m,layoutItem:u,legendEnabled:h,northArrowEnabled:c,scale:d,scaleEnabled:y,title:f,width:v}){if(!m&&!u)throw new s("print:layout-required","layout is not set");const w=new H({attributionVisible:t,forceFeatureAttributes:a,format:l,includeTables:p,layout:m,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:o||"",customTextElements:i,titleText:f||""},outScale:d??0,scalePreserved:y});v&&(w.exportOptions.width=v),n&&(w.exportOptions.height=n),r&&(w.exportOptions.dpi=r),!h&&w.layoutOptions&&(w.layoutOptions.legendLayers=[]);const T=this.layoutTemplateNorthArrowInfo;if(T){!(T.visible===c)&&w.layoutOptions&&(w.layoutOptions.elementOverrides={[T.name]:{visible:c}})}return w}async fetchLayoutTemplateInfo(t,e){if(!t.layoutItem?.id)return;const o=await this._fetchPortalLayoutTemplateInfo(t.layoutItem,e);this._layoutToTemplateInfo.set(t.layoutItem.id,o),t.layoutTemplateInfo=o;const{hasLegend:i,mapSurroundInfos:r,customTextElements:s}=o.layoutOptions,a=r.some((({type:t,visible:e})=>"CIMMarkerNorthArrow"===t&&e));t.layoutOptions={legend:i,northArrow:a};const n=l(this._serviceTemplateCustomTextElements)??{};n[t.layoutItem.id]=s,this._serviceTemplateCustomTextElements=Object.freeze(n)}getLayoutTemplateInfo(t){return this._layoutToTemplateInfo.get(t)}async addPortalTemplate(t){const e=new M({label:t.title,layoutItem:t});this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem?.id&&this.templateOptions.layoutItem?.id===t.layoutItem.id&&(this.templateOptions.layout=this.defaultTemplates.length||this.browseTemplates.length?null:this.templatesInfo?.layout?.defaultValue,this.templateOptions.layoutItem=null),this._layoutToTemplateInfo.delete(t.layoutItem.id),this.browseTemplates.remove(t)}async _loadResources(t){let e=[];if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{if(this.destroyed)return;try{await this.portal.load(t)}catch(l){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:l,url:this.effectivePrintServiceUrl})}if(this.portal.helperServices){const{asyncPrintTask:t,layoutInfoTask:o,printTask:i}=this.portal.helperServices;i&&(this._set("effectivePrintServiceUrl",i.url),e=i.templates?.map((t=>M.fromJSON(t)))??[]),this._asyncPrintTaskUrl=t?.url,await this._updateLayoutInfoTaskUrl(o?.url||this.effectivePrintServiceUrl)}}this.defaultTemplates.addMany(e);const o=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!o?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl});const[i,r,a]=await Promise.all([this._getPrintServiceLayouts(t),this._getPrintServiceTemplates(t),this._getPortalCustomTemplates(t)]);if(this._processPrintServiceLayouts(i),this._processPrintServiceTemplates(r),this._processPortalTemplates(a),this.templateOptions.layoutItem?.id){const e=this.templateOptions.layoutItem.id;let o=this.defaultTemplates.find((t=>t.layoutItem?.id===e));o||(o=new M({label:this.templateOptions.layoutItem.title,layoutItem:this.templateOptions.layoutItem})),await this.fetchLayoutTemplateInfo(o,t),this.templateOptions.layout=null,this.templateOptions.layoutItem=o.layoutItem}this._updateOverLayItem()}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const o=(await S(t,e)).find((t=>t.includes("Get Layout Templates Info")));o&&(this._layoutInfoTaskUrl=t.replace(V,`$1${encodeURI(o)}`))}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:o}=this.portal,i=x.test(this.portal.url),r=o?.userLicenseTypeId,s=r&&z.has(r);if(!e||i&&!s)return[];const a=new b({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(a,t);if(!l.total)return[];const n=l.results[0],p=new b({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;return m.length?m.map((t=>new M({label:t.title,layoutItem:t}))):[]}async _fetchPortalLayoutTemplateInfo(t,o){const{id:i}=t,r=this._layoutInfoTaskUrl;if(!r)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:r});"public"!==t.access&&e&&await e.getCredential(r);const a={Layout_Item_ID:JSON.stringify({id:i})};return(await this._fetchLayoutTemplateInfos(a,o))[0]}async _fetchLayoutTemplateInfos(t,e){const o=this._layoutInfoTaskUrl;if(!o)throw new s("print:invalid-layout-info-task-url","Can't fetch layout template info",{url:o});if("async"===await j(o)){const i=await E(o,t,void 0,e||void 0);await i.waitForJobCompletion({interval:1e3});return(await i.fetchResultData("Output_JSON")).value}return(await L(o,t,null,e)).results[0].value}_processPortalTemplates(t){if(t){this.defaultTemplates.addMany(t);for(const e of t)e.layoutItem?.id&&this.portalTemplateIds.push(e.layoutItem.id)}}_processPrintServiceTemplates(t){this._set("templatesInfo",t)}async _getPrintServiceLayouts(t){let e=[];try{e=await this._fetchLayoutTemplateInfos(void 0,t)}catch{}return e}_processPrintServiceLayouts(t){const e={};for(const o of t){const{layoutTemplate:t,layoutOptions:i}=o,r=k(t);this._layoutToTemplateInfo.set(r,o),e[r]=i.customTextElements}this._serviceTemplateCustomTextElements=Object.freeze(e)}async _getPrintServiceTemplates(t){let e;try{({data:e}=await o(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw p(l)?l:new s("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:i}=e,r=i.find((({name:t})=>"Format"===t)),a=i.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(r),layout:this._getLayout(a)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(U(t)))),o=(e.length?e:t.choiceList).map(U).filter(i),r=U(t.defaultValue),s=o.includes(r)?r:o[0];return{choiceList:o,defaultValue:s}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),o="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(k(t)))),r=(o.length?o:e).map(k).filter(i),s=k(t.defaultValue),a=r.includes(s)?s:r.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??r.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??r[0];return{choiceList:r,defaultValue:a}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new A({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([u((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),D.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),D.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),o=t.layoutItem?.id??t.layout,i=this.view,r=i.spatialReference,[s,a]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("map-only"===o)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(o){const{webMapFrameSize:e,pageUnits:i}=this._layoutToTemplateInfo.get(o)??{};let l=!1;if(e&&i)if(this._isFreeHand){const t=e[0]/e[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=q.fromJSON(i.toLowerCase()),o=r.unit;d(t)===d(o)?(n=y(e[0],t,o),p=y(e[1],t,o)):(l=!0,n=e[0],p=e[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(s/n,a/p):f(r)*v*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=s,p=a;else{const t=(s-.1*s)/n,e=(a-.1*a)/p,o=Math.min(t,e);n*=o,p*=o}}const{scaleEnabled:m,scale:u}=t,h=m&&u?u/this.view.scale:1;e.boxWidth=n*h||s,e.boxHeight=p*h||a,l&&(e.padding=l),e.backgroundWidth=s??0,e.backgroundHeight=a??0}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:o,y:i}=t,{x:r,y:s}=t.origin;o>r?(e.x=r,e.boxWidth=o-r):(e.x=o,e.boxWidth=r-o),i>s?(e.y=s,e.boxHeight=i-s):(e.y=i,e.boxHeight=s-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,o=e.toMap(c(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:o}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([w()],J.prototype,"_serviceTemplateCustomTextElements",void 0),t([w()],J.prototype,"_layoutToTemplateInfo",void 0),t([w()],J.prototype,"allowedFormats",void 0),t([w()],J.prototype,"allowedLayouts",void 0),t([w({type:G})],J.prototype,"browseTemplates",void 0),t([w({type:G})],J.prototype,"defaultTemplates",void 0),t([w()],J.prototype,"error",void 0),t([w()],J.prototype,"extraParameters",void 0),t([w()],J.prototype,"includeDefaultTemplates",void 0),t([w({readOnly:!0})],J.prototype,"effectivePrintServiceUrl",null),t([w()],J.prototype,"effectiveTemplateCustomTextElements",null),t([w()],J.prototype,"layoutTemplateInfo",null),t([w({type:O})],J.prototype,"portal",void 0),t([w()],J.prototype,"portalTemplateIds",void 0),t([w()],J.prototype,"showPrintAreaEnabled",void 0),t([w()],J.prototype,"printServiceUrl",void 0),t([w()],J.prototype,"printTimeout",void 0),t([w({readOnly:!0})],J.prototype,"state",null),t([w({readOnly:!0})],J.prototype,"templatesInfo",void 0),t([w()],J.prototype,"updateDelay",void 0),t([w()],J.prototype,"view",void 0),t([w()],J.prototype,"templateCustomTextElements",void 0),t([w({type:W})],J.prototype,"templateOptions",void 0),t([w()],J.prototype,"layoutTemplateNorthArrowInfo",null),J=t([T("esri.widgets.Print.PrintViewModel")],J);const Q=J;export{Q as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as w,convertDateFormatToIntlOptions as _}from"../../intl/date.js";import{getLanguage as I}from"../../intl/locale.js";import g from"../../portal/Portal.js";import O from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import{execute as x,getTasks as P}from"../../rest/print.js";import{fromJSON as S}from"../../rest/support/fileFormat.js";import{fromJSON as U}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as E}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as L}from"../../views/input/InputManager.js";import C from"../../views/overlay/BoxOverlayItem.js";import H from"./CustomTemplate.js";import D from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as F}from"./utils.js";import W from"../../geometry/Extent.js";import A from"../../geometry/SpatialReference.js";const R=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(H);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=w(Date.now(),_("short-date"));"ar"===I()&&(i="‏"+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let Q=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=g.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new D}initialize(){this.addHandles([m((()=>this.showPrintAreaEnabled),(t=>{t?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:E(new W,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await x(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleEnabled:f,title:v,width:T}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const w=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:v||""},outScale:y??0,scalePreserved:f});if(T&&(w.exportOptions.width=T),n&&(w.exportOptions.height=n),a&&(w.exportOptions.dpi=a),w.layoutOptions){d||(w.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){N(w,t.northArrow[0],c);const e=t.scaleBar;for(const t of e)N(w,t,f)}}return w}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id||this._templateIdToCustomTemplate.has(t.id))return;const e=new H({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:null;await this.templateOptions.applyTemplate(t,e)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(e?.id){let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new H({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await P(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t){return this.portal?.helperServices?.printTask?.templates?.map((e=>{const i=H.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=b.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new O({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new O({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new H({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e){if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const i=this._getPortalDefaultTemplates(t);this.defaultTemplates.addMany(i);const s=await this._getPortalCustomTemplates(e);this.defaultTemplates.addMany(s);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}this.defaultTemplates.length||t.forEach(((t,e)=>{const i=new H({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;e&&"map-only"!==e&&this._set("defaultTemplate",this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e)))}async _getLayoutToLayoutTemplateInfos(t){const e=await F(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=U(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>this.allowedFormats.includes(S(t)))),s=(e.length?e:t.choiceList).map(S).filter(i),o=S(t.defaultValue),a=s.includes(o)?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(U(t)))),o=(s.length?s:e).map(U).filter(i),a=U(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new C({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),L.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),L.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=R;break;case"error":e.strokeColor=V}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([v()],Q.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],Q.prototype,"_templateIdToCustomTemplate",void 0),t([v()],Q.prototype,"allowedFormats",void 0),t([v()],Q.prototype,"allowedLayouts",void 0),t([v({type:B})],Q.prototype,"browseTemplates",void 0),t([v({type:B})],Q.prototype,"defaultTemplates",void 0),t([v()],Q.prototype,"error",void 0),t([v()],Q.prototype,"extraParameters",void 0),t([v()],Q.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],Q.prototype,"effectivePrintServiceUrl",null),t([v()],Q.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:A})],Q.prototype,"outSpatialReference",void 0),t([v({type:g})],Q.prototype,"portal",void 0),t([v()],Q.prototype,"portalTemplateIds",void 0),t([v({type:B})],Q.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],Q.prototype,"defaultTemplate",void 0),t([v()],Q.prototype,"showPrintAreaEnabled",void 0),t([v()],Q.prototype,"printServiceUrl",void 0),t([v()],Q.prototype,"printTimeout",void 0),t([v({readOnly:!0})],Q.prototype,"state",null),t([v({readOnly:!0})],Q.prototype,"templatesInfo",void 0),t([v()],Q.prototype,"updateDelay",void 0),t([v()],Q.prototype,"view",void 0),t([v()],Q.prototype,"templateCustomTextElements",void 0),t([v({type:D})],Q.prototype,"templateOptions",void 0),Q=t([T("esri.widgets.Print.PrintViewModel")],Q);const $=Q;export{$ 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/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../portal/PortalItem.js";let s=class extends o{constructor(t){super(t),this.attributionEnabled=!0,this.author=null,this.copyright=null,this.customTextElements=null,this.dpi=96,this.fileName=null,this.forceFeatureAttributes=!1,this.format="pdf",this.height=null,this.includeTables=!0,this.layout="letter-ansi-a-landscape",this.layoutItem=null,this.legendEnabled=!0,this.northArrowEnabled=!1,this.scale=null,this.scaleEnabled=!1,this.title=null,this.width=null}};t([e()],s.prototype,"attributionEnabled",void 0),t([e()],s.prototype,"author",void 0),t([e()],s.prototype,"copyright",void 0),t([e()],s.prototype,"customTextElements",void 0),t([e()],s.prototype,"dpi",void 0),t([e()],s.prototype,"fileName",void 0),t([e()],s.prototype,"forceFeatureAttributes",void 0),t([e()],s.prototype,"format",void 0),t([e()],s.prototype,"height",void 0),t([e()],s.prototype,"includeTables",void 0),t([e()],s.prototype,"layout",void 0),t([e({type:i})],s.prototype,"layoutItem",void 0),t([e()],s.prototype,"legendEnabled",void 0),t([e()],s.prototype,"northArrowEnabled",void 0),t([e()],s.prototype,"scale",void 0),t([e()],s.prototype,"scaleEnabled",void 0),t([e()],s.prototype,"title",void 0),t([e()],s.prototype,"width",void 0),s=t([r("esri.widgets.Print.TemplateOptions")],s);const p=s;export{p as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{clone as e}from"../../core/lang.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../portal/PortalItem.js";let i=class extends o{constructor(t){super(t),this._abortController=null,this.attributionEnabled=!0,this.author=null,this.copyright=null,this.customTextElements=null,this.dpi=96,this.fileName=null,this.forceFeatureAttributes=!1,this.format="pdf",this.height=null,this.includeTables=!0,this.id=null,this.state="ready",this.layout="letter-ansi-a-landscape",this.layoutItem=null,this.legendEnabled=!0,this.northArrowEnabled=!1,this.scale=null,this.scaleBarEnabled=!1,this.scaleEnabled=!1,this.title=null,this.width=null}async applyTemplate(t,o){if((t?.id!==this.id||"error"===t?.state)&&(this._abortController&&(this._abortController.abort(),this._abortController=null),t)){if(this._set("state","pending"),this._resetMapSurroundInfoOptions(),this._set("id",t.id),this.set({layout:t.layout,layoutItem:t.layoutItem}),!t.layoutOptions&&t.layoutItem){const o=new AbortController;if(this._abortController=o,await t.fetchLayoutItemTemplateInfo({signal:this._abortController.signal}),"loaded"!==t.state){if("error"===t.state&&this._set("state","error"),this._abortController!==o)return;return void(this._abortController=null)}this._abortController=null}this.set({customTextElements:o?e(o):this.customTextElements,format:this.format??t.format,legendEnabled:t.layoutOptions?.legend??this.legendEnabled,northArrowEnabled:t.layoutOptions?.northArrow??this.northArrowEnabled,scaleBarEnabled:t.layoutOptions?.scaleBar??this.scaleBarEnabled}),this._set("state","ready")}}reset(){this._set("id",null),this._set("state","ready"),this.set({layout:null,layoutItem:null,customTextElements:null}),this._resetMapSurroundInfoOptions()}_resetMapSurroundInfoOptions(){this.set({legendEnabled:!0,northArrowEnabled:!1,scaleBarEnabled:!1})}};t([r()],i.prototype,"attributionEnabled",void 0),t([r()],i.prototype,"author",void 0),t([r()],i.prototype,"copyright",void 0),t([r()],i.prototype,"customTextElements",void 0),t([r()],i.prototype,"dpi",void 0),t([r()],i.prototype,"fileName",void 0),t([r()],i.prototype,"forceFeatureAttributes",void 0),t([r()],i.prototype,"format",void 0),t([r()],i.prototype,"height",void 0),t([r()],i.prototype,"includeTables",void 0),t([r({readOnly:!0})],i.prototype,"id",void 0),t([r({readOnly:!0})],i.prototype,"state",void 0),t([r()],i.prototype,"layout",void 0),t([r({type:l})],i.prototype,"layoutItem",void 0),t([r()],i.prototype,"legendEnabled",void 0),t([r()],i.prototype,"northArrowEnabled",void 0),t([r()],i.prototype,"scale",void 0),t([r()],i.prototype,"scaleBarEnabled",void 0),t([r()],i.prototype,"scaleEnabled",void 0),t([r()],i.prototype,"title",void 0),t([r()],i.prototype,"width",void 0),i=t([s("esri.widgets.Print.TemplateOptions")],i);const a=i;export{a as default};