@arcgis/core 4.24.0-next.20220508 → 4.24.0-next.20220511

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 (338) hide show
  1. package/AggregateGraphic.js +1 -1
  2. package/analysis/Analysis.js +1 -1
  3. package/analysis/DimensioningAnalysis.js +1 -1
  4. package/analysis/LengthDimension.d.ts +4 -0
  5. package/analysis/LengthDimension.js +5 -0
  6. package/analysis/dimensionUtils.js +5 -0
  7. package/arcade/Dictionary.js +1 -1
  8. package/arcade/Feature.js +1 -1
  9. package/arcade/arcade.js +1 -1
  10. package/arcade/arcadeAsyncRuntime.js +1 -1
  11. package/arcade/arcadeCompiler.js +1 -1
  12. package/arcade/credentials.js +1 -1
  13. package/arcade/featureSetCollection.js +1 -1
  14. package/arcade/featureSetUtils.js +1 -1
  15. package/arcade/featureset/actions/Adapted.js +1 -1
  16. package/arcade/featureset/actions/AttributeFilter.js +1 -1
  17. package/arcade/featureset/actions/GroupBy.js +1 -1
  18. package/arcade/featureset/actions/OrderBy.js +1 -1
  19. package/arcade/featureset/actions/SpatialFilter.js +1 -1
  20. package/arcade/featureset/actions/Top.js +1 -1
  21. package/arcade/featureset/sources/Empty.js +1 -1
  22. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  23. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  24. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  25. package/arcade/featureset/support/FeatureSet.js +1 -1
  26. package/arcade/featureset/support/FeatureSetIterator.js +1 -1
  27. package/arcade/featureset/support/shared.js +1 -1
  28. package/arcade/featureset/support/stats.js +1 -1
  29. package/arcade/functions/featuresetbase.js +1 -1
  30. package/arcade/functions/featuresetgeom.js +1 -1
  31. package/arcade/functions/featuresetstats.js +1 -1
  32. package/arcade/functions/featuresetstring.js +1 -1
  33. package/arcade/functions/geomasync.js +1 -1
  34. package/arcade/languageUtils.js +1 -1
  35. package/arcade/request.js +1 -1
  36. package/assets/esri/core/workers/RemoteClient.js +1 -1
  37. package/assets/esri/core/workers/chunks/0564f1cfa3d17ff1aad3.js +1 -0
  38. package/assets/esri/core/workers/chunks/0806d5d706a864542bfb.js +1 -0
  39. package/assets/esri/core/workers/chunks/0a6977144ea1abf96fbf.js +1 -0
  40. package/assets/esri/core/workers/chunks/13387f56acbc3291561a.js +1 -0
  41. package/assets/esri/core/workers/chunks/16c4e0a32d50d4db984d.js +1 -0
  42. package/assets/esri/core/workers/chunks/{076d1b1101b59af0d389.js → 1c010202b4c7e1d15f23.js} +1 -1
  43. package/assets/esri/core/workers/chunks/26827ec144676e6385f8.js +1 -0
  44. package/assets/esri/core/workers/chunks/287c484fd40eee643f3a.js +1 -0
  45. package/assets/esri/core/workers/chunks/5210f0b42dba27945226.js +1 -0
  46. package/assets/esri/core/workers/chunks/{db6c5b3b4efe8d804f9c.js → 52478ee2d2a1354b6900.js} +1 -1
  47. package/assets/esri/core/workers/chunks/5759af97f96f24c40105.js +1 -0
  48. package/assets/esri/core/workers/chunks/{b85218d44c6094b7e5e6.js → 6d7e2a23a0a5dd9ded1d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/70b6356357e7640c4e8b.js +1 -0
  50. package/assets/esri/core/workers/chunks/7574316b3af61c389e8f.js +1 -0
  51. package/assets/esri/core/workers/chunks/7bc828fbdd54c0b28aac.js +1 -0
  52. package/assets/esri/core/workers/chunks/7e5c22b5a32ac74b1b6e.js +1 -0
  53. package/assets/esri/core/workers/chunks/8102bb78fe96e6197e4e.js +1 -0
  54. package/assets/esri/core/workers/chunks/88384e7cafbfd2348598.js +1 -0
  55. package/assets/esri/core/workers/chunks/9d7533aaeac3b8d145c4.js +1 -0
  56. package/assets/esri/core/workers/chunks/{1eecae5227318f491263.js → 9f4d892abf55e8625bc9.js} +3 -3
  57. package/assets/esri/core/workers/chunks/{98607a0da63626cc4614.js → a054a52712a118c6d505.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{69a20e4d9e28c3e599fc.js → a3bb600bfcb0282622f1.js} +1 -1
  59. package/assets/esri/core/workers/chunks/aa49841b14c6e6df2a07.js +1 -0
  60. package/assets/esri/core/workers/chunks/b089058b64db3912478f.js +1 -0
  61. package/assets/esri/core/workers/chunks/b28539c5a6bedb71b038.js +1 -0
  62. package/assets/esri/core/workers/chunks/b4f171db73355c6f766e.js +1 -0
  63. package/assets/esri/core/workers/chunks/b7572b0921b23aef8b9d.js +1 -0
  64. package/assets/esri/core/workers/chunks/b758f3c419edc2306784.js +1 -0
  65. package/assets/esri/core/workers/chunks/c3e7290fb128d4fefd44.js +1 -0
  66. package/assets/esri/core/workers/chunks/c51c9b5da855f84b9a48.js +1 -0
  67. package/assets/esri/core/workers/chunks/c66ac36da6392b6bf331.js +1 -0
  68. package/assets/esri/core/workers/chunks/d16b328d32a6ddc2fdb9.js +1 -0
  69. package/assets/esri/core/workers/chunks/d94c5f36d52cf71f0bb9.js +1 -0
  70. package/assets/esri/core/workers/chunks/db937849b2c1af87b481.js +1 -0
  71. package/assets/esri/core/workers/chunks/{66cd99e91dad60c5274c.js → dc3ed59f450283d97a19.js} +1 -1
  72. package/assets/esri/core/workers/chunks/dcd0653191cd4a1ccaae.js +2 -0
  73. package/assets/esri/core/workers/chunks/{31df729c17470245288c.js.LICENSE.txt → dcd0653191cd4a1ccaae.js.LICENSE.txt} +2 -2
  74. package/assets/esri/core/workers/chunks/e4fdd1eaf987977d0a51.js +1 -0
  75. package/assets/esri/core/workers/chunks/e51f0e71f2a55af604d3.js +1 -0
  76. package/assets/esri/core/workers/chunks/eb3855d3753d6b8334bd.js +1 -0
  77. package/assets/esri/core/workers/chunks/{7c290763920f52a1f504.js → eeed138930a4a805691d.js} +1 -1
  78. package/assets/esri/core/workers/chunks/f435dc615fdc8917f6ca.js +1 -0
  79. package/assets/esri/core/workers/chunks/{d5c5b9f7f5401f36a3a5.js → f7f3dde4c8f9c687cc1e.js} +1 -1
  80. package/assets/esri/core/workers/chunks/fc6beaf9466ea3898549.js +1 -0
  81. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  82. package/assets/esri/themes/base/widgets/_Tooltip.scss +1 -0
  83. package/assets/esri/themes/base/widgets/_Weather.scss +1 -2
  84. package/assets/esri/themes/dark/main.css +1 -1
  85. package/assets/esri/themes/light/main.css +1 -1
  86. package/assets/esri/themes/light/view.css +1 -1
  87. package/chunks/BlendLayers.glsl.js +6 -6
  88. package/chunks/arcade.js +1 -1
  89. package/chunks/array.js +1 -1
  90. package/chunks/languageUtils.js +1 -1
  91. package/config.js +1 -1
  92. package/core/sql/StandardizedFunctions.js +1 -1
  93. package/geohash/GeohashTree.js +1 -1
  94. package/geometry/support/contains.js +1 -1
  95. package/geometry/support/heightModelInfoUtils.js +1 -1
  96. package/geometry/support/intersects.js +1 -1
  97. package/geometry/support/intersectsBase.js +1 -1
  98. package/geometry/support/normalizeUtilsCommon.js +1 -1
  99. package/geometry/support/spatialReferenceUtils.js +1 -1
  100. package/interfaces.d.ts +685 -37
  101. package/layers/MediaLayer.d.ts +4 -0
  102. package/layers/MediaLayer.js +5 -0
  103. package/layers/VoxelLayer.js +1 -1
  104. package/layers/VoxelWasmPerSceneView.js +5 -0
  105. package/layers/graphics/OptimizedGeometry.js +1 -1
  106. package/layers/graphics/data/BoundsStore.js +1 -1
  107. package/layers/support/CornersGeoreference.d.ts +4 -0
  108. package/layers/support/CornersGeoreference.js +5 -0
  109. package/layers/support/ExtentAndRotationGeoreference.d.ts +4 -0
  110. package/layers/support/ExtentAndRotationGeoreference.js +5 -0
  111. package/layers/support/FeatureReduction.js +1 -1
  112. package/layers/support/FeatureReductionBinning.js +5 -0
  113. package/layers/support/GeoreferenceBase.js +5 -0
  114. package/layers/support/ImageElement.d.ts +4 -0
  115. package/layers/support/ImageElement.js +5 -0
  116. package/layers/support/LocalMediaElementSource.d.ts +4 -0
  117. package/layers/support/LocalMediaElementSource.js +5 -0
  118. package/layers/support/MediaElementBase.d.ts +4 -0
  119. package/layers/support/MediaElementBase.js +5 -0
  120. package/layers/support/RouteStopSymbols.d.ts +4 -0
  121. package/layers/support/RouteSymbols.d.ts +4 -0
  122. package/layers/support/VoxelFormat.d.ts +4 -0
  123. package/layers/support/VoxelStyle.d.ts +4 -0
  124. package/layers/support/VoxelVariable.d.ts +4 -0
  125. package/layers/support/VoxelVolume.d.ts +4 -0
  126. package/layers/support/VoxelVolumeStyle.d.ts +4 -0
  127. package/layers/support/arcgisLayerUrl.js +1 -1
  128. package/layers/support/featureReductionUtils.js +1 -1
  129. package/layers/support/fieldUtils.js +1 -1
  130. package/layers/support/rasterFormats/Lerc.js +1 -1
  131. package/package.json +3 -3
  132. package/request.js +1 -1
  133. package/support/requestUtils.js +1 -1
  134. package/support/revision.js +1 -1
  135. package/symbols/Font.js +1 -1
  136. package/symbols/support/textUtils.js +1 -1
  137. package/views/2d/engine/brushes.js +1 -1
  138. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  139. package/views/2d/engine/webgl/Overlay.js +5 -0
  140. package/views/2d/engine/webgl/OverlayContainer.js +5 -0
  141. package/views/2d/engine/webgl/brushes/BrushOverlay.js +5 -0
  142. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  143. package/views/2d/engine/webgl/shaders/OverlayPrograms.js +5 -0
  144. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  145. package/views/2d/layerViewModuleImportUtils.js +1 -1
  146. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  147. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  148. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  149. package/views/2d/layers/MediaLayerView2D.js +5 -0
  150. package/views/2d/layers/StreamLayerView2D.js +1 -1
  151. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  152. package/views/2d/layers/features/FeatureStore2D.js +1 -1
  153. package/views/2d/layers/features/Pipeline.js +1 -1
  154. package/views/2d/layers/features/Store2D.js +1 -1
  155. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  156. package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
  157. package/views/2d/layers/features/schemaUtils.js +1 -1
  158. package/views/2d/layers/features/sources/GeoEventSource.js +1 -1
  159. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  160. package/views/2d/layers/features/support/BinStore.js +5 -0
  161. package/views/2d/layers/features/support/ClusterStore.js +1 -1
  162. package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
  163. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  164. package/views/2d/layers/support/clusterUtils.js +1 -1
  165. package/views/2d/magnifier/MagnifierView2D.js +1 -1
  166. package/views/2d/navigation/actions/Pinch.js +1 -1
  167. package/views/2d/viewpointUtils.js +1 -1
  168. package/views/3d/analysis/AnalysisView3D.js +1 -1
  169. package/views/3d/analysis/Dimensioning/DimensioningTool.js +5 -0
  170. package/views/3d/analysis/Dimensioning/DimensioningVisualization.js +1 -1
  171. package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +5 -0
  172. package/views/3d/analysis/Dimensioning/{LinearDimensionVisualization.js → LengthDimensionVisualization.js} +1 -1
  173. package/views/3d/analysis/Dimensioning/settings.js +5 -0
  174. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  175. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  176. package/views/3d/interactive/SegmentLabels3D.js +5 -0
  177. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  178. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  179. package/views/3d/interactive/editingTools/reshapeGraphic/GraphicReshapeTool.js +1 -1
  180. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  181. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  182. package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateObjectSymbol3DAdapter.js +1 -1
  183. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  184. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  185. package/views/3d/layerViewModuleImportUtils.js +1 -1
  186. package/views/3d/layers/I3SMeshView3D.js +1 -1
  187. package/views/3d/layers/MediaLayerView3D.js +5 -0
  188. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  189. package/views/3d/layers/i3s/IDBCache.js +1 -1
  190. package/views/3d/state/controllers/RotateController.js +1 -1
  191. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  192. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  193. package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
  194. package/views/3d/support/ResourceController.js +1 -1
  195. package/views/3d/support/sunUtils.js +1 -1
  196. package/views/3d/terrain/TerrainRenderer.js +1 -1
  197. package/views/3d/terrain/TerrainSurface.js +1 -1
  198. package/views/3d/terrain/TileCompositor.js +1 -1
  199. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  200. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  201. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js +1 -1
  202. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  203. package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
  204. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  205. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  206. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  207. package/views/DOMContainer.js +1 -1
  208. package/views/GroundView.js +1 -1
  209. package/views/SceneView.js +1 -1
  210. package/views/ToolViewManager.js +1 -1
  211. package/views/View.js +1 -1
  212. package/views/draw/DrawOperation.js +1 -1
  213. package/views/draw/support/Reshape.js +1 -1
  214. package/views/interactive/GraphicManipulator.js +1 -1
  215. package/views/interactive/InteractiveToolBase.js +1 -1
  216. package/views/interactive/SegmentLabels.js +5 -0
  217. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  218. package/views/interactive/snapping/LineSnapper.js +1 -1
  219. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  220. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  221. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  222. package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
  223. package/views/interactive/snapping/SnappingManager.js +1 -1
  224. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  225. package/views/interactive/snapping/snappingUtils.js +1 -1
  226. package/views/interactive/support/viewUtils.js +5 -0
  227. package/views/interactive/tooltip/DrawPointTooltipInfo.js +5 -0
  228. package/views/interactive/tooltip/DrawPolygonTooltipInfo.js +5 -0
  229. package/views/interactive/tooltip/DrawPolylineTooltipInfo.js +5 -0
  230. package/views/interactive/tooltip/Tooltip.js +1 -1
  231. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  232. package/views/interactive/tooltip/support/measurements.js +5 -0
  233. package/views/layers/FeatureLayerView.js +1 -1
  234. package/views/layers/GroupLayerView.js +1 -1
  235. package/views/overlay/TextOverlayItem.js +1 -1
  236. package/views/support/Scheduler.js +1 -1
  237. package/views/support/screenUtils.js +1 -1
  238. package/webscene/Slide.js +1 -1
  239. package/widgets/Attribution/AttributionViewModel.js +1 -1
  240. package/widgets/Bookmarks.js +1 -1
  241. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  242. package/widgets/Editor/EditorViewModel.js +1 -1
  243. package/widgets/Editor/UpdateWorkflow.js +1 -1
  244. package/widgets/Editor/workflowUtils.js +1 -1
  245. package/widgets/Editor.js +1 -1
  246. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  247. package/widgets/ElevationProfile.js +1 -1
  248. package/widgets/Feature/FeatureAttachments.js +1 -1
  249. package/widgets/Feature/FeatureContent/FeatureContentViewModel.js +1 -1
  250. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  251. package/widgets/Feature/FeatureExpression.js +1 -1
  252. package/widgets/Feature/FeatureFields.js +1 -1
  253. package/widgets/Feature/FeatureViewModel.js +1 -1
  254. package/widgets/Feature.js +1 -1
  255. package/widgets/FeatureForm/InputFieldGroup.js +1 -1
  256. package/widgets/FeatureForm.js +1 -1
  257. package/widgets/FeatureTable/FieldColumn.js +1 -1
  258. package/widgets/FeatureTable/Grid/Column.js +1 -1
  259. package/widgets/FeatureTable/Grid/Grid.js +11 -11
  260. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  261. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  262. package/widgets/FeatureTemplates/TemplateItem.js +1 -1
  263. package/widgets/FeatureTemplates.js +1 -1
  264. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  265. package/widgets/FloorFilter.js +1 -1
  266. package/widgets/HistogramRangeSlider.js +1 -1
  267. package/widgets/LayerList/LayerListViewModel.js +1 -1
  268. package/widgets/LayerList/ListItem.js +1 -1
  269. package/widgets/LayerList/ListItemPanel.js +1 -1
  270. package/widgets/LayerList.js +1 -1
  271. package/widgets/Legend/LegendViewModel.js +1 -1
  272. package/widgets/Legend/styles/Card.js +1 -1
  273. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  274. package/widgets/Legend.js +1 -1
  275. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  276. package/widgets/Measurement.js +1 -1
  277. package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
  278. package/widgets/Popup/PopupViewModel.js +1 -1
  279. package/widgets/Popup.js +1 -1
  280. package/widgets/Print/FileLink.js +1 -1
  281. package/widgets/Print.js +1 -1
  282. package/widgets/ScaleBar.js +1 -1
  283. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  284. package/widgets/ScaleRangeSlider.js +1 -1
  285. package/widgets/Search/SearchViewModel.js +1 -1
  286. package/widgets/Search.js +1 -1
  287. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  288. package/widgets/Sketch/SketchViewModel.js +1 -1
  289. package/widgets/Sketch.js +1 -1
  290. package/widgets/TableList/ListItem.js +1 -1
  291. package/widgets/Weather/LabeledSlider.js +1 -1
  292. package/widgets/Weather/VisibleElements.js +5 -0
  293. package/widgets/Weather/css.js +1 -1
  294. package/widgets/Weather.js +1 -1
  295. package/widgets/support/AnalysisViewModel.js +1 -1
  296. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  297. package/analysis/LinearDimension.d.ts +0 -4
  298. package/analysis/LinearDimension.js +0 -5
  299. package/assets/esri/core/workers/chunks/0018053ac16a09feba70.js +0 -1
  300. package/assets/esri/core/workers/chunks/042938ca73f0b9e5a7e2.js +0 -1
  301. package/assets/esri/core/workers/chunks/048645611caa28dca7cd.js +0 -1
  302. package/assets/esri/core/workers/chunks/0b72d123386dc4ec7538.js +0 -1
  303. package/assets/esri/core/workers/chunks/13b04d5bf348ab5054c2.js +0 -1
  304. package/assets/esri/core/workers/chunks/215007e7c44811d90777.js +0 -1
  305. package/assets/esri/core/workers/chunks/31df729c17470245288c.js +0 -2
  306. package/assets/esri/core/workers/chunks/36272141b3c33cb19026.js +0 -1
  307. package/assets/esri/core/workers/chunks/36c8e8de9c3f67d32572.js +0 -1
  308. package/assets/esri/core/workers/chunks/37c428489c59df4b597b.js +0 -1
  309. package/assets/esri/core/workers/chunks/493169fd978fd543ef3b.js +0 -1
  310. package/assets/esri/core/workers/chunks/4f378ad6f4299183df85.js +0 -1
  311. package/assets/esri/core/workers/chunks/58e4c6ce1580427e7b55.js +0 -1
  312. package/assets/esri/core/workers/chunks/6c5441da675a8af35be2.js +0 -1
  313. package/assets/esri/core/workers/chunks/6ea16f6a0df946de480b.js +0 -1
  314. package/assets/esri/core/workers/chunks/7dfd70f4fa1096e56641.js +0 -1
  315. package/assets/esri/core/workers/chunks/88193e61072d7bf957f5.js +0 -1
  316. package/assets/esri/core/workers/chunks/8ccbde593c86c872e525.js +0 -1
  317. package/assets/esri/core/workers/chunks/9c6be39f1f21ab8b1c2d.js +0 -1
  318. package/assets/esri/core/workers/chunks/a73795cce722ba15b3da.js +0 -1
  319. package/assets/esri/core/workers/chunks/a8ed1a938dc164b401d9.js +0 -1
  320. package/assets/esri/core/workers/chunks/a9a73bc4875a5aeaf1b9.js +0 -1
  321. package/assets/esri/core/workers/chunks/adcc5bce6c0971c1b592.js +0 -1
  322. package/assets/esri/core/workers/chunks/afddfe620e6539991e6b.js +0 -1
  323. package/assets/esri/core/workers/chunks/b340c9bdabdb37995c8f.js +0 -1
  324. package/assets/esri/core/workers/chunks/b4c23630d6c85f7b59c0.js +0 -1
  325. package/assets/esri/core/workers/chunks/c180c40838246985479d.js +0 -1
  326. package/assets/esri/core/workers/chunks/caed2365bd296fcc8a75.js +0 -1
  327. package/assets/esri/core/workers/chunks/d85b5b73a151c6fbb658.js +0 -1
  328. package/assets/esri/core/workers/chunks/da6261673c3e1537b6a6.js +0 -1
  329. package/assets/esri/core/workers/chunks/dafe120243db6648a4ab.js +0 -1
  330. package/assets/esri/core/workers/chunks/ec6d138e8183e193f977.js +0 -1
  331. package/assets/esri/core/workers/chunks/ed4519ac9533a4d340f1.js +0 -1
  332. package/assets/esri/core/workers/chunks/f206300eef4560611728.js +0 -1
  333. package/assets/esri/core/workers/chunks/f55cbaf5a1d6ee6ac171.js +0 -1
  334. package/layers/GeoreferencedImageLayer.d.ts +0 -4
  335. package/layers/GeoreferencedImageLayer.js +0 -5
  336. package/layers/VoxelWasmManager.js +0 -5
  337. package/layers/VoxelWasmPerScene.js +0 -5
  338. package/views/3d/interactive/measurementTools/support/viewUtils.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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t}from"../../core/handleUtils.js";import{isSome as i}from"../../core/maybe.js";import{onAbort as a,createAbortError as s,throwIfAborted as o,isAborted as r}from"../../core/promiseUtils.js";import{watch as d}from"../../core/watchUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import{Edits as c}from"./Edits.js";import u from"./UpdateWorkflowData.js";import m from"./Workflow.js";import{createWorkflowSteps as h,fetchCandidates as w,fetchFullFeature as f,findLayerInfo as p,getVisualVariableAttributes as g,setUpGeometryUpdate as v}from"./workflowUtils.js";var y;const b="candidate-highlight";let M=y=class extends m{constructor(e){super(e),this.type="update"}static create(e,t,i){const a=new y({data:new u({edits:new c,viewModel:e}),onCommit:async e=>{const t=e.edits.feature,a=t.sourceLayer,s=t.clone();if(!e.edits.attributesModified){const{objectIdField:e}=a;s.attributes={[e]:t.getAttribute(e)}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}highlight(e){const{data:{viewModel:{view:t}}}=this,i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer));l(i)&&this.handles.add(i.highlight(e),b)}unhighlight(){this.handles.remove(b)}static _createWorkflowSteps(e,n="awaiting-feature-to-update"){const{data:l,handles:c}=e;return h(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],n,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e,view:t}=l.viewModel;let i=null;c.add({remove(){i&&(i.abort(),i=null)}},this.id),l.edits.feature=null;const r=t.on("immediate-click",(r=>{e.location=r.mapPoint,e.visible=!0,i&&i.abort();const{editableItems:d}=l.viewModel;i=new AbortController,new Promise(((e,o)=>{a(i.signal,(()=>o(s()))),e(w(d,t,r,i.signal))})).then((e=>{if(o(i),l.candidates=e.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),l.viewModel.spinnerViewModel.visible=1===l.candidates.length,0!==l.candidates.length)if(1===l.candidates.length){const e=l.candidates[0];l.edits.feature=e,l.viewModel.activeWorkflow.go("editing-existing-feature").catch((()=>{})).then((()=>l.viewModel.spinnerViewModel.visible=!1))}else l.viewModel.activeWorkflow.next()}))}));c.add(r,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=l;t.feature=null,c.add(d(t,"feature",(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const a=l.edits.feature,s=l.viewModel;l.editableItem=s.editableItems.find((e=>e.layer===a.layer));const o=new AbortController;c.add({remove:()=>o.abort()},this.id);const d=s.view.whenLayerView(a.layer),n=f(a,s.view,o.signal),u=await d,m=await n;if(r(o))return;l.edits.updateGeometry(m.geometry),l.edits.updateAttributes(m.attributes),l.edits.trackChanges(),s.attachmentsViewModel.set({graphic:m,mode:"view"});const h=m.sourceLayer,w=p(s.layerInfos,h)?.formTemplate;s.featureFormViewModel.set({feature:m,formTemplate:w});const y="createInteractiveEditSession"in u?u.createInteractiveEditSession(a):null,b=[s.featureFormViewModel.on("value-change",(e=>{l.edits.updateAttributes(s.featureFormViewModel.getValues()),m.attributes=l.edits.feature.attributes,y&&y.setAttribute(e.fieldName,e.value)})),s.attachmentsViewModel.watch("mode",(e=>{"add"===e&&l.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&l.viewModel.activeWorkflow.go("editing-attachment")}))];y&&(b.push(t((()=>y.rollback()))),c.add(t((()=>y.commit())),e._handleKeys.afterCommit));const{supportsGeometryUpdate:M}=h.capabilities.editing;if(M){s.sketchViewModel.allowDeleteKey=!1;const t=g(m),{interactive:a,visual:o}=await v(m,t,s.sketchViewModel,s.view,(({geometry:e,attributes:a})=>{if(i(t.rotation)){const{field:e}=t.rotation;s.featureFormViewModel.setValue(e,a[e])}if(i(t.size)){const{field:e}=t.size;s.featureFormViewModel.setValue(e,a[e])}l.edits.updateAttributes(a),l.edits.updateGeometry(e)}));b.push(a,o),c.add(a,e._handleKeys.beforeCommit),c.add(o,e._handleKeys.afterCommit)}else e.highlight(m);c.add(b,this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}})})}};M=y=e([n("esri.widgets.Editor.UpdateWorkflow")],M);const V=M;export{V as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t}from"../../core/handleUtils.js";import{isSome as i}from"../../core/maybe.js";import{onAbort as a,createAbortError as s,throwIfAborted as o,isAborted as r}from"../../core/promiseUtils.js";import{watch as d}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import{Edits as c}from"./Edits.js";import u from"./UpdateWorkflowData.js";import m from"./Workflow.js";import{createWorkflowSteps as h,fetchCandidates as w,fetchFullFeature as f,findLayerInfo as p,getVisualVariableAttributes as g,setUpGeometryUpdate as v}from"./workflowUtils.js";var y;const b="candidate-highlight";let M=y=class extends m{constructor(e){super(e),this.type="update"}static create(e,t,i){const a=new y({data:new u({edits:new c,viewModel:e}),onCommit:async e=>{const t=e.edits.feature,a=t.sourceLayer,s=t.clone();if(!e.edits.attributesModified){const{objectIdField:e}=a;s.attributes={[e]:t.getAttribute(e)}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}highlight(e){const{data:{viewModel:{view:t}}}=this,i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer));l(i)&&this.handles.add(i.highlight(e),b)}unhighlight(){this.handles.remove(b)}static _createWorkflowSteps(e,n="awaiting-feature-to-update"){const{data:l,handles:c}=e;return h(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],n,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e,view:t}=l.viewModel;let i=null;c.add({remove(){i&&(i.abort(),i=null)}},this.id),l.edits.feature=null;const r=t.on("immediate-click",(r=>{e.location=r.mapPoint,e.visible=!0,i&&i.abort();const{editableItems:d}=l.viewModel;i=new AbortController,new Promise(((e,o)=>{a(i.signal,(()=>o(s()))),e(w(d,t,r,i.signal))})).then((e=>{if(o(i),l.candidates=e.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),l.viewModel.spinnerViewModel.visible=1===l.candidates.length,0!==l.candidates.length)if(1===l.candidates.length){const e=l.candidates[0];l.edits.feature=e,l.viewModel.activeWorkflow.go("editing-existing-feature").catch((()=>{})).then((()=>l.viewModel.spinnerViewModel.visible=!1))}else l.viewModel.activeWorkflow.next()}))}));c.add(r,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=l;t.feature=null,c.add(d((()=>t.feature),(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const a=l.edits.feature,s=l.viewModel;l.editableItem=s.editableItems.find((e=>e.layer===a.layer));const o=new AbortController;c.add({remove:()=>o.abort()},this.id);const n=s.view.whenLayerView(a.layer),u=f(a,s.view,o.signal),m=await n,h=await u;if(r(o))return;l.edits.updateGeometry(h.geometry),l.edits.updateAttributes(h.attributes),l.edits.trackChanges(),s.attachmentsViewModel.set({graphic:h,mode:"view"});const w=h.sourceLayer,y=p(s.layerInfos,w)?.formTemplate;s.featureFormViewModel.set({feature:h,formTemplate:y});const b="createInteractiveEditSession"in m?m.createInteractiveEditSession(a):null,M=[s.featureFormViewModel.on("value-change",(e=>{l.edits.updateAttributes(s.featureFormViewModel.getValues()),h.attributes=l.edits.feature.attributes,b&&b.setAttribute(e.fieldName,e.value)})),d((()=>s.attachmentsViewModel.mode),(e=>{"add"===e&&l.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&l.viewModel.activeWorkflow.go("editing-attachment")}))];b&&(M.push(t((()=>b.rollback()))),c.add(t((()=>b.commit())),e._handleKeys.afterCommit));const{supportsGeometryUpdate:V}=w.capabilities.editing;if(V){s.sketchViewModel.allowDeleteKey=!1;const t=g(h),{interactive:a,visual:o}=await v(h,t,s.sketchViewModel,s.view,(({geometry:e,attributes:a})=>{if(i(t.rotation)){const{field:e}=t.rotation;s.featureFormViewModel.setValue(e,a[e])}if(i(t.size)){const{field:e}=t.size;s.featureFormViewModel.setValue(e,a[e])}l.edits.updateAttributes(a),l.edits.updateGeometry(e)}));M.push(a,o),c.add(a,e._handleKeys.beforeCommit),c.add(o,e._handleKeys.afterCommit)}else e.highlight(h);c.add(M,this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){}})})}};M=y=e([n("esri.widgets.Editor.UpdateWorkflow")],M);const V=M;export{V 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.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import"../../core/has.js";import{isSome as t,isNone as r,removeMaybe as i}from"../../core/maybe.js";import{whenOrAbort as a,eachAlways as n}from"../../core/promiseUtils.js";import{px2pt as s}from"../../core/screenUtils.js";import{init as o,whenFalseOnce as l}from"../../core/watchUtils.js";import{diff as c}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as p}from"../../renderers/support/lengthUtils.js";import{getTransformationType as y,TransformationType as f}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as d,getSize as m}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as h}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as g}from"../../symbols/support/symbolUtils.js";import{GraphicState as b}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as w}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as v}from"../../views/support/hitTestSelectUtils.js";function S(e){const r=e.sourceLayer;if("feature"!==r.type||!F(r.renderer))return{rotation:null,size:null};let i=null,a=null;const n=r.renderer.getVisualVariablesForType("rotation").filter((r=>(!r.axis||"heading"===r.axis)&&r.field&&!r.valueExpression&&t(d(r,e))));1===n.length&&(i=j(n[0],r));const s=r.renderer.getVisualVariablesForType("size").filter((r=>r.field&&!r.useSymbolValue&&!r.valueExpression&&y(r)===f.RealWorldSize&&t(m(r,e))));return 1===s.length&&(a=U(s[0],r)),{rotation:i,size:a}}function j(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,z((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function I(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function V(e,t,i){if(r(t))return 0;const{symbol:a}=h(t);if(r(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(C.icon,(await e(n,C.icon))[0])||C.icon}case"text":return n.size||C.text;case"line":return n.size||C.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return I(await t(n,e.scale/C.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/C.viewScaleSizeFactor;case"extrude":return n.size||e.scale/C.viewScaleSizeFactor;default:return 0}}function U(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=p[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>z(l(await V(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,z(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function z(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function F(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function L(e){const r=await g(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=c(e.symbol,r);t(i)&&(e.symbol=r)}function x(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function M(e,t,r){await R(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await L(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function R(e,t){const r=t.layer,i={...t.template.prototype.attributes};await E(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(x(r.geometryType),a)}async function E(t,i,a){const n=new e({sourceLayer:i,attributes:a}),{rotation:s,size:o}=S(n);let l=await g(n,{useSourceLayer:!0}),c=!1;for(const e of[o,s]){if(r(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(l,t.view),c=!0)}switch(c&&(l=await g(n,{useSourceLayer:!0})),l?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=l;break;case"simple-line":case"line-3d":t.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=l}}function T(e,t){return e&&e.find((e=>e.layer===t))}async function k(e,t,r,i){if(0===e.length)return[];const{updatable:s,graphicsByLayer:o}=await r.async((async()=>{const{results:n}=await a(v(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};n.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.includes("update")&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return a(n(s.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function A(e,t,r,i){if(0===e.length)return[];let s=null;const o=await r.async((async()=>{const{results:n}=await a(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;s=n,s.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.includes("update")&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return a(n(o.map((({layer:e})=>{const{objectIdField:a,displayField:n}=e,o=[a];e.fieldsIndex.has(n)&&o.push(n);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?u({renderer:e.renderer,event:r}):0;return l.geometry=w(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(s.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[a]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function G(e,t,r,i){switch(t.type){case"3d":return k(e,t,r,i);case"2d":return A(e,t,r,i)}}async function P(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function q(e,i,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(r(a))return;const n=i.attributes[a.field];if(t(n))a.initValue(n);else{const t=await a.getDefault(i.symbol,e.view);a.initValue(t),i.setAttribute(a.field,t),s=!0}})),s&&await L(i);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=t(o),c.enableScaling=t(l)),e.layer.elevationInfo=a.elevationInfo,e.update(i,c)}function D(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Z(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Q(e,r,i,a){if(!t(r.geometry)||"point"!==r.geometry?.type)return;const n=a.rotation,s=D(i.toolEventInfo);if(t(n)&&t(s))if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:t,getValue:i}=n;r.attributes[t]=i(s.angle,e)}const o=a.size,l=Z(i.toolEventInfo);if(t(o)&&t(l))if("scale-stop"===l.type)o.isUpdatingInteractively=!1,o.initValue();else{o.isUpdatingInteractively=!0;const{field:t,getValue:i}=o;r.attributes[t]=i(l.xScale,e)}await L(r)}async function B(e,a,n,s,c){const u=e.clone();await L(u),s.map.add(n.layer),n.layer.add(u);const p=e.sourceLayer,y=s.whenLayerView(p),f=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return y.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){y.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let d=null,m=null;if("3d"===s.type){const e=new b({graphic:u});d=s.trackGraphicState(e),o(e,"displaying",(e=>{m=e?f():i(m)}))}else m=f();await q(n,u,p,a);let h=null;y.then((e=>h=e),(()=>{}));const g=a.size,w=a.rotation,v=e.watch("attributes",(async e=>{let i=!1;for(const a in e){const n=e[a];n!==u.attributes[a]&&(u.setAttribute(a,n),t(g)&&!g.isUpdatingInteractively&&g.field===a&&g.initValue(n),t(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),(r(h)||h.requiredFields.includes(a))&&(i=!0))}i&&await L(u)})),S=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return q(n,t,p,a);await Q(s,t,e,a),c(t.clone())})),j=n.on(["undo","redo"],(async e=>{c(e.graphics[0].clone())})),I=()=>{};return{interactive:{remove(){j.remove(),S.remove(),n.cancel(),v&&v.remove(),this.remove=I}},visual:{remove(){i(m),s.whenLayerView(p).then((e=>l(e,"updating"))).then((()=>{i(d),n.layer.remove(u),this.remove=I}))}}}}const C={icon:s(24),text:s(12),line:s(1),viewScaleSizeFactor:100};function O(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function W(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function H(e,r){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===r[0].id){const i=W(e.viewModel.featureTemplatesViewModel.items);t(i)&&(e.creationInfo={layer:i.layer,template:i.template},r.shift())}return r}export{H as avoidFeatureTemplateSelectionWithOnlyOneItem,O as createWorkflowSteps,G as fetchCandidates,P as fetchFullFeature,T as findLayerInfo,S as getVisualVariableAttributes,M as setUpFeatureAdd,B as setUpGeometryUpdate,C as sizeDefaults,R as startCreatingNewFeature,q as startUpdatingFeature,L as updateGraphicSymbolWhenRequired,Q as visualVariableInteractiveUpdate};
5
+ import e from"../../Graphic.js";import"../../core/has.js";import{handlesGroup as t}from"../../core/handleUtils.js";import{isSome as r,isNone as i,removeMaybe as a}from"../../core/maybe.js";import{whenOrAbort as n,eachAlways as s}from"../../core/promiseUtils.js";import{watch as o,initial as l,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as y}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as d,TransformationType as m}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as g}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as b}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{GraphicState as v}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as S}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as j}from"../../views/support/hitTestSelectUtils.js";function I(e){const t=e.sourceLayer;if("feature"!==t.type||!x(t.renderer))return{rotation:null,size:null};let i=null,a=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&r(h(t,e))));1===n.length&&(i=V(n[0],t));const s=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&d(t)===m.RealWorldSize&&r(g(t,e))));return 1===s.length&&(a=F(s[0],t)),{rotation:i,size:a}}function V(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,L((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function U(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function z(e,t,r){if(i(t))return 0;const{symbol:a}=b(t);if(i(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(W.icon,(await e(n,W.icon))[0])||W.icon}case"text":return n.size||W.text;case"line":return n.size||W.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return U(await t(n,e.scale/W.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/W.viewScaleSizeFactor;case"extrude":return n.size||e.scale/W.viewScaleSizeFactor;default:return 0}}function F(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=f[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>L(l(await z(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,L(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function L(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function x(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function M(e){const t=await w(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=p(e.symbol,t);r(i)&&(e.symbol=t)}function R(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function E(e,t,r){await T(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return T(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function T(e,t){const r=t.layer,i={...t.template.prototype.attributes};await k(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(R(r.geometryType),a)}async function k(t,r,a){const n=new e({sourceLayer:r,attributes:a}),{rotation:s,size:o}=I(n);let l=await w(n,{useSourceLayer:!0}),c=!1;for(const e of[o,s]){if(i(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(l,t.view),c=!0)}switch(c&&(l=await w(n,{useSourceLayer:!0})),l?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=l;break;case"simple-line":case"line-3d":t.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=l}}function A(e,t){return e&&e.find((e=>e.layer===t))}async function G(e,t,r,i){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await r.async((async()=>{const{results:a}=await n(j(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};a.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.includes("update")&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return n(s(a.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function P(e,t,r,i){if(0===e.length)return[];let a=null;const o=await r.async((async()=>{const{results:s}=await n(t.hitTest(r),i);if(0===s.length)return[];const o=new Set;a=s,a.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.includes("update")&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return n(s(o.map((({layer:e})=>{const{objectIdField:n,displayField:s}=e,o=[n];e.fieldsIndex.has(s)&&o.push(s);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?y({renderer:e.renderer,event:r}):0;return l.geometry=S(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(a.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[n]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function q(e,t,r,i){switch(t.type){case"3d":return G(e,t,r,i);case"2d":return P(e,t,r,i)}}async function D(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function Z(e,t,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(i(a))return;const n=t.attributes[a.field];if(r(n))a.initValue(n);else{const r=await a.getDefault(t.symbol,e.view);a.initValue(r),t.setAttribute(a.field,r),s=!0}})),s&&await M(t);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=r(o),c.enableScaling=r(l)),e.layer.elevationInfo=a.elevationInfo,e.update(t,c)}function Q(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function B(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function C(e,t,i,a){if(!r(t.geometry)||"point"!==t.geometry?.type)return;const n=a.rotation,s=Q(i.toolEventInfo);if(r(n)&&r(s))if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:i}=n;t.attributes[r]=i(s.angle,e)}const o=a.size,l=B(i.toolEventInfo);if(r(o)&&r(l))if("scale-stop"===l.type)o.isUpdatingInteractively=!1,o.initValue();else{o.isUpdatingInteractively=!0;const{field:r,getValue:i}=o;t.attributes[r]=i(l.xScale,e)}await M(t)}async function O(e,n,s,u,p){const y=e.clone();await M(y),u.map.add(s.layer),s.layer.add(y);const f=e.sourceLayer,d=u.whenLayerView(f),m=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return d.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){d.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let h=null,g=null;if("3d"===u.type){const e=new v({graphic:y});h=t([u.trackGraphicState(e),o((()=>e.displaying),(e=>{g=e?m():a(g)}),l)])}else g=m();await Z(s,y,f,n);let b=null;d.then((e=>b=e),(()=>{}));const w=n.size,S=n.rotation,j=o((()=>e.attributes),(async e=>{let t=!1;for(const a in e){const n=e[a];n!==y.attributes[a]&&(y.setAttribute(a,n),r(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),r(S)&&!S.isUpdatingInteractively&&S.field===a&&S.initValue(n),(i(b)||b.requiredFields.includes(a))&&(t=!0))}t&&await M(y)})),I=s.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return Z(s,t,f,n);await C(u,t,e,n),p(t.clone())})),V=s.on(["undo","redo"],(async e=>{p(e.graphics[0].clone())})),U=()=>{};return{interactive:{remove(){V.remove(),I.remove(),s.cancel(),j&&j.remove(),this.remove=U}},visual:{remove(){a(g),u.whenLayerView(f).then((e=>c((()=>!e.updating)))).then((()=>{a(h),s.layer.remove(y),this.remove=U}))}}}}const W={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function H(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function J(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function K(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=J(e.viewModel.featureTemplatesViewModel.items);r(i)&&(e.creationInfo={layer:i.layer,template:i.template},t.shift())}return t}export{K as avoidFeatureTemplateSelectionWithOnlyOneItem,H as createWorkflowSteps,q as fetchCandidates,D as fetchFullFeature,A as findLayerInfo,I as getVisualVariableAttributes,E as setUpFeatureAdd,O as setUpGeometryUpdate,W as sizeDefaults,T as startCreatingNewFeature,Z as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,C as visualVariableInteractiveUpdate};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as F}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const U="esri.widgets.Editor",V=s.getLogger(U);let x=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new A({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(V,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(V,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(V,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:d??!0,beforeBack:i??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],x.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],x.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],x.prototype,"allowedWorkflows",void 0),e([p()],x.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],x.prototype,"headingLevel",void 0),e([p()],x.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],x.prototype,"label",void 0),e([d("viewModel.layerInfos")],x.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],x.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],x.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],x.prototype,"snappingOptions",void 0),e([p()],x.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],x.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],x.prototype,"viewModel",void 0),e([p()],x.prototype,"visibleElements",void 0),e([c("visibleElements")],x.prototype,"castVisibleElements",null),e([F()],x.prototype,"_handleDelete",null),e([F()],x.prototype,"_handleAttachmentAdd",null),e([F()],x.prototype,"_handleAttachmentUpdate",null),e([F()],x.prototype,"_handleAttachmentDelete",null),e([F()],x.prototype,"_handleAdd",null),e([F()],x.prototype,"_handleEdit",null),e([F()],x.prototype,"_handleDone",null),x=e([h(U)],x);const D=x;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a,on as r,when as o,initial as n}from"../core/reactiveUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/snapping/SnappingOptions.js";import u from"./Attachments.js";import g from"./FeatureForm.js";import v from"./FeatureTemplates.js";import _ from"./Spinner.js";import w from"./Widget.js";import{workflowDeprecation as f}from"./Editor/deprecationUtils.js";import k from"./Editor/EditorViewModel.js";import{ItemList as y}from"./FeatureTemplates/ItemList.js";import{Heading as b,incrementHeadingLevel as C}from"./support/Heading.js";import M from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{classes as S}from"./support/widgetUtils.js";import{substitute as E}from"../intl/substitute.js";const B={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},P={undoRedoButtons:!1};function j(e){e.focus()}const L="esri.widgets.Editor",U=s.getLogger(L);let V=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new g,this._stateStack=[],this._attachments=new u({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new v({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new _,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=B.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new m,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new k,this.visibleElements={...P},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new M({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([a((()=>this.headingLevel),(e=>{this._featureForm.headingLevel=C(e),this._featureTemplates.headingLevel=C(e)}),n),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null}),n),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})}),n),r((()=>this.viewModel?.sketchViewModel),"create",(()=>{this.scheduleRender()})),r((()=>this.viewModel?.activeWorkflow),"cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),a((()=>this.supportingWidgetDefaults),(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))}),n),a((()=>this._attachments?.error),(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),a((()=>this.viewModel?.failures),(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:E(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),a((()=>this.viewModel?.state),(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),a((()=>[this._attachments?.selectedFile,this._attachments?.submitting]),(()=>this.scheduleRender())),o((()=>!this.viewModel?.activeWorkflow),(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...P,...e}}startCreateWorkflowAtFeatureTypeSelection(){return f(U,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return f(U,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return f(U,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return T("div",{class:B.base});const{state:a}=s,r=i(t)?T("calcite-scrim",null,this.renderPrompt(t)):null;return T("div",{class:B.base},s.syncing||e.submitting?this.renderProgressBar():null,T("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return T("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?E(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),T(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},T("div",{class:B.panelContentSection},T("div",{class:B.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(E(i.clickToFinishTemplate,{button:m})),v?T("div",{key:"attachments"},T("div",null,i.attachments),this._attachments.render()):null)),T("div",{class:this._prompt?"":B.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return T(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return T(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},T("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return T(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return T("div",{class:B.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return T(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},T("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(h)))}renderControls(e){return T("div",{class:B.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(B.controlButton,B.button,"secondary"===s?B.buttonSecondary:"tertiary"===s?B.buttonTertiary:null,e?B.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=T("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:j},i.primary.label),o=a?T("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return T("div",{class:`${B.promptContainer}--${s}`},T("div",{class:B.promptHeader},T("calcite-icon",{icon:"exclamation-mark-triangle"}),T(b,{class:B.promptHeading,level:this.headingLevel},e)),T("div",{class:B.promptMessage},t),T("div",{class:B.promptDivider}),T("div",{class:B.promptActions},o,r))}renderProgressBar(){return T("div",{class:this.classes(B.progressBar),key:"progress-bar"})}renderButton(e){return T("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return T(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},T("div",{key:"edit-actions",class:B.panelContentSection},this.renderUpdateActions()),T("div",{key:"create-actions",class:B.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.editFeatures),T("div",{class:B.updateFeaturesActionButtons},T("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:B.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return T("div",null,T(b,{level:C(this.headingLevel)},e.createFeatures),T("div",{key:"templates",class:B.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=E(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return T(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},y({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return T("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:d??!0,beforeBack:i??null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},T("calcite-popover-manager",{autoClose:s,class:B.panelToolbar},T("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed",placement:"bottom"},T("div",{class:B.snappingControlsPopover},h.render())),T("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:B.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[T("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),T("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),T("div",{class:S(B.panelContent,B.scroller)},t,c?T("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){this._snappingPopover?.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=h(t);return a&&i[a]&&`${i[a]}`||E(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],V.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],V.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],V.prototype,"allowedWorkflows",void 0),e([c()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],V.prototype,"headingLevel",void 0),e([c()],V.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],V.prototype,"label",void 0),e([l("viewModel.layerInfos")],V.prototype,"layerInfos",void 0),e([c(),F("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([c(),F("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([c(),F("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([c()],V.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],V.prototype,"view",void 0),e([c(),W(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([c()],V.prototype,"visibleElements",void 0),e([d("visibleElements")],V.prototype,"castVisibleElements",null),e([A()],V.prototype,"_handleDelete",null),e([A()],V.prototype,"_handleAttachmentAdd",null),e([A()],V.prototype,"_handleAttachmentUpdate",null),e([A()],V.prototype,"_handleAttachmentDelete",null),e([A()],V.prototype,"_handleAdd",null),e([A()],V.prototype,"_handleEdit",null),e([A()],V.prototype,"_handleDone",null),V=e([p(L)],V);const x=V;export{x 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.24/esri/copyright.txt for details.
4
4
  */
5
- import"../../../intl.js";import{binaryFindClosest as i}from"../../../core/arrayUtils.js";import{makeHandle as e,handlesGroup as t}from"../../../core/handleUtils.js";import{isNone as o,applySome as n,isSome as a,unwrapOr as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{formatDecimal as l,unitName as d}from"../../../core/unitFormatUtils.js";import{convertUnit as c}from"../../../core/unitUtils.js";import{CHART_CSS as m}from"../css.js";import{NO_DATA_VALUE as x,FORMAT_PRECISION as p,NOT_AVAILABLE as u,MAX_CHART_RATIO as g}from"./constants.js";import{getTranslatedLineTitle as f}from"./intlUtils.js";import{niceScale as h}from"./niceScale.js";import{loadChartsModule as b}from"../../support/chartUtils.js";import{isRTL as v}from"../../support/widgetUtils.js";import{isDarkTheme as T}from"../../support/widgetThemeUtils.js";import{substitute as A}from"../../../intl/substitute.js";import{formatNumber as C}from"../../../intl/number.js";const y="#f8f8f8",L="#a9a9a9",z="#323232",k="line",P="fill",S=15,F=12,w=30,M=.001,Y=.5,X=.5,I=30,W=.02,j=.02,H={sideSpacing:S,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,axisFontSize:9,axisFontWeight:"400",axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:L,axisTooltipFontSize:12,axisTooltipBackgroundColor:z,axisTooltipLabelColor:y,axisTooltipPaddingTop:Math.round(F/4),axisTooltipPaddingBottom:Math.round(F/4),axisTooltipPaddingHorizontal:Math.round(S/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(F/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(S/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:y,seriesTooltipLabelColor:z,seriesFillLighten:.9,seriesTooltipSpacing:F/2,seriesTooltipPaddingVertical:Math.round(S/4),seriesTooltipPaddingHorizontal:Math.round(S/4),tooltipBorderRadius:0},O={...H,axisGridStroke:z,axisLabelsColor:L,axisTooltipBackgroundColor:z,axisTooltipLabelColor:y,seriesTooltipBackgroundColor:z,seriesTooltipLabelColor:y,seriesFillLighten:-.75},U={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function B(i){const e=await b();r(i.abortOptions);const{am4core:n,am4charts:a}=e;n.options.minPolylineStep=Y,n.options.autoSetClassName=!0,n.options.animationsEnabled=!1;const s=T(),l=s?O:H;s&&n.useTheme(e.am4themes_dark);const d=n.create(i.container,a.XYChart);d.arrangeTooltips=!1,d.preloader.disabled=!0,d.zoomOutButton.disabled=!0;const c=v(i.container);d.rtl=c,d.padding(l.paddingTop,c?l.paddingLeft:l.paddingRight,l.paddingBottom,c?l.paddingRight:l.paddingLeft);const m=d.plotContainer.background;m.strokeWidth=0,m.strokeOpacity=0,m.stroke=null;const x=d.xAxes.push(new a.ValueAxis),p=d.yAxes.push(new a.ValueAxis),u={params:i,amCharts4Index:e,amChart:d,xAxis:x,yAxis:p,series:new Map,data:null,messages:null,theme:l,zooming:!1,pointerIsOver:!1};d.cursor=E(u),D(u),G(u),R(u);const g=[ei(u,i.onRangeChange),oi(u,i.onCursorPositionChange),ti(u)];let f=null,h=!1;const A=()=>{o(f)||("undefined"!=typeof window&&"cancelIdleCallback"in window?window.cancelIdleCallback(f):clearTimeout(f),f=null)};return{...u,destroy(){h=!0,A(),t(g).remove(),d.dispose()},update(i){if(i.data===u.data&&i.messages===u.messages)return;if(A(),h)return;const e=()=>{h||(f=null,V(u,i))};f="undefined"!=typeof window&&"requestIdleCallback"in window?window.requestIdleCallback(e,{timeout:I}):setTimeout(e,I)},zoomOut(){h||(u.yAxis.zoom({start:0,end:1},!1,!0),u.xAxis.zoom({start:0,end:1},!1,!0))}}}function E(i){const e=new i.amCharts4Index.am4charts.XYCursor;return e.trackable=!0,e.lineY.disabled=!0,e.behavior="zoomXY",e}function D(i){const e=i.theme,t=i.amChart.tooltip,{am4core:o}=i.amCharts4Index;t.id="series-tooltip",t.fitPointerToBounds=!0,t.pointerOrientation="vertical",t.zIndex=-1,t.getFillFromObject=!1,t.label.fontSize=e.seriesTooltipFontSize,t.label.fill=o.color(e.seriesTooltipLabelColor),t.label.padding(e.seriesTooltipPaddingVertical,e.seriesTooltipPaddingHorizontal,e.seriesTooltipPaddingVertical,e.seriesTooltipPaddingHorizontal),t.background.cornerRadius=e.tooltipBorderRadius,t.background.stroke=null,t.background.fill=o.color(e.seriesTooltipBackgroundColor),t.background.padding(0,0,0,0),t.adapter.add("dy",(()=>e.seriesTooltipSpacing*(t.background.pointerY<=0?1:-1))),v(i.params.container)&&(t.label.textAlign="middle")}function G(i){const{xAxis:e,theme:t}=i,{am4core:o}=i.amCharts4Index;e.numberFormatter=di(i,"distance"),e.strictMinMax=!0,e.cursorTooltipEnabled=!1,e.title.visible=!1;const n=e.renderer;n.line.visible=!1,n.minGridDistance=t.xAxisMinGridDistance,n.minLabelPosition=t.xAxisMinLabelPosition,n.maxLabelPosition=t.xAxisMaxLabelPosition,n.fontWeight=t.axisFontWeight,n.fontSize=t.axisFontSize,n.baseGrid.disabled=!0;const a=n.labels.template;a.fontSize=t.axisLabelsFontSize,a.fontWeight=t.axisLabelsFontWeight,a.fill=o.color(t.axisLabelsColor),a.paddingTop=t.xAxisLabelsSpacing,a.horizontalCenter="left",a.paddingLeft=0;const s=e.tooltip;s.id="axis-tooltip",s.background.fill=o.color(t.axisTooltipBackgroundColor),s.background.stroke=null,s.background.padding(0,0,0,0),s.label.fontSize=t.axisTooltipFontSize,s.label.fill=o.color(t.axisTooltipLabelColor),s.label.padding(t.axisTooltipPaddingTop,t.axisTooltipPaddingHorizontal,t.axisTooltipPaddingBottom,t.axisTooltipPaddingHorizontal);const r=n.grid.template;r.strokeOpacity=1,r.stroke=o.color(t.axisGridStroke)}function R(i){const{yAxis:e,theme:t}=i,{am4core:o}=i.amCharts4Index;e.numberFormatter=di(i,"elevation"),e.title.visible=!1,e.cursorTooltipEnabled=!1,e.strictMinMax=!0,e.baseValue=x;const n=e.renderer;n.inside=!0,n.line.opacity=0,n.line.visible=!1,n.minGridDistance=t.yAxisMinGridDistance,n.minLabelPosition=t.yAxisMinLabelPosition,n.maxLabelPosition=t.yAxisMaxLabelPosition,n.fontWeight=t.axisFontWeight,n.fontSize=t.axisFontSize,n.baseGrid.disabled=!0;const a=n.labels.template;a.fontSize=t.axisLabelsFontSize,a.fontWeight=t.axisLabelsFontWeight,a.fill=o.color(t.axisLabelsColor),a.verticalCenter="bottom",a.paddingLeft=t.yAxisLabelSpacing,a.paddingBottom=0;const s=n.grid.template;s.strokeOpacity=1,s.stroke=o.color(t.axisGridStroke),v(i.params.container)&&(n.opposite=!0,a.textAlign="middle",a.paddingLeft=0,a.paddingRight=t.yAxisLabelSpacing)}function V(i,{data:e,messages:t}){const o=a(e)&&e.refined;i.amChart.cursor.disabled=!o,i.amChart.htmlContainer.classList.toggle(m.cursorEnabled,o);const s=i.data!==e,r=n(i.data,(i=>i.effectiveUnits))!==n(e,(i=>i.effectiveUnits));i.data=e,i.messages=t,s&&($(i),_(i)),r&&(i.yAxis.invalidateLabels(),i.xAxis.invalidateLabels()),ni(i)}function $(i){const{xAxis:e,yAxis:t}=i,{minX:o,maxX:n,minY:a,maxY:s}=Z({data:i.data,pixelWidth:e.pixelWidth,pixelHeight:t.pixelHeight});e.min=o,e.max=n,t.min=a,t.max=s}function Z({data:i,pixelWidth:e,pixelHeight:t}){if(o(i))return U;const a=i.statistics,s=0,r=n(a,(i=>i.maxDistance));let l=n(a,(i=>i.minElevation)),d=n(a,(i=>i.maxElevation));if(o(r)||o(l)||o(d))return U;const m=Math.max(r-s,M);let x=Math.max(d-l,M);const p=i.effectiveUnits;if(i.dynamicElevationRange){const i=c(m,p.distance,p.elevation);x=Math.max(x,i/g)}return l-=j*x,d=l+x+W*x,[l,d]=h(l,d,10),x=d-l,i.uniformScaling?q({data:i,bounds:{minX:s,maxX:r,minY:l,maxY:d},pixelWidth:e,pixelHeight:t,centered:!0}):{minX:s,maxX:s+m,minY:l,maxY:l+x}}function q({data:i,bounds:e,pixelWidth:t,pixelHeight:n,centered:a}){if(o(i))return e;let{minX:s,maxX:r,minY:l,maxY:d}=e;const m=r-s,x=d-l,p=i.effectiveUnits,u=c(x,p.elevation,p.distance)/n/(m/t);return u>=1?[s,r]=N([s,r],u,a):[l,d]=N([l,d],1/u,a),{minX:s,maxX:r,minY:l,maxY:d}}function N([i,e],t,o){const n=(e-i)*t;if(o){const t=(i+e)/2-n/2;return[t,t+n]}return[i,i+n]}function _(i){const{amChart:e,data:t}=i;if(o(t)||0===t.lines.length)return void e.series.clear();const a=new Map,s=new Set(e.series.values),r=t.lines.length;for(let o=0;o<r;o++){const l=t.lines[o];let d=i.series.get(l.id);d?(n(d.fill,(i=>s.delete(i))),s.delete(d.line)):(d=Q(i,l),n(d.fill,(i=>e.series.push(i))),e.series.push(d.line)),a.set(d.id,d);const c=r-o-1;n(d.fill,(i=>i.zIndex=c)),d.line.zIndex=r+c,J(i,d,l)}i.series=a;for(const o of s)e.series.removeValue(o)}function J(i,{line:e,fill:t},o){const{theme:a}=i,{am4core:r}=i.amCharts4Index,{r:l,g:d,b:c,a:m}=o.color,x=r.color({r:l,g:d,b:c,a:m}),p=s(o.samples,[]),u=p.length>0;e.stroke=x,e.visible=u,n(t,(i=>{i.visible=u,i.fill=x.lighten(a.seriesFillLighten)}));const g=p.length,f=e.data;if(f.length===g){for(let i=0;i<g;++i)K(f[i],p[i]);e.invalidateRawData(),n(t,(i=>i.invalidateRawData()))}else e.data=p,n(t,(i=>i.data=p))}function K(i,e){i.x=e.x,i.y=e.y,i.z=e.z,i.distance=e.distance,i.elevation=e.elevation}function Q(i,e){const{id:t}=e,o=ii(i,`${k}-${t}`);o.strokeWidth=e.chartStrokeWidth,o.dy=e.chartStrokeOffsetY;let n=null;return e.chartFillEnabled&&(n=ii(i,`${P}-${t}`),n.fillOpacity=1),{id:t,line:o,fill:n}}function ii(i,e){const t=new i.amCharts4Index.am4charts.LineSeries;t.id=e,t.showOnInit=!1,t.simplifiedProcessing=!0,t.minDistance=X,t.excludeFromTotal=!0,t.clickable=!1,t.contextMenuDisabled=!0,t.cursorHoverEnabled=!1,t.cursorTooltipEnabled=!1,t.connect=!1,t.fill=null,t.stroke=null;const o="distance";t.dataFields.valueX=o;const n="elevation";return t.dataFields.valueY=n,t}function ei(i,t){const{amChart:n,xAxis:a,yAxis:s}=i;let r=!1;const l=()=>{const{data:e}=i;if(!r||o(e)||!e.uniformScaling)return;r=!1;const{minX:t,maxX:l,minY:d,maxY:c}=q({data:i.data,bounds:{minX:a.minZoomed,maxX:a.maxZoomed,minY:s.minZoomed,maxY:s.maxZoomed},pixelWidth:a.pixelWidth,pixelHeight:s.pixelHeight,centered:!0});a.zoomToValues(t,l,!0),s.zoomToValues(d,c,!0),n.validate(),ni(i)},d=()=>{t(i.xAxis.zoomFactor,i.yAxis.zoomFactor)},c=e=>{i.zooming=e,ni(i)},m=[n.events.on("down",(()=>c(!0))),n.events.on("up",(()=>c(!1))),n.cursor.events.on("zoomended",(()=>{r=!0})),a.events.on("startendchanged",l),s.events.on("startendchanged",l),a.events.on("rangechangeended",d),s.events.on("rangechangeended",d)];return e((()=>{m.forEach((i=>i.dispose()))}))}function ti({xAxis:i,yAxis:t}){const o=i=>()=>{i.renderer.grid.each((i=>{i.visible="none"!==i.dataItem.label.dom.getAttribute("display")}))},n=[i.events.on("rangechangeended",o(i)),i.events.on("validated",o(i)),t.events.on("rangechangeended",o(t)),t.events.on("validated",o(t))];return e((()=>{n.forEach((i=>i.dispose()))}))}function oi(i,t){const{amChart:o,xAxis:n,yAxis:a}=i,{cursor:s,events:r}=o,l=e=>{i.pointerIsOver=e,ni(i)},d=()=>{l(!1),t(null,null)},c=[s.events.on("cursorpositionchanged",(()=>{if(!i.pointerIsOver)return;ni(i);const e=n.toAxisPosition(s.xPosition),o=a.toAxisPosition(s.yPosition);t(e,o)})),r.on("over",(()=>l(!0))),r.on("out",d),r.on("blur",d)];return e((()=>{c.forEach((i=>i.dispose()))}))}function ni(i){const{amChart:e,xAxis:t,data:n,theme:s,zooming:r,pointerIsOver:l}=i;if(i.amChart.tooltip.hide(),i.xAxis.hideTooltip(),!l)return;if(r)return;if(o(n)||!n.refined)return;const d=ai(i);if(a(d)){const{cursor:o,tooltip:n}=e;o.show(0),o.validate(),n.text=d.text,n.show(0),n.validate();const a=d.y-n.contentHeight-s.seriesTooltipSpacing;n.pointerOrientation=a<w?"up":"down",n.pointTo(d,!0),n.validate();const r=t.tooltip;r.text=li(i),r.show(0),r.validate()}}function ai(i){const{amChart:e,yAxis:t,data:a}=i;if(o(a))return null;const s=a.lines.map((e=>({line:e,y:n(ci(i,e),(i=>i.elevation))}))).sort(si),r=s.length?s[0].y:null;if(o(r))return null;const l=e.cursor,d=t.measuredHeight,c=d+e.pixelPaddingTop;return{text:s.map((({y:e,line:t})=>ri(i,t,e))).join("\n"),x:l.point.x+l.parent.pixelX+e.pixelPaddingLeft,y:c-t.valueToPosition(r)*d}}function si({y:i},{y:e}){return o(i)?1:o(e)?-1:e-i}function ri(i,e,t){const{data:n,messages:s}=i;if(o(n)||o(s))return"";const r=A(s.chartTooltip,{name:f(e,s),elevation:a(t)?l(s,t,n.effectiveUnits.elevation,p):u});return`[${e.color.toHex()}]●[/] ${r}`}function li(i){const{data:e,messages:t}=i;if(o(e)||o(t))return"";const n=e.lines[0],s=n?ci(i,n):null;return a(s)?l(t,s.distance,e.effectiveUnits.distance,p):"-"}function di(i,e){const t=i.xAxis.numberFormatter.clone();return t.format=(t,n,a)=>{const{messages:s,data:r}=i;if(o(s)||o(r)||"string"==typeof t)return"";return`${C(t,{maximumFractionDigits:a})} ${d(s,r.effectiveUnits[e],"abbr")}`},t}function ci({amChart:e,xAxis:t},o){const n=s(o.samples,[]);if(0===n.length)return null;const a=t.toAxisPosition(e.cursor.xPosition),r=t.positionToValue(a);return i(n,r,(i=>i.distance))}export{B as createChart,Z as getAdjustedBounds};
5
+ import"../../../intl.js";import{binaryFindClosest as i}from"../../../core/arrayUtils.js";import{makeHandle as e,handlesGroup as t}from"../../../core/handleUtils.js";import{isNone as o,applySome as n,isSome as a,unwrapOr as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{formatDecimal as l,unitName as d}from"../../../core/unitFormatUtils.js";import{convertUnit as c}from"../../../core/unitUtils.js";import{CHART_CSS as m}from"../css.js";import{NO_DATA_VALUE as x,FORMAT_PRECISION as p,NOT_AVAILABLE as u,MAX_CHART_RATIO as g}from"./constants.js";import{getTranslatedLineTitle as f}from"./intlUtils.js";import{niceScale as h}from"./niceScale.js";import{loadChartsModule as b}from"../../support/chartUtils.js";import{isRTL as v}from"../../support/widgetUtils.js";import{isDarkTheme as T}from"../../support/widgetThemeUtils.js";import{substitute as A}from"../../../intl/substitute.js";import{formatNumber as C}from"../../../intl/number.js";const y="#f8f8f8",L="#a9a9a9",z="#323232",k="line",P="fill",S=15,F=12,w=30,M=.001,Y=.5,X=.5,I=30,W=.02,j=.02,H={sideSpacing:S,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,axisFontSize:9,axisFontWeight:"400",axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:L,axisTooltipFontSize:12,axisTooltipBackgroundColor:z,axisTooltipLabelColor:y,axisTooltipPaddingTop:Math.round(F/4),axisTooltipPaddingBottom:Math.round(F/4),axisTooltipPaddingHorizontal:Math.round(S/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(F/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(S/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:y,seriesTooltipLabelColor:z,seriesFillLighten:.9,seriesTooltipSpacing:F/2,seriesTooltipPaddingVertical:Math.round(S/4),seriesTooltipPaddingHorizontal:Math.round(S/4),tooltipBorderRadius:0},O={...H,axisGridStroke:z,axisLabelsColor:L,axisTooltipBackgroundColor:z,axisTooltipLabelColor:y,seriesTooltipBackgroundColor:z,seriesTooltipLabelColor:y,seriesFillLighten:-.75},U={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function B(i){const e=await b(),{am4core:n,am4charts:a}=e;r(i.abortOptions);const{options:s}=n;s.minPolylineStep=Y,s.autoSetClassName=!0,s.animationsEnabled=!1;const l=T(),d=l?O:H;l&&n.useTheme(e.am4themes_dark);const c=n.create(i.container,a.XYChart);c.arrangeTooltips=!1,c.preloader.disabled=!0,c.zoomOutButton.disabled=!0;const m=v(i.container);c.rtl=m,c.padding(d.paddingTop,m?d.paddingLeft:d.paddingRight,d.paddingBottom,m?d.paddingRight:d.paddingLeft);const x=c.plotContainer.background;x.strokeWidth=0,x.strokeOpacity=0,x.stroke=null;const p=c.xAxes.push(new a.ValueAxis),u=c.yAxes.push(new a.ValueAxis),g={params:i,amCharts4Index:e,amChart:c,xAxis:p,yAxis:u,series:new Map,data:null,messages:null,theme:d,zooming:!1,pointerIsOver:!1};c.cursor=E(g),D(g),G(g),R(g);const f=[ei(g,i.onRangeChange),oi(g,i.onCursorPositionChange),ti(g)];let h=null,A=!1;const C=()=>{o(h)||("undefined"!=typeof window&&"cancelIdleCallback"in window?window.cancelIdleCallback(h):clearTimeout(h),h=null)};return{...g,destroy(){A=!0,C(),t(f).remove(),c.dispose()},update(i){if(i.data===g.data&&i.messages===g.messages)return;if(C(),A)return;const e=()=>{A||(h=null,V(g,i))};h="undefined"!=typeof window&&"requestIdleCallback"in window?window.requestIdleCallback(e,{timeout:I}):setTimeout(e,I)},zoomOut(){A||(g.yAxis.zoom({start:0,end:1},!1,!0),g.xAxis.zoom({start:0,end:1},!1,!0))}}}function E(i){const e=new i.amCharts4Index.am4charts.XYCursor;return e.trackable=!0,e.lineY.disabled=!0,e.behavior="zoomXY",e}function D(i){const e=i.theme,t=i.amChart.tooltip,{am4core:o}=i.amCharts4Index;t.id="series-tooltip",t.fitPointerToBounds=!0,t.pointerOrientation="vertical",t.zIndex=-1,t.getFillFromObject=!1,t.label.fontSize=e.seriesTooltipFontSize,t.label.fill=o.color(e.seriesTooltipLabelColor),t.label.padding(e.seriesTooltipPaddingVertical,e.seriesTooltipPaddingHorizontal,e.seriesTooltipPaddingVertical,e.seriesTooltipPaddingHorizontal),t.background.cornerRadius=e.tooltipBorderRadius,t.background.stroke=null,t.background.fill=o.color(e.seriesTooltipBackgroundColor),t.background.padding(0,0,0,0),t.adapter.add("dy",(()=>e.seriesTooltipSpacing*(t.background.pointerY<=0?1:-1))),v(i.params.container)&&(t.label.textAlign="middle")}function G(i){const{xAxis:e,theme:t}=i,{am4core:o}=i.amCharts4Index;e.numberFormatter=di(i,"distance"),e.strictMinMax=!0,e.cursorTooltipEnabled=!1,e.title.visible=!1;const n=e.renderer;n.line.visible=!1,n.minGridDistance=t.xAxisMinGridDistance,n.minLabelPosition=t.xAxisMinLabelPosition,n.maxLabelPosition=t.xAxisMaxLabelPosition,n.fontWeight=t.axisFontWeight,n.fontSize=t.axisFontSize,n.baseGrid.disabled=!0;const a=n.labels.template;a.fontSize=t.axisLabelsFontSize,a.fontWeight=t.axisLabelsFontWeight,a.fill=o.color(t.axisLabelsColor),a.paddingTop=t.xAxisLabelsSpacing,a.horizontalCenter="left",a.paddingLeft=0;const s=e.tooltip;s.id="axis-tooltip",s.background.fill=o.color(t.axisTooltipBackgroundColor),s.background.stroke=null,s.background.padding(0,0,0,0),s.label.fontSize=t.axisTooltipFontSize,s.label.fill=o.color(t.axisTooltipLabelColor),s.label.padding(t.axisTooltipPaddingTop,t.axisTooltipPaddingHorizontal,t.axisTooltipPaddingBottom,t.axisTooltipPaddingHorizontal);const r=n.grid.template;r.strokeOpacity=1,r.stroke=o.color(t.axisGridStroke)}function R(i){const{yAxis:e,theme:t}=i,{am4core:o}=i.amCharts4Index;e.numberFormatter=di(i,"elevation"),e.title.visible=!1,e.cursorTooltipEnabled=!1,e.strictMinMax=!0,e.baseValue=x;const n=e.renderer;n.inside=!0,n.line.opacity=0,n.line.visible=!1,n.minGridDistance=t.yAxisMinGridDistance,n.minLabelPosition=t.yAxisMinLabelPosition,n.maxLabelPosition=t.yAxisMaxLabelPosition,n.fontWeight=t.axisFontWeight,n.fontSize=t.axisFontSize,n.baseGrid.disabled=!0;const a=n.labels.template;a.fontSize=t.axisLabelsFontSize,a.fontWeight=t.axisLabelsFontWeight,a.fill=o.color(t.axisLabelsColor),a.verticalCenter="bottom",a.paddingLeft=t.yAxisLabelSpacing,a.paddingBottom=0;const s=n.grid.template;s.strokeOpacity=1,s.stroke=o.color(t.axisGridStroke),v(i.params.container)&&(n.opposite=!0,a.textAlign="middle",a.paddingLeft=0,a.paddingRight=t.yAxisLabelSpacing)}function V(i,{data:e,messages:t}){const{htmlContainer:o}=i.amChart;if(!o)return;const s=a(e)&&e.refined;i.amChart.cursor.disabled=!s,o.classList.toggle(m.cursorEnabled,s);const r=i.data!==e,l=n(i.data,(i=>i.effectiveUnits))!==n(e,(i=>i.effectiveUnits));i.data=e,i.messages=t,r&&($(i),_(i)),l&&(i.yAxis.invalidateLabels(),i.xAxis.invalidateLabels()),ni(i)}function $(i){const{xAxis:e,yAxis:t}=i,{minX:o,maxX:n,minY:a,maxY:s}=Z({data:i.data,pixelWidth:e.pixelWidth,pixelHeight:t.pixelHeight});e.min=o,e.max=n,t.min=a,t.max=s}function Z({data:i,pixelWidth:e,pixelHeight:t}){if(o(i))return U;const a=i.statistics,s=0,r=n(a,(i=>i.maxDistance));let l=n(a,(i=>i.minElevation)),d=n(a,(i=>i.maxElevation));if(o(r)||o(l)||o(d))return U;const m=Math.max(r-s,M);let x=Math.max(d-l,M);const p=i.effectiveUnits;if(i.dynamicElevationRange){const i=c(m,p.distance,p.elevation);x=Math.max(x,i/g)}return l-=j*x,d=l+x+W*x,[l,d]=h(l,d,10),x=d-l,i.uniformScaling?q({data:i,bounds:{minX:s,maxX:r,minY:l,maxY:d},pixelWidth:e,pixelHeight:t,centered:!0}):{minX:s,maxX:s+m,minY:l,maxY:l+x}}function q({data:i,bounds:e,pixelWidth:t,pixelHeight:n,centered:a}){if(o(i))return e;let{minX:s,maxX:r,minY:l,maxY:d}=e;const m=r-s,x=d-l,p=i.effectiveUnits,u=c(x,p.elevation,p.distance)/n/(m/t);return u>=1?[s,r]=N([s,r],u,a):[l,d]=N([l,d],1/u,a),{minX:s,maxX:r,minY:l,maxY:d}}function N([i,e],t,o){const n=(e-i)*t;if(o){const t=(i+e)/2-n/2;return[t,t+n]}return[i,i+n]}function _(i){const{amChart:e,data:t}=i;if(o(t)||0===t.lines.length)return void e.series.clear();const a=new Map,s=new Set(e.series.values),r=t.lines.length;for(let o=0;o<r;o++){const l=t.lines[o];let d=i.series.get(l.id);d?(n(d.fill,(i=>s.delete(i))),s.delete(d.line)):(d=Q(i,l),n(d.fill,(i=>e.series.push(i))),e.series.push(d.line)),a.set(d.id,d);const c=r-o-1;n(d.fill,(i=>i.zIndex=c)),d.line.zIndex=r+c,J(i,d,l)}i.series=a;for(const o of s)e.series.removeValue(o)}function J(i,{line:e,fill:t},o){const{theme:a}=i,{am4core:r}=i.amCharts4Index,{r:l,g:d,b:c,a:m}=o.color,x=r.color({r:l,g:d,b:c,a:m}),p=s(o.samples,[]),u=p.length>0;e.stroke=x,e.visible=u,n(t,(i=>{i.visible=u,i.fill=x.lighten(a.seriesFillLighten)}));const g=p.length,f=e.data;if(f.length===g){for(let i=0;i<g;++i)K(f[i],p[i]);e.invalidateRawData(),n(t,(i=>i.invalidateRawData()))}else e.data=p,n(t,(i=>i.data=p))}function K(i,e){i.x=e.x,i.y=e.y,i.z=e.z,i.distance=e.distance,i.elevation=e.elevation}function Q(i,e){const{id:t}=e,o=ii(i,`${k}-${t}`);o.strokeWidth=e.chartStrokeWidth,o.dy=e.chartStrokeOffsetY;let n=null;return e.chartFillEnabled&&(n=ii(i,`${P}-${t}`),n.fillOpacity=1),{id:t,line:o,fill:n}}function ii(i,e){const t=new i.amCharts4Index.am4charts.LineSeries;t.id=e,t.showOnInit=!1,t.simplifiedProcessing=!0,t.minDistance=X,t.excludeFromTotal=!0,t.clickable=!1,t.contextMenuDisabled=!0,t.cursorHoverEnabled=!1,t.cursorTooltipEnabled=!1,t.connect=!1,t.fill=null,t.stroke=null;const o="distance";t.dataFields.valueX=o;const n="elevation";return t.dataFields.valueY=n,t}function ei(i,t){const{amChart:n,xAxis:a,yAxis:s}=i;let r=!1;const l=()=>{const{data:e}=i;if(!r||o(e)||!e.uniformScaling)return;r=!1;const{minX:t,maxX:l,minY:d,maxY:c}=q({data:i.data,bounds:{minX:a.minZoomed,maxX:a.maxZoomed,minY:s.minZoomed,maxY:s.maxZoomed},pixelWidth:a.pixelWidth,pixelHeight:s.pixelHeight,centered:!0});a.zoomToValues(t,l,!0),s.zoomToValues(d,c,!0),n.validate(),ni(i)},d=()=>{t(i.xAxis.zoomFactor,i.yAxis.zoomFactor)},c=e=>{i.zooming=e,ni(i)},m=[n.events.on("down",(()=>c(!0))),n.events.on("up",(()=>c(!1))),n.cursor.events.on("zoomended",(()=>{r=!0})),a.events.on("startendchanged",l),s.events.on("startendchanged",l),a.events.on("rangechangeended",d),s.events.on("rangechangeended",d)];return e((()=>{m.forEach((i=>i.dispose()))}))}function ti({xAxis:i,yAxis:t}){const o=i=>()=>{i.renderer.grid.each((i=>{i.visible="none"!==i.dataItem.label.dom.getAttribute("display")}))},n=[i.events.on("rangechangeended",o(i)),i.events.on("validated",o(i)),t.events.on("rangechangeended",o(t)),t.events.on("validated",o(t))];return e((()=>{n.forEach((i=>i.dispose()))}))}function oi(i,t){const{amChart:o,xAxis:n,yAxis:a}=i,{cursor:s,events:r}=o,l=e=>{i.pointerIsOver=e,ni(i)},d=()=>{l(!1),t(null,null)},c=[s.events.on("cursorpositionchanged",(()=>{if(!i.pointerIsOver)return;ni(i);const e=n.toAxisPosition(s.xPosition),o=a.toAxisPosition(s.yPosition);t(e,o)})),r.on("over",(()=>l(!0))),r.on("out",d),r.on("blur",d)];return e((()=>{c.forEach((i=>i.dispose()))}))}function ni(i){const{amChart:e,xAxis:t,data:n,theme:s,zooming:r,pointerIsOver:l}=i;if(i.amChart.tooltip.hide(),i.xAxis.hideTooltip(),!l)return;if(r)return;if(o(n)||!n.refined)return;const d=ai(i);if(a(d)){const{cursor:o,tooltip:n}=e;o.show(0),o.validate(),n.text=d.text,n.show(0),n.validate();const a=d.y-n.contentHeight-s.seriesTooltipSpacing;n.pointerOrientation=a<w?"up":"down",n.pointTo(d,!0),n.validate();const r=t.tooltip;r.text=li(i),r.show(0),r.validate()}}function ai(i){const{amChart:e,yAxis:t,data:a}=i;if(o(a))return null;const s=a.lines.map((e=>({line:e,y:n(ci(i,e),(i=>i.elevation))}))).sort(si),r=s.length?s[0].y:null;if(o(r))return null;const l=e.cursor,d=t.measuredHeight,c=d+e.pixelPaddingTop;return{text:s.map((({y:e,line:t})=>ri(i,t,e))).join("\n"),x:l.point.x+l.parent.pixelX+e.pixelPaddingLeft,y:c-t.valueToPosition(r)*d}}function si({y:i},{y:e}){return o(i)?1:o(e)?-1:e-i}function ri(i,e,t){const{data:n,messages:s}=i;if(o(n)||o(s))return"";const r=A(s.chartTooltip,{name:f(e,s),elevation:a(t)?l(s,t,n.effectiveUnits.elevation,p):u});return`[${e.color.toHex()}]●[/] ${r}`}function li(i){const{data:e,messages:t}=i;if(o(e)||o(t))return"";const n=e.lines[0],s=n?ci(i,n):null;return a(s)?l(t,s.distance,e.effectiveUnits.distance,p):"-"}function di(i,e){const t=i.xAxis.numberFormatter.clone();return t.format=(t,n,a)=>{const{messages:s,data:r}=i;if(o(s)||o(r)||"string"==typeof t)return"";return`${C(t,{maximumFractionDigits:a})} ${d(s,r.effectiveUnits[e],"abbr")}`},t}function ci({amChart:e,xAxis:t},o){const n=s(o.samples,[]);if(0===n.length)return null;const a=t.toAxisPosition(e.cursor.xPosition),r=t.positionToValue(a);return i(n,r,(i=>i.distance))}export{B as createChart,Z as getAdjustedBounds};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import{isNone as e,isSome as s,destroyMaybe as i,applySome as o,abortMaybe as r}from"../core/maybe.js";import{memoize as n}from"../core/memoize.js";import{createTask as a}from"../core/promiseUtils.js";import{watch as l,initial as c}from"../core/reactiveUtils.js";import{aliasOf as h}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import u from"./Widget.js";import{CSS as m}from"./ElevationProfile/css.js";import _ from"./ElevationProfile/ElevationProfileViewModel.js";import C from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as v}from"./ElevationProfile/components/Legend.js";import{SettingsButton as g}from"./ElevationProfile/components/SettingsButton.js";import{createChart as f}from"./ElevationProfile/support/chartUtils.js";import{ElevationProfileErrorState as y,PORTRAIT_MODE_PIXEL_BREAKPOINT as b,ElevationProfileState as k,LARGE_CHART_SAMPLES as w}from"./ElevationProfile/support/constants.js";import{onResize as S}from"./support/widgetUtils.js";import{messageBundle as B}from"./support/decorators/messageBundle.js";import{tsx as M}from"./support/jsxFactory.js";var P;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(P||(P={}));const E=[{type:P.Select},{type:P.Sketch}],j={[y.None]:null,[y.NoValidInput]:"noProfile",[y.NoVisibleProfiles]:"noProfile",[y.RefinedButNoChartData]:"noProfile",[y.TooComplex]:"tooComplex",[y.UnknownError]:"unknown",[y.InvalidGeometry]:"invalidGeometry",[y.InvalidElevationInfo]:"invalidElevationInfo"};let z=class extends u{constructor(t,e){super(t,e),this.viewModel=null,this.view=null,this.input=null,this.profiles=null,this.unitOptions=[],this.unit="metric",this.geodesicDistanceThreshold=1e5,this.visibleElements=new C,this.iconClass=m.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._portrait=!1,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=n(((t,e,s,i)=>({chart:t,data:e,stationary:s,messages:i}))),this._getDetailsPropsMemoized=n(((t,e)=>({effectiveUnits:t,profiles:e}))),t?.viewModel||(this._defaultViewModel=new _({view:t?.view}),this.viewModel=this._defaultViewModel)}initialize(){this._legend=new v(this._legendProps),this._settingsButton=new g(this._settingsButtonProps),this.own([l((()=>this._legendProps),(t=>this._legend.set(t))),l((()=>this._settingsButtonProps),(t=>this._settingsButton.set(t)))])}postInitialize(){this.own([l((()=>this._chartContainer),(()=>{this._destroyChart();const t=this._chartContainer;e(t)||(this._chartInitTask=a((e=>this._initializeChart(t,e))))}),c),l((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),c)])}destroy(){this._destroyChart(),s(this._defaultViewModel)&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy(),this._legend=i(this._legend),this._settingsButton=i(this._settingsButton)}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,!s(t)||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _legendProps(){return this._getDetailsPropsMemoized(this.viewModel.effectiveUnits,this._profilesArray)}get _profilesArray(){return this.profiles.toArray()}get _settingsButtonProps(){return{viewModel:this.viewModel,visibleElements:this.visibleElements}}render(){const{viewModel:t,visible:e}=this;return M("div",{key:this,class:this.classes({[m.base]:e,[m.esriWidget]:e,[m.esriWidgetDisabled]:e&&"disabled"===t.state,[m.portrait]:this._portrait,[m.refined]:1===t.progress}),"aria-label":this.messages.widgetLabel,afterCreate:t=>{this.own(S(t,(t=>{this._portrait=t.contentRect.width<b})))}},e&&this._renderContentForState())}_renderContentForState(){switch(this.viewModel.state){case k.Ready:return this._renderContentForReadyState();case k.Selecting:return this._renderContentForSelectingState();case k.Creating:return this._renderContentForCreatingState();case k.Selected:return this._renderContentForSelectedState();case k.Created:return this._renderContentForCreatedState();case k.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,s=this.messages;let i;return i=t&&e?s.readyPrompt:t?s.readyPromptCreateOnly:e?s.readyPromptSelectOnly:s.errors?.noProfile,this._renderContent({prompt:i,chart:!1,actions:E})}_renderContentForSelectingState(){const t=this.view;if(e(t))return null;const s=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:s,chart:!1,actions:[{type:P.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:s}=this;if(e(t))return null;const i=s.hasVertices?[{type:P.SketchCancel},{type:P.SketchDone,disabled:!s.tool.interaction.canStopCreating}]:[{type:P.Select},{type:P.Sketch,disabled:!0}];if(s.errorState===y.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const o=this._getErrorMessage();return o?this._renderContent({chart:!1,actions:i,prompt:o}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:E,prompt:t}):this._renderContent({chart:!0,actions:E})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:E,prompt:t}):this._renderContent({chart:!0,actions:E})}_getErrorMessage(){const t=j[this.viewModel.errorState];return this.messages?.errors?.[t]}_renderContent(t){const e=s(t.prompt)?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),i=s(this.viewModel.input);return[M("header",{key:"header",class:m.header},this._zoomOutButtonVisible&&this._renderZoomOutButton(),this.visibleElements.clearButton&&i&&this._renderClearButton(),this.visibleElements.settingsButton&&this._settingsButton.render()),M("div",{class:m.mainContainer},...e),this.visibleElements.legend&&this._legend.render(),this._renderActions(t)]}_renderZoomOutButton(){return M("button",{key:"zoom-out",class:m.zoomOutButton,bind:this,onclick:this._onZoomOutButtonClick,title:this.messages.zoomOut,type:"button"})}_onZoomOutButtonClick(){o(this._chart,(t=>t.zoomOut()))}_renderClearButton(){return M("button",{key:"clear-profile",class:m.clearButton,bind:this,onclick:this._onClearButtonClick,title:this.messages.clearProfile,type:"button"})}_onClearButtonClick(){this.viewModel.clear()}_renderPrompt(t){return[M("div",{key:"prompt-container",bind:this,class:m.promptContainer},M("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return[M("div",{key:"empty-chart-container",class:m.chartContainer})];const t=this._chartIsRefined||this._canRenderChart();if(!t)return[this._renderSpinner({size:"large"}),M("div",{key:"chart-container-empty",class:m.chartContainer})];const{chartData:e,progress:i}=this.viewModel;return[s(e)&&i>0&&i<1&&this._renderSpinner({size:t?"small":"large"}),M("div",{key:"chart-container",bind:this,class:m.chartContainer,afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved})]}_renderSpinner(t){return M("div",{key:"spinner",class:this.classes(m.chartSpinner,{[m.chartSpinnerSmall]:"small"===t.size}),afterCreate:this._onSpinnerAfterCreate,exitAnimation:this._onSpinnerExit})}_onSpinnerAfterCreate(t){requestAnimationFrame((()=>t.classList.add(m.chartSpinnerVisible)))}_onSpinnerExit(t,e){t.classList.remove(m.chartSpinnerVisible),setTimeout(e,200)}_canRenderChart(){const t=this.viewModel.chartData;if(e(t))return!1;if(!this.viewModel.inputIsSketched)return t.refined;let i=0;for(const{samples:e}of t.lines)i+=s(e)?e.length:0;return t.refined||i<=w}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case P.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onSketchButtonClick,className:m.sketchButton,label:this.messages.sketchButtonLabel});case P.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:m.sketchCancelButton,label:this.messagesCommon.cancel});case P.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:m.sketchDoneButton,label:this.messagesCommon.done});case P.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:m.selectButton,label:this.messages.selectButtonLabel});case P.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:m.selectCancelButton,label:this.messagesCommon.cancel})}})).filter(Boolean);return e.length?M("footer",{key:"footer",class:m.footer},...e):null}_renderAction({action:t,onClick:e,className:s,label:i}){return M("button",{key:`action-${t.type}`,class:this.classes(m.actionButton,s,{[m.buttonDisabled]:t.disabled}),bind:this,disabled:t.disabled,onclick:e,type:"button"},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_updateChart(t){const{data:i,chart:o,messages:r,stationary:n}=t;!e(o)&&!e(r)&&n&&this._canRenderChart()&&(o.update(t),this._chartIsRefined=s(i)&&i.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}async _initializeChart(t,e){this._chart=await f({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}}),this._updateChart(this._chartUpdateParams)}_destroyChart(){this._chartInitTask=r(this._chartInitTask),this._chart=i(this._chart),this._chartIsRefined=!1}};t([d({type:_})],z.prototype,"viewModel",void 0),t([h("viewModel.view")],z.prototype,"view",void 0),t([h("viewModel.input")],z.prototype,"input",void 0),t([h("viewModel.profiles")],z.prototype,"profiles",void 0),t([h("viewModel.unitOptions")],z.prototype,"unitOptions",void 0),t([h("viewModel.unit")],z.prototype,"unit",void 0),t([h("viewModel.geodesicDistanceThreshold")],z.prototype,"geodesicDistanceThreshold",void 0),t([d({type:C,nonNullable:!0})],z.prototype,"visibleElements",void 0),t([d()],z.prototype,"iconClass",void 0),t([h("messages.widgetLabel",{overridable:!0})],z.prototype,"label",void 0),t([h("viewModel.visible")],z.prototype,"visible",void 0),t([d(),B("esri/widgets/ElevationProfile/t9n/ElevationProfile")],z.prototype,"messages",void 0),t([d(),B("esri/t9n/common")],z.prototype,"messagesCommon",void 0),t([d(),B("esri/core/t9n/Units")],z.prototype,"messagesUnits",void 0),t([d()],z.prototype,"_chartContainer",void 0),t([d()],z.prototype,"_chart",void 0),t([d()],z.prototype,"_chartInitTask",void 0),t([d()],z.prototype,"_chartIsRefined",void 0),t([d()],z.prototype,"_settingsButton",void 0),t([d()],z.prototype,"_legend",void 0),t([d()],z.prototype,"_portrait",void 0),t([d()],z.prototype,"_zoomOutButtonVisible",void 0),t([d()],z.prototype,"_chartUpdateParams",null),t([d()],z.prototype,"_chartMessages",null),t([d()],z.prototype,"_legendProps",null),t([d()],z.prototype,"_profilesArray",null),t([d()],z.prototype,"_settingsButtonProps",null),z=t([p("esri.widgets.ElevationProfile")],z);const I=z;export{I as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import{equalsShallow as e}from"../core/lang.js";import{isSome as i,destroyMaybe as s,isNone as o,applySome as r,abortMaybe as n}from"../core/maybe.js";import{memoize as a}from"../core/memoize.js";import{createTask as l,createAbortError as c}from"../core/promiseUtils.js";import{watch as h,initial as d}from"../core/reactiveUtils.js";import{aliasOf as p}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/accessorSupport/ensureType.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import _ from"./Widget.js";import{CSS as C}from"./ElevationProfile/css.js";import v from"./ElevationProfile/ElevationProfileViewModel.js";import g from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as f}from"./ElevationProfile/components/Legend.js";import{SettingsButton as y}from"./ElevationProfile/components/SettingsButton.js";import{createChart as w}from"./ElevationProfile/support/chartUtils.js";import{ElevationProfileErrorState as b,PORTRAIT_MODE_PIXEL_BREAKPOINT as k,ElevationProfileState as S,LARGE_CHART_SAMPLES as B}from"./ElevationProfile/support/constants.js";import{onResize as M}from"./support/widgetUtils.js";import{messageBundle as P}from"./support/decorators/messageBundle.js";import{tsx as E}from"./support/jsxFactory.js";var j;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(j||(j={}));const z=[{type:j.Select},{type:j.Sketch}],I={[b.None]:null,[b.NoValidInput]:"noProfile",[b.NoVisibleProfiles]:"noProfile",[b.RefinedButNoChartData]:"noProfile",[b.TooComplex]:"tooComplex",[b.UnknownError]:"unknown",[b.InvalidGeometry]:"invalidGeometry",[b.InvalidElevationInfo]:"invalidElevationInfo"};let A=class extends _{constructor(t,e){super(t,e),this.viewModel=null,this.view=null,this.input=null,this.profiles=null,this.unitOptions=[],this.unit="metric",this.geodesicDistanceThreshold=1e5,this.visibleElements=new g,this.iconClass=C.widgetIcon,this.label=void 0,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._width=0,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=a(((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s}))),this._getDetailsPropsMemoized=a(((t,e)=>({effectiveUnits:t,profiles:e}))),t?.viewModel||(this._defaultViewModel=new v({view:t?.view}),this.viewModel=this._defaultViewModel)}initialize(){this._legend=new f(this._legendProps),this._settingsButton=new y(this._settingsButtonProps),this.own([h((()=>this._legendProps),(t=>this._legend.set(t))),h((()=>this._settingsButtonProps),(t=>this._settingsButton.set(t)))])}postInitialize(){this.own([h((()=>({container:this._chartContainer,width:this._width})),(({container:t,width:e})=>{this._destroyChart(),i(t)&&e>0&&this._initializeChart(t)}),{initial:!0,equals:e}),h((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),d)])}destroy(){this._destroyChart(),i(this._defaultViewModel)&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy(),this._legend=s(this._legend),this._settingsButton=s(this._settingsButton)}get _portrait(){return this._width<k}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,!i(t)||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _legendProps(){return this._getDetailsPropsMemoized(this.viewModel.effectiveUnits,this._profilesArray)}get _profilesArray(){return this.profiles.toArray()}get _settingsButtonProps(){return{viewModel:this.viewModel,visibleElements:this.visibleElements}}render(){const{viewModel:t,visible:e}=this;return E("div",{key:this,class:this.classes({[C.base]:e,[C.esriWidget]:e,[C.esriWidgetDisabled]:e&&"disabled"===t.state,[C.portrait]:this._portrait,[C.refined]:1===t.progress}),"aria-label":this.messages.widgetLabel,afterCreate:t=>{this.own(M(t,(t=>{this._width=t.contentRect.width})))}},e&&this._renderContentForState())}_renderContentForState(){switch(this.viewModel.state){case S.Ready:return this._renderContentForReadyState();case S.Selecting:return this._renderContentForSelectingState();case S.Creating:return this._renderContentForCreatingState();case S.Selected:return this._renderContentForSelectedState();case S.Created:return this._renderContentForCreatedState();case S.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,i=this.messages;let s;return s=t&&e?i.readyPrompt:t?i.readyPromptCreateOnly:e?i.readyPromptSelectOnly:i.errors?.noProfile,this._renderContent({prompt:s,chart:!1,actions:z})}_renderContentForSelectingState(){const t=this.view;if(o(t))return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:j.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(o(t))return null;const i=e.hasVertices?[{type:j.SketchCancel},{type:j.SketchDone,disabled:!e.tool.interaction.canStopCreating}]:[{type:j.Select},{type:j.Sketch,disabled:!0}];if(e.errorState===b.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:z,prompt:t}):this._renderContent({chart:!0,actions:z})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:z,prompt:t}):this._renderContent({chart:!0,actions:z})}_getErrorMessage(){const t=I[this.viewModel.errorState];return this.messages?.errors?.[t]}_renderContent(t){const e=i(t.prompt)?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),s=i(this.viewModel.input);return[E("header",{key:"header",class:C.header},this._zoomOutButtonVisible&&this._renderZoomOutButton(),this.visibleElements.clearButton&&s&&this._renderClearButton(),this.visibleElements.settingsButton&&this._settingsButton.render()),E("div",{class:C.mainContainer},...e),this.visibleElements.legend&&this._legend.render(),this._renderActions(t)]}_renderZoomOutButton(){return E("button",{key:"zoom-out",class:C.zoomOutButton,bind:this,onclick:this._onZoomOutButtonClick,title:this.messages.zoomOut,type:"button"})}_onZoomOutButtonClick(){r(this._chart,(t=>t.zoomOut()))}_renderClearButton(){return E("button",{key:"clear-profile",class:C.clearButton,bind:this,onclick:this._onClearButtonClick,title:this.messages.clearProfile,type:"button"})}_onClearButtonClick(){this.viewModel.clear()}_renderPrompt(t){return[E("div",{key:"prompt-container",bind:this,class:C.promptContainer},E("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return[E("div",{key:"empty-chart-container",class:C.chartContainer})];const t=this._chartIsRefined||this._canRenderChart();if(!t)return[this._renderSpinner({size:"large"}),E("div",{key:"chart-container-empty",class:C.chartContainer})];const{chartData:e,progress:s}=this.viewModel;return[i(e)&&s>0&&s<1&&this._renderSpinner({size:t?"small":"large"}),E("div",{key:"chart-container",bind:this,class:C.chartContainer,afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved})]}_renderSpinner(t){return E("div",{key:"spinner",class:this.classes(C.chartSpinner,{[C.chartSpinnerSmall]:"small"===t.size}),afterCreate:this._onSpinnerAfterCreate,exitAnimation:this._onSpinnerExit})}_onSpinnerAfterCreate(t){requestAnimationFrame((()=>t.classList.add(C.chartSpinnerVisible)))}_onSpinnerExit(t,e){t.classList.remove(C.chartSpinnerVisible),setTimeout(e,200)}_canRenderChart(){const t=this.viewModel.chartData;if(o(t))return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:s}of t.lines)e+=i(s)?s.length:0;return t.refined||e<=B}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case j.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onSketchButtonClick,className:C.sketchButton,label:this.messages.sketchButtonLabel});case j.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:C.sketchCancelButton,label:this.messagesCommon.cancel});case j.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:C.sketchDoneButton,label:this.messagesCommon.done});case j.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:C.selectButton,label:this.messages.selectButtonLabel});case j.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:C.selectCancelButton,label:this.messagesCommon.cancel})}})).filter(Boolean);return e.length?E("footer",{key:"footer",class:C.footer},...e):null}_renderAction({action:t,onClick:e,className:i,label:s}){return E("button",{key:`action-${t.type}`,class:this.classes(C.actionButton,i,{[C.buttonDisabled]:t.disabled}),bind:this,disabled:t.disabled,onclick:e,type:"button"},s)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_updateChart(t){const{data:e,chart:s,messages:r,stationary:n}=t;!o(s)&&!o(r)&&n&&this._canRenderChart()&&(s.update(t),this._chartIsRefined=i(e)&&e.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}_initializeChart(t){n(this._chartInitTask),this._chartInitTask=l((async e=>{const i=await w({container:t,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(i),c();this._chart=i,this._updateChart(this._chartUpdateParams)}))}_destroyChart(){this._chartInitTask=n(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([u({type:v})],A.prototype,"viewModel",void 0),t([p("viewModel.view")],A.prototype,"view",void 0),t([p("viewModel.input")],A.prototype,"input",void 0),t([p("viewModel.profiles")],A.prototype,"profiles",void 0),t([p("viewModel.unitOptions")],A.prototype,"unitOptions",void 0),t([p("viewModel.unit")],A.prototype,"unit",void 0),t([p("viewModel.geodesicDistanceThreshold")],A.prototype,"geodesicDistanceThreshold",void 0),t([u({type:g,nonNullable:!0})],A.prototype,"visibleElements",void 0),t([u()],A.prototype,"iconClass",void 0),t([p("messages.widgetLabel",{overridable:!0})],A.prototype,"label",void 0),t([p("viewModel.visible")],A.prototype,"visible",void 0),t([u(),P("esri/widgets/ElevationProfile/t9n/ElevationProfile")],A.prototype,"messages",void 0),t([u(),P("esri/t9n/common")],A.prototype,"messagesCommon",void 0),t([u(),P("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),t([u()],A.prototype,"_chartContainer",void 0),t([u()],A.prototype,"_chart",void 0),t([u()],A.prototype,"_chartInitTask",void 0),t([u()],A.prototype,"_chartIsRefined",void 0),t([u()],A.prototype,"_settingsButton",void 0),t([u()],A.prototype,"_legend",void 0),t([u()],A.prototype,"_width",void 0),t([u()],A.prototype,"_portrait",null),t([u()],A.prototype,"_zoomOutButtonVisible",void 0),t([u()],A.prototype,"_chartUpdateParams",null),t([u()],A.prototype,"_chartMessages",null),t([u()],A.prototype,"_legendProps",null),t([u()],A.prototype,"_profilesArray",null),t([u()],A.prototype,"_settingsButtonProps",null),A=t([m("esri.widgets.ElevationProfile")],A);const D=A;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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{init as t}from"../../core/watchUtils.js";import{aliasOf as o}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Attachments.js";import a from"../Widget.js";import p from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import n from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const c={base:"esri-feature-attachments"};let d=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new i,this.description=null,this.displayType=null,this.graphic=null,this.headingLevel=2,this.title=null,this.viewModel=new p}initialize(){this._featureElementInfo=new n,t(this,["viewModel.description","viewModel.title","headingLevel"],(()=>this._setupFeatureElementInfo())),t(this,"viewModel.graphic",(e=>this.attachmentsWidget.graphic=e))}destroy(){this.attachmentsWidget.destroy(),this._featureElementInfo.destroy()}render(){const{attachmentsWidget:e}=this;return l("div",{class:c.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:o}=this;this._featureElementInfo.set({description:e,title:t,headingLevel:o})}};e([s({readOnly:!0})],d.prototype,"attachmentsWidget",void 0),e([o("viewModel.description")],d.prototype,"description",void 0),e([o("attachmentsWidget.displayType")],d.prototype,"displayType",void 0),e([o("viewModel.graphic")],d.prototype,"graphic",void 0),e([s()],d.prototype,"headingLevel",void 0),e([o("viewModel.title")],d.prototype,"title",void 0),e([s({type:p})],d.prototype,"viewModel",void 0),d=e([r("esri.widgets.Feature.FeatureAttachments")],d);const h=d;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as s}from"../../core/reactiveUtils.js";import{aliasOf as i}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Attachments.js";import p from"../Widget.js";import n from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import l from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as c}from"../support/jsxFactory.js";const d={base:"esri-feature-attachments"};let h=class extends p{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new a,this.description=null,this.displayType=null,this.graphic=null,this.headingLevel=2,this.title=null,this.viewModel=new n}initialize(){this._featureElementInfo=new l,this.own([t((()=>[this.viewModel?.description,this.viewModel?.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),s),t((()=>this.viewModel?.graphic),(e=>this.attachmentsWidget.graphic=e),s)])}destroy(){this.attachmentsWidget.destroy(),this._featureElementInfo.destroy()}render(){const{attachmentsWidget:e}=this;return c("div",{class:d.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:s}=this;this._featureElementInfo.set({description:e,title:t,headingLevel:s})}};e([o({readOnly:!0})],h.prototype,"attachmentsWidget",void 0),e([i("viewModel.description")],h.prototype,"description",void 0),e([i("attachmentsWidget.displayType")],h.prototype,"displayType",void 0),e([i("viewModel.graphic")],h.prototype,"graphic",void 0),e([o()],h.prototype,"headingLevel",void 0),e([i("viewModel.title")],h.prototype,"title",void 0),e([o({type:n})],h.prototype,"viewModel",void 0),h=e([r("esri.widgets.Feature.FeatureAttachments")],h);const m=h;export{m 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import e from"../../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../../core/HandleOwner.js";import{init as s}from"../../../core/watchUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{graphicCallback as c}from"../support/featureUtils.js";let n=class extends(o(e)){constructor(t){super(t),this._loadingPromise=null,this.created=null,this.creator=null,this.destroyer=null,this.graphic=null,this.handles.add(s(this,"creator",(t=>{this._destroyContent(),this._createContent(t)})))}destroy(){this._destroyContent()}get state(){return this._loadingPromise?"loading":"ready"}_destroyContent(){const{created:t,graphic:r,destroyer:e}=this;t&&(c(e,{graphic:r}).catch((()=>null)),this._set("created",null))}async _createContent(t){const{graphic:r}=this,e=c(t,{graphic:r}).catch((()=>null));this._loadingPromise=e,this.notifyChange("state");const o=await e;e===this._loadingPromise&&(this._loadingPromise=null,this.notifyChange("state"),this._set("created",o))}};t([i({readOnly:!0})],n.prototype,"created",void 0),t([i()],n.prototype,"creator",void 0),t([i()],n.prototype,"destroyer",void 0),t([i({type:r})],n.prototype,"graphic",void 0),t([i({readOnly:!0})],n.prototype,"state",null),n=t([a("esri.widgets.Feature.FeatureContent.FeatureContentViewModel")],n);const p=n;export{p as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{HandleOwnerMixin as o}from"../../../core/HandleOwner.js";import{watch as s,initial as i}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{graphicCallback as n}from"../support/featureUtils.js";let p=class extends(o(r)){constructor(t){super(t),this._loadingPromise=null,this.created=null,this.creator=null,this.destroyer=null,this.graphic=null,this.handles.add(s((()=>this.creator),(t=>{this._destroyContent(),this._createContent(t)}),i))}destroy(){this._destroyContent()}get state(){return this._loadingPromise?"loading":"ready"}_destroyContent(){const{created:t,graphic:e,destroyer:r}=this;t&&(n(r,{graphic:e}).catch((()=>null)),this._set("created",null))}async _createContent(t){const{graphic:e}=this,r=n(t,{graphic:e}).catch((()=>null));this._loadingPromise=r,this.notifyChange("state");const o=await r;r===this._loadingPromise&&(this._loadingPromise=null,this.notifyChange("state"),this._set("created",o))}};t([a({readOnly:!0})],p.prototype,"created",void 0),t([a()],p.prototype,"creator",void 0),t([a()],p.prototype,"destroyer",void 0),t([a({type:e})],p.prototype,"graphic",void 0),t([a({readOnly:!0})],p.prototype,"state",null),p=t([c("esri.widgets.Feature.FeatureContent.FeatureContentViewModel")],p);const l=p;export{l 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{x as o}from"../../../chunks/languageUtils.js";import r from"../../../core/Accessor.js";import{HandleOwnerMixin as n}from"../../../core/HandleOwner.js";import{throttle as s}from"../../../core/throttle.js";import{init as i}from"../../../core/watchUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import m from"../../../popup/content/TextContent.js";import d from"../../../popup/ElementExpressionInfo.js";import h from"../FeatureContent/FeatureContentViewModel.js";import u from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcadeUtils as _,createCompiledExpression as y}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends(n(r)){constructor(e){super(e),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.view=null,this._cancelQuery=()=>{const{_abortController:e}=this;e&&e.abort(),this._abortController=null},this._createVM=()=>{const e=this.contentElement?.type;this.contentElementViewModel?.destroy();const t="fields"===e?new u:"media"===e?new f:"text"===e?new h:null;this._set("contentElementViewModel",t)},this._compile=async()=>{this._cancelQuery();const e=new AbortController;this._abortController=e,await this._compileExpression(),this._abortController===e&&(this._abortController=null)},this._compileThrottled=s(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:e,graphic:t,interceptor:r,spatialReference:n,map:s,view:i,_abortController:l}=this;if(!(e&&t&&n&&s))return void this._set("contentElement",null);const p=await _();if(l!==this._abortController)return;const d=await y({arcadeUtils:p,expressionInfo:e,graphic:t,interceptor:r,map:s,spatialReference:n,view:i});if(!d||"esri.arcade.Dictionary"!==d.declaredClass)return void this._set("contentElement",null);const h=await o(d,l.signal),u=h?.type,f="media"===u?c.fromJSON(h):"text"===u?m.fromJSON(h):"fields"===u?a.fromJSON(h):null;this._set("contentElement",f)},this.handles.add([i(this,["expressionInfo","graphic","map","spatialReference","view"],this._compileThrottled),i(this,"contentElement",this._createVM)])}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference||null}set spatialReference(e){void 0!==e?this._override("spatialReference",e):this._clearOverride("spatialReference")}get state(){const{_abortController:e,contentElement:t,contentElementViewModel:o}=this;return e?"loading":t||o?"ready":"disabled"}get map(){return this.view?.map||null}set map(e){void 0!==e?this._override("map",e):this._clearOverride("map")}};e([l()],j.prototype,"_abortController",void 0),e([l({type:d})],j.prototype,"expressionInfo",void 0),e([l({type:t})],j.prototype,"graphic",void 0),e([l({readOnly:!0})],j.prototype,"contentElement",void 0),e([l({readOnly:!0})],j.prototype,"contentElementViewModel",void 0),e([l()],j.prototype,"interceptor",void 0),e([l()],j.prototype,"spatialReference",null),e([l({readOnly:!0})],j.prototype,"state",null),e([l()],j.prototype,"map",null),e([l()],j.prototype,"view",void 0),j=e([p("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],j);const E=j;export{E as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{x as o}from"../../../chunks/languageUtils.js";import r from"../../../core/Accessor.js";import{HandleOwnerMixin as n}from"../../../core/HandleOwner.js";import{watch as s,initial as i}from"../../../core/reactiveUtils.js";import{throttle as l}from"../../../core/throttle.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import c from"../../../popup/content/FieldsContent.js";import m from"../../../popup/content/MediaContent.js";import h from"../../../popup/content/TextContent.js";import d from"../../../popup/ElementExpressionInfo.js";import u from"../FeatureContent/FeatureContentViewModel.js";import f from"../FeatureFields/FeatureFieldsViewModel.js";import _ from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcadeUtils as y,createCompiledExpression as w}from"../support/arcadeFeatureUtils.js";const j=1;let v=class extends(n(r)){constructor(e){super(e),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.view=null,this._cancelQuery=()=>{const{_abortController:e}=this;e&&e.abort(),this._abortController=null},this._createVM=()=>{const e=this.contentElement?.type;this.contentElementViewModel?.destroy();const t="fields"===e?new f:"media"===e?new _:"text"===e?new u:null;this._set("contentElementViewModel",t)},this._compile=async()=>{this._cancelQuery();const e=new AbortController;this._abortController=e,await this._compileExpression(),this._abortController===e&&(this._abortController=null)},this._compileThrottled=l(this._compile,j,this),this._compileExpression=async()=>{const{expressionInfo:e,graphic:t,interceptor:r,spatialReference:n,map:s,view:i,_abortController:l}=this;if(!(e&&t&&n&&s))return void this._set("contentElement",null);const p=await y();if(l!==this._abortController)return;const a=await w({arcadeUtils:p,expressionInfo:e,graphic:t,interceptor:r,map:s,spatialReference:n,view:i});if(!a||"esri.arcade.Dictionary"!==a.declaredClass)return void this._set("contentElement",null);const d=await o(a,l.signal),u=d?.type,f="media"===u?m.fromJSON(d):"text"===u?h.fromJSON(d):"fields"===u?c.fromJSON(d):null;this._set("contentElement",f)},this.handles.add([s((()=>[this.expressionInfo,this.graphic,this.map,this.spatialReference,this.view]),(()=>this._compileThrottled()),i),s((()=>[this.contentElement]),(()=>this._createVM()),i)])}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference||null}set spatialReference(e){void 0!==e?this._override("spatialReference",e):this._clearOverride("spatialReference")}get state(){const{_abortController:e,contentElement:t,contentElementViewModel:o}=this;return e?"loading":t||o?"ready":"disabled"}get map(){return this.view?.map||null}set map(e){void 0!==e?this._override("map",e):this._clearOverride("map")}};e([p()],v.prototype,"_abortController",void 0),e([p({type:d})],v.prototype,"expressionInfo",void 0),e([p({type:t})],v.prototype,"graphic",void 0),e([p({readOnly:!0})],v.prototype,"contentElement",void 0),e([p({readOnly:!0})],v.prototype,"contentElementViewModel",void 0),e([p()],v.prototype,"interceptor",void 0),e([p()],v.prototype,"spatialReference",null),e([p({readOnly:!0})],v.prototype,"state",null),e([p()],v.prototype,"map",null),e([p()],v.prototype,"view",void 0),v=e([a("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],v);const E=v;export{E 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{init as t}from"../../core/watchUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Widget.js";import r from"./FeatureContent.js";import n from"./FeatureFields.js";import d from"./FeatureMedia.js";import a from"./FeatureExpression/FeatureExpressionViewModel.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const p={iconLoading:"esri-icon-loading-indicator esri-rotating",base:"esri-feature-expression",loadingSpinnerContainer:"esri-feature__loading-container",spinner:"esri-feature__loading-spinner"};let c=class extends i{constructor(e,t){super(e,t),this.viewModel=new a}initialize(){t(this,"viewModel.contentElementViewModel",(()=>this._setupExpressionWidget()))}destroy(){this._destroyContentWidget()}renderLoading(){return l("div",{key:"loading-container",class:p.loadingSpinnerContainer},l("span",{class:this.classes(p.iconLoading,p.spinner)}))}render(){const{state:e}=this.viewModel;return l("div",{class:p.base},"loading"===e?this.renderLoading():"disabled"===e?null:this._contentWidget?.render())}_destroyContentWidget(){const{_contentWidget:e}=this;e&&(e.viewModel=null,e.destroy()),this._contentWidget=null}_setupExpressionWidget(){const{contentElementViewModel:e,contentElement:t}=this.viewModel,o=t?.type;this._destroyContentWidget();const s=e?"fields"===o?new n({viewModel:e}):"media"===o?new d({viewModel:e}):"text"===o?new r({viewModel:e}):null:null;this._contentWidget=s,this.scheduleRender()}};e([o({type:a})],c.prototype,"viewModel",void 0),c=e([s("esri.widgets.Feature.FeatureExpression")],c);const u=c;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Widget.js";import n from"./FeatureContent.js";import d from"./FeatureFields.js";import a from"./FeatureMedia.js";import l from"./FeatureExpression/FeatureExpressionViewModel.js";import"../support/widgetUtils.js";import{tsx as p}from"../support/jsxFactory.js";const c={iconLoading:"esri-icon-loading-indicator esri-rotating",base:"esri-feature-expression",loadingSpinnerContainer:"esri-feature__loading-container",spinner:"esri-feature__loading-spinner"};let u=class extends r{constructor(e,t){super(e,t),this.viewModel=new l}initialize(){this.own(t((()=>this.viewModel?.contentElementViewModel),(()=>this._setupExpressionWidget()),o))}destroy(){this._destroyContentWidget()}renderLoading(){return p("div",{key:"loading-container",class:c.loadingSpinnerContainer},p("span",{class:this.classes(c.iconLoading,c.spinner)}))}render(){const{state:e}=this.viewModel;return p("div",{class:c.base},"loading"===e?this.renderLoading():"disabled"===e?null:this._contentWidget?.render())}_destroyContentWidget(){const{_contentWidget:e}=this;e&&(e.viewModel=null,e.destroy()),this._contentWidget=null}_setupExpressionWidget(){const{contentElementViewModel:e,contentElement:t}=this.viewModel,o=t?.type;this._destroyContentWidget();const s=e?"fields"===o?new d({viewModel:e}):"media"===o?new a({viewModel:e}):"text"===o?new n({viewModel:e}):null:null;this._contentWidget=s,this.scheduleRender()}};e([s({type:l})],u.prototype,"viewModel",void 0),u=e([i("esri.widgets.Feature.FeatureExpression")],u);const m=u;export{m 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{init as t}from"../../core/watchUtils.js";import{aliasOf as s}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Widget.js";import l from"./FeatureFields/FeatureFieldsViewModel.js";import a from"./support/FeatureElementInfo.js";import{autoLink as d}from"../support/uriUtils.js";import"../support/widgetUtils.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as p}from"../support/jsxFactory.js";const f={base:"esri-feature-fields",fieldHeader:"esri-feature-fields__field-header",fieldData:"esri-feature-fields__field-data",fieldDataDate:"esri-feature-fields__field-data--date",esriTable:"esri-widget__table"};let u=class extends o{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attributes=null,this.description=null,this.expressionInfos=null,this.fieldInfos=null,this.title=null,this.viewModel=new l,this.messages=null,this.messagesURIUtils=null}initialize(){this._featureElementInfo=new a,t(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo()))}destroy(){this._featureElementInfo.destroy()}renderFieldInfo(e,t){const{attributes:s}=this.viewModel,r=e.fieldName,i=e.label||r,o=s?null==s[r]?"":s[r]:"",l=!(!e.format||!e.format.dateFormat),a="number"==typeof o&&!l?this._forceLTR(o):d(this.messagesURIUtils,o),n={[f.fieldDataDate]:l};return p("tr",{key:`fields-element-info-row-${r}-${t}`},p("th",{key:`fields-element-info-row-header-${r}-${t}`,class:f.fieldHeader,innerHTML:i}),p("td",{key:`fields-element-info-row-data-${r}-${t}`,class:this.classes(f.fieldData,n),innerHTML:a}))}renderFields(){const{formattedFieldInfos:e}=this.viewModel;return e?.length?p("table",{class:f.esriTable,summary:this.messages.fieldsSummary},p("tbody",null,e.map(((e,t)=>this.renderFieldInfo(e,t))))):null}render(){return p("div",{class:f.base},this._featureElementInfo?.render(),this.renderFields())}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_forceLTR(e){return`&lrm;${e}`}};e([s("viewModel.attributes")],u.prototype,"attributes",void 0),e([s("viewModel.description")],u.prototype,"description",void 0),e([s("viewModel.expressionInfos")],u.prototype,"expressionInfos",void 0),e([s("viewModel.fieldInfos")],u.prototype,"fieldInfos",void 0),e([s("viewModel.title")],u.prototype,"title",void 0),e([r({type:l})],u.prototype,"viewModel",void 0),e([r(),n("esri/widgets/Feature/t9n/Feature")],u.prototype,"messages",void 0),e([r(),n("esri/widgets/support/t9n/uriUtils")],u.prototype,"messagesURIUtils",void 0),u=e([i("esri.widgets.Feature.FeatureFields")],u);const m=u;export{m as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as s}from"../../core/reactiveUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import l from"../Widget.js";import a from"./FeatureFields/FeatureFieldsViewModel.js";import d from"./support/FeatureElementInfo.js";import{autoLink as n}from"../support/uriUtils.js";import"../support/widgetUtils.js";import{messageBundle as p}from"../support/decorators/messageBundle.js";import{tsx as f}from"../support/jsxFactory.js";const u={base:"esri-feature-fields",fieldHeader:"esri-feature-fields__field-header",fieldData:"esri-feature-fields__field-data",fieldDataDate:"esri-feature-fields__field-data--date",esriTable:"esri-widget__table"};let m=class extends l{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attributes=null,this.description=null,this.expressionInfos=null,this.fieldInfos=null,this.title=null,this.viewModel=new a,this.messages=null,this.messagesURIUtils=null}initialize(){this._featureElementInfo=new d,this.own(t((()=>[this.viewModel?.description,this.viewModel?.title]),(()=>this._setupFeatureElementInfo()),s))}destroy(){this._featureElementInfo.destroy()}renderFieldInfo(e,t){const{attributes:s}=this.viewModel,r=e.fieldName,i=e.label||r,o=s?null==s[r]?"":s[r]:"",l=!(!e.format||!e.format.dateFormat),a="number"==typeof o&&!l?this._forceLTR(o):n(this.messagesURIUtils,o),d={[u.fieldDataDate]:l};return f("tr",{key:`fields-element-info-row-${r}-${t}`},f("th",{key:`fields-element-info-row-header-${r}-${t}`,class:u.fieldHeader,innerHTML:i}),f("td",{key:`fields-element-info-row-data-${r}-${t}`,class:this.classes(u.fieldData,d),innerHTML:a}))}renderFields(){const{formattedFieldInfos:e}=this.viewModel;return e?.length?f("table",{class:u.esriTable,summary:this.messages.fieldsSummary},f("tbody",null,e.map(((e,t)=>this.renderFieldInfo(e,t))))):null}render(){return f("div",{class:u.base},this._featureElementInfo?.render(),this.renderFields())}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_forceLTR(e){return`&lrm;${e}`}};e([r("viewModel.attributes")],m.prototype,"attributes",void 0),e([r("viewModel.description")],m.prototype,"description",void 0),e([r("viewModel.expressionInfos")],m.prototype,"expressionInfos",void 0),e([r("viewModel.fieldInfos")],m.prototype,"fieldInfos",void 0),e([r("viewModel.title")],m.prototype,"title",void 0),e([i({type:a})],m.prototype,"viewModel",void 0),e([i(),p("esri/widgets/Feature/t9n/Feature")],m.prototype,"messages",void 0),e([i(),p("esri/widgets/support/t9n/uriUtils")],m.prototype,"messagesURIUtils",void 0),m=e([o("esri.widgets.Feature.FeatureFields")],m);const c=m;export{c 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.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as r}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import i from"../../core/Accessor.js";import o from"../../core/Handles.js";import s from"../../core/Logger.js";import{isSome as n}from"../../core/maybe.js";import{isAbortError as a,eachAlways as l}from"../../core/promiseUtils.js";import{throttle as p}from"../../core/throttle.js";import{init as c}from"../../core/watchUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as u}from"../../core/accessorSupport/decorators/cast.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../popup/content/TextContent.js";import m from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import _ from"./FeatureContent/FeatureContentViewModel.js";import y from"./FeatureExpression/FeatureExpressionViewModel.js";import b from"./FeatureFields/FeatureFieldsViewModel.js";import g from"./FeatureMedia/FeatureMediaViewModel.js";import{createCompiledExpressions as A}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as I,preRequestCallback as M,createfieldInfoMap as x,getAllFieldInfos as w,getSourceLayer as v,substituteFieldsInLinksAndAttributes as C,isExpressionField as F,isRelatedField as E,formatEditInfo as T,graphicCallback as V,queryUpdatedFeature as P,formatAttributes as j}from"./support/featureUtils.js";import{queryLayerInfos as L,queryRelatedFeatures as R,setRelatedFeatures as O,getRelatedFieldInfo as S,createRelatedInfo as k,updateRelatedInfo as U}from"./support/relatedFeatureUtils.js";var N;const q=1,D="content-view-models",Q="esri.widgets.FeatureViewModel",B=s.getLogger(Q),G={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0};let H=N=class extends i{constructor(e){super(e),this._handles=new o,this._error=null,this._featureAbortController=null,this.graphicChangedThrottled=p(this._graphicChanged,q,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...G},this.content=null,this.contentViewModels=[],this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&t.attachmentsContent||"custom"===e.type&&t.customContent||"fields"===e.type&&t.fieldsContent||"media"===e.type&&t.mediaContent||"text"===e.type&&t.textContent||"expression"===e.type&&t.expressionContent},this._handles.add(c(this,["graphic","_effectivePopupTemplate","abilities"],(()=>this.graphicChangedThrottled())))}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this._handles.destroy(),this._handles=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return n(this.graphic)?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return x(w(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return v(this.graphic)}castAbilities(e){return{...G,...e}}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?e.clone():null)}get spatialReference(){return this.get("view.spatialReference")||null}set spatialReference(e){void 0!==e?this._override("spatialReference",e):this._clearOverride("spatialReference")}get map(){return this.get("view.map")||null}set map(e){void 0!==e?this._override("map",e):this._clearOverride("map")}get waitingForContent(){return!!this._featureAbortController}setActiveMedia(e,t){const r=this.contentViewModels[e];r instanceof g&&r.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof g&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof g&&t.previous()}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(r){a(r)||(this._error=r,B.error("error","The popupTemplate could not be displayed for this feature.",{error:r,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))):"string"==typeof e?this._compileText(new h({text:e}),0).text:e}_destroyContentViewModels(){this._handles?.remove(D),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_setExpressionContentVM(e,t){const{formattedAttributes:r}=this,{contentElement:i,contentElementViewModel:o}=e,s=i?.type;o&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:i,contentElementIndex:t,formattedAttributes:r}),o.set(this._createFieldsVMParams(i,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:i,contentElementIndex:t,formattedAttributes:r}),o.set(this._createMediaVMParams(i,t))),"text"===s&&o.set(this._createTextVMParams(i)))}_compileExpression(e,t){const{expressionInfo:r}=e,{graphic:i,map:o,spatialReference:s,view:n}=this,a=new y({expressionInfo:r,graphic:i,interceptor:N.interceptor,map:o,spatialReference:s,view:n});return this.contentViewModels[t]=a,this._handles.add(c(a,"contentElementViewModel",(()=>this._setExpressionContentVM(a,t))),D),e}_compileAttachments(e,t){const{graphic:r}=this,{description:i,title:o}=e;return this.contentViewModels[t]=new m({graphic:r,...this._compileTitleAndDesc({title:o,description:i})}),e}_compileCustom(e,t){const{graphic:r}=this,{creator:i,destroyer:o}=e;return this.contentViewModels[t]=new _({graphic:r,creator:i,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:r,_sourceLayer:i,graphic:o,formattedAttributes:s,_expressionAttributes:n}=this,{attributes:a}=o,l=s.global;return{title:C({attributes:a,fieldInfoMap:r,globalAttributes:l,expressionAttributes:n,layer:i,text:e}),description:C({attributes:a,fieldInfoMap:r,globalAttributes:l,expressionAttributes:n,layer:i,text:t})}}_createFieldsVMParams(e,t){const{_effectivePopupTemplate:r,formattedAttributes:i}=this,o={...i.global,...i.content[t]},s=(e?.fieldInfos||r?.fieldInfos)?.filter((({fieldName:e})=>F(e)||E(e)||o.hasOwnProperty(e))),n=r?.expressionInfos,{description:a,title:l}=e;return{attributes:o,expressionInfos:n,fieldInfos:s,...this._compileTitleAndDesc({title:l,description:a})}}_compileFields(e,t){const r=e.clone(),i=new b(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=i,r.fieldInfos=i.formattedFieldInfos.slice(0),r}_createMediaVMParams(e,t){const{abilities:r,graphic:i,_fieldInfoMap:o,formattedAttributes:s,_effectivePopupTemplate:n,relatedInfos:a,_sourceLayer:l,_expressionAttributes:p}=this,{attributes:c}=i,{description:d,mediaInfos:u,title:f}=e;return{abilities:{chartAnimation:r.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,layer:l,fieldInfoMap:o,formattedAttributes:{...s.global,...s.content[t]},expressionAttributes:p,mediaInfos:u,popupTemplate:n,relatedInfos:a,...this._compileTitleAndDesc({title:f,description:d})}}_compileMedia(e,t){const r=e.clone(),i=new g(this._createMediaVMParams(e,t));return r.mediaInfos=i.formattedMediaInfos.slice(0),this.contentViewModels[t]=i,r}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:r,_sourceLayer:i,_expressionAttributes:o}=this;if(e&&e.text){const{attributes:s}=t,n=this.formattedAttributes.global;e.text=C({attributes:s,fieldInfoMap:r,globalAttributes:n,expressionAttributes:o,layer:i,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const r=e.clone();return this.contentViewModels[t]=new _(this._createTextVMParams(r)),r}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:r}=this;if(!e)return;const{lastEditInfoEnabled:i}=e,o=t?.editFieldsInfo;return i&&o?T(o,r.attributes):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:r,graphic:i,_expressionAttributes:o}=this,{attributes:s}=i,n=this.formattedAttributes.global;return C({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:o,layer:r,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this,r=e?.title;return V(r,{graphic:t})}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this,r=e?.content;return V(r,{graphic:t})}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:r,graphic:i,_effectivePopupTemplate:o,spatialReference:s,map:n,view:a}=this,{content:{value:p},title:{value:c}}=await l({content:this._getContent(),title:this._getTitle()});if(t!==this._featureAbortController||!i)return;await P({graphic:i,popupTemplate:o,layer:r,spatialReference:s},e);const{expressionAttributes:{value:d}}=await l({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:A({expressionInfos:o?.expressionInfos,spatialReference:s,graphic:i,map:n,interceptor:N.interceptor,view:a})});t===this._featureAbortController&&i&&(this._expressionAttributes=d,this._graphicExpressionAttributes={...i.attributes,...d},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(c)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:r}){const{_effectivePopupTemplate:i,graphic:o,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l}=this;r.content[t]=j({fieldInfos:i?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:r}){if(e.fieldInfos){const{graphic:i,relatedInfos:o,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a}=this;r.content[t]=j({fieldInfos:e.fieldInfos,graphic:i,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:o})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:r,relatedInfos:i,_sourceLayer:o,_fieldInfoMap:s,_graphicExpressionAttributes:n}=this,a=t?.fieldInfos,l={global:j({fieldInfos:a,graphic:r,attributes:n,layer:o,fieldInfoMap:s,relatedInfos:i}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l})})),l}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:r}=this;return this._queryRelatedInfos(t,w(r),e)}async _queryRelatedInfos(e,t,r){const{relatedInfos:i,_sourceLayer:o}=this;i.clear();const s=n(o.associatedLayer)?await o.associatedLayer.load(r):o;if(!s)return;const a=t.filter((e=>e&&E(e.fieldName)));if(!a||!a.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const l=await L({relatedInfos:i,layer:s},r);Object.keys(l).forEach((e=>{const t=i.get(e.toString()),r=l[e]?.value;t&&r&&(t.layerInfo=r.data)}));const p=await R({graphic:e,relatedInfos:i,layer:s},r);Object.keys(p).forEach((e=>{O(p[e]?.value,i.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:r}=this,i=S(e.fieldName);if(!i)return;const{layerId:o,fieldName:s}=i;if(!o)return;const n=r.get(o.toString())||k(o,t);n&&(U({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(o,n))}};H.interceptor=new r(I,M),e([d()],H.prototype,"_error",void 0),e([d()],H.prototype,"_featureAbortController",void 0),e([d({readOnly:!0})],H.prototype,"_effectivePopupTemplate",null),e([d({readOnly:!0})],H.prototype,"_fieldInfoMap",null),e([d({readOnly:!0})],H.prototype,"_sourceLayer",null),e([d()],H.prototype,"abilities",void 0),e([u("abilities")],H.prototype,"castAbilities",null),e([d({readOnly:!0})],H.prototype,"content",void 0),e([d({readOnly:!0})],H.prototype,"contentViewModels",void 0),e([d({type:Boolean})],H.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],H.prototype,"state",null),e([d({readOnly:!0})],H.prototype,"formattedAttributes",void 0),e([d({type:t,value:null})],H.prototype,"graphic",null),e([d({readOnly:!0})],H.prototype,"lastEditInfo",void 0),e([d({readOnly:!0})],H.prototype,"relatedInfos",void 0),e([d()],H.prototype,"spatialReference",null),e([d({readOnly:!0})],H.prototype,"title",void 0),e([d()],H.prototype,"map",null),e([d({readOnly:!0})],H.prototype,"waitingForContent",null),e([d()],H.prototype,"view",void 0),H=N=e([f(Q)],H);const z=H;export{z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as r}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import i from"../../core/Accessor.js";import o from"../../core/Handles.js";import s from"../../core/Logger.js";import{isSome as n}from"../../core/maybe.js";import{isAbortError as a,eachAlways as l}from"../../core/promiseUtils.js";import{watch as p,initial as c}from"../../core/reactiveUtils.js";import{throttle as d}from"../../core/throttle.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as f}from"../../core/accessorSupport/decorators/cast.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../popup/content/TextContent.js";import _ from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import y from"./FeatureContent/FeatureContentViewModel.js";import b from"./FeatureExpression/FeatureExpressionViewModel.js";import g from"./FeatureFields/FeatureFieldsViewModel.js";import A from"./FeatureMedia/FeatureMediaViewModel.js";import{createCompiledExpressions as I}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as M,preRequestCallback as x,createfieldInfoMap as v,getAllFieldInfos as w,getSourceLayer as C,substituteFieldsInLinksAndAttributes as F,isExpressionField as E,isRelatedField as T,formatEditInfo as V,graphicCallback as P,queryUpdatedFeature as j,formatAttributes as L}from"./support/featureUtils.js";import{queryLayerInfos as R,queryRelatedFeatures as O,setRelatedFeatures as S,getRelatedFieldInfo as k,createRelatedInfo as U,updateRelatedInfo as N}from"./support/relatedFeatureUtils.js";var q;const D=1,Q="content-view-models",B="esri.widgets.FeatureViewModel",G=s.getLogger(B),H={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0};let z=q=class extends i{constructor(e){super(e),this._handles=new o,this._error=null,this._featureAbortController=null,this.graphicChangedThrottled=d(this._graphicChanged,D,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...H},this.content=null,this.contentViewModels=[],this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&t.attachmentsContent||"custom"===e.type&&t.customContent||"fields"===e.type&&t.fieldsContent||"media"===e.type&&t.mediaContent||"text"===e.type&&t.textContent||"expression"===e.type&&t.expressionContent},this._handles.add(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities]),(()=>this.graphicChangedThrottled()),c))}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this._handles.destroy(),this._handles=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return n(this.graphic)?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return v(w(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return C(this.graphic)}castAbilities(e){return{...H,...e}}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?e.clone():null)}get spatialReference(){return this.get("view.spatialReference")||null}set spatialReference(e){void 0!==e?this._override("spatialReference",e):this._clearOverride("spatialReference")}get map(){return this.get("view.map")||null}set map(e){void 0!==e?this._override("map",e):this._clearOverride("map")}get waitingForContent(){return!!this._featureAbortController}setActiveMedia(e,t){const r=this.contentViewModels[e];r instanceof A&&r.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof A&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof A&&t.previous()}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(r){a(r)||(this._error=r,G.error("error","The popupTemplate could not be displayed for this feature.",{error:r,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))):"string"==typeof e?this._compileText(new m({text:e}),0).text:e}_destroyContentViewModels(){this._handles?.remove(Q),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_setExpressionContentVM(e,t){const{formattedAttributes:r}=this,{contentElement:i,contentElementViewModel:o}=e,s=i?.type;o&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:i,contentElementIndex:t,formattedAttributes:r}),o.set(this._createFieldsVMParams(i,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:i,contentElementIndex:t,formattedAttributes:r}),o.set(this._createMediaVMParams(i,t))),"text"===s&&o.set(this._createTextVMParams(i)))}_compileExpression(e,t){const{expressionInfo:r}=e,{graphic:i,map:o,spatialReference:s,view:n}=this,a=new b({expressionInfo:r,graphic:i,interceptor:q.interceptor,map:o,spatialReference:s,view:n});return this.contentViewModels[t]=a,this._handles.add(p((()=>a.contentElementViewModel),(()=>this._setExpressionContentVM(a,t)),c),Q),e}_compileAttachments(e,t){const{graphic:r}=this,{description:i,title:o}=e;return this.contentViewModels[t]=new _({graphic:r,...this._compileTitleAndDesc({title:o,description:i})}),e}_compileCustom(e,t){const{graphic:r}=this,{creator:i,destroyer:o}=e;return this.contentViewModels[t]=new y({graphic:r,creator:i,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:r,_sourceLayer:i,graphic:o,formattedAttributes:s,_expressionAttributes:n}=this,{attributes:a}=o,l=s.global;return{title:F({attributes:a,fieldInfoMap:r,globalAttributes:l,expressionAttributes:n,layer:i,text:e}),description:F({attributes:a,fieldInfoMap:r,globalAttributes:l,expressionAttributes:n,layer:i,text:t})}}_createFieldsVMParams(e,t){const{_effectivePopupTemplate:r,formattedAttributes:i}=this,o={...i.global,...i.content[t]},s=(e?.fieldInfos||r?.fieldInfos)?.filter((({fieldName:e})=>E(e)||T(e)||o.hasOwnProperty(e))),n=r?.expressionInfos,{description:a,title:l}=e;return{attributes:o,expressionInfos:n,fieldInfos:s,...this._compileTitleAndDesc({title:l,description:a})}}_compileFields(e,t){const r=e.clone(),i=new g(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=i,r.fieldInfos=i.formattedFieldInfos.slice(0),r}_createMediaVMParams(e,t){const{abilities:r,graphic:i,_fieldInfoMap:o,formattedAttributes:s,_effectivePopupTemplate:n,relatedInfos:a,_sourceLayer:l,_expressionAttributes:p}=this,{attributes:c}=i,{description:d,mediaInfos:u,title:f}=e;return{abilities:{chartAnimation:r.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,layer:l,fieldInfoMap:o,formattedAttributes:{...s.global,...s.content[t]},expressionAttributes:p,mediaInfos:u,popupTemplate:n,relatedInfos:a,...this._compileTitleAndDesc({title:f,description:d})}}_compileMedia(e,t){const r=e.clone(),i=new A(this._createMediaVMParams(e,t));return r.mediaInfos=i.formattedMediaInfos.slice(0),this.contentViewModels[t]=i,r}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:r,_sourceLayer:i,_expressionAttributes:o}=this;if(e&&e.text){const{attributes:s}=t,n=this.formattedAttributes.global;e.text=F({attributes:s,fieldInfoMap:r,globalAttributes:n,expressionAttributes:o,layer:i,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const r=e.clone();return this.contentViewModels[t]=new y(this._createTextVMParams(r)),r}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:r}=this;if(!e)return;const{lastEditInfoEnabled:i}=e,o=t?.editFieldsInfo;return i&&o?V(o,r.attributes):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:r,graphic:i,_expressionAttributes:o}=this,{attributes:s}=i,n=this.formattedAttributes.global;return F({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:o,layer:r,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this,r=e?.title;return P(r,{graphic:t})}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this,r=e?.content;return P(r,{graphic:t})}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:r,graphic:i,_effectivePopupTemplate:o,spatialReference:s,map:n,view:a}=this,{content:{value:p},title:{value:c}}=await l({content:this._getContent(),title:this._getTitle()});if(t!==this._featureAbortController||!i)return;await j({graphic:i,popupTemplate:o,layer:r,spatialReference:s},e);const{expressionAttributes:{value:d}}=await l({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:I({expressionInfos:o?.expressionInfos,spatialReference:s,graphic:i,map:n,interceptor:q.interceptor,view:a})});t===this._featureAbortController&&i&&(this._expressionAttributes=d,this._graphicExpressionAttributes={...i.attributes,...d},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(c)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:r}){const{_effectivePopupTemplate:i,graphic:o,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l}=this;r.content[t]=L({fieldInfos:i?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:r}){if(e.fieldInfos){const{graphic:i,relatedInfos:o,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a}=this;r.content[t]=L({fieldInfos:e.fieldInfos,graphic:i,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:o})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:r,relatedInfos:i,_sourceLayer:o,_fieldInfoMap:s,_graphicExpressionAttributes:n}=this,a=t?.fieldInfos,l={global:L({fieldInfos:a,graphic:r,attributes:n,layer:o,fieldInfoMap:s,relatedInfos:i}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:l})})),l}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:r}=this;return this._queryRelatedInfos(t,w(r),e)}async _queryRelatedInfos(e,t,r){const{relatedInfos:i,_sourceLayer:o}=this;i.clear();const s=n(o.associatedLayer)?await o.associatedLayer.load(r):o;if(!s)return;const a=t.filter((e=>e&&T(e.fieldName)));if(!a||!a.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const l=await R({relatedInfos:i,layer:s},r);Object.keys(l).forEach((e=>{const t=i.get(e.toString()),r=l[e]?.value;t&&r&&(t.layerInfo=r.data)}));const p=await O({graphic:e,relatedInfos:i,layer:s},r);Object.keys(p).forEach((e=>{S(p[e]?.value,i.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:r}=this,i=k(e.fieldName);if(!i)return;const{layerId:o,fieldName:s}=i;if(!o)return;const n=r.get(o.toString())||U(o,t);n&&(N({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(o,n))}};z.interceptor=new r(M,x),e([u()],z.prototype,"_error",void 0),e([u()],z.prototype,"_featureAbortController",void 0),e([u({readOnly:!0})],z.prototype,"_effectivePopupTemplate",null),e([u({readOnly:!0})],z.prototype,"_fieldInfoMap",null),e([u({readOnly:!0})],z.prototype,"_sourceLayer",null),e([u()],z.prototype,"abilities",void 0),e([f("abilities")],z.prototype,"castAbilities",null),e([u({readOnly:!0})],z.prototype,"content",void 0),e([u({readOnly:!0})],z.prototype,"contentViewModels",void 0),e([u({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([u({readOnly:!0})],z.prototype,"state",null),e([u({readOnly:!0})],z.prototype,"formattedAttributes",void 0),e([u({type:t,value:null})],z.prototype,"graphic",null),e([u({readOnly:!0})],z.prototype,"lastEditInfo",void 0),e([u({readOnly:!0})],z.prototype,"relatedInfos",void 0),e([u()],z.prototype,"spatialReference",null),e([u({readOnly:!0})],z.prototype,"title",void 0),e([u()],z.prototype,"map",null),e([u({readOnly:!0})],z.prototype,"waitingForContent",null),e([u()],z.prototype,"view",void 0),z=q=e([h(B)],z);const J=z;export{J as default};