@arcgis/core 4.32.0-next.20241021 → 4.32.0-next.20241023

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 (257) hide show
  1. package/applications/MapViewer/templateUtils.d.ts +4 -0
  2. package/applications/MapViewer/templateUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0b7ee57bec7ffac312f2.js +1 -0
  5. package/assets/esri/core/workers/chunks/{1ba1d9c867ec6a492af9.js → 0f3912bca9fe25eea75c.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{842ebde78db9bfcaf07b.js → 1678d1d0ecb9b2af69a8.js} +1 -1
  7. package/assets/esri/core/workers/chunks/1d16ca7791f64dd7c7fb.js +1 -0
  8. package/assets/esri/core/workers/chunks/1d4be734ff961e313257.js +1 -0
  9. package/assets/esri/core/workers/chunks/{b292758308dfac4ba8ee.js → 2d8aa31dc96bbd014036.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{53f648321c5fde26bfe4.js → 319e06888467f9f460ab.js} +1 -1
  11. package/assets/esri/core/workers/chunks/33cae7ece52a77394b05.js +1 -0
  12. package/assets/esri/core/workers/chunks/{210a954f5299fe105e0b.js → 539060ffb7f230fb1bd0.js} +1 -1
  13. package/assets/esri/core/workers/chunks/545441dcc8e915e63ff1.js +1 -0
  14. package/assets/esri/core/workers/chunks/{303f39b9b7bd33109df8.js → 587df97288a83721d251.js} +1 -1
  15. package/assets/esri/core/workers/chunks/5caa02a7a85d05e253b4.js +1 -0
  16. package/assets/esri/core/workers/chunks/5cfecb320e1dcd258b2e.js +1 -0
  17. package/assets/esri/core/workers/chunks/67018ef25736f0722f6e.js +1 -0
  18. package/assets/esri/core/workers/chunks/89f74819ac1b5884c149.js +1 -0
  19. package/assets/esri/core/workers/chunks/92b2d81ef16877341f97.js +1 -0
  20. package/assets/esri/core/workers/chunks/{e6e77cbdeb99d90caad1.js → 97f62fad6d416a666319.js} +1 -1
  21. package/assets/esri/core/workers/chunks/98c1956b2e27058c8a51.js +1 -0
  22. package/assets/esri/core/workers/chunks/9c8a910b6261a4d5da77.js +1 -0
  23. package/assets/esri/core/workers/chunks/ab6eaa3ae2e233f91a5e.js +1 -0
  24. package/assets/esri/core/workers/chunks/{63719f892a7d1025c7d3.js → b42c1ab7579a3c464f72.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{03eba36affe6ed1f5a11.js → bc4ef18d0a02354186e3.js} +7 -7
  26. package/assets/esri/core/workers/chunks/{c71304c88fce556340ef.js → c859f73b57a764e99b02.js} +1 -1
  27. package/assets/esri/core/workers/chunks/cb3038ec3ef0d86bf2a0.js +1 -0
  28. package/assets/esri/core/workers/chunks/{ae20ca2008a2ea6a46b2.js → d8f4bd2b4366388f8a28.js} +1 -1
  29. package/assets/esri/core/workers/chunks/e71fa25ed45bae5a1adb.js +320 -0
  30. package/assets/esri/core/workers/chunks/{9c9a8a529494c6d1dfa3.js → ec9d5af8887854e821c8.js} +1 -1
  31. package/assets/esri/libs/parquet/pkg/arcgis_parquet_bg.wasm +0 -0
  32. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +14 -0
  33. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +1 -1
  34. package/assets/esri/themes/dark/main.css +1 -1
  35. package/assets/esri/themes/light/main.css +1 -1
  36. package/assets/esri/themes/light/view.css +1 -1
  37. package/chunks/Bufferer-BhkgvSV4.js +5 -0
  38. package/chunks/{Distance2DCalculator-DM4OojiI.js → Distance2DCalculator-BX0Ep7eP.js} +1 -1
  39. package/chunks/{GeodeticDistanceCalculator-DzvUOSaR.js → GeodeticDistanceCalculator-B5uO-Y_z.js} +1 -1
  40. package/chunks/OperatorCrosses.js +5 -0
  41. package/chunks/OperatorCut.js +1 -1
  42. package/chunks/OperatorGeodesicBuffer.js +1 -1
  43. package/chunks/OperatorGeodeticArea.js +1 -1
  44. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  45. package/chunks/OperatorGeodeticDistance.js +1 -1
  46. package/chunks/OperatorGeodeticLength.js +1 -1
  47. package/chunks/OperatorIntersects.js +5 -0
  48. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  49. package/chunks/OperatorOverlaps.js +5 -0
  50. package/chunks/OperatorProximity.js +1 -1
  51. package/chunks/OperatorProximityGeodesic.js +1 -1
  52. package/chunks/OperatorShapePreservingLength.js +1 -1
  53. package/chunks/OperatorTouches.js +5 -0
  54. package/chunks/OperatorWithin.js +5 -0
  55. package/chunks/QuadraticBezier.js +1 -1
  56. package/chunks/SSAOBlur.glsl.js +5 -5
  57. package/chunks/SideCalculator2D-CoWc8Oe3.js +1 -1
  58. package/chunks/Transformation2D.js +1 -1
  59. package/core/MemCache.js +1 -1
  60. package/core/MemCachePool.js +1 -1
  61. package/core/unitUtils.js +1 -1
  62. package/geometry/Mesh.js +1 -1
  63. package/geometry/operators/affineTransformOperator.js +1 -1
  64. package/geometry/operators/alphaShapeOperator.js +1 -1
  65. package/geometry/operators/areaOperator.js +1 -1
  66. package/geometry/operators/autoCompleteOperator.js +1 -1
  67. package/geometry/operators/boundaryOperator.js +1 -1
  68. package/geometry/operators/bufferOperator.js +1 -1
  69. package/geometry/operators/centroidOperator.js +1 -1
  70. package/geometry/operators/clipOperator.js +1 -1
  71. package/geometry/operators/containsOperator.js +1 -1
  72. package/geometry/operators/convexHullOperator.js +1 -1
  73. package/geometry/operators/crossesOperator.js +1 -1
  74. package/geometry/operators/cutOperator.js +1 -1
  75. package/geometry/operators/densifyOperator.js +1 -1
  76. package/geometry/operators/differenceOperator.js +1 -1
  77. package/geometry/operators/disjointOperator.js +1 -1
  78. package/geometry/operators/distanceOperator.js +1 -1
  79. package/geometry/operators/equalsOperator.js +1 -1
  80. package/geometry/operators/extendOperator.js +1 -1
  81. package/geometry/operators/generalizeOperator.js +1 -1
  82. package/geometry/operators/geodesicBufferOperator.js +1 -1
  83. package/geometry/operators/geodesicProximityOperator.js +1 -1
  84. package/geometry/operators/geodeticAreaOperator.js +1 -1
  85. package/geometry/operators/geodeticDensifyOperator.js +1 -1
  86. package/geometry/operators/geodeticDistanceOperator.js +1 -1
  87. package/geometry/operators/geodeticLengthOperator.js +1 -1
  88. package/geometry/operators/graphicBufferOperator.js +1 -1
  89. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  90. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  91. package/geometry/operators/gx/operatorBoundary.js +1 -1
  92. package/geometry/operators/gx/operatorBuffer.js +1 -1
  93. package/geometry/operators/gx/operatorConvexHull.js +1 -1
  94. package/geometry/operators/gx/operatorDifference.js +1 -1
  95. package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
  96. package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
  97. package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
  98. package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
  99. package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
  100. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  101. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  102. package/geometry/operators/gx/operatorIntersection.js +1 -1
  103. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  104. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  105. package/geometry/operators/gx/operatorLocateBetween.js +1 -1
  106. package/geometry/operators/gx/operatorOffset.js +1 -1
  107. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  108. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  109. package/geometry/operators/gx/operatorProject.js +1 -1
  110. package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
  111. package/geometry/operators/gx/operatorSimplify.js +1 -1
  112. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  113. package/geometry/operators/gx/operatorUnion.js +1 -1
  114. package/geometry/operators/integrateOperator.js +1 -1
  115. package/geometry/operators/intersectionOperator.js +1 -1
  116. package/geometry/operators/intersectsOperator.js +1 -1
  117. package/geometry/operators/isNearOperator.js +1 -1
  118. package/geometry/operators/json/containsOperator.js +5 -0
  119. package/geometry/operators/json/crossesOperator.js +5 -0
  120. package/geometry/operators/json/disjointOperator.js +5 -0
  121. package/geometry/operators/json/intersectsOperator.js +5 -0
  122. package/geometry/operators/json/offsetOperator.js +5 -0
  123. package/geometry/operators/json/overlapsOperator.js +5 -0
  124. package/geometry/operators/json/touchesOperator.js +5 -0
  125. package/geometry/operators/json/withinOperator.js +5 -0
  126. package/geometry/operators/labelPointOperator.js +1 -1
  127. package/geometry/operators/lengthOperator.js +1 -1
  128. package/geometry/operators/linesToPolygonsOperator.js +1 -1
  129. package/geometry/operators/locateBetweenOperator.js +1 -1
  130. package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
  131. package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
  132. package/geometry/operators/offsetOperator.js +1 -1
  133. package/geometry/operators/overlapsOperator.js +1 -1
  134. package/geometry/operators/polygonOverlayOperator.js +1 -1
  135. package/geometry/operators/polygonSlicerOperator.js +1 -1
  136. package/geometry/operators/projectOperator.js +1 -1
  137. package/geometry/operators/proximityOperator.js +1 -1
  138. package/geometry/operators/relateOperator.js +1 -1
  139. package/geometry/operators/reshapeOperator.js +1 -1
  140. package/geometry/operators/simplifyOperator.js +1 -1
  141. package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
  142. package/geometry/operators/support/apiConverter.js +5 -0
  143. package/geometry/operators/support/initNoPeFactory.js +5 -0
  144. package/geometry/operators/support/jsonConverter.js +5 -0
  145. package/geometry/operators/support/proximityResult.js +1 -1
  146. package/geometry/operators/symmetricDifferenceOperator.js +1 -1
  147. package/geometry/operators/touchesOperator.js +1 -1
  148. package/geometry/operators/unionOperator.js +1 -1
  149. package/geometry/operators/withinOperator.js +1 -1
  150. package/geometry/support/MeshVertexAttributes.js +1 -1
  151. package/interfaces.d.ts +134 -0
  152. package/layers/LinkChartLayer.js +1 -1
  153. package/layers/SceneLayer.js +1 -1
  154. package/layers/graphics/OptimizedGeometry.js +1 -1
  155. package/layers/graphics/sources/ParquetSource.js +1 -1
  156. package/layers/knowledgeGraph/supportUtils.js +1 -1
  157. package/layers/support/ElevationQueryTileCache.js +1 -1
  158. package/layers/support/ElevationTileData.js +1 -1
  159. package/layers/support/mediaUtils.js +1 -1
  160. package/layers/support/parquetLayerUtils.js +1 -1
  161. package/layers/support/rasterFunctions/ClipFunction.js +1 -1
  162. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  163. package/layers/support/rasterFunctions/localUtils.js +1 -1
  164. package/libs/parquet/parquet.js +1 -1
  165. package/linkChart/LinkChartProperties.js +1 -1
  166. package/package.json +1 -1
  167. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  168. package/smartMapping/raster/renderers/rgb.js +1 -1
  169. package/smartMapping/raster/renderers/stretch.js +1 -1
  170. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  171. package/smartMapping/raster/support/adapters/RasterLayerAdapter.js +1 -1
  172. package/smartMapping/renderers/support/rendererUtils.d.ts +4 -0
  173. package/support/revision.js +1 -1
  174. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  175. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  176. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  177. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  178. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  179. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
  180. package/views/2d/grid/GridView2D.js +1 -1
  181. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  182. package/views/2d/layers/MediaLayerView2D.js +1 -1
  183. package/views/2d/layers/TileLayerView2D.js +1 -1
  184. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  185. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  186. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  187. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  188. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  189. package/views/3d/glTF/loader.js +1 -1
  190. package/views/3d/layers/I3SMeshView3D.js +1 -1
  191. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  192. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  193. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  194. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  195. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  196. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  197. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  198. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  199. package/views/3d/layers/i3s/CachedMeshData.js +5 -0
  200. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  201. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  202. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  203. package/views/3d/layers/support/FeatureTile.js +1 -1
  204. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  205. package/views/3d/state/ViewStateManager.js +1 -1
  206. package/views/3d/state/controllers/FovController.js +1 -1
  207. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  208. package/views/3d/terrain/Tile.js +1 -1
  209. package/views/3d/terrain/TileTexture.js +1 -1
  210. package/views/3d/webgl/ManagedFBO.js +1 -1
  211. package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
  212. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  213. package/views/3d/webgl-engine/core/FBOPool.js +1 -1
  214. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  215. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  216. package/views/3d/webgl-engine/materials/ProceduralTextureRepository.js +1 -1
  217. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  218. package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +1 -1
  219. package/views/input/BrowserEventSource.js +1 -1
  220. package/views/webgl/Texture.js +1 -1
  221. package/views/webgl/VertexArrayObject.js +1 -1
  222. package/webdoc/support/webdocSaveUtils.js +1 -1
  223. package/widgets/Attribution/AttributionViewModel.js +1 -1
  224. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  225. package/widgets/BatchAttributeForm/css.js +1 -1
  226. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  227. package/widgets/BatchAttributeForm.js +1 -1
  228. package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
  229. package/widgets/ElevationProfile/support/ProfileLine2D.js +5 -0
  230. package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
  231. package/widgets/ElevationProfile/support/constants.js +1 -1
  232. package/widgets/ElevationProfile/support/visualizationUtils.js +5 -0
  233. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  234. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  235. package/widgets/FeatureTable/support/columnUtils.js +1 -1
  236. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  237. package/widgets/FeatureTable/support/templateUtils.js +5 -0
  238. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  239. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  240. package/widgets/support/GridControls.js +1 -1
  241. package/assets/esri/core/workers/chunks/03d0394fff1463c224f9.js +0 -1
  242. package/assets/esri/core/workers/chunks/0c40cac18711f79f0a7d.js +0 -1
  243. package/assets/esri/core/workers/chunks/1a97f98facfc62a9fc69.js +0 -1
  244. package/assets/esri/core/workers/chunks/1e3ed3ee48c2977cff6f.js +0 -1
  245. package/assets/esri/core/workers/chunks/1fc064e37d030e449d5e.js +0 -1
  246. package/assets/esri/core/workers/chunks/4daab36de5efa03a8cbb.js +0 -1
  247. package/assets/esri/core/workers/chunks/77d129134c2a66cd86d8.js +0 -1
  248. package/assets/esri/core/workers/chunks/88bd9e023764da377aa7.js +0 -1
  249. package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +0 -1
  250. package/assets/esri/core/workers/chunks/a5675c989d00b7400f98.js +0 -1
  251. package/assets/esri/core/workers/chunks/c06c5c815b5e37717fa1.js +0 -1
  252. package/assets/esri/core/workers/chunks/ca1385e165aae8a32ca2.js +0 -1
  253. package/assets/esri/core/workers/chunks/ce8c1208916f54af7e68.js +0 -320
  254. package/assets/esri/core/workers/chunks/df51c93b2dbcc89efc23.js +0 -1
  255. package/assets/esri/core/workers/chunks/efa3c919261672871f2f.js +0 -1
  256. package/chunks/Bufferer-fr1_Nc47.js +0 -5
  257. package/geometry/operators/support/converterAPI.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Handles.js";import{destroyMaybe as e}from"../../../core/maybe.js";import{watch as i,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{ElevationProfileState as n}from"./constants.js";import{HoveredPoints as o}from"./HoveredPoints.js";import{InputRepresentation2D as r}from"./InputRepresentation2D.js";class h{constructor(e,n){this._handles=new t,this._inputRepresentation=new r({view:e}),this._hoveredPoints=new o({view:e}),this._handles.add([i((()=>n.viewModel.hoveredPoints),(t=>this._hoveredPoints.update(t)),s),i((()=>{const{state:t,highlightEnabled:e,viewModel:i}=n;return{input:i.input,state:t,highlightEnabled:e}}),(t=>this._updateInputRepresentation(t)),s)])}destroy(){this._handles=e(this._handles),this._inputRepresentation=e(this._inputRepresentation),this._hoveredPoints=e(this._hoveredPoints)}_updateInputRepresentation({input:t,state:e,highlightEnabled:i}){e===n.Selected&&i?this._inputRepresentation.update(t):this._inputRepresentation.remove()}}export{h as ElevationProfileView2D};
5
+ import e from"../../../core/Handles.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as i,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{ElevationProfileState as o}from"./constants.js";import{HoveredPoints as s}from"./HoveredPoints.js";import{InputRepresentation2D as r}from"./InputRepresentation2D.js";import{ProfileLine2D as h}from"./ProfileLine2D.js";class p{constructor(t,o){this._handles=new e,this._inputRepresentation=new r({view:t}),this._hoveredPoints=new s({view:t}),this._profileLine=new h({view:t}),this._handles.add([i((()=>o.viewModel.hoveredPoints),(e=>this._hoveredPoints.update(e)),n),i((()=>{const{state:e,highlightEnabled:t,viewModel:i}=o;return{input:i.input,state:e,highlightEnabled:t}}),(e=>this._updateInputRepresentation(e)),n),i((()=>o.viewModel.chartData),(e=>this._profileLine.update(e)),n),i((()=>o.viewModel.input?.geometry),(()=>{this._profileLine.remove()}),n)])}destroy(){this._handles=t(this._handles),this._inputRepresentation=t(this._inputRepresentation),this._hoveredPoints=t(this._hoveredPoints),this._profileLine=t(this._profileLine)}_updateInputRepresentation({input:e,state:t,highlightEnabled:i}){t===o.Selected&&i?this._inputRepresentation.update(e):this._inputRepresentation.remove()}}export{p as ElevationProfileView2D};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import"../../../symbols.js";import r from"../../../core/Accessor.js";import{getContrast as o}from"../../../core/colorUtils.js";import{watch as i,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{throttle as a}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../layers/GraphicsLayer.js";import{getConfig as n}from"./constants.js";import{createLineGeometry as m}from"./visualizationUtils.js";import h from"../../../symbols/CIMSymbol.js";let d=class extends r{constructor(t){super(t),this._chartData=null,this._graphic=new e,this._layer=new p({listMode:"hide",internal:!0,title:"Profile line"}),this._update=t=>{const{chartData:e}=t;if(null==e)return this.remove();if(!e.refined)return;const r=e.lines.find((t=>t.viewVisualizationEnabled));if(!r)return;this._graphic.geometry=m(r,t.spatialReference),this._graphic.symbol=new h({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,10],lineDashEnding:"HalfPattern",controlPointEnding:"HalfPattern"}],capStyle:"Butt",width:1.5,color:r.color.toArray()},{type:"CIMSolidStroke",capStyle:"Butt",width:2,color:o(r.color).toArray()}]}}});const i=this.view?.map?.layers;i&&!i.includes(this._layer)&&i.add(this._layer)}}initialize(){this._layer.add(this._graphic);const t=n().profileLinesUpdateThrottleMillis;let e=this._update;if(t>0){const r=a(this._update,t);this.addHandles(r),e=r}this.addHandles(i((()=>({spatialReference:this.view.spatialReference,chartData:this._chartData})),e,s))}destroy(){this.remove()}remove(){this.view?.map?.remove(this._layer)}update(t){this._chartData=t}};t([l()],d.prototype,"view",void 0),t([l()],d.prototype,"_chartData",void 0),d=t([c("esri.widgets.ElevationProfile.support.ProfileLine2D")],d);export{d as ProfileLine2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import s from"../../../core/Accessor.js";import{watch as o,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{fromArray as n}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import c from"../../../geometry/Polyline.js";import{OutlineVisualElement as h}from"../../../views/3d/interactive/visualElements/OutlineVisualElement.js";import{getConfig as p}from"./constants.js";let m=class extends s{constructor(e){super(e),this._chartData=null,this._visualElements=[],this._update=e=>{const{chartData:s}=e;if(null==s)return this.remove();if(!s.refined)return;const o=this._visualElements,r=s.lines.filter((e=>e.viewVisualizationEnabled)),i=r.length;for(;o.length>i;)o.pop().destroy();const l=p().profileLinesStyle3D;for(;o.length<i;){const e=new h({view:this.view,elevationInfo:{mode:"absolute-height",offset:0},innerWidth:l.innerWidth,innerColor:l.innerColor,width:l.width,falloff:l.falloff,renderOccluded:l.renderOccluded,isDecoration:!0});o.push(e)}const a=e.spatialReference;for(let c=0;c<i;++c){const e=o[c],s=r[i-1-c];e.geometry=this._createLineGeometry(s,a),e.color=n(t.toUnitRGBA(s.color))}}}initialize(){const e=p().profileLines3DUpdateThrottleMillis;let t=this._update;if(e>0){const s=i(this._update,e);this.addHandles(s),t=s}this.addHandles([o((()=>({spatialReference:this.view.spatialReference,chartData:this._chartData})),t,r)])}destroy(){this._destroyVisualElements()}remove(){this._destroyVisualElements()}update(e){this._chartData=e}_createLineGeometry(e,t){const s=e.samples??[],o=s.length-1,r=[];let i=[];for(let l=0;l<=o;l++){const{x:e,y:t,z:a}=s[l];null!=a&&i.push([e,t,a]),l!==o&&null!=a||!i.length||(r.push(i),i=[])}return new c({paths:r,hasZ:!0,spatialReference:t})}_destroyVisualElements(){this._visualElements.forEach((e=>e.destroy())),this._visualElements.length=0}};e([l()],m.prototype,"view",void 0),e([l()],m.prototype,"_chartData",void 0),m=e([a("esri.widgets.ElevationProfile.support.ProfileLines3D")],m);export{m as ProfileLines3D};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Color.js";import o from"../../../core/Accessor.js";import{watch as s,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{fromArray as n}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{OutlineVisualElement as c}from"../../../views/3d/interactive/visualElements/OutlineVisualElement.js";import{getConfig as p}from"./constants.js";import{createLineGeometry as m}from"./visualizationUtils.js";let h=class extends o{constructor(t){super(t),this._chartData=null,this._visualElements=[],this._update=t=>{const{chartData:o}=t;if(null==o)return this.remove();if(!o.refined)return;const s=this._visualElements,r=o.lines.filter((t=>t.viewVisualizationEnabled)),i=r.length;for(;s.length>i;)s.pop().destroy();const l=p().profileLinesStyle3D;for(;s.length<i;){const t=new c({view:this.view,elevationInfo:{mode:"absolute-height",offset:0},innerWidth:l.innerWidth,innerColor:l.innerColor,width:l.width,falloff:l.falloff,renderOccluded:l.renderOccluded,isDecoration:!0});s.push(t)}const a=t.spatialReference;for(let c=0;c<i;++c){const t=s[c],o=r[i-1-c];t.geometry=m(o,a),t.color=n(e.toUnitRGBA(o.color))}}}initialize(){const t=p().profileLinesUpdateThrottleMillis;let e=this._update;if(t>0){const o=i(this._update,t);this.addHandles(o),e=o}this.addHandles([s((()=>({spatialReference:this.view.spatialReference,chartData:this._chartData})),e,r)])}destroy(){this._destroyVisualElements()}remove(){this._destroyVisualElements()}update(t){this._chartData=t}_destroyVisualElements(){this._visualElements.forEach((t=>t.destroy())),this._visualElements.length=0}};t([l()],h.prototype,"view",void 0),t([l()],h.prototype,"_chartData",void 0),h=t([a("esri.widgets.ElevationProfile.support.ProfileLines3D")],h);export{h as ProfileLines3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{convertUnit as e}from"../../../core/unitUtils.js";import{fromValues as i}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderOccludedFlag as o}from"../../../views/3d/webgl-engine/lib/Material.js";var t,a;!function(e){e.Disabled="disabled",e.Ready="ready",e.Creating="creating",e.Created="created",e.Selecting="selecting",e.Selected="selected"}(t||(t={})),function(e){e.NoValidInput="no-valid-input",e.NoVisibleProfiles="no-visible-profiles",e.InvalidGeometry="invalid-geometry",e.TooComplex="too-complex",e.InvalidElevationInfo="invalid-elevation-info",e.UnknownError="unknown-error",e.RefinedButNoChartData="refined-but-no-chart-data",e.None="none"}(a||(a={}));let l={noDataValue:-5e5,defaultQueryOptions:()=>({noDataValue:l.noDataValue,demResolution:"auto",maximumAutoTileRequests:150,ignoreInvisibleLayers:!0}),updateThrottleMillis:100,delayAfterPreviewMillis:500,defaultDemResolution:e(10,"centimeters","meters"),densificationMaxSamples:3e3,largeChartSamples:1e4,maxTotalSamples:1e5,maxChartRatio:300,minSlopeSampleDistance:10,formatPrecision:1,portraitModePixelBreakpoint:400,profileLinesStyle3D:{width:3,falloff:0,innerWidth:0,innerColor:i(0,0,0,0),renderOccluded:o.Opaque},profileLines3DUpdateThrottleMillis:100,hoveredPointsStyle:{size:14,borderStyle:"solid",borderWidth:3,borderColor:"#ffffff",boxShadow:"0px 0px 0px 5px rgba(255,255,255,0.2)"}};function r(){return l}function n(e){l=e}const s=" ― ",d={progress:1,hasZ:!1,samples:[],statistics:null,spatialReference:null};export{a as ElevationProfileErrorState,t as ElevationProfileState,d as errorResult,r as getConfig,s as notAvailable,n as setConfig};
5
+ import{convertUnit as e}from"../../../core/unitUtils.js";import{fromValues as i}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderOccludedFlag as o}from"../../../views/3d/webgl-engine/lib/Material.js";var t,a;!function(e){e.Disabled="disabled",e.Ready="ready",e.Creating="creating",e.Created="created",e.Selecting="selecting",e.Selected="selected"}(t||(t={})),function(e){e.NoValidInput="no-valid-input",e.NoVisibleProfiles="no-visible-profiles",e.InvalidGeometry="invalid-geometry",e.TooComplex="too-complex",e.InvalidElevationInfo="invalid-elevation-info",e.UnknownError="unknown-error",e.RefinedButNoChartData="refined-but-no-chart-data",e.None="none"}(a||(a={}));let l={noDataValue:-5e5,defaultQueryOptions:()=>({noDataValue:l.noDataValue,demResolution:"auto",maximumAutoTileRequests:150,ignoreInvisibleLayers:!0}),updateThrottleMillis:100,delayAfterPreviewMillis:500,defaultDemResolution:e(10,"centimeters","meters"),densificationMaxSamples:3e3,largeChartSamples:1e4,maxTotalSamples:1e5,maxChartRatio:300,minSlopeSampleDistance:10,formatPrecision:1,portraitModePixelBreakpoint:400,profileLinesStyle3D:{width:3,falloff:0,innerWidth:0,innerColor:i(0,0,0,0),renderOccluded:o.Opaque},profileLinesUpdateThrottleMillis:100,hoveredPointsStyle:{size:14,borderStyle:"solid",borderWidth:3,borderColor:"#ffffff",boxShadow:"0px 0px 0px 5px rgba(255,255,255,0.2)"}};function r(){return l}function n(e){l=e}const s=" ― ",d={progress:1,hasZ:!1,samples:[],statistics:null,spatialReference:null};export{a as ElevationProfileErrorState,t as ElevationProfileState,d as errorResult,r as getConfig,s as notAvailable,n as setConfig};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import e from"../../../geometry/Polyline.js";function t(t,l){const n=t.samples??[],s=n.length-1,o=[];let r=[];for(let e=0;e<=s;e++){const{x:t,y:l,z:p}=n[e];null!=p&&r.push([t,l,p]),e!==s&&null!=p||!r.length||(o.push(r),r=[])}return new e({paths:o,hasZ:!0,spatialReference:l})}export{t as createLineGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Error.js";import l from"../../core/Handles.js";import n from"../../core/Logger.js";import{debounce as a,ignoreAbortErrors as r,createResolver as h}from"../../core/promiseUtils.js";import{watch as d,initial as c,on as m}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as u}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as b,isSubtypeGroupLayer as f}from"../../layers/support/layerUtils.js";import{highlightsSupported as y}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as w}from"../../views/support/selectionUtils.js";import T from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import I from"./FieldColumn.js";import C from"./RelationshipColumn.js";import v from"./Grid/Column.js";import E from"./Grid/Grid.js";import j from"./Grid/GridViewModel.js";import S from"./Grid/GroupColumn.js";import A from"./support/AttachmentsColumnTemplate.js";import F from"./support/AttachmentsViewOptions.js";import{downloadAttachmentInfo as R,exportToCSV as x}from"./support/exportUtils.js";import O from"./support/FeatureStore.js";import U from"./support/FieldColumnTemplate.js";import V from"./support/RelationshipColumnTemplate.js";import z from"./support/TableTemplate.js";import{findRelationship as P,uniqueColumnNames as W,getRelationshipIdsToShow as L}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as B}from"../support/decorators/messageBundle.js";import{onLocaleChange as G}from"../../intl/locale.js";import{substitute as Z}from"../../intl/substitute.js";import{fetchMessageBundle as k}from"../../intl/messages.js";const M="80px";let H=class extends j{constructor(e){super(e),this._debounceRefresh=a((()=>this._refresh())),this._highlights=new l,this.actionColumnConfig=null,this.attachmentsViewOptions=new F,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:o}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===o.length&&-1===o.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const l=this.paginationEnabled?this.pageIndex:e.page,n=await s.fetchItems({...e,page:l});t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new t,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new O),this._set("grid",new E({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await k("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await k("esri/t9n/common"),this.messagesUnits=await k("esri/core/t9n/Units"),this.messagesURIUtils=await k("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([G((()=>{e(),this._generateColumns()})),d((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this.refreshCellContent()}),c),m((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),d((()=>this.attachmentsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),d((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),d((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),d((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),d((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),d((()=>this.store.state),(e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())})),d((()=>this._effectiveTableTemplate),(()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()})),d((()=>this.editingEnabled),(e=>{this.editableColumns.forEach((t=>t.tableEditingEnabled=e)),this.refreshCellContent()})),d((()=>this.timeZone??this.view?.timeZone),(()=>this.refreshCellContent())),d((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),m((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),m((()=>this.grid),["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],(({index:e,item:t,native:i,path:s,type:o})=>{const l=t?.feature,n=l?.getObjectId(),a="cell-keydown"===o&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(o,{feature:l,index:e,native:i,type:o,fieldName:s??void 0,objectId:n}),(a||"cell-click"===o)&&this._onCellInteraction(n)})),d((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.relatedRecordsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),m((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()}),d((()=>[this.paginationEnabled,this.pageIndex]),(()=>this.refreshPageCache())),d((()=>this.activeSortOrders),(e=>this.store.sortOrders=e)),d((()=>this.pageCount),(()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)})),d((()=>this.state),(e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()})),m((()=>this.tableParent?.highlightIds),"change",(({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:o}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:o}})),m((()=>this.tableParent),"cell-click",(e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)})),d((()=>this.attachmentsViewOptions.objectId),((e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return u(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return y(e)?e:null}get _relationshipInfos(){return this.store.relationshipInfos}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return w(e)&&this._selectionManager?.sources.includes(e)?e:null}get _subtypes(){return b(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,l=new t;return e&&l.push({type:"geometry",geometry:e}),s?l.push({type:"selection",objectIds:o.toArray()}):i.length&&l.push({type:"objectId",objectIds:i.toArray()}),l}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get isSyncingAttachments(){return this.store.syncingAttachmentEdits||this.relatedTables.some((e=>!!e.isSyncingAttachments))}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerView(){return this.store.layerView}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){const{store:{supportsDeletingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this._get("timeZone")}set timeZone(e){this.allColumns.forEach((t=>t.tableTimeZone=e)),this._set("timeZone",e)}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach((t=>t.view=e)),this.refreshCellContent()}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,i){const{relatedLayer:s,objectId:o,relationshipId:l}=i,{objectIdField:n}=s,a=P(s,l),r=s.displayField||a?.keyField||n;e.set({highlightIds:new t([o]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,r,l)});const h=e.hiddenFields;h.includes(W.action)||h.add(W.action),h.includes(W.attachments)||h.add(W.attachments),e.scrollLeft()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find((e=>e.id===t));R(i)}drainRelatedTables(){this.relatedTables.drain((e=>e.destroy())),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([W.action,W.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach((e=>e.destroy()));const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await x({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(n.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(W.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){return this.relatedTables.forEach((async e=>await e.refresh())),r(this._debounceRefresh())}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({index:e,objectId:i}){const{attachmentsViewOptions:s,hiddenFields:o,layer:l}=this;if(!this.attachmentsEnabled||!l)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await l.load();const n=l.displayField||l.objectIdField,a=await this.store.getAttachmentsByObjectId(i,!0);s.set({attachmentInfos:a,mode:a.length?"list":"file",objectId:i}),this.set({highlightIds:new t([i]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),o.includes(W.action)||o.add(W.action),null!=e&&this.scrollToIndex(e)}clearSelectionFilter(){s(n.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,n=s.objectId===e;await l.updateAttachment(e,t,i).catch((e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)})),n&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.refreshPageCache()}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&f(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,o=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=o),this.grid?.set("pageSize",o),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&(this.attachmentsEnabled&&!t.some((e=>"onShowAttachments"in e))&&t.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this._relationshipInfos.length&&!t.some((e=>"relationshipId"in e))&&t.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t))}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r,view:h}=this;if(!s)return[];const d=s.fields??[],c=[],m=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach(((e,d)=>{const{autoWidth:p,description:g,direction:u,flexGrow:b,fieldName:f,formatFunction:y,frozen:w,frozenToEnd:T,icon:_,initialSortPriority:C,invalid:E,label:j,menuConfig:A,resizable:F,sortable:R,textAlign:x,textWrap:O,timeZone:U,type:V,width:z}=e;if(!V)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(w&&T)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===e.visible;if("group"===V){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const t=this._generateColumnsFromTemplates(e.columnTemplates),s=P||this._isFieldHidden(e.label);c.push(new S({autoWidth:p,columns:t,description:g,flexGrow:b,frozen:w,frozenToEnd:T,grid:i,hidden:s,icon:_,invalid:E,label:j,menuConfig:A,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:F,tableTimeZone:r,textAlign:x,textWrap:O,timeZone:U,width:z}))}else if("attachment"===V){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");c.push(this._generateAttachmentsColumnFromTemplate(e,d))}else if("relationship"===V){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this._relationshipInfos.find((e=>e.relationshipId===t));if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");c.push(this._generateRelationshipColumnFromTemplate(i,e,d))}else if(!f)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const W=P||this._isFieldHidden(f);if("column"===V)c.push(new v({autoWidth:p,description:g,direction:u,fieldName:f,flexGrow:b,formatFunction:y,frozen:w,frozenToEnd:T,grid:i,hidden:W,icon:_,initialSortPriority:C,invalid:E,label:j,menuConfig:A,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:F,sortable:R,tableTimeZone:r,textAlign:x,textWrap:O,timeZone:U,width:z}));else if("field"===V){const d=m(e);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:f,required:v}=e;c.push(new I({autoWidth:p,description:g,direction:u,editable:f,field:d,fieldName:d.name,flexGrow:b,formatFunction:y,frozen:w,frozenToEnd:T,grid:i,hidden:W,icon:_,initialSortPriority:C,invalid:E,label:j,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,menuConfig:A,required:v,resizable:F,sortable:R,store:a,tableEditingEnabled:t,tableTimeZone:r,template:e,textAlign:x,textWrap:O,timeZone:U,width:z,view:h,onShowPromptCallback:this._onShowPromptCallback}))}})),c}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:l,store:n,timeZone:a,view:r}=this,h=[];return i?.fields.length?(i.fields.forEach((d=>{if(!d.visible||"geometry"===d.type)return;const c=d.name;h.push(new I({field:d,fieldName:c,grid:t,hidden:this._isFieldHidden(c),layer:i,messages:s,messagesCommon:o,messagesURIUtils:l,store:n,tableEditingEnabled:e,tableTimeZone:a,view:r,onShowPromptCallback:this._onShowPromptCallback}))})),h):h}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r}=this,{attachmentsViewEnabled:h,autoWidth:d,description:c,flexGrow:m,fieldName:p,formatFunction:g,frozen:u,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,resizable:I,textAlign:C,textWrap:v,thumbnailAppearance:E,thumbnailCount:j,thumbnailIconScale:S,thumbnailsEnabled:A,timeZone:F,width:R}=e;return new _({attachmentsViewEnabled:h,autoWidth:d,description:c,fieldName:`${W.attachments}-${t}`,flexGrow:m,formatFunction:g,frozen:u,frozenToEnd:b,grid:i,hidden:!1===e.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,layer:s,menuConfig:T,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:I,store:a,tableTimeZone:r,textAlign:C,textWrap:v,thumbnailAppearance:E,thumbnailCount:j,thumbnailIconScale:S,thumbnailsEnabled:A,timeZone:F,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(){const{grid:e,layer:t,messages:i,messagesCommon:s,messagesURIUtils:o,store:l,timeZone:n}=this,a=W.attachments,r=this._isFieldHidden(a);return new _({fieldName:a,grid:e,hidden:r,layer:t,messages:i,messagesCommon:s,messagesURIUtils:o,store:l,tableTimeZone:n,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r}=this,{autoWidth:h,collapsed:d,description:c,flexGrow:m,fieldName:p,formatFunction:g,frozen:u,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,relationshipId:_,resizable:I,textAlign:v,textWrap:E,timeZone:j,width:S}=t;return new C({autoWidth:h,collapsed:d,description:c,fieldName:`${W.relationship}-${_}-${i}`,flexGrow:m,formatFunction:g,frozen:u,frozenToEnd:b,grid:s,hidden:!1===t.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,menuConfig:T,messages:o,messagesCommon:l,messagesURIUtils:n,relationshipId:_,resizable:I,store:a,tableTimeZone:r,textAlign:v,textWrap:E,timeZone:j,width:S,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{_relationshipInfos:e,grid:t,messages:i,messagesCommon:s,messagesURIUtils:o,relationshipColumnConfigs:l}=this,n=[];if(!e?.length)return n;const a={grid:t,messages:i,messagesCommon:s,messagesURIUtils:o};return l?l.forEach(((t,i)=>{const{relationshipId:s}=t,o=e.find((e=>e.relationshipId===s));o&&n.push(new C({...t,...a,fieldName:`${W.relationship}-${s}-${i}`,layer:o.relatedLayer,relatedLayer:o.layer,relationshipId:s,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):e.forEach((({layer:e,relatedLayer:t,relationshipId:i},s)=>{n.push(new C({...a,fieldName:`${W.relationship}-${i}-${s}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),n}_generateActionColumn(){return new T({hidden:this._isFieldHidden(W.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o=s?.feature??e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(W.action)||s.add(W.action),s.includes(W.attachments)||s.add(W.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const t=e.layer?.displayField||e.layer?.objectIdField||"";e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(t)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:L(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([W.action,W.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new z({columnTemplates:[new U({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([s,o])=>({selected:s===t,label:o||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}})))},resizable:!1}),new V({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:M})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new U({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}})))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new A({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:M})),new z({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:o}=e,{_subtypes:l,layer:n}=this;if(!n||!l.length)return void t.cancel();const a=l.find((e=>e.code===o));if(!a)return void t.cancel();const r=h(),d=this._createSubtypeEditPrompt(s,a,r),c=!!n.parent;try{this.showPrompt(d);const e=await r.promise,s=[{fieldName:t.fieldName,value:o}];switch(e){case"update-fields":for(const[e,t]of Object.entries(a.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),c&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),c&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,i){const{_subtypes:s,messages:o,messagesCommon:l}=this,n=s.find((t=>t.code===e))?.name??`${e}`;let a="update-fields";const r=[{label:o.subtypes.useDefaultValuesOption,value:"update-fields"},{label:o.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:o.subtypes.changeWarningTitle,message:Z(o.subtypes.changeWarning,{originalType:n,newType:t.name}),radios:r,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:l.apply,action:()=>i.resolve(a),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>i.resolve("undo")}},cancel:()=>i.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new z({columnTemplates:[new U({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map((([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}})))},resizable:!1}),new A({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:M})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter((({type:e})=>"field"===e||"column"===e)).map((({fieldName:e,label:t})=>[e,t])):i?.fields.map((e=>[e.name,e.alias]))??[]}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){n.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([p()],H.prototype,"_defaultHiddenFields",null),e([p()],H.prototype,"_effectiveTableTemplate",null),e([p()],H.prototype,"_highlights",void 0),e([p()],H.prototype,"_highlightableLayerView",null),e([p()],H.prototype,"_relationshipInfos",null),e([p()],H.prototype,"_selectionManager",null),e([p()],H.prototype,"_selectableLayer",null),e([p()],H.prototype,"_subtypes",null),e([p()],H.prototype,"_tableHighlightsReady",null),e([p()],H.prototype,"_viewSelection",null),e([p()],H.prototype,"_viewSelectionReady",null),e([p()],H.prototype,"actionColumnConfig",void 0),e([p()],H.prototype,"allRelatedTablesVisible",null),e([p()],H.prototype,"activeFilters",null),e([p({readOnly:!0})],H.prototype,"activeSortOrders",null),e([p()],H.prototype,"attachmentsEnabled",null),e([p()],H.prototype,"attachmentsViewOptions",void 0),e([p()],H.prototype,"autoRefreshEnabled",void 0),e([p()],H.prototype,"clearPrompt",null),e([p({readOnly:!0})],H.prototype,"columns",void 0),e([p()],H.prototype,"dataProvider",void 0),e([p()],H.prototype,"editingEnabled",void 0),e([p()],H.prototype,"filterGeometry",null),e([p()],H.prototype,"filterBySelectionEnabled",null),e([p({readOnly:!0})],H.prototype,"grid",void 0),e([p()],H.prototype,"hiddenFields",null),e([p()],H.prototype,"highlightEnabled",void 0),e([p()],H.prototype,"initialSize",null),e([p()],H.prototype,"isQueryingOrSyncing",null),e([p()],H.prototype,"isSyncingAttachments",null),e([p({readOnly:!0})],H.prototype,"itemIdPath",void 0),e([p()],H.prototype,"layer",null),e([p()],H.prototype,"layerView",null),e([p()],H.prototype,"messages",void 0),e([p(),B("esri/t9n/common")],H.prototype,"messagesCommon",void 0),e([p(),B("esri/core/t9n/Units")],H.prototype,"messagesUnits",void 0),e([p(),B("esri/widgets/support/t9n/uriUtils")],H.prototype,"messagesURIUtils",void 0),e([p()],H.prototype,"outFields",null),e([p()],H.prototype,"prompt",void 0),e([p()],H.prototype,"relatedRecordsEnabled",null),e([p()],H.prototype,"relatedTable",null),e([p()],H.prototype,"relatedTables",void 0),e([p()],H.prototype,"relationship",null),e([p()],H.prototype,"relationshipColumnConfigs",void 0),e([p()],H.prototype,"relationshipConfig",null),e([p()],H.prototype,"relationships",null),e([p()],H.prototype,"returnGeometryEnabled",null),e([p()],H.prototype,"returnMEnabled",null),e([p()],H.prototype,"returnZEnabled",null),e([p()],H.prototype,"selectionSource",void 0),e([p()],H.prototype,"showAllRelatedTables",null),e([p()],H.prototype,"showPrompt",null),e([p()],H.prototype,"showRelatedTableCallback",void 0),e([p({readOnly:!0,type:O})],H.prototype,"store",void 0),e([p()],H.prototype,"supportsAttachments",null),e([p()],H.prototype,"supportsAddAttachments",null),e([p()],H.prototype,"supportsDeleteAttachments",null),e([p()],H.prototype,"supportsResizeAttachments",null),e([p()],H.prototype,"supportsUpdateAttachments",null),e([p()],H.prototype,"tableController",void 0),e([p()],H.prototype,"tableParent",void 0),e([p({type:z})],H.prototype,"tableTemplate",void 0),e([p()],H.prototype,"tableTemplateOverride",void 0),e([p()],H.prototype,"timeExtent",null),e([p()],H.prototype,"timeZone",null),e([p()],H.prototype,"view",null),H=e([g("esri.widgets.FeatureTable.FeatureTableViewModel")],H);const N=H;export{N as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Error.js";import l from"../../core/Handles.js";import n from"../../core/Logger.js";import{debounce as a,ignoreAbortErrors as r,createResolver as h}from"../../core/promiseUtils.js";import{watch as d,initial as c,on as m}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as u}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as b,isSubtypeGroupLayer as f}from"../../layers/support/layerUtils.js";import{highlightsSupported as y}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as w}from"../../views/support/selectionUtils.js";import T from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import I from"./FieldColumn.js";import C from"./RelationshipColumn.js";import v from"./Grid/Column.js";import E from"./Grid/Grid.js";import j from"./Grid/GridViewModel.js";import S from"./Grid/GroupColumn.js";import A from"./support/AttachmentsColumnTemplate.js";import F from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as R,isRelationshipColumn as x}from"./support/columnUtils.js";import{downloadAttachmentInfo as O,exportToCSV as U}from"./support/exportUtils.js";import V from"./support/FeatureStore.js";import z from"./support/FieldColumnTemplate.js";import P from"./support/RelationshipColumnTemplate.js";import W from"./support/TableTemplate.js";import{findRelationship as L,uniqueColumnNames as B,getRelationshipIdsToShow as G}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as Z}from"../support/decorators/messageBundle.js";import{onLocaleChange as k}from"../../intl/locale.js";import{substitute as M}from"../../intl/substitute.js";import{fetchMessageBundle as H}from"../../intl/messages.js";const N="80px";let $=class extends j{constructor(e){super(e),this._debounceRefresh=a((()=>this._refresh())),this._highlights=new l,this.actionColumnConfig=null,this.attachmentsViewOptions=new F,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:o}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===o.length&&-1===o.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const l=this.paginationEnabled?this.pageIndex:e.page,n=await s.fetchItems({...e,page:l});t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new t,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new V),this._set("grid",new E({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await H("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await H("esri/t9n/common"),this.messagesUnits=await H("esri/core/t9n/Units"),this.messagesURIUtils=await H("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([k((()=>{e(),this._generateColumns()})),d((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this.refreshCellContent()}),c),m((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),d((()=>this.attachmentsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),d((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),d((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),d((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),d((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),d((()=>this.store.state),(e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())})),d((()=>this._effectiveTableTemplate),(()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()})),d((()=>this.editingEnabled),(e=>{this.editableColumns.forEach((t=>t.tableEditingEnabled=e)),this.refreshCellContent()})),d((()=>this.timeZone??this.view?.timeZone),(()=>this.refreshCellContent())),d((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),m((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),m((()=>this.grid),["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],(({index:e,item:t,native:i,path:s,type:o})=>{const l=t?.feature,n=l?.getObjectId(),a="cell-keydown"===o&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(o,{feature:l,index:e,native:i,type:o,fieldName:s??void 0,objectId:n}),(a||"cell-click"===o)&&this._onCellInteraction(n)})),d((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.relatedRecordsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),m((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()}),d((()=>[this.paginationEnabled,this.pageIndex]),(()=>this.refreshPageCache())),d((()=>this.activeSortOrders),(e=>this.store.sortOrders=e)),d((()=>this.pageCount),(()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)})),d((()=>this.state),(e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()})),m((()=>this.tableParent?.highlightIds),"change",(({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:o}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:o}})),m((()=>this.tableParent),"cell-click",(e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)})),d((()=>this.attachmentsViewOptions.objectId),((e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return u(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return y(e)?e:null}get _relationshipInfos(){return this.store.relationshipInfos}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return w(e)&&this._selectionManager?.sources.includes(e)?e:null}get _subtypes(){return b(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,l=new t;return e&&l.push({type:"geometry",geometry:e}),s?l.push({type:"selection",objectIds:o.toArray()}):i.length&&l.push({type:"objectId",objectIds:i.toArray()}),l}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get isSyncingAttachments(){return this.store.syncingAttachmentEdits||this.relatedTables.some((e=>!!e.isSyncingAttachments))}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerView(){return this.store.layerView}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){const{store:{supportsDeletingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this._get("timeZone")}set timeZone(e){this.allColumns.forEach((t=>t.tableTimeZone=e)),this._set("timeZone",e)}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach((t=>t.view=e)),this.refreshCellContent()}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,i){const{relatedLayer:s,objectId:o,relationshipId:l}=i,{objectIdField:n}=s,a=L(s,l),r=s.displayField||a?.keyField||n;e.set({highlightIds:new t([o]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,r,l)});const h=e.hiddenFields;h.includes(B.action)||h.add(B.action),h.includes(B.attachments)||h.add(B.attachments),e.scrollLeft()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find((e=>e.id===t));O(i)}drainRelatedTables(){this.relatedTables.drain((e=>e.destroy())),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([B.action,B.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach((e=>e.destroy()));const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await U({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(n.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(B.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){return this.relatedTables.forEach((async e=>await e.refresh())),r(this._debounceRefresh())}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({index:e,objectId:i}){const{attachmentsViewOptions:s,hiddenFields:o,layer:l}=this;if(!this.attachmentsEnabled||!l)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await l.load();const n=l.displayField||l.objectIdField,a=await this.store.getAttachmentsByObjectId(i,!0);s.set({attachmentInfos:a,mode:a.length?"list":"file",objectId:i}),this.set({highlightIds:new t([i]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),o.includes(B.action)||o.add(B.action),null!=e&&this.scrollToIndex(e)}clearSelectionFilter(){s(n.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,n=s.objectId===e;await l.updateAttachment(e,t,i).catch((e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)})),n&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.refreshPageCache()}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&f(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,o=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=o),this.grid?.set("pageSize",o),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&(this.attachmentsEnabled&&!t.some((e=>R(e)))&&t.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this._relationshipInfos.length&&!t.some((e=>x(e)))&&t.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t))}_generateColumnsFromTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r,view:h}=this;if(!s)return[];const d=s.fields??[],c=[],m=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach(((e,d)=>{const{autoWidth:p,description:g,direction:u,flexGrow:b,fieldName:f,formatFunction:y,frozen:w,frozenToEnd:T,icon:_,initialSortPriority:C,invalid:E,label:j,menuConfig:A,resizable:F,sortable:R,textAlign:x,textWrap:O,timeZone:U,type:V,width:z}=e;if(!V)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(w&&T)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===e.visible;if("group"===V){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const t=this._generateColumnsFromTemplates(e.columnTemplates),s=P||this._isFieldHidden(e.label);c.push(new S({autoWidth:p,columns:t,description:g,flexGrow:b,frozen:w,frozenToEnd:T,grid:i,hidden:s,icon:_,invalid:E,label:j,menuConfig:A,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:F,tableTimeZone:r,textAlign:x,textWrap:O,timeZone:U,width:z}))}else if("attachment"===V){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");c.push(this._generateAttachmentsColumnFromTemplate(e,d))}else if("relationship"===V){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this._relationshipInfos.find((e=>e.relationshipId===t));if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");c.push(this._generateRelationshipColumnFromTemplate(i,e,d))}else if(!f)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const W=P||this._isFieldHidden(f);if("column"===V)c.push(new v({autoWidth:p,description:g,direction:u,fieldName:f,flexGrow:b,formatFunction:y,frozen:w,frozenToEnd:T,grid:i,hidden:W,icon:_,initialSortPriority:C,invalid:E,label:j,menuConfig:A,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:F,sortable:R,tableTimeZone:r,textAlign:x,textWrap:O,timeZone:U,width:z}));else if("field"===V){const d=m(e);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:f,required:v}=e;c.push(new I({autoWidth:p,description:g,direction:u,editable:f,field:d,fieldName:d.name,flexGrow:b,formatFunction:y,frozen:w,frozenToEnd:T,grid:i,hidden:W,icon:_,initialSortPriority:C,invalid:E,label:j,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,menuConfig:A,required:v,resizable:F,sortable:R,store:a,tableEditingEnabled:t,tableTimeZone:r,template:e,textAlign:x,textWrap:O,timeZone:U,width:z,view:h,onShowPromptCallback:this._onShowPromptCallback}))}})),c}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:l,store:n,timeZone:a,view:r}=this,h=[];return i?.fields.length?(i.fields.forEach((d=>{if(!d.visible||"geometry"===d.type)return;const c=d.name;h.push(new I({field:d,fieldName:c,grid:t,hidden:this._isFieldHidden(c),layer:i,messages:s,messagesCommon:o,messagesURIUtils:l,store:n,tableEditingEnabled:e,tableTimeZone:a,view:r,onShowPromptCallback:this._onShowPromptCallback}))})),h):h}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r}=this,{attachmentsViewEnabled:h,autoWidth:d,description:c,flexGrow:m,fieldName:p,formatFunction:g,frozen:u,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,resizable:I,textAlign:C,textWrap:v,thumbnailAppearance:E,thumbnailCount:j,thumbnailIconScale:S,thumbnailsEnabled:A,timeZone:F,width:R}=e;return new _({attachmentsViewEnabled:h,autoWidth:d,description:c,fieldName:`${B.attachments}-${t}`,flexGrow:m,formatFunction:g,frozen:u,frozenToEnd:b,grid:i,hidden:!1===e.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,layer:s,menuConfig:T,messages:o,messagesCommon:l,messagesURIUtils:n,resizable:I,store:a,tableTimeZone:r,textAlign:C,textWrap:v,thumbnailAppearance:E,thumbnailCount:j,thumbnailIconScale:S,thumbnailsEnabled:A,timeZone:F,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(){const{grid:e,layer:t,messages:i,messagesCommon:s,messagesURIUtils:o,store:l,timeZone:n}=this,a=B.attachments,r=this._isFieldHidden(a);return new _({fieldName:a,grid:e,hidden:r,layer:t,messages:i,messagesCommon:s,messagesURIUtils:o,store:l,tableTimeZone:n,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:o,messagesCommon:l,messagesURIUtils:n,store:a,timeZone:r}=this,{autoWidth:h,collapsed:d,description:c,flexGrow:m,fieldName:p,formatFunction:g,frozen:u,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,relationshipId:_,resizable:I,textAlign:v,textWrap:E,timeZone:j,width:S}=t;return new C({autoWidth:h,collapsed:d,description:c,fieldName:`${B.relationship}-${_}-${i}`,flexGrow:m,formatFunction:g,frozen:u,frozenToEnd:b,grid:s,hidden:!1===t.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,menuConfig:T,messages:o,messagesCommon:l,messagesURIUtils:n,relationshipId:_,resizable:I,store:a,tableTimeZone:r,textAlign:v,textWrap:E,timeZone:j,width:S,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{_relationshipInfos:e,grid:t,messages:i,messagesCommon:s,messagesURIUtils:o,relationshipColumnConfigs:l}=this,n=[];if(!e?.length)return n;const a={grid:t,messages:i,messagesCommon:s,messagesURIUtils:o};return l?l.forEach(((t,i)=>{const{relationshipId:s}=t,o=e.find((e=>e.relationshipId===s));o&&n.push(new C({...t,...a,fieldName:`${B.relationship}-${s}-${i}`,layer:o.relatedLayer,relatedLayer:o.layer,relationshipId:s,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):e.forEach((({layer:e,relatedLayer:t,relationshipId:i},s)=>{n.push(new C({...a,fieldName:`${B.relationship}-${i}-${s}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),n}_generateActionColumn(){return new T({hidden:this._isFieldHidden(B.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o=s?.feature??e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(B.action)||s.add(B.action),s.includes(B.attachments)||s.add(B.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const t=e.layer?.displayField||e.layer?.objectIdField||"";e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(t)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:G(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([B.action,B.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new W({columnTemplates:[new z({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([s,o])=>({selected:s===t,label:o||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}})))},resizable:!1}),new P({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:N})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new z({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}})))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new A({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:N})),new W({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:o}=e,{_subtypes:l,layer:n}=this;if(!n||!l.length)return void t.cancel();const a=l.find((e=>e.code===o));if(!a)return void t.cancel();const r=h(),d=this._createSubtypeEditPrompt(s,a,r),c=!!n.parent;try{this.showPrompt(d);const e=await r.promise,s=[{fieldName:t.fieldName,value:o}];switch(e){case"update-fields":for(const[e,t]of Object.entries(a.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),c&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),c&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,i){const{_subtypes:s,messages:o,messagesCommon:l}=this,n=s.find((t=>t.code===e))?.name??`${e}`;let a="update-fields";const r=[{label:o.subtypes.useDefaultValuesOption,value:"update-fields"},{label:o.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:o.subtypes.changeWarningTitle,message:M(o.subtypes.changeWarning,{originalType:n,newType:t.name}),radios:r,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:l.apply,action:()=>i.resolve(a),type:"positive"},secondary:{label:l.cancel,type:"neutral",action:()=>i.resolve("undo")}},cancel:()=>i.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new W({columnTemplates:[new z({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map((([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}})))},resizable:!1}),new A({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:N})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter((({type:e})=>"field"===e||"column"===e)).map((({fieldName:e,label:t})=>[e,t])):i?.fields.map((e=>[e.name,e.alias]))??[]}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){n.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([p()],$.prototype,"_defaultHiddenFields",null),e([p()],$.prototype,"_effectiveTableTemplate",null),e([p()],$.prototype,"_highlights",void 0),e([p()],$.prototype,"_highlightableLayerView",null),e([p()],$.prototype,"_relationshipInfos",null),e([p()],$.prototype,"_selectionManager",null),e([p()],$.prototype,"_selectableLayer",null),e([p()],$.prototype,"_subtypes",null),e([p()],$.prototype,"_tableHighlightsReady",null),e([p()],$.prototype,"_viewSelection",null),e([p()],$.prototype,"_viewSelectionReady",null),e([p()],$.prototype,"actionColumnConfig",void 0),e([p()],$.prototype,"allRelatedTablesVisible",null),e([p()],$.prototype,"activeFilters",null),e([p({readOnly:!0})],$.prototype,"activeSortOrders",null),e([p()],$.prototype,"attachmentsEnabled",null),e([p()],$.prototype,"attachmentsViewOptions",void 0),e([p()],$.prototype,"autoRefreshEnabled",void 0),e([p()],$.prototype,"clearPrompt",null),e([p({readOnly:!0})],$.prototype,"columns",void 0),e([p()],$.prototype,"dataProvider",void 0),e([p()],$.prototype,"editingEnabled",void 0),e([p()],$.prototype,"filterGeometry",null),e([p()],$.prototype,"filterBySelectionEnabled",null),e([p({readOnly:!0})],$.prototype,"grid",void 0),e([p()],$.prototype,"hiddenFields",null),e([p()],$.prototype,"highlightEnabled",void 0),e([p()],$.prototype,"initialSize",null),e([p()],$.prototype,"isQueryingOrSyncing",null),e([p()],$.prototype,"isSyncingAttachments",null),e([p({readOnly:!0})],$.prototype,"itemIdPath",void 0),e([p()],$.prototype,"layer",null),e([p()],$.prototype,"layerView",null),e([p()],$.prototype,"messages",void 0),e([p(),Z("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([p(),Z("esri/core/t9n/Units")],$.prototype,"messagesUnits",void 0),e([p(),Z("esri/widgets/support/t9n/uriUtils")],$.prototype,"messagesURIUtils",void 0),e([p()],$.prototype,"outFields",null),e([p()],$.prototype,"prompt",void 0),e([p()],$.prototype,"relatedRecordsEnabled",null),e([p()],$.prototype,"relatedTable",null),e([p()],$.prototype,"relatedTables",void 0),e([p()],$.prototype,"relationship",null),e([p()],$.prototype,"relationshipColumnConfigs",void 0),e([p()],$.prototype,"relationshipConfig",null),e([p()],$.prototype,"relationships",null),e([p()],$.prototype,"returnGeometryEnabled",null),e([p()],$.prototype,"returnMEnabled",null),e([p()],$.prototype,"returnZEnabled",null),e([p()],$.prototype,"selectionSource",void 0),e([p()],$.prototype,"showAllRelatedTables",null),e([p()],$.prototype,"showPrompt",null),e([p()],$.prototype,"showRelatedTableCallback",void 0),e([p({readOnly:!0,type:V})],$.prototype,"store",void 0),e([p()],$.prototype,"supportsAttachments",null),e([p()],$.prototype,"supportsAddAttachments",null),e([p()],$.prototype,"supportsDeleteAttachments",null),e([p()],$.prototype,"supportsResizeAttachments",null),e([p()],$.prototype,"supportsUpdateAttachments",null),e([p()],$.prototype,"tableController",void 0),e([p()],$.prototype,"tableParent",void 0),e([p({type:W})],$.prototype,"tableTemplate",void 0),e([p()],$.prototype,"tableTemplateOverride",void 0),e([p()],$.prototype,"timeExtent",null),e([p()],$.prototype,"timeZone",null),e([p()],$.prototype,"view",null),$=e([g("esri.widgets.FeatureTable.FeatureTableViewModel")],$);const D=$;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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Collection.js";import{referenceSetter as o}from"../../../core/collectionUtils.js";import i from"../../../core/Evented.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 l}from"../../../core/accessorSupport/decorators/subclass.js";import{uniqueColumnNames as s,isPageIndexValid as r}from"../support/tableUtils.js";let d=class extends i.EventedAccessor{constructor(t){super(t),this.cellPartNameGenerator=(t,e)=>{let o="";e?.item&&this.rowHighlightIds.includes(e.item.objectId)&&(o+=" highlight");const i=this.findColumn(t?.path);return i?(i.invalid&&(o+=" invalid"),i.textWrap&&(o+=" text-wrap"),"editInfo"in i&&i.editInfo&&i.editInfo.rowData?.index===e.index&&(o+=" editing"),o):o},this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new e,this.dataProvider=async(t,e)=>{const{store:o}=this;if(!e)return;if(!o)return void(e&&e([]));e(await o.fetchItems(t))},this.maxSize=null,this.multipleSelectionEnabled=!0,this.multiSortEnabled=!1,this.paginationEnabled=!1,this.rowDetailsRenderer=null,this.store=null}get actionColumn(){return this.allColumns.find((t=>t.fieldName===s.action))}get allColumns(){return this.columns.toArray().flatMap((t=>[t,..."columns"in t&&t.columns?.length?t.columns:[]]))}get columnMenuIsOpen(){return this.allColumns.some((t=>t.menuIsOpen))}get editing(){return this.editableColumns.some((t=>t.editInfo))}get editableColumns(){return this.allColumns.filter((t=>"editable"in t))}get effectiveSize(){const{filterBySelectionEnabled:t,highlightIds:e,objectIds:o,pageSize:i,size:n}=this;if(this.paginationEnabled){const l=this.pageCount===this.pageIndex+1?n%i:i;return t?Math.min(e.length,l):o.length?Math.min(o.length,l):l}return t?e.length:o.length?o.length:n}get fieldColumns(){return this.allColumns.filter((t=>"field"in t))}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(t){this._set("filterBySelectionEnabled",t)}get groupColumns(){return this.columns.toArray().filter((t=>"columns"in t))}get highlightIds(){return this._get("highlightIds")||new e}set highlightIds(t){const i=Array.isArray(t)?new e(t):t;this.multipleSelectionEnabled||i.splice(1,i.length-1),this._set("highlightIds",o(i,this._get("highlightIds"),e))}get objectIds(){return this._get("objectIds")??new e}set objectIds(t){this._set("objectIds",o(t,this._get("objectIds"),e))}get pageCount(){const{pageSize:t,size:e}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(t){const{pageCount:e}=this;r(t,e)&&this._set("pageIndex",t)}get pageSize(){return this._get("pageSize")??50}set pageSize(t){this.store?.set("pageSize",t),this._set("pageSize",t)}get relationshipColumns(){return this.allColumns.filter((t=>"relationshipId"in t))}get rowHighlightIds(){return this._get("rowHighlightIds")||new e}set rowHighlightIds(t){this._set("rowHighlightIds",o(t,this._get("rowHighlightIds"),e))}get size(){const t=this.store?.count??0,{maxSize:e}=this;return null!=t&&null!=e?Math.min(e,t):t}get state(){return this.store?.state??"disabled"}closeColumnMenus(){this.allColumns.forEach((t=>t.closeMenu()))}sortColumn(t,e){if(!t)return;const o=this.findColumn(t);o&&(o.direction=e)}hideColumn(t){const e=this.findColumn(t);!1===e?.hidden&&(e.hidden=!0)}showColumn(t){const e=this.findColumn(t);e?.hidden&&(e.hidden=!1)}showAllColumns(){this.allColumns.forEach((t=>{t.hidden&&(t.hidden=!1)}))}findColumn(t){return this.allColumns.find((e=>e.fieldName===t))}refresh(){this.store&&(this.store.reset(),this.store.load())}toggleColumnVisibility(t){const e=this.findColumn(t);e&&(e.hidden=!e.hidden)}};t([n()],d.prototype,"actionColumn",null),t([n()],d.prototype,"allColumns",null),t([n()],d.prototype,"cellPartNameGenerator",void 0),t([n()],d.prototype,"columnMenuIsOpen",null),t([n()],d.prototype,"columnPerformanceModeEnabled",void 0),t([n()],d.prototype,"columnReorderingEnabled",void 0),t([n()],d.prototype,"columns",void 0),t([n()],d.prototype,"dataProvider",void 0),t([n()],d.prototype,"editing",null),t([n()],d.prototype,"editableColumns",null),t([n()],d.prototype,"effectiveSize",null),t([n()],d.prototype,"fieldColumns",null),t([n()],d.prototype,"filterBySelectionEnabled",null),t([n()],d.prototype,"groupColumns",null),t([n()],d.prototype,"highlightIds",null),t([n()],d.prototype,"maxSize",void 0),t([n()],d.prototype,"multipleSelectionEnabled",void 0),t([n()],d.prototype,"multiSortEnabled",void 0),t([n()],d.prototype,"objectIds",null),t([n()],d.prototype,"pageCount",null),t([n()],d.prototype,"pageIndex",null),t([n()],d.prototype,"pageSize",null),t([n()],d.prototype,"paginationEnabled",void 0),t([n()],d.prototype,"relationshipColumns",null),t([n()],d.prototype,"rowHighlightIds",null),t([n()],d.prototype,"rowDetailsRenderer",void 0),t([n({readOnly:!0})],d.prototype,"size",null),t([n()],d.prototype,"store",void 0),t([n({readOnly:!0})],d.prototype,"state",null),d=t([l("esri.widgets.FeatureTable.Grid.GridViewModel")],d);const h=d;export{h as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Collection.js";import{referenceSetter as o}from"../../../core/collectionUtils.js";import i from"../../../core/Evented.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 l}from"../../../core/accessorSupport/decorators/subclass.js";import{isGroupColumn as s,isFieldColumn as r,isRelationshipColumn as d}from"../support/columnUtils.js";import{uniqueColumnNames as h,isPageIndexValid as a}from"../support/tableUtils.js";let u=class extends i.EventedAccessor{constructor(t){super(t),this.cellPartNameGenerator=(t,e)=>{let o="";e?.item&&this.rowHighlightIds.includes(e.item.objectId)&&(o+=" highlight");const i=this.findColumn(t?.path);return i?(i.invalid&&(o+=" invalid"),i.textWrap&&(o+=" text-wrap"),"editInfo"in i&&i.editInfo&&i.editInfo.rowData?.index===e.index&&(o+=" editing"),o):o},this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new e,this.dataProvider=async(t,e)=>{const{store:o}=this;if(!e)return;if(!o)return void(e&&e([]));e(await o.fetchItems(t))},this.maxSize=null,this.multipleSelectionEnabled=!0,this.multiSortEnabled=!1,this.paginationEnabled=!1,this.rowDetailsRenderer=null,this.store=null}get actionColumn(){return this.allColumns.find((t=>t.fieldName===h.action))}get allColumns(){return this.columns.toArray().flatMap((t=>[t,...s(t)&&t.columns?.length?t.columns:[]]))}get columnMenuIsOpen(){return this.allColumns.some((t=>t.menuIsOpen))}get editing(){return this.editableColumns.some((t=>t.editInfo))}get editableColumns(){return this.allColumns.filter((t=>"editable"in t))}get effectiveSize(){const{filterBySelectionEnabled:t,highlightIds:e,objectIds:o,pageSize:i,size:n}=this;if(this.paginationEnabled){const l=this.pageCount===this.pageIndex+1?n%i:i;return t?Math.min(e.length,l):o.length?Math.min(o.length,l):l}return t?e.length:o.length?o.length:n}get fieldColumns(){return this.allColumns.filter((t=>r(t)))}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(t){this._set("filterBySelectionEnabled",t)}get groupColumns(){return this.columns.toArray().filter((t=>s(t)))}get highlightIds(){return this._get("highlightIds")||new e}set highlightIds(t){const i=Array.isArray(t)?new e(t):t;this.multipleSelectionEnabled||i.splice(1,i.length-1),this._set("highlightIds",o(i,this._get("highlightIds"),e))}get objectIds(){return this._get("objectIds")??new e}set objectIds(t){this._set("objectIds",o(t,this._get("objectIds"),e))}get pageCount(){const{pageSize:t,size:e}=this;return 0===e||0===t?1:Math.ceil(e/t)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(t){const{pageCount:e}=this;a(t,e)&&this._set("pageIndex",t)}get pageSize(){return this._get("pageSize")??50}set pageSize(t){this.store?.set("pageSize",t),this._set("pageSize",t)}get relationshipColumns(){return this.allColumns.filter((t=>d(t)))}get rowHighlightIds(){return this._get("rowHighlightIds")||new e}set rowHighlightIds(t){this._set("rowHighlightIds",o(t,this._get("rowHighlightIds"),e))}get size(){const t=this.store?.count??0,{maxSize:e}=this;return null!=t&&null!=e?Math.min(e,t):t}get state(){return this.store?.state??"disabled"}closeColumnMenus(){this.allColumns.forEach((t=>t.closeMenu()))}sortColumn(t,e){if(!t)return;const o=this.findColumn(t);o&&(o.direction=e)}hideColumn(t){const e=this.findColumn(t);!1===e?.hidden&&(e.hidden=!0)}showColumn(t){const e=this.findColumn(t);e?.hidden&&(e.hidden=!1)}showAllColumns(){this.allColumns.forEach((t=>{t.hidden&&(t.hidden=!1)}))}findColumn(t){return this.allColumns.find((e=>e.fieldName===t))}refresh(){this.store&&(this.store.reset(),this.store.load())}toggleColumnVisibility(t){const e=this.findColumn(t);e&&(e.hidden=!e.hidden)}};t([n()],u.prototype,"actionColumn",null),t([n()],u.prototype,"allColumns",null),t([n()],u.prototype,"cellPartNameGenerator",void 0),t([n()],u.prototype,"columnMenuIsOpen",null),t([n()],u.prototype,"columnPerformanceModeEnabled",void 0),t([n()],u.prototype,"columnReorderingEnabled",void 0),t([n()],u.prototype,"columns",void 0),t([n()],u.prototype,"dataProvider",void 0),t([n()],u.prototype,"editing",null),t([n()],u.prototype,"editableColumns",null),t([n()],u.prototype,"effectiveSize",null),t([n()],u.prototype,"fieldColumns",null),t([n()],u.prototype,"filterBySelectionEnabled",null),t([n()],u.prototype,"groupColumns",null),t([n()],u.prototype,"highlightIds",null),t([n()],u.prototype,"maxSize",void 0),t([n()],u.prototype,"multipleSelectionEnabled",void 0),t([n()],u.prototype,"multiSortEnabled",void 0),t([n()],u.prototype,"objectIds",null),t([n()],u.prototype,"pageCount",null),t([n()],u.prototype,"pageIndex",null),t([n()],u.prototype,"pageSize",null),t([n()],u.prototype,"paginationEnabled",void 0),t([n()],u.prototype,"relationshipColumns",null),t([n()],u.prototype,"rowHighlightIds",null),t([n()],u.prototype,"rowDetailsRenderer",void 0),t([n({readOnly:!0})],u.prototype,"size",null),t([n()],u.prototype,"store",void 0),t([n({readOnly:!0})],u.prototype,"state",null),u=t([l("esri.widgets.FeatureTable.Grid.GridViewModel")],u);const p=u;export{p 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.32/esri/copyright.txt for details.
4
4
  */
5
- function t(t){return null!=t&&"object"==typeof t&&"type"in t&&null!==t.type&&("column"===t.type||"field"===t.type||"group"===t.type||"attachment"===t.type||"relationship"===t.type)}export{t as isTemplateObjectWithType};
5
+ function n(n){return null!=n&&"object"==typeof n&&"type"in n&&null!==n.type&&("column"===n.type||"field"===n.type||"group"===n.type||"attachment"===n.type||"relationship"===n.type)}function t(n){return!(!n||!("field"in n))}function e(n){return!(!n||!("columns"in n))}function i(n){return!(!n||!("relationshipId"in n))}function o(n){return!(!n||!("onShowAttachments"in n))}export{o as isAttachmentsColumn,t as isFieldColumn,e as isGroupColumn,i as isRelationshipColumn,n as isTemplateObjectWithType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{loadCalciteComponents as t}from"../../support/componentsUtils.js";const e={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"},n=()=>t({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-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")}),i=()=>Promise.all([t({input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),option:()=>import("@esri/calcite-components/dist/components/calcite-option.js"),select:()=>import("@esri/calcite-components/dist/components/calcite-select.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")}),n()]),o=()=>Promise.all([t({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js")}),i()]);function c(t){return t&&"selection"===t.type}function r(t){return null!=t&&"object"==typeof t&&"createQuery"in t&&"getField"in t&&"queryFeatureCount"in t&&"queryFeatures"in t&&"queryObjectIds"in t&&"capabilities"in t&&"fields"in t&&"fieldsIndex"in t&&"id"in t&&"load"in t&&"objectIdField"in t&&"type"in t&&"when"in t}function s(t){return r(t)&&"queryAttachments"in t}function a(t){return s(t)&&"addAttachment"in t&&"deleteAttachments"in t&&"updateAttachment"in t}function l(t){return r(t)&&"editingEnabled"in t&&"applyEdits"in t}function p(t){return r(t)&&"relationships"in t&&"queryRelatedFeatures"in t&&"queryRelatedFeaturesCount"in t}function u(t){return null!=t&&"object"==typeof t&&"type"in t&&"map-image"===t.type}function d(t,e,{relatedTableId:n}){if(!e?.map)return;const i="scene"===t.type&&t.associatedLayer?t.associatedLayer.url:t.url,o=e=>!(!p(e)||e===t)&&("sublayer"===e.type&&e.layer?.url===t.url?e.id===n:i===e.url&&e.layerId===n);if("sublayer"===t.type&&u(t.parent)){const e=e=>p(e)&&e!==t&&e.id===n,i=t.parent,o=i.sublayers?.find(e)||i.subtables?.find(e);if(p(o))return o}const c=[...e.map.allLayers,...e.map.allTables];let r=null;for(const s of c)if(u(s)){const t=s.sublayers?.find(o)||s.subtables?.find(o);if(t){r=t;break}}else if(o(s)){r=s;break}return p(r)?r:void 0}function m(t,e){return null!=t&&Number.isInteger(t)&&t>-1&&t<e}function f(t){return null==t||0===t.trim().length}function y(t,e){return(t.relationships??[]).filter((t=>!(t.id===e&&"one-to-one"===t.cardinality))).map((({id:t})=>({relationshipId:t})))}function b(t,e){return t.relationships?.find((({id:t})=>t===e))}export{d as findRelatedLayer,b as findRelationship,y as getRelationshipIdsToShow,f as isEmptyStringOrWhitespace,r as isIFeatureTableSupportedLayer,s as isIFeatureTableSupportedLayerWithAttachments,a as isIFeatureTableSupportedLayerWithAttachmentsEditing,l as isIFeatureTableSupportedLayerWithEditing,p as isIFeatureTableSupportedLayerWithRelationships,u as isMapImageLayer,m as isPageIndexValid,c as isSelectionFilter,n as loadColumnComponents,i as loadEditorColumnComponents,o as loadFieldColumnComponents,e as uniqueColumnNames};
5
+ import{loadCalciteComponents as t}from"../../support/componentsUtils.js";const e={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"},n=()=>t({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-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item.js"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")}),i=()=>Promise.all([t({input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),option:()=>import("@esri/calcite-components/dist/components/calcite-option.js"),select:()=>import("@esri/calcite-components/dist/components/calcite-select.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")}),n()]),o=()=>Promise.all([t({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js")}),i()]);function c(t){return t&&"selection"===t.type}function r(t){return null!=t&&"object"==typeof t&&"createQuery"in t&&"getField"in t&&"queryFeatureCount"in t&&"queryFeatures"in t&&"queryObjectIds"in t&&"capabilities"in t&&"fields"in t&&"fieldsIndex"in t&&"id"in t&&"load"in t&&"objectIdField"in t&&"type"in t&&"when"in t}function s(t){return r(t)&&"queryAttachments"in t}function a(t){return s(t)&&"addAttachment"in t&&"deleteAttachments"in t&&"updateAttachment"in t}function l(t){return r(t)&&"editingEnabled"in t&&"applyEdits"in t}function p(t){return r(t)&&"relationships"in t&&"queryRelatedFeatures"in t&&"queryRelatedFeaturesCount"in t}function u(t){return null!=t&&"object"==typeof t&&"type"in t&&"map-image"===t.type}function m(t,e,{relatedTableId:n}){if(!e?.map)return;const i="scene"===t.type&&t.associatedLayer?t.associatedLayer.url:t.url,o=e=>!(!p(e)||e===t)&&("sublayer"===e.type&&e.layer?.url===t.url?e.id===n:i===e.url&&e.layerId===n);if("sublayer"===t.type&&u(t.parent)){const e=e=>p(e)&&e!==t&&e.id===n,i=t.parent,o=i.sublayers?.find(e)||i.subtables?.find(e);if(p(o))return o}const c=[...e.map.allLayers,...e.map.allTables];let r=null;for(const s of c)if(u(s)){const t=s.sublayers?.find(o)||s.subtables?.find(o);if(t){r=t;break}}else if(o(s)){r=s;break}return p(r)?r:void 0}function d(t,e){return null!=t&&Number.isInteger(t)&&t>-1&&t<e}function f(t){return null==t||0===t.trim().length}function y(t,e){return(t.relationships??[]).filter((t=>!(t.id===e&&"one-to-one"===t.cardinality))).map((({id:t})=>({relationshipId:t})))}function b(t,e){return t.relationships?.find((({id:t})=>t===e))}function j(t,e){return e.some((e=>!("group"!==e.type||!j(t,e.columnTemplates))||e.fieldName===t))}export{m as findRelatedLayer,b as findRelationship,y as getRelationshipIdsToShow,j as hasTemplateForField,f as isEmptyStringOrWhitespace,r as isIFeatureTableSupportedLayer,s as isIFeatureTableSupportedLayerWithAttachments,a as isIFeatureTableSupportedLayerWithAttachmentsEditing,l as isIFeatureTableSupportedLayerWithEditing,p as isIFeatureTableSupportedLayerWithRelationships,u as isMapImageLayer,d as isPageIndexValid,c as isSelectionFilter,n as loadColumnComponents,i as loadEditorColumnComponents,o as loadFieldColumnComponents,e as uniqueColumnNames};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
+ */
5
+ import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../tables/elements/AttributeTableAttachmentElement.js";import i from"../../../tables/elements/AttributeTableFieldElement.js";import n from"../../../tables/elements/AttributeTableGroupElement.js";import r from"../../../tables/elements/AttributeTableRelationshipElement.js";import l from"./AttachmentsColumnTemplate.js";import{isGroupColumn as o,isFieldColumn as s,isRelationshipColumn as m,isAttachmentsColumn as a}from"./columnUtils.js";import p from"./FieldColumnTemplate.js";import f from"./GroupColumnTemplate.js";import c from"./RelationshipColumnTemplate.js";function d(t,i){const n=[];return t?.forEach((t=>{const{description:r,label:l,type:o}=t;if("group"===o){const o=t.elements.map((e=>u(e,i))).filter(e);if(!o?.length)return;n.push(new f({description:r,columnTemplates:o,label:l}))}else{const e=u(t,i);if(!e)return;n.push(e)}})),n}function u(e,t){const{description:i,label:n,type:r}=e;if("field"===r){const r=e.fieldName??void 0,l=t.findIndex((e=>e.field&&e.field===r)),o=l>-1?t.at(l)?.order:void 0;return new p({description:i,direction:o,fieldName:r,initialSortPriority:l,label:n})}return"attachment"===r?new l({description:i,label:n}):"relationship"===r?new c({description:i,label:n,relationshipId:e.relationshipId}):void 0}function b(t){const i=[];return t.forEach((t=>{const{description:r,label:l,hidden:s}=t;if(o(t)){if(s)return;const o=t.columns?.map((e=>h(e))).filter(e);if(!o?.length)return;i.push(new n({description:r,elements:o,label:l}))}else{const e=h(t);if(!e)return;i.push(e)}})),i}function h(e){const{fieldName:n,description:l,hidden:o,label:p}=e;if(s(e)){if(!o)return new i({description:l,fieldName:n,label:p})}else if(m(e)){if(!o)return new r({description:l,label:p,relationshipId:e.relationshipId})}else if(a(e)&&!o)return new t({description:l,label:p})}export{b as createAttributeTableElements,d as createColumnTemplates,h as createNestedElement,u as createNestedTemplate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/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"../../symbols.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedProperty as s}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as c}from"../../core/JSONSupport.js";import{equalsShallow as u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as C}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as j}from"../../core/support/UpdatingHandles.js";import{intersect as A}from"../../geometry/geometryEngine.js";import{union as M}from"../../geometry/geometryEngineAsync.js";import{projectWithZConversion as O}from"../../geometry/projection.js";import{isClockwise as k}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as R}from"../../geometry/support/webMercatorUtils.js";import B from"../../layers/GraphicsLayer.js";import{searchImages as L}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as G}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as x,computePolygonForInspection as E,resizePolygon as H,checkIfPolygonContainsSelectedPoint as T}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as D,isElevationSource as z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as U,imageToWorldPanoramic as N}from"../../layers/orientedImagery/transformations/imageToWorld.js";import W from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as $,convertPixelToHeadingPitch as J,pointToArray as K,getUpdateElevationProps as Q,isElevationSampler as X,getImageToWorldProperties as Y,getImageToWorldPanoramicProperties as Z,getWorldToImageProperties as ee,convertHeadingPitchToSphereVertex as te}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as re,worldToImage as ie}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ae}from"../../layers/support/floorFilterUtils.js";import oe from"../../rest/support/AttachmentQuery.js";import{scale as se}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ne}from"../../views/input/InputManager.js";import le from"../PanoramicViewer.js";import{invalidCameraHeading as ce,sectorsInOrder as ue,sectorsRadii as he}from"./constants.js";import{crossSymbol as pe,crossSymbol3D as me,sourcePointSymbol as de,diamondSymbol as ge,diamondSymbol3D as ye,activeSourcePointSymbol as fe}from"./symbols.js";import{isNoAttachmentError as ve,getContentType as we,isTifOrMrf as be,filterOILLayerView as Fe,isSceneView as _e,isGraphic as Pe,calculateSegment as Ie,calculateDirection as Ce}from"./utils.js";import Se from"./components/ImageViewer.js";import Ve from"../../geometry/Point.js";import je from"../../geometry/SpatialReference.js";import Ae from"../../symbols/SimpleLineSymbol.js";import Me from"../../geometry/Multipoint.js";import Oe from"../../geometry/Polyline.js";import ke from"../../geometry/Polygon.js";const Re={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},Be=new Set(["JPG","JPEG"]),Le=/\.(\w+)$/,Ge=e=>"FA"===e;let xe=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new o,this.additionalCameraLocations=new o,this.additionalFootprints=new o,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,r)=>{const{currentBestFeature:i,selectedPoint:a,view:o}=this;if(o?.closePopup(),i&&a){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(r),await this._loadImage(r)}catch(s){y(s)||(this.loadImageError(s),h.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new o,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.overlayedCameraLocations=new o,this.overlayedMapFeatures=new w,this.pointSources=new o,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._highlightedFeatureHandle=null,this._imageViewer=new Se,this._initialCurrentCoverageUpdate=!0,this._overlays=new B({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new le,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new j,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=()=>{m(this._openPopupTask),this._openPopupTask=a((async e=>{const{currentBestFeature:r,popupEnabled:i,layer:a,view:o}=this;if(o?.closePopup(),!(o&&r&&i&&a))return;const{attributes:s,geometry:n}=r,l=new t({geometry:n,attributes:s.toJSON(),layer:a});f(e),await o.openPopup({features:[l],location:s.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(Re.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,ne.WIDGET),Re.click)},this._createImageClickHandle=()=>{this.removeHandles(Re.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:r,currentBestFeature:i,footprintExtent:o}=this,s=r?.imageSize;if(!(e&&"none"!==t&&s&&o&&i))return;r.clickAction="pixel-location";let n=null;const l=b((()=>r),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=a((async r=>{if(!e)return;const a=await this.getMapPoint(e,{feature:i,imageSize:s,mode:t});f(r),this.plotReferencePointOnGround(a)}))}));this.addHandles(l,Re.imageClick)},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new oe({objectIds:[t]}),a=await e.queryAttachments(i,r),o=a[`${t}`]?.[0],s=o?.url;if(!s)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:o.contentType.split("/")[1].toUpperCase(),url:s}},this._loadAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");f(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:a}=t,{imagePath:o,imageRotation:s,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:u,cameraOrientation:p,location:m}=a,d=(l??0)+(s??0),g=m.spatialReference.isWGS84&&4!==p?.type?R(m):new Ve(m);let v=o;if(Ge(o))try{v=await this._getImageSourceFromAttachment(r,u,e)}catch(w){if(y(w))return;return ve(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[r.objectIdField]:u,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${u}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:r,imageRotation:i,options:a}=t,o="string"==typeof e,s=o?e:e.url,{origin:n,pathname:l,searchParams:c}=new URL(s);let u=o?l.match(Le)?.[1]??"":e.datasetFormat;if(!u){const e=await we(s,{...t.options});e&&(u=e.split("/")[1]),u??="UNKNOWN FORMAT"}switch(r){case"default":this._imageViewer.imageSource={datasetFormat:u.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(c),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(a);break;case"panoramic":if(Be.has(u.toUpperCase())){const{selectedPoint:e}=this,{pitch:r,yaw:i,cameraLocation:o,viewAngle:n}=t;this._panoramicViewer.imageSource=s;let l=i??0;"number"==typeof n?l=n-l:o&&e&&(l=await $(o,e)-l),this._panoramicViewer.pitch=r??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(a)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:u});break}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a((async t=>{const{pointerType:r,button:i,mapPoint:a}=e;if(("mouse"!==r||0===i)&&a)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,r)=>{if(await v(r),!e)return;const i=new Ve({...c(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:pe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,a]=r,{heading:o,pitch:s}=J(e,i,a),n=te(o,s);this._crossSymbol=new t({geometry:new Ve(n,je.WebMercator),symbol:me}),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.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)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a((async r=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:r}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(Re.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,u)}),Re.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:r,vfov:i,hfov:a,pitch:o,yaw:s}=this._panoramicViewer;return e&&r&&"image-loading"!==t?[i,a,s,o]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,r,i,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:r,yaw:i,pitch:o},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,u)}),Re.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:a}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=a)}),_)])}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return s(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(h.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 be(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return s(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ce}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Fe(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ae(e):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?ue.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";if("error"===this.displayMessage?.type)return"image-load-error";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 o(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const a=e.trim();return be(a)?{url:a,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=[],a=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:s}=e;let n;const l=C(e.geometry.spatialReference);s.cameraHeight/=l,s.farDistance/=l,s.nearDistance/=l,D(s.elevationSource)&&(s.elevationSource.constantElevation/=l);const{polygon:c,frustum:u}=x(s);if(n=c.clone(),s.isInspection&&(n=E(s)),o&&(n=H(n,o)),T(n,t)){a.push(e);const{geometry:t,objectId:o,cameraHeight:n,cameraHeading:l}=s,h=t.clone();h.z=n,h.imageID=o,this.pointSources.push(h),l!==ce&&(r.push(c),u&&i.push(u))}})),{features:a,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ue[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(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?R(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async overlayCameraLocations(e){const{activeViewer:r,currentBestFeature:i,overlayedCameraLocations:a,layer:o,mode:s,state:n}=this,l=r?.imageSize;if(!l||!i||!o||"none"===s||n.includes("loading"))return;const{polygon:c}=x(i.attributes);if(r.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await o.queryFeatures({where:`${o.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[o.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:r,geometry:a}=e,o=await this.getPixels(a,{feature:i,imageSize:l,mode:s}),n=de.clone();return n.outline=new Ae({color:[0,0,0],width:1}),new t({attributes:r,symbol:n,geometry:o})})));a.addMany(n),r.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e){const{activeViewer:i,currentBestFeature:a,mode:s,state:n}=this,l=i?.imageSize;if(!l||!a||"none"===s||n.includes("loading"))return;const{polygon:c}=x(a.attributes),{features:u}=await e.queryFeatures({geometry:c,returnGeometry:!0,outFields:[e.objectIdField]}),h=new o((await Promise.all(u.map((async r=>{const{attributes:i,geometry:o}=r;if(!o||"mesh"===o.type)return null;const n=A(c,o);if(!n)return null;const u=r.symbol?.clone()??e.renderer?.getSymbol(r).clone();switch(n?.type){case"point":{const r=await this.getPixels(n,{feature:a,imageSize:l,mode:s});return new t({attributes:i,layer:e,symbol:u,geometry:r,visible:e.visible})}case"polygon":{const{rings:r,spatialReference:o}=n,c=r.map((e=>e.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))))),h=await Promise.all(c.map((async e=>this.getPixels(e,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K))))));return new t({attributes:i,layer:e,symbol:u,geometry:new ke({rings:h,spatialReference:je.WebMercator}),visible:e.visible})}case"polyline":{const{paths:r,spatialReference:o}=n,c=r.map((e=>e.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))))),h=await Promise.all(c.map((async e=>this.getPixels(e,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K))))));return new t({attributes:i,layer:e,symbol:u,geometry:new Oe({paths:h,spatialReference:je.WebMercator}),visible:e.visible})}case"multipoint":{const{points:r,spatialReference:o}=n,c=r.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))),h=await this.getPixels(c,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K)));return new t({attributes:i,layer:e,symbol:u,geometry:new Me({points:h,spatialReference:je.WebMercator}),visible:e.visible})}}return null})))).filter(r));this.overlayGraphicsOnImage(`${e.id}`,h)}async getPixels(e,t){const{imageSize:r,mode:i}=t,a=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new Ve({x:e.x-.5,y:.5-e.y,spatialReference:je.WebMercator});const[t,a]=r,{heading:o,pitch:s}=J(e,t,a),n=te(o,s);return new Ve(n,je.WebMercator)}));return Array.isArray(e)?a:a[0]}async getMapPoint(e,t){const{feature:r,mode:i,imageSize:a}=t,{elevationSample:o,attributes:s}=r,{elevationSource:n,location:l,cameraHeight:c}=s;let u=l.clone();u.spatialReference.isGeographic&&(u=await O(u,je.WebMercator));const h=await Q((u.z??0)-c,{elevationSample:o,elevationSource:n,extent:this.footprintExtent});let p;if("elevationSample"in h&&X(h.elevationSample)&&(r.elevationSample=h.elevationSample),"default"===i){const t=Y(s,a[0],a[1]);p=await U(Array.isArray(e)?e:[e],{...t,cameraLocation:u},h)}else{const t=Z(s,a[0],a[1]);p=await N(Array.isArray(e)?e:[e],{...t,cameraLocation:u},h)}return Array.isArray(e)?p:p[0]}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 Ve({...e.toJSON()}),symbol:ge}),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=c(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:new Ve({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...r}),symbol:ge}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,a]=r,{heading:o,pitch:s}=J(e,i,a),n=te(o,s);this._referencePointOnImage=new t({geometry:new Ve(n,je.WebMercator),symbol:ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}async searchBestImage(e,t){try{const r=await L(e,t);r&&await this._processFeatureResponse(r,e.point,{signal:t?.signal})}catch(r){y(r)||(this.setMessage("imageLoadError","error",r.message),h.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}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const r=this.overlayedMapFeatures.get(e);r&&this._toggleVisiblity(r,t)}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e;let i=!1,a=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=t.spatialReference.equals(o.spatialReference)?t:await O(t,o.spatialReference);i=o.contains(e);break}case"mesh":{const e=t.spatialReference.equals(o.spatialReference)?t:await O(t,o.spatialReference);a=o.extent.contains(e);break}}if(!i&&!a)return;const s=await this.worldToImage(t,r);return s?(f(r),this.plotReferencePointOnImage(s),{x:s.x,y:s.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},a=this.view.toScreen(e);if(!a)return;const o=await this.view.hitTest(a,i);return this._processHitTestResults(r,o,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(r){if(y(r))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i,invalidCameraHeading:a}=this;if(!e||!t||!r||!i||a)return void(this._sectorData=null);this._sectorData={};for(const c of ue)this._sectorData[c]=new o;const s=e.map(((e,t)=>({...e,featureIndex:t})));s.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=s.map((({distance:e})=>e)),l=Math.max(...n);s.forEach((e=>{const{distance:t,angle:r,featureIndex:a}=e,o=t/l*he[2],s=Ie(t,l),n=Ce(r);if(!this._sectorData)return;const c=he[3]+o*Math.sin(r*Math.PI/180),u=he[3]+o*Math.cos(r*Math.PI/180);let h;const p=i.at(a),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)h=-90;else{const e=c-he[3],t=u-he[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),h=i}const g=""===s?n:`${s}_${n}`;m&&(h===this.bestFeatureAngle?this.previousFeatureAngle=h:this.bestFeatureAngle=h,this.navigatorCurrentBestFeature=d?null:{x:c,y:u,direction:n});const y=this._sectorData[g];y.add({angle:r,featureIndex:a,x:c,y:u,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:a,polygons:o,frustums:s}=this.filterByFootprints(i,t);if(!a.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(o),this.coverageFrustums.addMany(s),o[0]){let e=new ke({spatialReference:o[0].spatialReference});for(const r of o)e=await M(e,r);const t=[];for(const{geometry:r}of a)e.contains(r)||t.push([r.x,r.y]);if(t.sort(((e,t)=>+k([e,t]))),e.addRing(t),this.footprintExtent=se(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,r)}catch(l){y(l)||h.getLogger(this).error(l)}}if((n||a[0].attributes.elevationSource)&&this.footprintExtent){const e=a[0].attributes.elevationSource;z(e)&&!n&&(n=await q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const r=await Q((a[0].attributes.location.z??0)-a[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...o]=await W([t,...a.map((e=>e.attributes.geometry.clone()))],r);a[0].elevationSample=n??r.elevationSample,t.elevation=i.z,a.forEach(((e,t)=>{e.attributes.elevation=o[t].z}))}a[0].elevationSample&&a.forEach((e=>{e.elevationSample=a[0].elevationSample})),this._suitabilities=G({features:a,selectedPoint:t,camera:_e(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[a]}=t,o="graphic"===a?.type&&this.shouldShowSelectedImage,s=a?.mapPoint??this.view?.toMap(i);if(!s)return;const{layerFloorFilterClause:n}=this,l=I("1=1",I(e.definitionExpression,n)),c=s.spatialReference.isGeographic?1:C(s.spatialReference),u={layerInstanceOrURL:e,point:s,queryParams:{where:l,maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,objectIds:o?[a.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,r)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_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:a,isAdditionalPointSourcesVisible:o}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of r)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:fe,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:de,visible:o}))}}_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-he[3],i=e.y-he[3],a=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(a)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),r=o}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,invalidCameraHeading:r,selectedPoint:i,state:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!i||!t||"image-loaded"!==a||r)return;let o;try{o=await this.worldToImage(i,e),f(e),await this.plotSelectedPointOnImage(o,e)}catch(s){y(s)||h.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 worldToImage(e,t){const{footprintExtent:r}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!r)return;const{attributes:{location:a,elevationSource:o,cameraHeight:s,cameraHeading:n},elevationSample:l}=this.currentBestFeature;let c=a.clone();const u=await Q((a.z??0)-s,{elevationSample:l,elevationSource:o});this.currentBestFeature.elevationSample=u.elevationSample;let h,p=await W(Array.isArray(e)?e:[e],u);if(a.spatialReference.isGeographic&&(c=await O(c,je.WebMercator,t)),p=await Promise.all(p.map((async e=>c.spatialReference.equals(e.spatialReference)?e:await O(e,c.spatialReference,t)))),f(t),"panoramic"===this.mode)h=re(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:n,cameraLocation:c});else{const e=ee(this.currentBestFeature.attributes,i[0],i[1]);h=ie(p,{...e,cameraLocation:c})}return Array.isArray(e)?h:h[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:r,additionalCameraLocations:i,currentBestFeature:a,currentBestFeatureLocation:o,currentCoverageVisible:s,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=s,"panoramic"!==this.mode&&(this.bestFeatureFootprint=e),this.bestFeatureCurrentFootprint=e),l){const e=[...r,...i,this.bestFeatureCurrentFootprint,o].filter(Pe);l.supportsGround&&h&&c?.updateGroundElevation&&c.updateGroundElevation(e,h),n&&e.push(new t({geometry:n.clone(),symbol:pe.clone(),attributes:{imageID:u}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&h&&c?.updateGroundElevation&&c.updateGroundElevation([e],h),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],xe.prototype,"activeLayer",null),e([S({readOnly:!0})],xe.prototype,"activeViewer",null),e([S()],xe.prototype,"additionalFeatures",void 0),e([S({type:o.ofType(t)})],xe.prototype,"additionalCameraLocations",void 0),e([S({type:o.ofType(t)})],xe.prototype,"additionalFootprints",void 0),e([S()],xe.prototype,"bestFeatureAngle",void 0),e([S()],xe.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],xe.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],xe.prototype,"brightness",null),e([S({type:Number})],xe.prototype,"contrast",null),e([S()],xe.prototype,"coverageFrustums",void 0),e([S()],xe.prototype,"coveragePolygons",void 0),e([S()],xe.prototype,"currentBestFeature",void 0),e([S()],xe.prototype,"currentBestFeatureLocation",void 0),e([S()],xe.prototype,"currentCoverageVisible",void 0),e([S({json:{write:!1}})],xe.prototype,"determineWorkflowForFeature",void 0),e([S()],xe.prototype,"disabled",void 0),e([S()],xe.prototype,"displayMessage",void 0),e([S()],xe.prototype,"drawFootprint",void 0),e([S({readOnly:!0})],xe.prototype,"featureCount",null),e([S()],xe.prototype,"features",void 0),e([S({readOnly:!0})],xe.prototype,"imageGalleryEnabled",null),e([S({readOnly:!0})],xe.prototype,"imageLoaded",null),e([S({readOnly:!0})],xe.prototype,"invalidCameraHeading",null),e([S()],xe.prototype,"imagePointsInView",null),e([S()],xe.prototype,"isAdditionalCoverageVisible",void 0),e([S()],xe.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],xe.prototype,"layer",void 0),e([S()],xe.prototype,"layerView",null),e([S({readOnly:!0})],xe.prototype,"layerFloorFilterClause",null),e([S({type:Number})],xe.prototype,"localPort",void 0),e([S()],xe.prototype,"mapImageConversionToolState",void 0),e([S({readOnly:!0,value:"none"})],xe.prototype,"mode",null),e([S()],xe.prototype,"navigatorCurrentBestFeature",void 0),e([S({type:o.ofType(t)})],xe.prototype,"overlayedCameraLocations",void 0),e([S()],xe.prototype,"overlayedMapFeatures",void 0),e([S()],xe.prototype,"pointSources",void 0),e([S({readOnly:!0})],xe.prototype,"popupEnabled",null),e([S()],xe.prototype,"previousFeatureAngle",void 0),e([S()],xe.prototype,"referencePoint",null),e([S({readOnly:!0})],xe.prototype,"sectorData",null),e([S()],xe.prototype,"selectedPoint",void 0),e([S({type:Number})],xe.prototype,"sharpness",null),e([S()],xe.prototype,"shouldShowSelectedImage",void 0),e([S({readOnly:!0})],xe.prototype,"state",null),e([S({readOnly:!0})],xe.prototype,"thumbnails",null),e([S()],xe.prototype,"updateFootprint",void 0),e([S()],xe.prototype,"updateFootprintPanorama",void 0),e([S({value:null})],xe.prototype,"view",null),e([S()],xe.prototype,"_adapter",void 0),e([S()],xe.prototype,"_highlightedFeatureHandle",void 0),e([S()],xe.prototype,"_imageViewer",void 0),e([S()],xe.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],xe.prototype,"_overlays",void 0),e([S({readOnly:!0})],xe.prototype,"_overlaysView",null),e([S()],xe.prototype,"_panoramicViewer",void 0),e([S()],xe.prototype,"_referencePointOnGround",void 0),e([S()],xe.prototype,"_referencePointOnImage",void 0),e([S()],xe.prototype,"_sectorData",void 0),e([S({readOnly:!0})],xe.prototype,"_updatingHandles",void 0),e([S()],xe.prototype,"footprintExtent",void 0),xe=e([V("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],xe);const Ee=xe;export{Ee as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import"../../symbols.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedProperty as s}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as c}from"../../core/JSONSupport.js";import{equalsShallow as u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as C}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as j}from"../../core/support/UpdatingHandles.js";import{intersect as A}from"../../geometry/geometryEngine.js";import{union as O}from"../../geometry/geometryEngineAsync.js";import{projectWithZConversion as M}from"../../geometry/projection.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as k}from"../../geometry/support/webMercatorUtils.js";import B from"../../layers/GraphicsLayer.js";import{searchImages as L}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as G}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as x,computePolygonForInspection as E,resizePolygon as H,checkIfPolygonContainsSelectedPoint as T}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as D,isElevationSource as z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as U,imageToWorldPanoramic as N}from"../../layers/orientedImagery/transformations/imageToWorld.js";import W from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as $,convertPixelToHeadingPitch as J,pointToArray as K,getUpdateElevationProps as Q,isElevationSampler as X,getImageToWorldProperties as Y,getImageToWorldPanoramicProperties as Z,getWorldToImageProperties as ee,convertHeadingPitchToSphereVertex as te}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as re,worldToImage as ie}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ae}from"../../layers/support/floorFilterUtils.js";import oe from"../../rest/support/AttachmentQuery.js";import{scale as se}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ne}from"../../views/input/InputManager.js";import le from"../PanoramicViewer.js";import{invalidCameraHeading as ce,sectorsInOrder as ue,sectorsRadii as he}from"./constants.js";import{crossSymbol as pe,crossSymbol3D as me,sourcePointSymbol as de,diamondSymbol as ge,diamondSymbol3D as ye,activeSourcePointSymbol as fe}from"./symbols.js";import{isNoAttachmentError as ve,getContentType as we,isTifOrMrf as be,filterOILLayerView as Fe,isSceneView as _e,isGraphic as Pe,calculateSegment as Ie,calculateDirection as Ce}from"./utils.js";import Se from"./components/ImageViewer.js";import Ve from"../../geometry/Point.js";import je from"../../geometry/SpatialReference.js";import Ae from"../../symbols/SimpleLineSymbol.js";import Oe from"../../geometry/Multipoint.js";import Me from"../../geometry/Polyline.js";import Re from"../../geometry/Polygon.js";const ke={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},Be=new Set(["JPG","JPEG"]),Le=/\.(\w+)$/,Ge=e=>"FA"===e;let xe=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new o,this.additionalCameraLocations=new o,this.additionalFootprints=new o,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,r)=>{const{currentBestFeature:i,selectedPoint:a,view:o}=this;if(o?.closePopup(),i&&a){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons(r),await this._loadImage(r)}catch(s){y(s)||(this.loadImageError(s),h.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new o,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.overlayedCameraLocations=new o,this.overlayedMapFeatures=new w,this.pointSources=new o,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._highlightedFeatureHandle=null,this._imageViewer=new Se,this._initialCurrentCoverageUpdate=!0,this._overlays=new B({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new le,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new j,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=()=>{m(this._openPopupTask),this._openPopupTask=a((async e=>{const{currentBestFeature:r,popupEnabled:i,layer:a,view:o}=this;if(o?.closePopup(),!(o&&r&&i&&a))return;const{attributes:s,geometry:n}=r,l=new t({geometry:n,attributes:s.toJSON(),layer:a});f(e),await o.openPopup({features:[l],location:s.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ke.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,ne.WIDGET),ke.click)},this._createImageClickHandle=()=>{this.removeHandles(ke.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:r,currentBestFeature:i,footprintExtent:o}=this,s=r?.imageSize;if(!(e&&"none"!==t&&s&&o&&i))return;r.clickAction="pixel-location";let n=null;const l=b((()=>r),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=a((async r=>{if(!e)return;const a=await this.getMapPoint(e,{feature:i,imageSize:s,mode:t});f(r),this.plotReferencePointOnGround(a)}))}));this.addHandles(l,ke.imageClick)},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new oe({objectIds:[t]}),a=await e.queryAttachments(i,r),o=a[`${t}`]?.[0],s=o?.url;if(!s)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:o.contentType.split("/")[1].toUpperCase(),url:s}},this._loadAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");f(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:a}=t,{imagePath:o,imageRotation:s,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:u,cameraOrientation:p,location:m}=a,d=(l??0)+(s??0),g=m.spatialReference.isWGS84&&4!==p?.type?k(m):new Ve(m);let v=o;if(Ge(o))try{v=await this._getImageSourceFromAttachment(r,u,e)}catch(w){if(y(w))return;return ve(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[r.objectIdField]:u,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${u}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:r,imageRotation:i,options:a}=t,o="string"==typeof e,s=o?e:e.url,{origin:n,pathname:l,searchParams:c}=new URL(s);let u=o?l.match(Le)?.[1]??"":e.datasetFormat;if(!u){const e=await we(s,{...t.options});e&&(u=e.split("/")[1]),u??="UNKNOWN FORMAT"}switch(r){case"default":this._imageViewer.imageSource={datasetFormat:u.toUpperCase(),url:`${n}${l}`},this._imageViewer.customParameters=Object.fromEntries(c),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(a);break;case"panoramic":if(Be.has(u.toUpperCase())){const{selectedPoint:e}=this,{pitch:r,yaw:i,cameraLocation:o,viewAngle:n}=t;this._panoramicViewer.imageSource=s;let l=i??0;"number"==typeof n?l=n-l:o&&e&&(l=await $(o,e)-l),this._panoramicViewer.pitch=r??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(a)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:u});break}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a((async t=>{const{pointerType:r,button:i,mapPoint:a}=e;if(("mouse"!==r||0===i)&&a)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,r)=>{if(await v(r),!e)return;const i=new Ve({...c(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:pe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,a]=r,{heading:o,pitch:s}=J(e,i,a),n=te(o,s);this._crossSymbol=new t({geometry:new Ve(n,je.WebMercator),symbol:me}),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.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)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a((async r=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:r}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ke.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,u)}),ke.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:r,vfov:i,hfov:a,pitch:o,yaw:s}=this._panoramicViewer;return e&&r&&"image-loading"!==t?[i,a,s,o]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,r,i,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:r,yaw:i,pitch:o},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,u)}),ke.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:a}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=a)}),_)])}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return s(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(h.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 be(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return s(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ce}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Fe(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ae(e):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?ue.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";if("error"===this.displayMessage?.type)return"image-load-error";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 o(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const a=e.trim();return be(a)?{url:a,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=[],a=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:s}=e;let n;const l=C(e.geometry.spatialReference);s.cameraHeight/=l,s.farDistance/=l,s.nearDistance/=l,D(s.elevationSource)&&(s.elevationSource.constantElevation/=l);const{polygon:c,frustum:u}=x(s);if(n=c.clone(),s.isInspection&&(n=E(s)),o&&(n=H(n,o)),T(n,t)){a.push(e);const{geometry:t,objectId:o,cameraHeight:n,cameraHeading:l}=s,h=t.clone();h.z=n,h.imageID=o,this.pointSources.push(h),l!==ce&&(r.push(c),u&&i.push(u))}})),{features:a,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ue[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(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?k(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async overlayCameraLocations(e){const{activeViewer:r,currentBestFeature:i,overlayedCameraLocations:a,layer:o,mode:s,state:n}=this,l=r?.imageSize;if(!l||!i||!o||"none"===s||n.includes("loading"))return;const{polygon:c}=x(i.attributes);if(r.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await o.queryFeatures({where:`${o.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[o.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:r,geometry:a}=e,o=await this.getPixels(a,{feature:i,imageSize:l,mode:s}),n=de.clone();return n.outline=new Ae({color:[0,0,0],width:1}),new t({attributes:r,symbol:n,geometry:o})})));a.addMany(n),r.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e){const{activeViewer:i,currentBestFeature:a,mode:s,state:n}=this,l=i?.imageSize;if(!l||!a||"none"===s||n.includes("loading"))return;const{polygon:c}=x(a.attributes),{features:u}=await e.queryFeatures({geometry:c,returnGeometry:!0,outFields:[e.objectIdField]}),h=new o((await Promise.all(u.map((async r=>{const{attributes:i,geometry:o}=r;if(!o||"mesh"===o.type)return null;const n=A(c,o);if(!n)return null;const u=r.symbol?.clone()??e.renderer?.getSymbol(r).clone();switch(n?.type){case"point":{const r=await this.getPixels(n,{feature:a,imageSize:l,mode:s});return new t({attributes:i,layer:e,symbol:u,geometry:r,visible:e.visible})}case"polygon":{const{rings:r,spatialReference:o}=n,c=r.map((e=>e.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))))),h=await Promise.all(c.map((async e=>this.getPixels(e,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K))))));return new t({attributes:i,layer:e,symbol:u,geometry:new Re({rings:h,spatialReference:je.WebMercator}),visible:e.visible})}case"polyline":{const{paths:r,spatialReference:o}=n,c=r.map((e=>e.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))))),h=await Promise.all(c.map((async e=>this.getPixels(e,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K))))));return new t({attributes:i,layer:e,symbol:u,geometry:new Me({paths:h,spatialReference:je.WebMercator}),visible:e.visible})}case"multipoint":{const{points:r,spatialReference:o}=n,c=r.map((([e,t,r])=>new Ve({x:e,y:t,z:r,spatialReference:o}))),h=await this.getPixels(c,{feature:a,imageSize:l,mode:s}).then((e=>e.map(K)));return new t({attributes:i,layer:e,symbol:u,geometry:new Oe({points:h,spatialReference:je.WebMercator}),visible:e.visible})}}return null})))).filter(r));this.overlayGraphicsOnImage(`${e.id}`,h)}async getPixels(e,t){const{imageSize:r,mode:i}=t,a=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new Ve({x:e.x-.5,y:.5-e.y,spatialReference:je.WebMercator});const[t,a]=r,{heading:o,pitch:s}=J(e,t,a),n=te(o,s);return new Ve(n,je.WebMercator)}));return Array.isArray(e)?a:a[0]}async getMapPoint(e,t){const{feature:r,mode:i,imageSize:a}=t,{elevationSample:o,attributes:s}=r,{elevationSource:n,location:l,cameraHeight:c}=s;let u=l.clone();u.spatialReference.isGeographic&&(u=await M(u,je.WebMercator));const h=await Q((u.z??0)-c,{elevationSample:o,elevationSource:n,extent:this.footprintExtent});let p;if("elevationSample"in h&&X(h.elevationSample)&&(r.elevationSample=h.elevationSample),"default"===i){const t=Y(s,a[0],a[1]);p=await U(Array.isArray(e)?e:[e],{...t,cameraLocation:u},h)}else{const t=Z(s,a[0],a[1]);p=await N(Array.isArray(e)?e:[e],{...t,cameraLocation:u},h)}return Array.isArray(e)?p:p[0]}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 Ve({...e.toJSON()}),symbol:ge}),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.clearReferencePointOnImage(),this.mode){case"default":{const r=c(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:new Ve({spatialReference:this._imageViewer.imageRenderer.spatialReference.clone(),...r}),symbol:ge}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,a]=r,{heading:o,pitch:s}=J(e,i,a),n=te(o,s);this._referencePointOnImage=new t({geometry:new Ve(n,je.WebMercator),symbol:ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}async searchBestImage(e,t){try{const r=await L(e,t);r&&await this._processFeatureResponse(r,e.point,{signal:t?.signal})}catch(r){y(r)||(this.setMessage("imageLoadError","error",r.message),h.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}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const r=this.overlayedMapFeatures.get(e);r&&this._toggleVisiblity(r,t)}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e;let i=!1,a=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=t.spatialReference.equals(o.spatialReference)?t:await M(t,o.spatialReference);i=o.contains(e);break}case"mesh":{const e=t.spatialReference.equals(o.spatialReference)?t:await M(t,o.spatialReference);a=o.extent.contains(e);break}}if(!i&&!a)return void this.clearReferencePointOnImage();const s=await this.worldToImage(t,r);if(s)return f(r),this.plotReferencePointOnImage(s),{x:s.x,y:s.y};this.clearReferencePointOnImage()}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},a=this.view.toScreen(e);if(!a)return;const o=await this.view.hitTest(a,i);return this._processHitTestResults(r,o,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(r){if(y(r))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i,invalidCameraHeading:a}=this;if(!e||!t||!r||!i||a)return void(this._sectorData=null);this._sectorData={};for(const c of ue)this._sectorData[c]=new o;const s=e.map(((e,t)=>({...e,featureIndex:t})));s.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=s.map((({distance:e})=>e)),l=Math.max(...n);s.forEach((e=>{const{distance:t,angle:r,featureIndex:a}=e,o=t/l*he[2],s=Ie(t,l),n=Ce(r);if(!this._sectorData)return;const c=he[3]+o*Math.sin(r*Math.PI/180),u=he[3]+o*Math.cos(r*Math.PI/180);let h;const p=i.at(a),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)h=-90;else{const e=c-he[3],t=u-he[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),h=i}const g=""===s?n:`${s}_${n}`;m&&(h===this.bestFeatureAngle?this.previousFeatureAngle=h:this.bestFeatureAngle=h,this.navigatorCurrentBestFeature=d?null:{x:c,y:u,direction:n});const y=this._sectorData[g];y.add({angle:r,featureIndex:a,x:c,y:u,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:a,polygons:o,frustums:s}=this.filterByFootprints(i,t);if(!a.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(o),this.coverageFrustums.addMany(s),o[0]){let e=new Re({spatialReference:o[0].spatialReference});for(const r of o)e=await O(e,r);const t=[];for(const{geometry:r}of a)e.contains(r)||t.push([r.x,r.y]);if(t.sort(((e,t)=>+R([e,t]))),e.addRing(t),this.footprintExtent=se(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,r)}catch(l){y(l)||h.getLogger(this).error(l)}}if((n||a[0].attributes.elevationSource)&&this.footprintExtent){const e=a[0].attributes.elevationSource;z(e)&&!n&&(n=await q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const r=await Q((a[0].attributes.location.z??0)-a[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...o]=await W([t,...a.map((e=>e.attributes.geometry.clone()))],r);a[0].elevationSample=n??r.elevationSample,t.elevation=i.z,a.forEach(((e,t)=>{e.attributes.elevation=o[t].z}))}a[0].elevationSample&&a.forEach((e=>{e.elevationSample=a[0].elevationSample})),this._suitabilities=G({features:a,selectedPoint:t,camera:_e(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[a]}=t,o="graphic"===a?.type&&this.shouldShowSelectedImage,s=a?.mapPoint??this.view?.toMap(i);if(!s)return;const{layerFloorFilterClause:n}=this,l=I("1=1",I(e.definitionExpression,n)),c=s.spatialReference.isGeographic?1:C(s.spatialReference),u={layerInstanceOrURL:e,point:s,queryParams:{where:l,maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,objectIds:o?[a.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,r)}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_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:a,isAdditionalPointSourcesVisible:o}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of r)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:fe,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:de,visible:o}))}}_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-he[3],i=e.y-he[3],a=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(a)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),r=o}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()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}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,invalidCameraHeading:r,selectedPoint:i,state:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!i||!t||"image-loaded"!==a||r)return;let o;try{o=await this.worldToImage(i,e),f(e),await this.plotSelectedPointOnImage(o,e)}catch(s){y(s)||h.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 worldToImage(e,t){const{footprintExtent:r}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!r)return;const{attributes:{location:a,elevationSource:o,cameraHeight:s,cameraHeading:n},elevationSample:l}=this.currentBestFeature;let c=a.clone();const u=await Q((a.z??0)-s,{elevationSample:l,elevationSource:o});this.currentBestFeature.elevationSample=u.elevationSample;let h,p=await W(Array.isArray(e)?e:[e],u);if(a.spatialReference.isGeographic&&(c=await M(c,je.WebMercator,t)),p=await Promise.all(p.map((async e=>c.spatialReference.equals(e.spatialReference)?e:await M(e,c.spatialReference,t)))),f(t),"panoramic"===this.mode)h=re(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:n,cameraLocation:c});else{const e=ee(this.currentBestFeature.attributes,i[0],i[1]);h=ie(p,{...e,cameraLocation:c})}return Array.isArray(e)?h:h[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:r,additionalCameraLocations:i,currentBestFeature:a,currentBestFeatureLocation:o,currentCoverageVisible:s,selectedPoint:n,view:l,_adapter:c}=this,{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=s,"panoramic"!==this.mode&&(this.bestFeatureFootprint=e),this.bestFeatureCurrentFootprint=e),l){const e=[...r,...i,this.bestFeatureCurrentFootprint,o].filter(Pe);l.supportsGround&&h&&c?.updateGroundElevation&&c.updateGroundElevation(e,h),n&&e.push(new t({geometry:n.clone(),symbol:pe.clone(),attributes:{imageID:u}})),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&h&&c?.updateGroundElevation&&c.updateGroundElevation([e],h),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],xe.prototype,"activeLayer",null),e([S({readOnly:!0})],xe.prototype,"activeViewer",null),e([S()],xe.prototype,"additionalFeatures",void 0),e([S({type:o.ofType(t)})],xe.prototype,"additionalCameraLocations",void 0),e([S({type:o.ofType(t)})],xe.prototype,"additionalFootprints",void 0),e([S()],xe.prototype,"bestFeatureAngle",void 0),e([S()],xe.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],xe.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],xe.prototype,"brightness",null),e([S({type:Number})],xe.prototype,"contrast",null),e([S()],xe.prototype,"coverageFrustums",void 0),e([S()],xe.prototype,"coveragePolygons",void 0),e([S()],xe.prototype,"currentBestFeature",void 0),e([S()],xe.prototype,"currentBestFeatureLocation",void 0),e([S()],xe.prototype,"currentCoverageVisible",void 0),e([S({json:{write:!1}})],xe.prototype,"determineWorkflowForFeature",void 0),e([S()],xe.prototype,"disabled",void 0),e([S()],xe.prototype,"displayMessage",void 0),e([S()],xe.prototype,"drawFootprint",void 0),e([S({readOnly:!0})],xe.prototype,"featureCount",null),e([S()],xe.prototype,"features",void 0),e([S({readOnly:!0})],xe.prototype,"imageGalleryEnabled",null),e([S({readOnly:!0})],xe.prototype,"imageLoaded",null),e([S({readOnly:!0})],xe.prototype,"invalidCameraHeading",null),e([S()],xe.prototype,"imagePointsInView",null),e([S()],xe.prototype,"isAdditionalCoverageVisible",void 0),e([S()],xe.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],xe.prototype,"layer",void 0),e([S()],xe.prototype,"layerView",null),e([S({readOnly:!0})],xe.prototype,"layerFloorFilterClause",null),e([S({type:Number})],xe.prototype,"localPort",void 0),e([S()],xe.prototype,"mapImageConversionToolState",void 0),e([S({readOnly:!0,value:"none"})],xe.prototype,"mode",null),e([S()],xe.prototype,"navigatorCurrentBestFeature",void 0),e([S({type:o.ofType(t)})],xe.prototype,"overlayedCameraLocations",void 0),e([S()],xe.prototype,"overlayedMapFeatures",void 0),e([S()],xe.prototype,"pointSources",void 0),e([S({readOnly:!0})],xe.prototype,"popupEnabled",null),e([S()],xe.prototype,"previousFeatureAngle",void 0),e([S()],xe.prototype,"referencePoint",null),e([S({readOnly:!0})],xe.prototype,"sectorData",null),e([S()],xe.prototype,"selectedPoint",void 0),e([S({type:Number})],xe.prototype,"sharpness",null),e([S()],xe.prototype,"shouldShowSelectedImage",void 0),e([S({readOnly:!0})],xe.prototype,"state",null),e([S({readOnly:!0})],xe.prototype,"thumbnails",null),e([S()],xe.prototype,"updateFootprint",void 0),e([S()],xe.prototype,"updateFootprintPanorama",void 0),e([S({value:null})],xe.prototype,"view",null),e([S()],xe.prototype,"_adapter",void 0),e([S()],xe.prototype,"_highlightedFeatureHandle",void 0),e([S()],xe.prototype,"_imageViewer",void 0),e([S()],xe.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],xe.prototype,"_overlays",void 0),e([S({readOnly:!0})],xe.prototype,"_overlaysView",null),e([S()],xe.prototype,"_panoramicViewer",void 0),e([S()],xe.prototype,"_referencePointOnGround",void 0),e([S()],xe.prototype,"_referencePointOnImage",void 0),e([S()],xe.prototype,"_sectorData",void 0),e([S({readOnly:!0})],xe.prototype,"_updatingHandles",void 0),e([S()],xe.prototype,"footprintExtent",void 0),xe=e([V("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],xe);const Ee=xe;export{Ee as default};