@arcgis/core 4.33.0-next.20250228 → 4.33.0-next.20250302

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 (292) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/066844a51cd22cbef0e6.js +1 -0
  3. package/assets/esri/core/workers/chunks/0ce1bfcdcccb679569f8.js +1 -0
  4. package/assets/esri/core/workers/chunks/0e164b19e4ea3aa73843.js +1 -0
  5. package/assets/esri/core/workers/chunks/12d798775a96a45aada2.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f298cda10a9ffe35ea49.js → 1377ddd582518e5fa051.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{95a5ed95f0060b43f38f.js → 15fe629cd4da1bb2169f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/1a5f96b1b892ecceb36a.js +1 -0
  9. package/assets/esri/core/workers/chunks/{b4002b4fd99748fdf5da.js → 1e631e34ee495eb0e76e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/22618753349eb9d8b3df.js +1 -0
  11. package/assets/esri/core/workers/chunks/25a686f00479ac12a1ca.js +1 -0
  12. package/assets/esri/core/workers/chunks/25ef080163f3f795911a.js +1 -0
  13. package/assets/esri/core/workers/chunks/{afdbdc1569b56489c14d.js → 29fe3e9a0ecab74bb729.js} +1 -1
  14. package/assets/esri/core/workers/chunks/2c091edee3601f345f5f.js +1 -0
  15. package/assets/esri/core/workers/chunks/2f23fc27d005ffa18f47.js +1 -0
  16. package/assets/esri/core/workers/chunks/2f818b9a6b1f2b61410d.js +978 -0
  17. package/assets/esri/core/workers/chunks/3010a22d00f45fce5939.js +1 -0
  18. package/assets/esri/core/workers/chunks/{05869484d7de75f86916.js → 33005043f7084048296d.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{835fa4484c58d9b31c78.js → 3315de71eb8791189c05.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{f7a055be225f3498baaf.js → 354117429b3a0a0794c9.js} +1 -1
  21. package/assets/esri/core/workers/chunks/361a3253877acd3b4f07.js +1 -0
  22. package/assets/esri/core/workers/chunks/{53bc621e2cbc519b2535.js → 36b406131cd864567033.js} +1 -1
  23. package/assets/esri/core/workers/chunks/385dd6466fd967ce3ae9.js +1 -0
  24. package/assets/esri/core/workers/chunks/394b9723d108cff7136e.js +1 -0
  25. package/assets/esri/core/workers/chunks/4395b7263a299a8020d4.js +1 -0
  26. package/assets/esri/core/workers/chunks/47c04980098dc0c228d7.js +1 -0
  27. package/assets/esri/core/workers/chunks/{d6ee6ebdaf582f39c14b.js → 4c8164955f8d844c09ee.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{e4d7f1e685f69b3bf54d.js → 4c9160e3d596fe75392d.js} +1 -1
  29. package/assets/esri/core/workers/chunks/534f3d7e4300b662191a.js +1 -0
  30. package/assets/esri/core/workers/chunks/55c7c51e56d72f507c22.js +1 -0
  31. package/assets/esri/core/workers/chunks/5802406d0a239a27a9a3.js +1 -0
  32. package/assets/esri/core/workers/chunks/6ce738960ee47904968f.js +314 -0
  33. package/assets/esri/core/workers/chunks/{b12f2eaa15f6753fa1a8.js → 6ff981ec0c725efe5525.js} +1 -1
  34. package/assets/esri/core/workers/chunks/7ca33e03a2fd217b9443.js +1 -0
  35. package/assets/esri/core/workers/chunks/7d93ff4f18fd21c7b9f2.js +1 -0
  36. package/assets/esri/core/workers/chunks/{983d787730bf8b74fe13.js → 7ec2f531217718e76469.js} +1 -1
  37. package/assets/esri/core/workers/chunks/8196ff250c0de00104f7.js +1 -0
  38. package/assets/esri/core/workers/chunks/{ae25c6108918d37e61bf.js → 8278d9263e9b7e3bf2d1.js} +1 -1
  39. package/assets/esri/core/workers/chunks/852c32b5e717c54e3ae0.js +1 -0
  40. package/assets/esri/core/workers/chunks/856b03020b2dd047291d.js +1 -0
  41. package/assets/esri/core/workers/chunks/85a9025c2990a8bbd61b.js +1 -0
  42. package/assets/esri/core/workers/chunks/8b057b5a606ac3669a78.js +1 -0
  43. package/assets/esri/core/workers/chunks/8bf623f560b1ed440004.js +1 -0
  44. package/assets/esri/core/workers/chunks/8d421e0a01e2c3f6980c.js +1 -0
  45. package/assets/esri/core/workers/chunks/{f27828ba83846d686072.js → 97078a7871e243c19b6b.js} +1 -1
  46. package/assets/esri/core/workers/chunks/a68b48fd1a529f69705e.js +1 -0
  47. package/assets/esri/core/workers/chunks/{272662e4e28341419b4f.js → a73a262ddc959a59819f.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{4253438dd3045566892d.js → aba4353892c47de98eb3.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{14cb593dfb50c724b9eb.js → ac6b582ca180210e596c.js} +1 -1
  50. package/assets/esri/core/workers/chunks/af27a3f646a4404d3b8d.js +1 -0
  51. package/assets/esri/core/workers/chunks/{fc07d47d44c04f123650.js → b1e275607d9754079f60.js} +1 -1
  52. package/assets/esri/core/workers/chunks/b3c126e8a0a722c03efc.js +1 -0
  53. package/assets/esri/core/workers/chunks/b464b7800a2ddd92b9a7.js +1 -0
  54. package/assets/esri/core/workers/chunks/b52a3a48d2d3ff22542d.js +1 -0
  55. package/assets/esri/core/workers/chunks/be883ebdbaf11647b718.js +1 -0
  56. package/assets/esri/core/workers/chunks/bf9b45604249520b596a.js +1 -0
  57. package/assets/esri/core/workers/chunks/c0400c25c53fd90fc90e.js +1 -0
  58. package/assets/esri/core/workers/chunks/c2939e0c45a6d074cac0.js +1 -0
  59. package/assets/esri/core/workers/chunks/{fccf505dbd98e59e721a.js → c3dc8d1958ddc71e1129.js} +1 -1
  60. package/assets/esri/core/workers/chunks/c68c68e918c72932b247.js +1 -0
  61. package/assets/esri/core/workers/chunks/c8cd9a3175f516624842.js +1 -0
  62. package/assets/esri/core/workers/chunks/cc1aedb2b3aa3854b0de.js +1 -0
  63. package/assets/esri/core/workers/chunks/d374d2a1487faee3672d.js +1 -0
  64. package/assets/esri/core/workers/chunks/d630e64463687090db92.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbdca19978fbee8dc106.js +1 -0
  66. package/assets/esri/core/workers/chunks/ddfb5a2055a36576ba0d.js +1 -0
  67. package/assets/esri/core/workers/chunks/e1a90f63d2e6c761953b.js +1 -0
  68. package/assets/esri/core/workers/chunks/{5b5d89b94e020b4bfcc1.js → e3b0bb6850d5252d5f24.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{4235bb1334c95f3c828d.js → e45404a982e173459990.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{b7a3d9c5d18e59da378f.js → eab1e3c101158675abba.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{8a3290ee6e6587fa39a6.js → ed4afafbcb31491c2049.js} +1 -1
  72. package/assets/esri/core/workers/chunks/ef46613c3aa363dc1cfc.js +1 -0
  73. package/assets/esri/core/workers/chunks/{6c5877e4ad108a6d074e.js → f0351930cbb3d8643119.js} +1 -1
  74. package/assets/esri/core/workers/chunks/f31986ea5cadfade8344.js +1 -0
  75. package/assets/esri/core/workers/chunks/f350aefc5e348ebad1da.js +1 -0
  76. package/assets/esri/core/workers/chunks/{a2e52b40eeeda4282c07.js → f70dd16f14279bb7e60d.js} +1 -1
  77. package/assets/esri/core/workers/chunks/f995a74bd9b58c069c07.js +1 -0
  78. package/assets/esri/core/workers/chunks/{7437b7423c8b7fb4f0dd.js → fe3ed029b07bb1e4aef3.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{e6e6247ea5ce0c2b125f.js → fe8ee1938d196a70d809.js} +1 -1
  80. package/assets/esri/themes/base/widgets/_LabeledSwitch.scss +0 -2
  81. package/assets/esri/themes/dark/main.css +1 -1
  82. package/assets/esri/themes/light/main.css +1 -1
  83. package/assets/esri/themes/light/view.css +1 -1
  84. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  85. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  86. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  87. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  88. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  89. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  90. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  91. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  92. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  93. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  94. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  95. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  96. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  97. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  98. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  99. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  100. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  101. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  102. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  103. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  104. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  105. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  106. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  107. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  108. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  109. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  110. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  111. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  112. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  113. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  114. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  115. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  116. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  117. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  118. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  119. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  120. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  121. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  122. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  123. package/chunks/Envelope.js +1 -1
  124. package/chunks/{GeodeticDistanceCalculator-D4iQ-_NX.js → GeodeticDistanceCalculator-CcF1gMZX.js} +1 -1
  125. package/chunks/LineSeries.js +1 -1
  126. package/chunks/OperatorGeodeticArea.js +1 -1
  127. package/chunks/OperatorGeodeticDistance.js +1 -1
  128. package/chunks/OperatorProximityGeodesic.js +1 -1
  129. package/chunks/Point2D.js +1 -1
  130. package/chunks/ProjectionTransformation.js +1 -1
  131. package/chunks/QuadraticBezier.js +1 -1
  132. package/chunks/Theme.js +1 -1
  133. package/chunks/chartUtilsAm5.js +1 -1
  134. package/chunks/distanceOperator.js +1 -1
  135. package/core/timeUtils.js +1 -1
  136. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  137. package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
  138. package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
  139. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  140. package/editing/templateUtils.js +1 -1
  141. package/geometry/operators/extendOperator.js +1 -1
  142. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  143. package/geometry/operators/gx/operatorBuffer.js +1 -1
  144. package/geometry/operators/gx/operatorConvexHull.js +1 -1
  145. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  146. package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
  147. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  148. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  149. package/geometry/operators/isNearOperator.js +1 -1
  150. package/geometry/operators/support/jsonConverter.js +1 -1
  151. package/geometry/support/PolylineBuilder.js +5 -0
  152. package/geometry/support/TileClipper.js +1 -1
  153. package/interfaces.d.ts +9 -9
  154. package/intl/date.js +1 -1
  155. package/layers/graphics/sources/WFSSource.js +1 -1
  156. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  157. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  158. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  159. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  160. package/layers/mixins/ImageryTileMixin.js +1 -1
  161. package/layers/ogc/ogcFeatureUtils.js +1 -1
  162. package/layers/support/FieldsIndex.js +1 -1
  163. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  164. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  165. package/networks/support/UtilityNetworkLookupHelper.js +5 -0
  166. package/package.json +2 -2
  167. package/smartMapping/support/utils.js +1 -1
  168. package/support/guards.js +1 -1
  169. package/support/revision.js +1 -1
  170. package/symbols/cim/CIMOperators.js +1 -1
  171. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  172. package/symbols/cim/defaultCIMValues.js +1 -1
  173. package/symbols/cim/effects/EffectEnclosingPolygon.js +5 -0
  174. package/symbols/cim/effects/EffectRadial.js +5 -0
  175. package/symbols/cim/effects/EffectTaperedPolygon.js +5 -0
  176. package/symbols/cim/utils.js +1 -1
  177. package/time/TimeExtent.js +1 -1
  178. package/time/constants.js +5 -0
  179. package/time/timeZoneUtils.js +1 -1
  180. package/views/2d/engine/webgl/TextureManager.js +1 -1
  181. package/views/2d/engine/webgl/Utils.js +1 -1
  182. package/views/2d/engine/webgl/mesh/factories/ResourceProxy.js +1 -1
  183. package/views/2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js +1 -1
  184. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriter.js +1 -1
  185. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexOutlineFillShader.js +1 -1
  186. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  187. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  188. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  189. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  190. package/views/2d/engine/webgl/textureUtils.js +5 -0
  191. package/views/2d/engine/webgl/urlUtils.js +5 -0
  192. package/views/2d/layers/MediaLayerView2D.js +1 -1
  193. package/views/2d/layers/TileLayerView2D.js +1 -1
  194. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  195. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  196. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  197. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  198. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  199. package/views/3d/terrain/TileRenderer.js +1 -1
  200. package/views/3d/webgl-engine/lib/TextureCompressionWorkerHandle.js +1 -1
  201. package/views/VideoView.js +1 -1
  202. package/views/View.js +1 -1
  203. package/views/support/TextureCompressionHelper.js +1 -1
  204. package/views/webgl/Texture.js +1 -1
  205. package/webmap/InitialViewProperties.js +1 -1
  206. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  207. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  208. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  209. package/widgets/Bookmarks.js +1 -1
  210. package/widgets/Directions/DirectionsViewModel.js +1 -1
  211. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  212. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  213. package/widgets/Feature/FeatureViewModel.js +1 -1
  214. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
  215. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  216. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  217. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  218. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  219. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  220. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  221. package/widgets/FeatureTable/FieldColumn.js +1 -1
  222. package/widgets/Features/FeaturesViewModel.js +1 -1
  223. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  224. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  225. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +1 -1
  226. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  227. package/widgets/OrientedImageryViewer.js +1 -1
  228. package/widgets/TimeSlider.js +1 -1
  229. package/widgets/TimeZoneLabel.js +1 -1
  230. package/widgets/support/LabeledSwitch.js +1 -1
  231. package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +5 -0
  232. package/widgets/support/UtilityNetworkAssociations/utils/formatPercentAlong.js +5 -0
  233. package/widgets/support/UtilityNetworkAssociations/utils/getAssociationTitle.js +5 -0
  234. package/widgets/support/UtilityNetworkAssociations/utils/getFeatureTitle.js +5 -0
  235. package/widgets/support/UtilityNetworkAssociations/utils/isConnectivity.js +5 -0
  236. package/widgets/support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js +5 -0
  237. package/widgets/support/UtilityNetworkAssociations/utils/isFromElement.js +5 -0
  238. package/widgets/support/dateUtils.js +1 -1
  239. package/assets/esri/core/workers/chunks/0509af0f6c732a847531.js +0 -1
  240. package/assets/esri/core/workers/chunks/1461ca910c3dba1d808b.js +0 -1
  241. package/assets/esri/core/workers/chunks/19f45bb389daf866dbc5.js +0 -1
  242. package/assets/esri/core/workers/chunks/1c4cafb879f21a42f7db.js +0 -978
  243. package/assets/esri/core/workers/chunks/2626f4201deb7bdd4866.js +0 -1
  244. package/assets/esri/core/workers/chunks/2e1126a35976b2d48197.js +0 -1
  245. package/assets/esri/core/workers/chunks/2eadc555038a38afdc9c.js +0 -1
  246. package/assets/esri/core/workers/chunks/36f0446d9d47685b7ce0.js +0 -1
  247. package/assets/esri/core/workers/chunks/3cf3aa74541f0cfff94f.js +0 -1
  248. package/assets/esri/core/workers/chunks/3d46327469ed5170e83e.js +0 -1
  249. package/assets/esri/core/workers/chunks/440afa7d26e721af578a.js +0 -1
  250. package/assets/esri/core/workers/chunks/460e5f78574cc0d157af.js +0 -1
  251. package/assets/esri/core/workers/chunks/4de09a997691305415b1.js +0 -1
  252. package/assets/esri/core/workers/chunks/5066fc5257296d95fe60.js +0 -1
  253. package/assets/esri/core/workers/chunks/53315ca098d76d34cf00.js +0 -1
  254. package/assets/esri/core/workers/chunks/539190038ac552e5374c.js +0 -1
  255. package/assets/esri/core/workers/chunks/55162949a2b2c8e1c95c.js +0 -1
  256. package/assets/esri/core/workers/chunks/58853056c16f2b525a9e.js +0 -1
  257. package/assets/esri/core/workers/chunks/5af9737d0530ca17b771.js +0 -1
  258. package/assets/esri/core/workers/chunks/5c0dfc75a9b654e6fa25.js +0 -1
  259. package/assets/esri/core/workers/chunks/6245c51d1525767ce2fe.js +0 -1
  260. package/assets/esri/core/workers/chunks/6728185fdf53b4921bf8.js +0 -1
  261. package/assets/esri/core/workers/chunks/68cb0c3462c90f2d1538.js +0 -1
  262. package/assets/esri/core/workers/chunks/6affa0f3d5bb74c7a1db.js +0 -1
  263. package/assets/esri/core/workers/chunks/6e108fb9884139dd3b52.js +0 -314
  264. package/assets/esri/core/workers/chunks/6f9bfa6ed34ef6efcc6f.js +0 -1
  265. package/assets/esri/core/workers/chunks/70943dc884d9ba8045a2.js +0 -1
  266. package/assets/esri/core/workers/chunks/7fe799c1e60e23a976e9.js +0 -1
  267. package/assets/esri/core/workers/chunks/80395a1d8ae91ff3961b.js +0 -1
  268. package/assets/esri/core/workers/chunks/87b78e491c800c96b503.js +0 -1
  269. package/assets/esri/core/workers/chunks/8abd2235aa702d8b239f.js +0 -1
  270. package/assets/esri/core/workers/chunks/8bf29e5e4c93d85a6abf.js +0 -1
  271. package/assets/esri/core/workers/chunks/99838ad20c10aa5aa471.js +0 -1
  272. package/assets/esri/core/workers/chunks/9fb568d25ed4f4660963.js +0 -1
  273. package/assets/esri/core/workers/chunks/9ff9cf156d024ade068b.js +0 -1
  274. package/assets/esri/core/workers/chunks/a288c2474ef193f9fbd3.js +0 -1
  275. package/assets/esri/core/workers/chunks/a2d0f7d82630dd8efb9b.js +0 -1
  276. package/assets/esri/core/workers/chunks/a66c3866888bd7e415e8.js +0 -1
  277. package/assets/esri/core/workers/chunks/b3bbe6f569ab6a3777b5.js +0 -1
  278. package/assets/esri/core/workers/chunks/ba33405a524c6bb88656.js +0 -1
  279. package/assets/esri/core/workers/chunks/bb1fb9990f8bf5f7a05f.js +0 -1
  280. package/assets/esri/core/workers/chunks/c22664f9f2b4ba7fe3d4.js +0 -1
  281. package/assets/esri/core/workers/chunks/c83245257deb230f79c0.js +0 -1
  282. package/assets/esri/core/workers/chunks/d2f8eed0b5b7cbdcd182.js +0 -1
  283. package/assets/esri/core/workers/chunks/d56426def776aae6fac6.js +0 -1
  284. package/assets/esri/core/workers/chunks/e12882be1b6820b8e9e8.js +0 -1
  285. package/assets/esri/core/workers/chunks/e648f1c96edf44c781eb.js +0 -1
  286. package/assets/esri/core/workers/chunks/ef6e9dbfc9a5bd38a7b6.js +0 -1
  287. package/assets/esri/core/workers/chunks/f2723d0c9c8d8ff4ec70.js +0 -1
  288. package/assets/esri/core/workers/chunks/f45ef721d21388846101.js +0 -1
  289. package/assets/esri/core/workers/chunks/fdab6921d007929ab288.js +0 -1
  290. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +0 -5
  291. /package/chunks/{Bufferer-B-V7yYm-.js → Bufferer-CicaNej1.js} +0 -0
  292. /package/chunks/{Distance2DCalculator-Coa0qAFt.js → Distance2DCalculator-C1KHhZwD.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,whenOnce as h,sync as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import _ from"../../geometry/SpatialReference.js";import{system as g}from"../../time/timeZoneUtils.js";import{createReactiveGraphic as v}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as F}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as y}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as I}from"./expressions/ExpressionsModel.js";import{BatchFormInputs as E}from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as w}from"./inputs/support/createBatchFormInputs.js";import{NoVisibleElementCodes as M,InputVisibilityCode as b,isGroupInput as x,isFieldInput as T}from"./inputs/support/inputUtils.js";import k from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as V}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as H}from"./templates/support/createBatchFormTemplate.js";let j=class extends i.EventedAccessor{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this.map=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new F,this._activeFormInputsByElementId=new Map,this._emptyForm=new E({inputs:[]}),this._emptyFormTemplate=new k({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._layerContingentValuesMap=new p,this._workingFeatures=new s,this._expressionsManager=new y({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:g}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l((()=>this.features),"after-changes",(()=>this._prepare()),{sync:!0}),u((()=>[this.features,this.map,this.timeZone,this.editType]),(()=>{this._prepare()}),m),u((()=>this.activeForm),(()=>this._activeFormInputsByElementId.clear()),m)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some((t=>t!==e))}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter((e=>e.visible))}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return M.noElements;const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case b.HIDDEN_NOT_IN_ALL_LAYERS:case b.HIDDEN_NO_DOMAIN_IN_COMMON:e.add(M.noElementsInCommon);break;case b.HIDDEN_FIELD_DEFINITION:case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:case b.HIDDEN_VISIBILITY_EXPRESSION_ALL:e.add(M.allElementsHidden);break;case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:case b.HIDDEN_VISIBILITY_EXPRESSION_SOME:return M.elementsHiddenInSome}return e.has(M.allElementsHidden)?M.allElementsHidden:M.noElementsInCommon}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach((t=>{const s=t.sourceLayer??t.layer;e.add(s)})),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find((t=>t.template.elementId===e));return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(x(e)){const t=e.inputs.find((e=>!e.valid));if(t)return{input:t,groupInput:e}}if(T(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._workingFeatures.find((({original:t})=>t===e));if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map((e=>e.original)),fieldName:e.fieldName,name:"value-change",value:t})}setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await h((()=>!1===this.calculating));const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?w(t,new s([e]),this._expressionsManager):this._emptyForm}async _prepare(){this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new y({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??_.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t((async t=>{try{n(t);const s=new Map;for(const t of e){const e=await V(t);if(e){const s=e.fieldGroups.flatMap((e=>e.fields));this._layerContingentValuesMap.set(t,new Set(s))}else this._layerContingentValuesMap.set(t,new Set);const r=await H(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,r),this._expressionsManager.layerExpressionsModelMap.set(t,new I({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:r.getExpressionExecutorsForLayer(t)}));for(const t of r.elements){const{elementId:e}=t;s.has(e)?s.get(e).foldIn(t):s.set(e,t.clone())}}const r=new k({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=w(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures)}catch(s){throw a.getLogger(this).error("Failed preparing form",s),s}}));this._updatingHandles.addPromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(v));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.original,e)}}};e([d()],j.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],j.prototype,"activeFeature",null),e([d()],j.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],j.prototype,"activeForm",null),e([d()],j.prototype,"disabled",void 0),e([d()],j.prototype,"calculating",null),e([d()],j.prototype,"editType",void 0),e([d()],j.prototype,"features",void 0),e([d()],j.prototype,"expressionEvaluationFailed",null),e([d()],j.prototype,"hasNonActiveInvalidFeatures",null),e([d()],j.prototype,"invalidFeatures",null),e([d()],j.prototype,"hasVisibleInputs",null),e([d()],j.prototype,"hasLayersWithContingentValues",null),e([d()],j.prototype,"visibleInputs",null),e([d()],j.prototype,"map",void 0),e([d()],j.prototype,"noVisibleElementsReason",null),e([d()],j.prototype,"spatialReference",void 0),e([d()],j.prototype,"submitHasBeenAttempted",void 0),e([d()],j.prototype,"timeZone",void 0),e([d()],j.prototype,"updating",null),e([d()],j.prototype,"valid",null),e([d()],j.prototype,"layers",null),e([d()],j.prototype,"mode",null),e([d()],j.prototype,"sharedForm",void 0),e([d()],j.prototype,"sharedFormTemplate",void 0),e([d()],j.prototype,"userHasChangedValues",void 0),e([d()],j.prototype,"_arcadeExecutorProvider",void 0),e([d()],j.prototype,"_prepareTask",void 0),e([d()],j.prototype,"_reactiveGraphicLookup",void 0),e([d()],j.prototype,"_layerTemplateMap",void 0),e([d()],j.prototype,"_layerContingentValuesMap",void 0),e([d()],j.prototype,"_workingFeatures",void 0),e([d()],j.prototype,"_expressionsManager",void 0),j=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],j);const L=j;export{L as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,whenOnce as h,sync as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import _ from"../../geometry/SpatialReference.js";import{system as g}from"../../time/constants.js";import{createReactiveGraphic as v}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as F}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as y}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as I}from"./expressions/ExpressionsModel.js";import{BatchFormInputs as E}from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as w}from"./inputs/support/createBatchFormInputs.js";import{NoVisibleElementCodes as M,InputVisibilityCode as b,isGroupInput as x,isFieldInput as T}from"./inputs/support/inputUtils.js";import k from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as V}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as H}from"./templates/support/createBatchFormTemplate.js";let j=class extends i.EventedAccessor{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this.map=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new F,this._activeFormInputsByElementId=new Map,this._emptyForm=new E({inputs:[]}),this._emptyFormTemplate=new k({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._layerContingentValuesMap=new p,this._workingFeatures=new s,this._expressionsManager=new y({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:g}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l((()=>this.features),"after-changes",(()=>this._prepare()),{sync:!0}),u((()=>[this.features,this.map,this.timeZone,this.editType]),(()=>{this._prepare()}),m),u((()=>this.activeForm),(()=>this._activeFormInputsByElementId.clear()),m)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some((t=>t!==e))}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter((e=>e.visible))}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return M.noElements;const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case b.HIDDEN_NOT_IN_ALL_LAYERS:case b.HIDDEN_NO_DOMAIN_IN_COMMON:e.add(M.noElementsInCommon);break;case b.HIDDEN_FIELD_DEFINITION:case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:case b.HIDDEN_VISIBILITY_EXPRESSION_ALL:e.add(M.allElementsHidden);break;case b.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:case b.HIDDEN_VISIBILITY_EXPRESSION_SOME:return M.elementsHiddenInSome}return e.has(M.allElementsHidden)?M.allElementsHidden:M.noElementsInCommon}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach((t=>{const s=t.sourceLayer??t.layer;e.add(s)})),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find((t=>t.template.elementId===e));return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(x(e)){const t=e.inputs.find((e=>!e.valid));if(t)return{input:t,groupInput:e}}if(T(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._workingFeatures.find((({original:t})=>t===e));if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map((e=>e.original)),fieldName:e.fieldName,name:"value-change",value:t})}setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await h((()=>!1===this.calculating));const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?w(t,new s([e]),this._expressionsManager):this._emptyForm}async _prepare(){this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new y({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??_.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t((async t=>{try{n(t);const s=new Map;for(const t of e){const e=await V(t);if(e){const s=e.fieldGroups.flatMap((e=>e.fields));this._layerContingentValuesMap.set(t,new Set(s))}else this._layerContingentValuesMap.set(t,new Set);const r=await H(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,r),this._expressionsManager.layerExpressionsModelMap.set(t,new I({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:r.getExpressionExecutorsForLayer(t)}));for(const t of r.elements){const{elementId:e}=t;s.has(e)?s.get(e).foldIn(t):s.set(e,t.clone())}}const r=new k({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=w(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures)}catch(s){throw a.getLogger(this).error("Failed preparing form",s),s}}));this._updatingHandles.addPromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(v));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.original,e)}}};e([d()],j.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],j.prototype,"activeFeature",null),e([d()],j.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],j.prototype,"activeForm",null),e([d()],j.prototype,"disabled",void 0),e([d()],j.prototype,"calculating",null),e([d()],j.prototype,"editType",void 0),e([d()],j.prototype,"features",void 0),e([d()],j.prototype,"expressionEvaluationFailed",null),e([d()],j.prototype,"hasNonActiveInvalidFeatures",null),e([d()],j.prototype,"invalidFeatures",null),e([d()],j.prototype,"hasVisibleInputs",null),e([d()],j.prototype,"hasLayersWithContingentValues",null),e([d()],j.prototype,"visibleInputs",null),e([d()],j.prototype,"map",void 0),e([d()],j.prototype,"noVisibleElementsReason",null),e([d()],j.prototype,"spatialReference",void 0),e([d()],j.prototype,"submitHasBeenAttempted",void 0),e([d()],j.prototype,"timeZone",void 0),e([d()],j.prototype,"updating",null),e([d()],j.prototype,"valid",null),e([d()],j.prototype,"layers",null),e([d()],j.prototype,"mode",null),e([d()],j.prototype,"sharedForm",void 0),e([d()],j.prototype,"sharedFormTemplate",void 0),e([d()],j.prototype,"userHasChangedValues",void 0),e([d()],j.prototype,"_arcadeExecutorProvider",void 0),e([d()],j.prototype,"_prepareTask",void 0),e([d()],j.prototype,"_reactiveGraphicLookup",void 0),e([d()],j.prototype,"_layerTemplateMap",void 0),e([d()],j.prototype,"_layerContingentValuesMap",void 0),e([d()],j.prototype,"_workingFeatures",void 0),e([d()],j.prototype,"_expressionsManager",void 0),j=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],j);const L=j;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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as a}from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import l from"../../../layers/support/RangeDomain.js";import{getDomainRange as o,dateTimeFieldValuesToNumericRange as u,isDomainValidForField as m}from"../../../layers/support/domainUtils.js";import{isNumericField as p,isStringField as d,isTimeOnlyField as f,getFieldRange as h,isDateOnlyField as c,isTimestampOffsetField as y}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../../smartMapping/support/utils.js";import{isNumber as _}from"../../../support/guards.js";import{unknown as x,utc as V}from"../../../time/timeZoneUtils.js";import{EditableInput as b}from"./EditableInput.js";import{MultiFeatureError as v,visibilityCodeToBoolean as E,InputVisibilityCode as D,isFieldInputWithShowNoValueOptionInput as F,differentValuesString as I}from"./support/inputUtils.js";import{FieldInputDataTypes as M,getMaxLength as N,getMinLength as T,isEmptyValue as w,dateIsValid as R,validateFormValue as S}from"../../support/forms/formUtils.js";let L=class extends b{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return v.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return v.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return p(e)?M.Number:d(e)?M.Text:g(e)||f(e)?M.Date:M.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==D.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===D.HIDDEN_VISIBILITY_EXPRESSION_ALL?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===D.HIDDEN_VISIBILITY_EXPRESSION_SOME?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!F(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return F(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===M.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return N({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return T({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=o(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>w(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:I}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?D.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:D.HIDDEN_FIELD_DEFINITION}get effectiveTimeZone(){const e=this.template;let t=e.formTimeZone??"system";return e.layerTimeZone?e.layerTimeZone===x?t=V:e.formTimeZone===x&&(t=e.layerTimeZone):e.formTimeZone===x&&(t=V),t}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[]}get codedValueOptions(){const e=this.codedValueDomainOptions,{value:t}=this,i=null==t||t===I||e.some((e=>e.value===t))?[]:[{name:`${t}`,value:t}];return[e,i]}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=u(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&R(t)?t.getTime():null,min:null!=r&&R(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=o(i,r);if(!n)return e;const{max:a,min:s,rawMax:l,rawMin:u}=e,{type:m}=t.field;if("date"===m){const{max:e,min:t}=n;return{max:_(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:_(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===m||"time-only"===m||"timestamp-offset"===m){const{max:e,min:t,rawMax:i,rawMin:r}=n,o=_(a)&&l&&(null==e||a<e),m=_(s)&&u&&(null==t||s>t);return{max:o?a:e,min:m?s:t,rawMax:o?l:i,rawMin:m?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=new i,r=this.fieldName;for(const i of this.features)i.getAttribute(r)!==e&&t.push(i);this._setValue(e),await this.expressionsManager.valueChanged(r,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([u]),p=this._requiredForFeature(s),d=s.getAttribute(t),f=S(d,{dataType:e,domain:m,field:o,maxLength:i,minLength:r,range:n,required:p});f&&a.push({error:f,feature:s.original})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&m(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const a of e)for(const[e,i]of t){a.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map((([e,t])=>new a({code:e,name:t})));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];if(e.length>1&&(t=e.reduce(((e,t)=>{const i=this._findMinMaxValuesBetweenTwoDomains(e,t);return i||null}),t)),t&&!m(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof l){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||y(r)?u(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new l,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,s=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),m=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(s,u),i.maxValue=Math.min(o,m),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(a)||f(a)||y(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return _(e)?e:t}};e([r()],L.prototype,"dataType",null),e([r()],L.prototype,"domain",null),e([r()],L.prototype,"distinctValues",null),e([r()],L.prototype,"editable",null),e([r()],L.prototype,"effectiveVisible",null),e([r()],L.prototype,"effectiveVisibilityCode",null),e([r()],L.prototype,"errors",null),e([r()],L.prototype,"featuresHaveSameValue",null),e([r()],L.prototype,"field",null),e([r()],L.prototype,"fieldName",null),e([r()],L.prototype,"group",void 0),e([r()],L.prototype,"invalidFeatures",null),e([r()],L.prototype,"isSubtypeField",null),e([r()],L.prototype,"showNoValueOptionEnabled",null),e([r()],L.prototype,"includeTime",null),e([r()],L.prototype,"includeTimeOffset",null),e([r()],L.prototype,"maxLength",null),e([r()],L.prototype,"minLength",null),e([r()],L.prototype,"range",null),e([r()],L.prototype,"required",null),e([r()],L.prototype,"submittable",null),e([r({readOnly:!0})],L.prototype,"type",void 0),e([r()],L.prototype,"userHasChangedValue",void 0),e([r()],L.prototype,"valid",null),e([r()],L.prototype,"value",null),e([r()],L.prototype,"visibilityCode",null),e([r()],L.prototype,"effectiveTimeZone",null),e([r()],L.prototype,"_evaluatedRequiredExpression",null),e([r()],L.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],L.prototype,"_allDomains",null),e([r()],L.prototype,"_fieldShouldHaveDomain",null),e([r()],L.prototype,"_dateFormRange",null),e([r()],L.prototype,"_dateRange",null),L=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],L);export{L as FieldInput};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as a}from"../../../layers/support/CodedValue.js";import s from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import l from"../../../layers/support/RangeDomain.js";import{getDomainRange as o,dateTimeFieldValuesToNumericRange as u,isDomainValidForField as m}from"../../../layers/support/domainUtils.js";import{isNumericField as p,isStringField as d,isTimeOnlyField as f,getFieldRange as h,isDateOnlyField as c,isTimestampOffsetField as y}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../../smartMapping/support/utils.js";import{isNumber as _}from"../../../support/guards.js";import{unknown as x,utc as V}from"../../../time/constants.js";import{EditableInput as b}from"./EditableInput.js";import{MultiFeatureError as v,visibilityCodeToBoolean as E,InputVisibilityCode as D,isFieldInputWithShowNoValueOptionInput as F,differentValuesString as I}from"./support/inputUtils.js";import{FieldInputDataTypes as M,getMaxLength as N,getMinLength as T,isEmptyValue as w,dateIsValid as R,validateFormValue as S}from"../../support/forms/formUtils.js";let L=class extends b{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return v.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return v.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return p(e)?M.Number:d(e)?M.Text:g(e)||f(e)?M.Date:M.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return E(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==D.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===D.HIDDEN_VISIBILITY_EXPRESSION_ALL?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===D.HIDDEN_VISIBILITY_EXPRESSION_SOME?D.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!F(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return F(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===M.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return N({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return T({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=o(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?h(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>w(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:I}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?D.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:D.HIDDEN_FIELD_DEFINITION}get effectiveTimeZone(){const e=this.template;let t=e.formTimeZone??"system";return e.layerTimeZone?e.layerTimeZone===x?t=V:e.formTimeZone===x&&(t=e.layerTimeZone):e.formTimeZone===x&&(t=V),t}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[]}get codedValueOptions(){const e=this.codedValueDomainOptions,{value:t}=this,i=null==t||t===I||e.some((e=>e.value===t))?[]:[{name:`${t}`,value:t}];return[e,i]}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=u(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&R(t)?t.getTime():null,min:null!=r&&R(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=o(i,r);if(!n)return e;const{max:a,min:s,rawMax:l,rawMin:u}=e,{type:m}=t.field;if("date"===m){const{max:e,min:t}=n;return{max:_(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:_(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===m||"time-only"===m||"timestamp-offset"===m){const{max:e,min:t,rawMax:i,rawMin:r}=n,o=_(a)&&l&&(null==e||a<e),m=_(s)&&u&&(null==t||s>t);return{max:o?a:e,min:m?s:t,rawMax:o?l:i,rawMin:m?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=new i,r=this.fieldName;for(const i of this.features)i.getAttribute(r)!==e&&t.push(i);this._setValue(e),await this.expressionsManager.valueChanged(r,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([u]),p=this._requiredForFeature(s),d=s.getAttribute(t),f=S(d,{dataType:e,domain:m,field:o,maxLength:i,minLength:r,range:n,required:p});f&&a.push({error:f,feature:s.original})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&m(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const a of e)for(const[e,i]of t){a.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const n=Array.from(r.entries()).map((([e,t])=>new a({code:e,name:t})));return n.length?new s({codedValues:n}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];if(e.length>1&&(t=e.reduce(((e,t)=>{const i=this._findMinMaxValuesBetweenTwoDomains(e,t);return i||null}),t)),t&&!m(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof l){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return c(r)||f(r)||y(r)?u(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new l,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,s=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),m=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(s,u),i.maxValue=Math.min(o,m),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((c(a)||f(a)||y(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return _(e)?e:t}};e([r()],L.prototype,"dataType",null),e([r()],L.prototype,"domain",null),e([r()],L.prototype,"distinctValues",null),e([r()],L.prototype,"editable",null),e([r()],L.prototype,"effectiveVisible",null),e([r()],L.prototype,"effectiveVisibilityCode",null),e([r()],L.prototype,"errors",null),e([r()],L.prototype,"featuresHaveSameValue",null),e([r()],L.prototype,"field",null),e([r()],L.prototype,"fieldName",null),e([r()],L.prototype,"group",void 0),e([r()],L.prototype,"invalidFeatures",null),e([r()],L.prototype,"isSubtypeField",null),e([r()],L.prototype,"showNoValueOptionEnabled",null),e([r()],L.prototype,"includeTime",null),e([r()],L.prototype,"includeTimeOffset",null),e([r()],L.prototype,"maxLength",null),e([r()],L.prototype,"minLength",null),e([r()],L.prototype,"range",null),e([r()],L.prototype,"required",null),e([r()],L.prototype,"submittable",null),e([r({readOnly:!0})],L.prototype,"type",void 0),e([r()],L.prototype,"userHasChangedValue",void 0),e([r()],L.prototype,"valid",null),e([r()],L.prototype,"value",null),e([r()],L.prototype,"visibilityCode",null),e([r()],L.prototype,"effectiveTimeZone",null),e([r()],L.prototype,"_evaluatedRequiredExpression",null),e([r()],L.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([r()],L.prototype,"_allDomains",null),e([r()],L.prototype,"_fieldShouldHaveDomain",null),e([r()],L.prototype,"_dateFormRange",null),e([r()],L.prototype,"_dateRange",null),L=e([n("esri.widgets.BatchAttributeForm.inputs.FieldInput")],L);export{L as FieldInput};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import t from"../../../../form/ExpressionInfo.js";import{isFieldElement as n,isGroupElement as o}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as i,isFieldVisibleByDefault as s}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as a,isSubtypeGroupLayer as l}from"../../../../layers/support/layerUtils.js";import{unknown as m}from"../../../../time/timeZoneUtils.js";import{makeExpressionInfosMap as d,makeExecutorSetForFormElement as p}from"../../expressions/expressionUtils.js";import f from"../BatchFormTemplate.js";import{FieldElementTemplate as c}from"../FieldElementTemplate.js";import{GroupElementTemplate as u}from"../GroupElementTemplate.js";const y="expression/dea57012-47ca4b55a000-8df62742ed0c",w=()=>r.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function x(e,r){return e.formTemplate?.elements&&e.formTemplate?.elements.length>0?E(e,r):b(e,r)}async function b(e,{arcadeExecutorProvider:r,formTimeZone:t}){const n=new Set(i(e)),o={arcadeExecutorProvider:r,editTrackingFields:n,formTimeZone:t,layer:e},s=[];for(const i of e.fields)g(i,e,n)&&s.push(Z(i,o));const a=await Promise.all(s);return new f({elements:a,preserveFieldValuesWhenHidden:!0})}function T(e,r){for(const t of e??[])if("group"!==t.type){if("field"===t.type){if(!1===t.editable&&!t.editableExpression)return!0;if(r.subtypeField&&(a(r)||l(r))&&t.fieldName?.toLowerCase()===r.subtypeField.toLowerCase())return!0}}else if(T(t.elements??[],r))return!0;return!1}async function E(e,r){const n=e.formTemplate;if(!n)return b(e,r);let o=null;T(n.elements??[],e)&&(o=new t({title:"",name:y,expression:"false"}));const i=d(o?[...n.expressionInfos??[],o]:n.expressionInfos),s={description:n.description,elements:new Array,title:n.title,preserveFieldValuesWhenHidden:n.preserveFieldValuesWhenHidden},{elements:a}=n;if(!a)return new f(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const t of a){const r=await h(t,{arcadeExecutorProvider:l,expressionInfos:i,layer:e,formTimeZone:m});r&&s.elements.push(r)}return new f(s)}async function h(r,t){return n(r)?v(r,t):o(r)?F(r,t):(w().warn(new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)),null)}async function v(r,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:m,domain:d,fieldName:f,hint:u,input:x,label:b}=r;if(null==f||!s.has(f))return w().warn(new e("batch-attribute-form:invalid-form-element-field",`Field element with label '${b}' does not refer to a valid field`)),null;const T={description:m,domain:d,field:s.get(f),hint:u,input:x,formTimeZone:i,layerTimeZone:I(o),label:b};!1!==r.editable||r.editableExpression||((r=r.clone()).editableExpression=y),o.subtypeField&&(a(o)||l(o))&&r.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((r=r.clone()).editableExpression=y);const E=new c(T),h=await p({element:r,expressionInfos:n,provider:t});return E.addLayer(o,h),E}async function F(e,r){const{arcadeExecutorProvider:t,expressionInfos:n,layer:o}=r,{description:i,label:s,initialState:a}=e,l={description:i,elements:[],label:s,initialState:a??"expanded"};for(const p of e.elements){const e=await h(p,r);e&&l.elements.push(e)}const m=new u(l),d=await p({element:e,expressionInfos:n,provider:t});return m.addLayer(o,d),m}async function Z(e,{arcadeExecutorProvider:r,layer:t,formTimeZone:n}){const o=new c({field:e,label:e.alias??e.name,formTimeZone:n,layerTimeZone:I(t)}),i={},s=(l(t)||a(t))&&t.subtypeField&&t.subtypeField.toLowerCase()===e.name.toLowerCase();return!s&&e.editable&&t.userHasUpdateItemPrivileges&&(i.editableExpression=await r.getArcadeExecutor("true")),s&&(i.editableExpression=await r.getArcadeExecutor("false")),o.addLayer(t,i),o}function g(e,r,t){return!t.has(e.name.toLowerCase())&&s(e,r)}function I(e){return a(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?m:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:null}export{E as convertFormTemplateToBatchFormTemplate,x as createBatchFormTemplate,b as createBatchFormTemplateFromFields};
5
+ import e from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import t from"../../../../form/ExpressionInfo.js";import{isFieldElement as n,isGroupElement as o}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as i,isFieldVisibleByDefault as s}from"../../../../layers/support/fieldUtils.js";import{isSubtypeSublayer as a,isSubtypeGroupLayer as l}from"../../../../layers/support/layerUtils.js";import{unknown as m}from"../../../../time/constants.js";import{makeExpressionInfosMap as d,makeExecutorSetForFormElement as p}from"../../expressions/expressionUtils.js";import f from"../BatchFormTemplate.js";import{FieldElementTemplate as c}from"../FieldElementTemplate.js";import{GroupElementTemplate as u}from"../GroupElementTemplate.js";const y="expression/dea57012-47ca4b55a000-8df62742ed0c",w=()=>r.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function x(e,r){return e.formTemplate?.elements&&e.formTemplate?.elements.length>0?E(e,r):b(e,r)}async function b(e,{arcadeExecutorProvider:r,formTimeZone:t}){const n=new Set(i(e)),o={arcadeExecutorProvider:r,editTrackingFields:n,formTimeZone:t,layer:e},s=[];for(const i of e.fields)Z(i,e,n)&&s.push(g(i,o));const a=await Promise.all(s);return new f({elements:a,preserveFieldValuesWhenHidden:!0})}function T(e,r){for(const t of e??[])if("group"!==t.type){if("field"===t.type){if(!1===t.editable&&!t.editableExpression)return!0;if(r.subtypeField&&(a(r)||l(r))&&t.fieldName?.toLowerCase()===r.subtypeField.toLowerCase())return!0}}else if(T(t.elements??[],r))return!0;return!1}async function E(e,r){const n=e.formTemplate;if(!n)return b(e,r);let o=null;T(n.elements??[],e)&&(o=new t({title:"",name:y,expression:"false"}));const i=d(o?[...n.expressionInfos??[],o]:n.expressionInfos),s={description:n.description,elements:new Array,title:n.title,preserveFieldValuesWhenHidden:n.preserveFieldValuesWhenHidden},{elements:a}=n;if(!a)return new f(s);const{arcadeExecutorProvider:l,formTimeZone:m}=r;for(const t of a){const r=await h(t,{arcadeExecutorProvider:l,expressionInfos:i,layer:e,formTimeZone:m});r&&s.elements.push(r)}return new f(s)}async function h(r,t){return n(r)?v(r,t):o(r)?F(r,t):(w().warn(new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)),null)}async function v(r,{arcadeExecutorProvider:t,expressionInfos:n,layer:o,formTimeZone:i}){const{fieldsIndex:s}=o,{description:m,domain:d,fieldName:f,hint:u,input:x,label:b}=r;if(null==f||!s.has(f))return w().warn(new e("batch-attribute-form:invalid-form-element-field",`Field element with label '${b}' does not refer to a valid field`)),null;const T={description:m,domain:d,field:s.get(f),hint:u,input:x,formTimeZone:i,layerTimeZone:I(o),label:b};!1!==r.editable||r.editableExpression||((r=r.clone()).editableExpression=y),o.subtypeField&&(a(o)||l(o))&&r.fieldName?.toLowerCase()===o.subtypeField.toLowerCase()&&((r=r.clone()).editableExpression=y);const E=new c(T),h=await p({element:r,expressionInfos:n,provider:t});return E.addLayer(o,h),E}async function F(e,r){const{arcadeExecutorProvider:t,expressionInfos:n,layer:o}=r,{description:i,label:s,initialState:a}=e,l={description:i,elements:[],label:s,initialState:a??"expanded"};for(const p of e.elements){const e=await h(p,r);e&&l.elements.push(e)}const m=new u(l),d=await p({element:e,expressionInfos:n,provider:t});return m.addLayer(o,d),m}async function g(e,{arcadeExecutorProvider:r,layer:t,formTimeZone:n}){const o=new c({field:e,label:e.alias??e.name,formTimeZone:n,layerTimeZone:I(t)}),i={},s=(l(t)||a(t))&&t.subtypeField&&t.subtypeField.toLowerCase()===e.name.toLowerCase();return!s&&e.editable&&t.userHasUpdateItemPrivileges&&(i.editableExpression=await r.getArcadeExecutor("true")),s&&(i.editableExpression=await r.getArcadeExecutor("false")),o.addLayer(t,i),o}function Z(e,r,t){return!t.has(e.name.toLowerCase())&&s(e,r)}function I(e){return a(e)&&e.parent&&(e=e.parent),e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone?m:e&&"preferredTimeZone"in e&&e.preferredTimeZone?e.preferredTimeZone:null}export{E as convertFormTemplateToBatchFormTemplate,x as createBatchFormTemplate,b as createBatchFormTemplateFromFields};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import o from"../core/Identifiable.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as a,convertDateFormatToIntlOptions as s}from"../intl/date.js";import{system as n}from"../time/timeZoneUtils.js";import{SlideThumbnail as l}from"../webdoc/support/SlideThumbnail.js";import d from"./Widget.js";import m from"./Bookmarks/BookmarksUserState.js";import c from"./Bookmarks/BookmarksViewModel.js";import u from"./Bookmarks/BookmarksVisibleElements.js";import{css as k}from"./Bookmarks/css.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as p}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import{calciteListFilterProps as _}from"./support/listUtils.js";import{setFocus as g}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as B}from"./support/jsxFactory.js";let w=class extends(o.IdentifiableMixin(d)){constructor(e,t){super(e,t),this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._lastDragDetail=null,this._selectedDragBookmarkUid=null,this._editIncludeTimeExtent=void 0,this._userState=null,this._focusRootFlowItem=!1,this._focusAddFlowItem=!1,this._focusEditFlowItem=!1,this.disabled=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new c,this.visibleElements=new u,this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t,bookmarks:o}=this,{toEl:i,fromEl:r,dragEl:a,newIndex:s}=e;if(!o.length)return;if(!r||!i||t?.newIndex===s&&t?.dragEl===a&&t?.toEl===i&&t?.fromEl===r)return;this._lastDragDetail=e;const n=Array.from(r.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));o.sort(((e,t)=>{const o=n.indexOf(e.uid),i=n.indexOf(t.uid);return o>i?1:o<i?-1:0})),this._selectedDragBookmarkUid=a.value}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"chip-group":()=>import("@esri/calcite-components/dist/components/calcite-chip-group"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row")})}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(e){this.viewModel.defaultEditOptions=e}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(e){this.viewModel.bookmarks=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"bookmark"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}endAddBookmark(){this._userState=null}goTo(e){return this.viewModel.goTo(e)}render(){return B("div",{class:this.classes(k.base,p.widget,p.panel)},this._renderBookmarksContainer())}startAddBookmark(){this._userState=new m({state:"add"}),this._focusAddFlowItem=!0}_renderNoBookmarksContainer(e){const{messages:t,viewModel:{state:o}}=this;return e.length||"loading"===o?null:B("div",{class:p.empty,key:"no-bookmarks"},B("calcite-icon",{icon:"bookmark",scale:"l"}),B(b,{class:this.classes(p.heading,k.noBookmarksHeader),level:this.headingLevel},t?.noBookmarksHeading),B("p",{class:k.noBookmarksDescription},t.noBookmarksDescription))}_renderEditBookmarkFlowItems(){const{_userState:e}=this,t=e?.editedBookmark;return t&&"edit"===e?.state?this._renderEditingBookmark(t):[]}_renderBookmarkItems(e){return e?e.toArray().map((e=>this._renderBookmark(e))):[]}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:o,oldIndex:i}=e;t.insertBefore(o,t.children[i])}_renderBookmarksContainer(){const{viewModel:{state:e,bookmarks:o},dragEnabled:i,messages:r,disabled:a,filterPlaceholder:s,filterText:n,visible:l,headingLevel:d,visibleElements:{closeButton:m,collapseButton:c,filter:u,heading:h,flow:p},uid:b}=this,g=o.filter(t),f=g.length?B("calcite-list",{class:k.list,displayMode:"flat",dragEnabled:i,filterEnabled:u,filterPlaceholder:s,filterProps:_,filterText:n,group:`bookmarks-${b}`,key:"bookmark-list",label:r.widgetLabel,selectionAppearance:"border",selectionMode:"none",onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},this._renderBookmarkItems(g),u?B("div",{class:k.filterNoResults,slot:"filter-no-results"},B("calcite-notice",{kind:"info",open:!0,width:"full"},B("div",{slot:"message"},r.noBookmarksHeading),";")):null):null,v=[B("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:m,closed:!l,collapsible:c,disabled:a,heading:h?r.widgetLabel:void 0,headingLevel:d,loading:"loading"===e,selected:!this._userState?.state,onCalciteFlowItemClose:()=>this.visible=!1},this._renderNoBookmarksContainer(g),f,this._renderAddBookmarkButton()),this._renderAddingBookmark(),this._renderEditBookmarkFlowItems()];return l?p?B("calcite-flow",{key:"root-flow"},v):v:null}_renderAddBookmarkButton(){const{messages:e,_userState:t,disabled:o,viewModel:{view:i,state:r},visibleElements:{addBookmarkButton:a}}=this,s=t?.loading??!1;return i&&"loading"!==r&&a?B("calcite-fab",{appearance:"outline-fill",bind:this,class:k.addBookmarkButton,disabled:o||s,icon:"plus",key:"add-bookmark-item",kind:"neutral",loading:s,onclick:this.startAddBookmark,slot:"fab",text:e.addBookmark,textEnabled:!0,title:e.addBookmark,type:"button"}):null}_renderEditContainer(e){const{messagesCommon:t,visibleElements:{editBookmarkButton:o}}=this,i=`${t.edit} ${this._getBookmarkTitle(e)}`;return o?B("calcite-action",{appearance:"transparent",icon:"pencil",key:"edit-action",onclick:()=>this._showEditBookmarkForm(e),slot:"actions-end",text:i,title:i}):null}_renderBookmarkImage(e,t){return t?B("img",{alt:"",class:k.bookmarkImage,key:"bookmark-image",src:e.thumbnail?.url}):null}_renderBookmarkTimeSwitch(e){const{messages:t,viewModel:{view:o}}=this,{timeExtent:i}=e;return o?.timeExtent??i?B("calcite-label",{layout:"inline-space-between"},t.includeTimeExtent,B("calcite-switch",{checked:!!i,onCalciteSwitchChange:e=>{this._editIncludeTimeExtent=!!e.currentTarget.checked}})):null}_renderEditBookmarkTimeExtent(e){return this._editIncludeTimeExtent?this._renderBookmarkTimeExtent(e):null}_getTimeExtentStrings(e){const{visibleElements:t}=this,{timeExtent:o}=e;if(!o)return{};const{start:i,end:r}=o,a=null!=r&&(null==i||i.getTime()!==r.getTime()),s=i?this._formatDate(i):"",n=i&&t.time?this._formatTime(i):"";if(!a)return{startDate:s,startTime:n};return{startDate:s,startTime:n,endDate:this._formatDate(r),endTime:t.time?this._formatTime(r):""}}_renderTimeExtentDescription(e){const{startDate:t,startTime:o,endDate:i,endTime:r}=this._getTimeExtentStrings(e);if(!t)return"";const a=`${t} ${o}`;return i?`${a} - ${`${i} ${r}`}`:a}_renderBookmarkTimeExtent(e,t=!1){const{messages:o}=this,{startDate:i,startTime:r,endDate:a,endTime:s}=this._getTimeExtentStrings(e),n=t?null:B("calcite-table-row",{slot:"table-header"},B("calcite-table-header",{heading:o.startDate}),a?B("calcite-table-header",{heading:o.endDate}):null);return i?B("calcite-table",{caption:o.timeExtent,scale:"s"},n,B("calcite-table-row",null,B("calcite-table-cell",null,i," ",r?[B("br",null),r]:null),a?B("calcite-table-cell",null,a,s?[B("br",null),s]:null):null)):null}_renderBookmarkActiveScrim(e,t){return this.viewModel.activeBookmark===e&&t?B("calcite-scrim",{key:"bookmark-active-scrim",loading:!0}):null}_renderBookmarkActiveLoader(e,t){return this.viewModel.activeBookmark!==e||t?null:B("calcite-loader",{class:k.loader,inline:!0,key:"bookmark-active-loader",label:this.messagesCommon.loading})}_renderBookmarkImageIcon(e,t){return this.viewModel.activeBookmark===e||t?null:B("calcite-icon",{icon:"bookmark",key:"bookmark-icon",scale:"s"})}_renderBookmarkThumbnail(e){const t=this.visibleElements.thumbnail&&!!e.thumbnail?.url;return B("div",{class:k.bookmarkImageContainer,slot:"content-start"},this._renderBookmarkActiveScrim(e,t),this._renderBookmarkImage(e,t),this._renderBookmarkActiveLoader(e,t),this._renderBookmarkImageIcon(e,t))}_focusSelectedDragEl(e,t){this._selectedDragBookmarkUid===t.uid&&(g(e),this._selectedDragBookmarkUid=null)}_renderBookmark(e){return B("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes({[k.dragEnabled]:this.dragEnabled}),description:this._renderTimeExtentDescription(e),key:e.uid,label:this._getBookmarkTitle(e),value:e.uid,onCalciteListItemSelect:()=>this._goToBookmark(e)},this._renderBookmarkThumbnail(e),this._renderBookmarkContent(e),this._renderEditContainer(e))}_renderBookmarkContent(e){return B("div",{class:k.bookmarkContent,slot:"content"},B("span",{class:k.bookmarkContentLabel},this._getBookmarkTitle(e)),this._renderBookmarkTimeExtent(e,!0))}_renderEditingBookmarkName(e){const{messages:t,_userState:o}=this,i="name-required"===o?.validationState;return B("calcite-label",null,t.title,B("calcite-input",{afterCreate:this._storeEditInput,bind:this,class:k.editBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:e.name}),i?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderEditingBookmarkActions(){const{messagesCommon:e,_userState:t}=this,o=t?.bookmark;return[B("calcite-button",{appearance:"transparent",kind:"danger",onclick:()=>this._deleteBookmark(o),slot:"footer",type:"button",width:"full"},e.delete),B("calcite-button",{appearance:"outline",bind:this,onclick:this._closeEditBookmarkForm,slot:"footer",type:"button",width:"full"},e.cancel),B("calcite-button",{slot:"footer",type:"submit",width:"full"},e.save)]}_handleUrlEditInputChange(){const{_userState:e,_urlEditInputNode:t}=this,o=t?.value;if(!e?.editedBookmark||!o)return;e.validationState=void 0,e.editedBookmark.thumbnail?.isDataURI&&(e.screenshotUrl=e.editedBookmark.thumbnail?.url);const i=new l({url:o});i.isSecureUrl&&(e.customUrl=o,e.editedBookmark.thumbnail=i)}_renderEditingTimeExtent(e){const{capabilities:t,view:o}=this.viewModel,{timeExtent:i}=e;return t.time&&(o?.timeExtent??i)?B("div",{key:"edit-bookmark-time-container"},this._renderBookmarkTimeSwitch(e),this._renderEditBookmarkTimeExtent(e)):null}_renderEditingBookmarkImage(e){const{_userState:t}=this,o=t?.thumbnailState,i=e.thumbnail?.isSecureUrl?"url"===o:e.thumbnail?.isDataURI?"screenshot"===o:null;if(i)return this._renderBookmarkImage(e,i)}_renderEditingThumbnail(e){const{_userState:t,visibleElements:o}=this,i=t?.thumbnailState;return o.thumbnail&&"none"!==i?B("div",{class:k.authoringImageContainer},this._renderEditingBookmarkImage(e)):null}_renderUpdateThumbnailButton(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail&&"screenshot"===i?B("calcite-button",{appearance:"outline",class:k.authoringRefreshThumbnailButton,iconStart:"refresh",key:"update-thumbnail",kind:"neutral",onclick:()=>{this._updateThumbnail()},width:"full"},t.updateThumbnail):null}_renderEditingBookmarkUrlInput(e){const{messages:t,_userState:o}=this,i=e.thumbnail?.url,r=e.thumbnail?.isSecureUrl?i:void 0,a=i&&"absolute-url-required"===o?.validationState,s=o?.thumbnailState;return"url"===s?B("calcite-label",{key:"thumbnail-url-input"},B("calcite-input",{afterCreate:this._storeUrlEditInput,bind:this,name:"bookmark-thumbnail-url",pattern:"https://.*",placeholder:t?`https://<${t.imageUrlPlaceholder}>`:void 0,required:!0,title:t.imageUrlTooltip,type:"text",value:r,onCalciteInputChange:this._handleUrlEditInputChange,onCalciteInputInput:this._handleUrlEditInputChange}),a?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidImageUrl):null):null}_renderThumbnailSelector(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail?B("calcite-label",{key:"thumbnail-chip-group"},t.thumbnail,B("calcite-chip-group",{label:t.thumbnail,selectionMode:"single-persist",onCalciteChipGroupSelect:e=>this._handleThumbnailTypeSelect(e.currentTarget.selectedItems[0].value)},B("calcite-chip",{label:t.screenshot,selected:"screenshot"===i,value:"screenshot"},t.screenshot),B("calcite-chip",{label:t.url,selected:"url"===i,value:"url"},t.url),B("calcite-chip",{label:t.none,selected:"none"===i,value:"none"},t.none))):null}_renderEditingBookmark(e){const{disabled:t,messagesCommon:o,headingLevel:i}=this;return e?B("form",{bind:this,class:k.form,disabled:this.disabled,onsubmit:this._editBookmarkSubmit},B("calcite-flow-item",{afterCreate:this._focusEditFlowItemNode,afterUpdate:this._focusEditFlowItemNode,bind:this,disabled:t,heading:o.edit,headingLevel:i,key:"edit-bookmark-form",selected:"edit"===this._userState?.state,onCalciteFlowItemBack:e=>{e.preventDefault(),this._closeEditBookmarkForm()}},B("div",{class:k.formContent},B("div",{class:k.authoring},this._renderEditingBookmarkName(e),this._renderThumbnailSelector(),this._renderEditingThumbnail(e),this._renderEditingBookmarkUrlInput(e),this._renderUpdateThumbnailButton(),this._renderEditingTimeExtent(e))),this._renderEditingBookmarkActions())):null}_renderAddingBookmarkName(){const{_userState:e,messages:t}=this,o="name-required"===e?.validationState;return B("calcite-label",null,t.title,B("calcite-input",{afterCreate:this._storeAddInput,bind:this,class:k.addBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:""}),o?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderAddingBookmarkActions(){const{messagesCommon:e}=this;return[B("calcite-button",{appearance:"outline",bind:this,onclick:this._endAddBookmark,slot:"footer",type:"button",width:"full"},e.cancel),B("calcite-button",{slot:"footer",type:"submit",width:"full"},e.add)]}_renderAddingBookmark(){const{disabled:e,messages:t,headingLevel:o,_userState:i}=this;return"add"===i?.state?B("form",{bind:this,class:k.form,disabled:e,onsubmit:this._addBookmarkSubmitClick},B("calcite-flow-item",{afterCreate:this._focusAddFlowItemNode,afterUpdate:this._focusAddFlowItemNode,bind:this,disabled:e,heading:t.addBookmark,headingLevel:o,key:"add-bookmark-form",selected:"add"===this._userState?.state,onCalciteFlowItemBack:e=>{e.preventDefault(),this._endAddBookmark()}},B("div",{class:k.formContent},this._renderAddingBookmarkName()),this._renderAddingBookmarkActions())):null}_getBookmarkTitle(e){return e?.name||this.messagesCommon.untitled}_formatDate(e){return e?a(e,{...s("short-date"),timeZone:this.viewModel.view?.timeZone??n}):""}_formatTime(e){return e?a(e,{...s("long-time"),timeZone:this.viewModel.view?.timeZone??n}):""}_endAddBookmark(){this.endAddBookmark(),this._focusRootFlowItem=!0}_showEditBookmarkForm(e){e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._userState=new m({bookmark:e,state:"edit"}),this._focusEditFlowItem=!0,this.viewModel.goTo(e))}async _createNewScreenshotUrl(){const e=await this.viewModel.createBookmark();return e.thumbnail?.url??null}_storeCurrentUrl(){const{_userState:e}=this,t=e?.editedBookmark?.thumbnail?.url;t&&(e?.editedBookmark?.thumbnail?.isSecureUrl?e.customUrl=t:e?.editedBookmark?.thumbnail?.isDataURI&&(e.screenshotUrl=t))}async _handleThumbnailTypeSelect(e){const{_userState:t}=this;if(!t)return;const{screenshotUrl:o,customUrl:i,editedBookmark:r}=t,a="screenshot"===e?o??await this._createNewScreenshotUrl():"url"===e&&i?i:null;this._storeCurrentUrl(),r&&a&&(r.thumbnail=new l({url:a})),t.validationState=void 0,t.thumbnailState=e}_closeEditBookmarkForm(){this._userState=null,this._focusRootFlowItem=!0}_addBookmarkSubmitClick(e){e.preventDefault(),this._addBookmarkSubmit()}async _addBookmarkSubmit(){const{_addInputNode:e,_userState:t,viewModel:o,viewModel:{bookmarks:i}}=this;if(!t)return;const r=e?e.value.trim():null;if(!r)return void(t.validationState="name-required");t.loading=!0;const a=await o.createBookmark();a.name=r,i.add(a),this._endAddBookmark()}async _editBookmarkAndClose(e,t){const{viewModel:o,viewModel:{defaultEditOptions:i}}=this;await o.editBookmark(e,{...i,...t}),this._closeEditBookmarkForm()}_editBookmarkSubmit(e){e.preventDefault();const{_editInputNode:t,_userState:o,_editIncludeTimeExtent:i,_urlEditInputNode:r}=this;if(!o?.bookmark||!o.editedBookmark)return;o.validationState=void 0,o.customUrl=void 0,o.screenshotUrl=void 0;const a=t?.value.trim();if(!a)return void(o.validationState="name-required");o.bookmark.name=a,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null);const s=o.thumbnailState;if("url"===s&&r){const e=r.value,t=new l({url:e});if(!t.isSecureUrl)return void(o.validationState="absolute-url-required");o.bookmark.thumbnail=t}else"none"===s&&(o.bookmark.thumbnail=null);this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})}_storeEditInput(e){this._editInputNode=e}_storeAddInput(e){this._addInputNode=e}_storeUrlEditInput(e){this._urlEditInputNode=e}_deleteBookmark(e){this._closeEditBookmarkForm(),e&&(this.viewModel.bookmarks.remove(e),e.destroy())}_goToBookmark(e){this.endAddBookmark(),this.viewModel.goTo(e)}async _updateThumbnail(){const{_userState:e,viewModel:t}=this;e&&(e.validationState=void 0,await t.editBookmark(e.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,g(e))}_focusEditFlowItemNode(e){this._focusEditFlowItem&&(this._focusEditFlowItem=!1,g(e))}_focusAddFlowItemNode(e){this._focusAddFlowItem&&(this._focusAddFlowItem=!1,g(e))}};e([i()],w.prototype,"_editIncludeTimeExtent",void 0),e([i({type:m})],w.prototype,"_userState",void 0),e([i()],w.prototype,"_focusRootFlowItem",void 0),e([i()],w.prototype,"_focusAddFlowItem",void 0),e([i()],w.prototype,"_focusEditFlowItem",void 0),e([i()],w.prototype,"defaultCreateOptions",null),e([i()],w.prototype,"defaultEditOptions",null),e([i()],w.prototype,"bookmarks",null),e([i()],w.prototype,"disabled",void 0),e([i()],w.prototype,"dragEnabled",void 0),e([i()],w.prototype,"filterPlaceholder",void 0),e([i()],w.prototype,"filterText",void 0),e([i()],w.prototype,"headingLevel",void 0),e([i()],w.prototype,"goToOverride",null),e([i()],w.prototype,"icon",null),e([i()],w.prototype,"label",null),e([i(),f("esri/widgets/Bookmarks/t9n/Bookmarks")],w.prototype,"messages",void 0),e([i(),f("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([i()],w.prototype,"uiStrings",void 0),e([i()],w.prototype,"view",null),e([i({type:c}),v(["select-bookmark","bookmark-edit","bookmark-select"])],w.prototype,"viewModel",void 0),e([i({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([i()],w.prototype,"endAddBookmark",null),e([i()],w.prototype,"startAddBookmark",null),w=e([r("esri.widgets.Bookmarks")],w);const E=w;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import o from"../core/Identifiable.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as a,convertDateFormatToIntlOptions as s}from"../intl/date.js";import{system as n}from"../time/constants.js";import{SlideThumbnail as l}from"../webdoc/support/SlideThumbnail.js";import d from"./Widget.js";import m from"./Bookmarks/BookmarksUserState.js";import c from"./Bookmarks/BookmarksViewModel.js";import u from"./Bookmarks/BookmarksVisibleElements.js";import{css as k}from"./Bookmarks/css.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as p}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import{calciteListFilterProps as _}from"./support/listUtils.js";import{setFocus as g}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{vmEvent as v}from"./support/decorators/vmEvent.js";import{tsx as B}from"./support/jsxFactory.js";let w=class extends(o.IdentifiableMixin(d)){constructor(e,t){super(e,t),this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._lastDragDetail=null,this._selectedDragBookmarkUid=null,this._editIncludeTimeExtent=void 0,this._userState=null,this._focusRootFlowItem=!1,this._focusAddFlowItem=!1,this._focusEditFlowItem=!1,this.disabled=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.viewModel=new c,this.visibleElements=new u,this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t,bookmarks:o}=this,{toEl:i,fromEl:r,dragEl:a,newIndex:s}=e;if(!o.length)return;if(!r||!i||t?.newIndex===s&&t?.dragEl===a&&t?.toEl===i&&t?.fromEl===r)return;this._lastDragDetail=e;const n=Array.from(r.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));o.sort(((e,t)=>{const o=n.indexOf(e.uid),i=n.indexOf(t.uid);return o>i?1:o<i?-1:0})),this._selectedDragBookmarkUid=a.value}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),"chip-group":()=>import("@esri/calcite-components/dist/components/calcite-chip-group"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),table:()=>import("@esri/calcite-components/dist/components/calcite-table"),"table-cell":()=>import("@esri/calcite-components/dist/components/calcite-table-cell"),"table-header":()=>import("@esri/calcite-components/dist/components/calcite-table-header"),"table-row":()=>import("@esri/calcite-components/dist/components/calcite-table-row")})}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(e){this.viewModel.defaultEditOptions=e}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(e){this.viewModel.bookmarks=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"bookmark"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}endAddBookmark(){this._userState=null}goTo(e){return this.viewModel.goTo(e)}render(){return B("div",{class:this.classes(k.base,p.widget,p.panel)},this._renderBookmarksContainer())}startAddBookmark(){this._userState=new m({state:"add"}),this._focusAddFlowItem=!0}_renderNoBookmarksContainer(e){const{messages:t,viewModel:{state:o}}=this;return e.length||"loading"===o?null:B("div",{class:p.empty,key:"no-bookmarks"},B("calcite-icon",{icon:"bookmark",scale:"l"}),B(b,{class:this.classes(p.heading,k.noBookmarksHeader),level:this.headingLevel},t?.noBookmarksHeading),B("p",{class:k.noBookmarksDescription},t.noBookmarksDescription))}_renderEditBookmarkFlowItems(){const{_userState:e}=this,t=e?.editedBookmark;return t&&"edit"===e?.state?this._renderEditingBookmark(t):[]}_renderBookmarkItems(e){return e?e.toArray().map((e=>this._renderBookmark(e))):[]}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:o,oldIndex:i}=e;t.insertBefore(o,t.children[i])}_renderBookmarksContainer(){const{viewModel:{state:e,bookmarks:o},dragEnabled:i,messages:r,disabled:a,filterPlaceholder:s,filterText:n,visible:l,headingLevel:d,visibleElements:{closeButton:m,collapseButton:c,filter:u,heading:h,flow:p},uid:b}=this,g=o.filter(t),f=g.length?B("calcite-list",{class:k.list,displayMode:"flat",dragEnabled:i,filterEnabled:u,filterPlaceholder:s,filterProps:_,filterText:n,group:`bookmarks-${b}`,key:"bookmark-list",label:r.widgetLabel,selectionAppearance:"border",selectionMode:"none",onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},this._renderBookmarkItems(g),u?B("div",{class:k.filterNoResults,slot:"filter-no-results"},B("calcite-notice",{kind:"info",open:!0,width:"full"},B("div",{slot:"message"},r.noBookmarksHeading),";")):null):null,v=[B("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:m,closed:!l,collapsible:c,disabled:a,heading:h?r.widgetLabel:void 0,headingLevel:d,loading:"loading"===e,selected:!this._userState?.state,onCalciteFlowItemClose:()=>this.visible=!1},this._renderNoBookmarksContainer(g),f,this._renderAddBookmarkButton()),this._renderAddingBookmark(),this._renderEditBookmarkFlowItems()];return l?p?B("calcite-flow",{key:"root-flow"},v):v:null}_renderAddBookmarkButton(){const{messages:e,_userState:t,disabled:o,viewModel:{view:i,state:r},visibleElements:{addBookmarkButton:a}}=this,s=t?.loading??!1;return i&&"loading"!==r&&a?B("calcite-fab",{appearance:"outline-fill",bind:this,class:k.addBookmarkButton,disabled:o||s,icon:"plus",key:"add-bookmark-item",kind:"neutral",loading:s,onclick:this.startAddBookmark,slot:"fab",text:e.addBookmark,textEnabled:!0,title:e.addBookmark,type:"button"}):null}_renderEditContainer(e){const{messagesCommon:t,visibleElements:{editBookmarkButton:o}}=this,i=`${t.edit} ${this._getBookmarkTitle(e)}`;return o?B("calcite-action",{appearance:"transparent",icon:"pencil",key:"edit-action",onclick:()=>this._showEditBookmarkForm(e),slot:"actions-end",text:i,title:i}):null}_renderBookmarkImage(e,t){return t?B("img",{alt:"",class:k.bookmarkImage,key:"bookmark-image",src:e.thumbnail?.url}):null}_renderBookmarkTimeSwitch(e){const{messages:t,viewModel:{view:o}}=this,{timeExtent:i}=e;return o?.timeExtent??i?B("calcite-label",{layout:"inline-space-between"},t.includeTimeExtent,B("calcite-switch",{checked:!!i,onCalciteSwitchChange:e=>{this._editIncludeTimeExtent=!!e.currentTarget.checked}})):null}_renderEditBookmarkTimeExtent(e){return this._editIncludeTimeExtent?this._renderBookmarkTimeExtent(e):null}_getTimeExtentStrings(e){const{visibleElements:t}=this,{timeExtent:o}=e;if(!o)return{};const{start:i,end:r}=o,a=null!=r&&(null==i||i.getTime()!==r.getTime()),s=i?this._formatDate(i):"",n=i&&t.time?this._formatTime(i):"";if(!a)return{startDate:s,startTime:n};return{startDate:s,startTime:n,endDate:this._formatDate(r),endTime:t.time?this._formatTime(r):""}}_renderTimeExtentDescription(e){const{startDate:t,startTime:o,endDate:i,endTime:r}=this._getTimeExtentStrings(e);if(!t)return"";const a=`${t} ${o}`;return i?`${a} - ${`${i} ${r}`}`:a}_renderBookmarkTimeExtent(e,t=!1){const{messages:o}=this,{startDate:i,startTime:r,endDate:a,endTime:s}=this._getTimeExtentStrings(e),n=t?null:B("calcite-table-row",{slot:"table-header"},B("calcite-table-header",{heading:o.startDate}),a?B("calcite-table-header",{heading:o.endDate}):null);return i?B("calcite-table",{caption:o.timeExtent,scale:"s"},n,B("calcite-table-row",null,B("calcite-table-cell",null,i," ",r?[B("br",null),r]:null),a?B("calcite-table-cell",null,a,s?[B("br",null),s]:null):null)):null}_renderBookmarkActiveScrim(e,t){return this.viewModel.activeBookmark===e&&t?B("calcite-scrim",{key:"bookmark-active-scrim",loading:!0}):null}_renderBookmarkActiveLoader(e,t){return this.viewModel.activeBookmark!==e||t?null:B("calcite-loader",{class:k.loader,inline:!0,key:"bookmark-active-loader",label:this.messagesCommon.loading})}_renderBookmarkImageIcon(e,t){return this.viewModel.activeBookmark===e||t?null:B("calcite-icon",{icon:"bookmark",key:"bookmark-icon",scale:"s"})}_renderBookmarkThumbnail(e){const t=this.visibleElements.thumbnail&&!!e.thumbnail?.url;return B("div",{class:k.bookmarkImageContainer,slot:"content-start"},this._renderBookmarkActiveScrim(e,t),this._renderBookmarkImage(e,t),this._renderBookmarkActiveLoader(e,t),this._renderBookmarkImageIcon(e,t))}_focusSelectedDragEl(e,t){this._selectedDragBookmarkUid===t.uid&&(g(e),this._selectedDragBookmarkUid=null)}_renderBookmark(e){return B("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes({[k.dragEnabled]:this.dragEnabled}),description:this._renderTimeExtentDescription(e),key:e.uid,label:this._getBookmarkTitle(e),value:e.uid,onCalciteListItemSelect:()=>this._goToBookmark(e)},this._renderBookmarkThumbnail(e),this._renderBookmarkContent(e),this._renderEditContainer(e))}_renderBookmarkContent(e){return B("div",{class:k.bookmarkContent,slot:"content"},B("span",{class:k.bookmarkContentLabel},this._getBookmarkTitle(e)),this._renderBookmarkTimeExtent(e,!0))}_renderEditingBookmarkName(e){const{messages:t,_userState:o}=this,i="name-required"===o?.validationState;return B("calcite-label",null,t.title,B("calcite-input",{afterCreate:this._storeEditInput,bind:this,class:k.editBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:e.name}),i?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderEditingBookmarkActions(){const{messagesCommon:e,_userState:t}=this,o=t?.bookmark;return[B("calcite-button",{appearance:"transparent",kind:"danger",onclick:()=>this._deleteBookmark(o),slot:"footer",type:"button",width:"full"},e.delete),B("calcite-button",{appearance:"outline",bind:this,onclick:this._closeEditBookmarkForm,slot:"footer",type:"button",width:"full"},e.cancel),B("calcite-button",{slot:"footer",type:"submit",width:"full"},e.save)]}_handleUrlEditInputChange(){const{_userState:e,_urlEditInputNode:t}=this,o=t?.value;if(!e?.editedBookmark||!o)return;e.validationState=void 0,e.editedBookmark.thumbnail?.isDataURI&&(e.screenshotUrl=e.editedBookmark.thumbnail?.url);const i=new l({url:o});i.isSecureUrl&&(e.customUrl=o,e.editedBookmark.thumbnail=i)}_renderEditingTimeExtent(e){const{capabilities:t,view:o}=this.viewModel,{timeExtent:i}=e;return t.time&&(o?.timeExtent??i)?B("div",{key:"edit-bookmark-time-container"},this._renderBookmarkTimeSwitch(e),this._renderEditBookmarkTimeExtent(e)):null}_renderEditingBookmarkImage(e){const{_userState:t}=this,o=t?.thumbnailState,i=e.thumbnail?.isSecureUrl?"url"===o:e.thumbnail?.isDataURI?"screenshot"===o:null;if(i)return this._renderBookmarkImage(e,i)}_renderEditingThumbnail(e){const{_userState:t,visibleElements:o}=this,i=t?.thumbnailState;return o.thumbnail&&"none"!==i?B("div",{class:k.authoringImageContainer},this._renderEditingBookmarkImage(e)):null}_renderUpdateThumbnailButton(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail&&"screenshot"===i?B("calcite-button",{appearance:"outline",class:k.authoringRefreshThumbnailButton,iconStart:"refresh",key:"update-thumbnail",kind:"neutral",onclick:()=>{this._updateThumbnail()},width:"full"},t.updateThumbnail):null}_renderEditingBookmarkUrlInput(e){const{messages:t,_userState:o}=this,i=e.thumbnail?.url,r=e.thumbnail?.isSecureUrl?i:void 0,a=i&&"absolute-url-required"===o?.validationState,s=o?.thumbnailState;return"url"===s?B("calcite-label",{key:"thumbnail-url-input"},B("calcite-input",{afterCreate:this._storeUrlEditInput,bind:this,name:"bookmark-thumbnail-url",pattern:"https://.*",placeholder:t?`https://<${t.imageUrlPlaceholder}>`:void 0,required:!0,title:t.imageUrlTooltip,type:"text",value:r,onCalciteInputChange:this._handleUrlEditInputChange,onCalciteInputInput:this._handleUrlEditInputChange}),a?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidImageUrl):null):null}_renderThumbnailSelector(){const{visibleElements:e,messages:t,_userState:o}=this,i=o?.thumbnailState;return e.thumbnail?B("calcite-label",{key:"thumbnail-chip-group"},t.thumbnail,B("calcite-chip-group",{label:t.thumbnail,selectionMode:"single-persist",onCalciteChipGroupSelect:e=>this._handleThumbnailTypeSelect(e.currentTarget.selectedItems[0].value)},B("calcite-chip",{label:t.screenshot,selected:"screenshot"===i,value:"screenshot"},t.screenshot),B("calcite-chip",{label:t.url,selected:"url"===i,value:"url"},t.url),B("calcite-chip",{label:t.none,selected:"none"===i,value:"none"},t.none))):null}_renderEditingBookmark(e){const{disabled:t,messagesCommon:o,headingLevel:i}=this;return e?B("form",{bind:this,class:k.form,disabled:this.disabled,onsubmit:this._editBookmarkSubmit},B("calcite-flow-item",{afterCreate:this._focusEditFlowItemNode,afterUpdate:this._focusEditFlowItemNode,bind:this,disabled:t,heading:o.edit,headingLevel:i,key:"edit-bookmark-form",selected:"edit"===this._userState?.state,onCalciteFlowItemBack:e=>{e.preventDefault(),this._closeEditBookmarkForm()}},B("div",{class:k.formContent},B("div",{class:k.authoring},this._renderEditingBookmarkName(e),this._renderThumbnailSelector(),this._renderEditingThumbnail(e),this._renderEditingBookmarkUrlInput(e),this._renderUpdateThumbnailButton(),this._renderEditingTimeExtent(e))),this._renderEditingBookmarkActions())):null}_renderAddingBookmarkName(){const{_userState:e,messages:t}=this,o="name-required"===e?.validationState;return B("calcite-label",null,t.title,B("calcite-input",{afterCreate:this._storeAddInput,bind:this,class:k.addBookmarkInput,name:"bookmark-name",placeholder:t.titlePlaceholder,required:!0,type:"text",value:""}),o?B("calcite-input-message",{icon:"exclamation-mark-triangle",status:"invalid"},t.invalidTitle):null)}_renderAddingBookmarkActions(){const{messagesCommon:e}=this;return[B("calcite-button",{appearance:"outline",bind:this,onclick:this._endAddBookmark,slot:"footer",type:"button",width:"full"},e.cancel),B("calcite-button",{slot:"footer",type:"submit",width:"full"},e.add)]}_renderAddingBookmark(){const{disabled:e,messages:t,headingLevel:o,_userState:i}=this;return"add"===i?.state?B("form",{bind:this,class:k.form,disabled:e,onsubmit:this._addBookmarkSubmitClick},B("calcite-flow-item",{afterCreate:this._focusAddFlowItemNode,afterUpdate:this._focusAddFlowItemNode,bind:this,disabled:e,heading:t.addBookmark,headingLevel:o,key:"add-bookmark-form",selected:"add"===this._userState?.state,onCalciteFlowItemBack:e=>{e.preventDefault(),this._endAddBookmark()}},B("div",{class:k.formContent},this._renderAddingBookmarkName()),this._renderAddingBookmarkActions())):null}_getBookmarkTitle(e){return e?.name||this.messagesCommon.untitled}_formatDate(e){return e?a(e,{...s("short-date"),timeZone:this.viewModel.view?.timeZone??n}):""}_formatTime(e){return e?a(e,{...s("long-time"),timeZone:this.viewModel.view?.timeZone??n}):""}_endAddBookmark(){this.endAddBookmark(),this._focusRootFlowItem=!0}_showEditBookmarkForm(e){e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._userState=new m({bookmark:e,state:"edit"}),this._focusEditFlowItem=!0,this.viewModel.goTo(e))}async _createNewScreenshotUrl(){const e=await this.viewModel.createBookmark();return e.thumbnail?.url??null}_storeCurrentUrl(){const{_userState:e}=this,t=e?.editedBookmark?.thumbnail?.url;t&&(e?.editedBookmark?.thumbnail?.isSecureUrl?e.customUrl=t:e?.editedBookmark?.thumbnail?.isDataURI&&(e.screenshotUrl=t))}async _handleThumbnailTypeSelect(e){const{_userState:t}=this;if(!t)return;const{screenshotUrl:o,customUrl:i,editedBookmark:r}=t,a="screenshot"===e?o??await this._createNewScreenshotUrl():"url"===e&&i?i:null;this._storeCurrentUrl(),r&&a&&(r.thumbnail=new l({url:a})),t.validationState=void 0,t.thumbnailState=e}_closeEditBookmarkForm(){this._userState=null,this._focusRootFlowItem=!0}_addBookmarkSubmitClick(e){e.preventDefault(),this._addBookmarkSubmit()}async _addBookmarkSubmit(){const{_addInputNode:e,_userState:t,viewModel:o,viewModel:{bookmarks:i}}=this;if(!t)return;const r=e?e.value.trim():null;if(!r)return void(t.validationState="name-required");t.loading=!0;const a=await o.createBookmark();a.name=r,i.add(a),this._endAddBookmark()}async _editBookmarkAndClose(e,t){const{viewModel:o,viewModel:{defaultEditOptions:i}}=this;await o.editBookmark(e,{...i,...t}),this._closeEditBookmarkForm()}_editBookmarkSubmit(e){e.preventDefault();const{_editInputNode:t,_userState:o,_editIncludeTimeExtent:i,_urlEditInputNode:r}=this;if(!o?.bookmark||!o.editedBookmark)return;o.validationState=void 0,o.customUrl=void 0,o.screenshotUrl=void 0;const a=t?.value.trim();if(!a)return void(o.validationState="name-required");o.bookmark.name=a,o.bookmark.thumbnail=o.editedBookmark.thumbnail,i||(o.bookmark.timeExtent=null);const s=o.thumbnailState;if("url"===s&&r){const e=r.value,t=new l({url:e});if(!t.isSecureUrl)return void(o.validationState="absolute-url-required");o.bookmark.thumbnail=t}else"none"===s&&(o.bookmark.thumbnail=null);this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:i})}_storeEditInput(e){this._editInputNode=e}_storeAddInput(e){this._addInputNode=e}_storeUrlEditInput(e){this._urlEditInputNode=e}_deleteBookmark(e){this._closeEditBookmarkForm(),e&&(this.viewModel.bookmarks.remove(e),e.destroy())}_goToBookmark(e){this.endAddBookmark(),this.viewModel.goTo(e)}async _updateThumbnail(){const{_userState:e,viewModel:t}=this;e&&(e.validationState=void 0,await t.editBookmark(e.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,g(e))}_focusEditFlowItemNode(e){this._focusEditFlowItem&&(this._focusEditFlowItem=!1,g(e))}_focusAddFlowItemNode(e){this._focusAddFlowItem&&(this._focusAddFlowItem=!1,g(e))}};e([i()],w.prototype,"_editIncludeTimeExtent",void 0),e([i({type:m})],w.prototype,"_userState",void 0),e([i()],w.prototype,"_focusRootFlowItem",void 0),e([i()],w.prototype,"_focusAddFlowItem",void 0),e([i()],w.prototype,"_focusEditFlowItem",void 0),e([i()],w.prototype,"defaultCreateOptions",null),e([i()],w.prototype,"defaultEditOptions",null),e([i()],w.prototype,"bookmarks",null),e([i()],w.prototype,"disabled",void 0),e([i()],w.prototype,"dragEnabled",void 0),e([i()],w.prototype,"filterPlaceholder",void 0),e([i()],w.prototype,"filterText",void 0),e([i()],w.prototype,"headingLevel",void 0),e([i()],w.prototype,"goToOverride",null),e([i()],w.prototype,"icon",null),e([i()],w.prototype,"label",null),e([i(),f("esri/widgets/Bookmarks/t9n/Bookmarks")],w.prototype,"messages",void 0),e([i(),f("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([i()],w.prototype,"uiStrings",void 0),e([i()],w.prototype,"view",null),e([i({type:c}),v(["select-bookmark","bookmark-edit","bookmark-select"])],w.prototype,"viewModel",void 0),e([i({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),e([i()],w.prototype,"endAddBookmark",null),e([i()],w.prototype,"startAddBookmark",null),w=e([r("esri.widgets.Bookmarks")],w);const E=w;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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,convertDateFormatToIntlOptions as m,formatTimestamp as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as g}from"../../intl/locale.js";import{fetchServiceDescription as f}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as S,defaultTimePattern as D}from"../../support/dateUtils.js";import{system as C,shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import I from"../support/GoTo.js";import{DateTime as L,FixedOffsetZone as j,IANAZone as R}from"luxon";function P(e){return e.map((e=>({locale:e,parts:g(e)}))).filter((({parts:e})=>!!e))}function E(e,t){return e.find((({parts:e})=>F(e.language,t.language)&&e.region===t.region))?.locale??e.find((({parts:e})=>F(e.language,t.language)))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function F(e,t){return e===t||N(e)&&N(t)}function O(e){return"esri.rest.support.Stop"===e?.declaredClass}var k;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(k||(k={}));let V=class extends(I(i.EventedAccessor)){constructor(e){super(e),this._debouncedSolveHandler=s((async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}})),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=k.Idle,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=void 0,this.departureIsoTime=void 0,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l((()=>this.layer),(e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d((()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null),(e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)}),{once:!0}))}}),u),l((()=>[this.layer,this.view]),(async()=>{this._layerView=await this._getRouteLayerView()}),u),n((()=>this._layerView),["create","delete","update"],(e=>{this._debouncedSolveHandler(e).catch((e=>{if(!a(e))throw e}))}))]);const e=p(this.view?.timeZone??C),t=L.fromMillis(Date.now());this.departureIsoDate=t.toFormat(S,A(e)),this.departureIsoTime=t.toFormat(D,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=g(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=L.fromJSDate(e,{zone:j.instance(t)}),i=L.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=L.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:m("short-date"),n=m("short-time");return v(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case k.Suspended:return"unauthenticated";case k.Idle:return"disabled";case k.Active:return"initializing";case k.Failed:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=O(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||this._serviceDescriptionStatus===k.Failed)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter((({geometry:e})=>null!=e)).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:d}=this._routeController;let c=null;try{c=await i.solve(u,{signal:d})}catch(h){if(!a(h)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:h});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of c.stops)null==r.geometry&&(r.name=null);return i.update(c),this._set("lastRoute",c),e.zoomToSolvedRoute&&this.zoomToRoute(),c}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find((({name:t,usageType:r})=>t===e&&"cost"===r))??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=L.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:j.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=k.Active;const t=await f(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=k.Complete}catch(t){if(a(t))return void(this._serviceDescriptionStatus=k.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=k.Suspended);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=k.Failed,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find((({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase())),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find((({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase()));return o??t}};e([c()],V.prototype,"_directionsLanguage",null),e([c()],V.prototype,"_layerView",void 0),e([c()],V.prototype,"_routeController",void 0),e([c()],V.prototype,"_serviceDescriptionStatus",void 0),e([c()],V.prototype,"apiKey",void 0),e([c()],V.prototype,"autoSolve",void 0),e([c()],V.prototype,"defaultTravelMode",void 0),e([c()],V.prototype,"departureTime",void 0),e([c()],V.prototype,"formattedEta",null),e([c({readOnly:!0})],V.prototype,"impedanceAttribute",null),e([c()],V.prototype,"lastError",void 0),e([c({readOnly:!0})],V.prototype,"lastRoute",void 0),e([c()],V.prototype,"layer",void 0),e([c({type:Number,range:{min:2,max:50},nonNullable:!0})],V.prototype,"maxStops",void 0),e([c({type:w,nonNullable:!0})],V.prototype,"routeParameters",void 0),e([c({readOnly:!0})],V.prototype,"selectedNetworkFeatures",null),e([c({type:T})],V.prototype,"selectedTravelMode",null),e([c({readOnly:!0})],V.prototype,"serviceDescription",void 0),e([c({readOnly:!0})],V.prototype,"state",null),e([c({readOnly:!0})],V.prototype,"timeAttribute",null),e([c()],V.prototype,"travelModes",null),e([c()],V.prototype,"view",void 0),e([c()],V.prototype,"zoomToRoute",null),V=e([h("esri.widgets.Directions.DirectionsViewModel")],V);const z=V;export{z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import i from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,convertDateFormatToIntlOptions as m,formatTimestamp as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as f}from"../../intl/locale.js";import{fetchServiceDescription as g}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as S,defaultTimePattern as D}from"../../support/dateUtils.js";import{system as C}from"../../time/constants.js";import{shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import I from"../support/GoTo.js";import{DateTime as j,FixedOffsetZone as L,IANAZone as R}from"luxon";function P(e){return e.map((e=>({locale:e,parts:f(e)}))).filter((({parts:e})=>!!e))}function E(e,t){return e.find((({parts:e})=>F(e.language,t.language)&&e.region===t.region))?.locale??e.find((({parts:e})=>F(e.language,t.language)))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function F(e,t){return e===t||N(e)&&N(t)}function O(e){return"esri.rest.support.Stop"===e?.declaredClass}var k;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(k||(k={}));let V=class extends(I(i.EventedAccessor)){constructor(e){super(e),this._debouncedSolveHandler=s((async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}})),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=k.Idle,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=void 0,this.departureIsoTime=void 0,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l((()=>this.layer),(e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d((()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null),(e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)}),{once:!0}))}}),u),l((()=>[this.layer,this.view]),(async()=>{this._layerView=await this._getRouteLayerView()}),u),n((()=>this._layerView),["create","delete","update"],(e=>{this._debouncedSolveHandler(e).catch((e=>{if(!a(e))throw e}))}))]);const e=p(this.view?.timeZone??C),t=j.fromMillis(Date.now());this.departureIsoDate=t.toFormat(S,A(e)),this.departureIsoTime=t.toFormat(D,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=f(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=j.fromJSDate(e,{zone:L.instance(t)}),i=j.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=j.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:m("short-date"),n=m("short-time");return v(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case k.Suspended:return"unauthenticated";case k.Idle:return"disabled";case k.Active:return"initializing";case k.Failed:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=O(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||this._serviceDescriptionStatus===k.Failed)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter((({geometry:e})=>null!=e)).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}this._routeController=new AbortController;const{signal:d}=this._routeController;let c=null;try{c=await i.solve(u,{signal:d})}catch(h){if(!a(h)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:h});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of c.stops)null==r.geometry&&(r.name=null);return i.update(c),this._set("lastRoute",c),e.zoomToSolvedRoute&&this.zoomToRoute(),c}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find((({name:t,usageType:r})=>t===e&&"cost"===r))??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=j.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:L.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=k.Active;const t=await g(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=k.Complete}catch(t){if(a(t))return void(this._serviceDescriptionStatus=k.Idle);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=k.Suspended);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=k.Failed,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find((({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase())),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find((({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase()));return o??t}};e([c()],V.prototype,"_directionsLanguage",null),e([c()],V.prototype,"_layerView",void 0),e([c()],V.prototype,"_routeController",void 0),e([c()],V.prototype,"_serviceDescriptionStatus",void 0),e([c()],V.prototype,"apiKey",void 0),e([c()],V.prototype,"autoSolve",void 0),e([c()],V.prototype,"defaultTravelMode",void 0),e([c()],V.prototype,"departureTime",void 0),e([c()],V.prototype,"formattedEta",null),e([c({readOnly:!0})],V.prototype,"impedanceAttribute",null),e([c()],V.prototype,"lastError",void 0),e([c({readOnly:!0})],V.prototype,"lastRoute",void 0),e([c()],V.prototype,"layer",void 0),e([c({type:Number,range:{min:2,max:50},nonNullable:!0})],V.prototype,"maxStops",void 0),e([c({type:w,nonNullable:!0})],V.prototype,"routeParameters",void 0),e([c({readOnly:!0})],V.prototype,"selectedNetworkFeatures",null),e([c({type:T})],V.prototype,"selectedTravelMode",null),e([c({readOnly:!0})],V.prototype,"serviceDescription",void 0),e([c({readOnly:!0})],V.prototype,"state",null),e([c({readOnly:!0})],V.prototype,"timeAttribute",null),e([c()],V.prototype,"travelModes",null),e([c()],V.prototype,"view",void 0),e([c()],V.prototype,"zoomToRoute",null),V=e([h("esri.widgets.Directions.DirectionsViewModel")],V);const z=V;export{z 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as l}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeature as y}from"./workflowUtils.js";import m from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as h}from"../support/UtilityNetworkAssociations/utilityNetworkUtils.js";var A;const f={exit:Symbol()};let g=class extends w{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new m,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._initializeUtilityNetworkAssociationAddAssociationViewModel()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const e=await y(o,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):h(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,e.networkSystemLayers.loadAssociationsTable(),this.addHandles([r((()=>o.selectedLayer),(t=>{t&&this.go("add-association-select-feature")})),r((()=>o.selectedFeature),(t=>{t&&this.go("add-association-create-association")}))],f.exit)}static async create(t){const e=new A({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:n}=a;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([n]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=l(u)&&u.parent?u.parent:u,w=d([p]),y=w.values().next().value?.featureService;if(!y)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(y?.load());const m=s?.gdbVersion??void 0;await t(y,[c],{gdbVersion:m}),await r.refresh()}}};t([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([a()],g.prototype,"_featureFormViewModel",void 0),t([a()],g.prototype,"editorItem",null),t([a()],g.prototype,"featureFormViewModel",null),t([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([a()],g.prototype,"sourceFeatureItem",void 0),t([a()],g.prototype,"hasPendingEdits",null),t([a()],g.prototype,"layer",null),t([a()],g.prototype,"parent",null),t([a()],g.prototype,"parentLayer",null),t([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([n("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as l}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeature as m}from"./workflowUtils.js";import y from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as h}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends w{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new y,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._initializeUtilityNetworkAssociationAddAssociationViewModel()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const e=await m(o,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):h(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,e.networkSystemLayers.loadAssociationsTable(),this.addHandles([r((()=>o.selectedLayer),(t=>{t&&this.go("add-association-select-feature")})),r((()=>o.selectedFeature),(t=>{t&&this.go("add-association-create-association")}))],f.exit)}static async create(t){const e=new A({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:n}=a;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([n]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=l(u)&&u.parent?u.parent:u,w=d([p]),m=w.values().next().value?.featureService;if(!m)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(m?.load());const y=s?.gdbVersion??void 0;await t(m,[c],{gdbVersion:y}),await r.refresh()}}};t([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([a()],g.prototype,"_featureFormViewModel",void 0),t([a()],g.prototype,"editorItem",null),t([a()],g.prototype,"featureFormViewModel",null),t([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([a()],g.prototype,"sourceFeatureItem",void 0),t([a()],g.prototype,"hasPendingEdits",null),t([a()],g.prototype,"layer",null),t([a()],g.prototype,"parent",null),t([a()],g.prototype,"parentLayer",null),t([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([n("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{isConnectivity as u,isConnectivityMidspan as m,formatPercentAlong as h}from"../support/UtilityNetworkAssociations/utilityNetworkUtils.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return u(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},u(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,m(e.association)?a("calcite-chip",{label:h(e.association),scale:"s",slot:"content-end"},h(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"actions-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"actions-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import n from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,on as m,whenOnce as _,initial as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{cast as w}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import M from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as x}from"../../support/popupUtils.js";import{system as T}from"../../time/timeZoneUtils.js";import C from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import E from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import V from"./FeatureFields/FeatureFieldsViewModel.js";import j from"./FeatureMedia/FeatureMediaViewModel.js";import k from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as P,formatArcadeValue as R}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as L,preRequestCallback as O,createFieldInfoMap as U,getAllFieldInfos as Z,getSourceLayer as N,querySourceLayer as B,isRelatableFeatureSupportedLayer as S,isAssociatedFeatureSupportedLayer as H,substituteFieldsInLinksAndAttributes as D,isExpressionField as G,isRelatedField as q,formatEditInfo as z,graphicCallback as Q,formatAttributes as J,queryUpdatedFeature as K}from"./support/featureUtils.js";import{queryLayerInfos as W,queryRelatedFeatures as X,setRelatedFeatures as Y,getRelatedFieldInfo as $,createRelatedInfo as ee,updateRelatedInfo as te}from"./support/relatedFeatureUtils.js";import ie from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var se;const oe=1,re="content-view-models",ae="relationship-view-models",ne="association-view-models",le={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let pe=class extends(n.IdentifiableMixin(s)){static{se=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...le},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,(()=>this.notifyChange("waitingForContent")),oe,this),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||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,(()=>this.notifyChange("waitingForContent")),oe,this),this.addHandles([u((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),y),f((()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([e])=>this._evaluateExpressionAttributesThrottled(e)))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(L,O)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return U(Z(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return N(this.graphic)}castAbilities(e){return{...le,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof j&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await B({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r((async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await K({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),P(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}}))}_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):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(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))).filter(o):"string"==typeof e?this._compileText(new M({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(ae),this.removeHandles(re),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new se({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))})),e.forEach((i=>{const s=t?.find((e=>this._matchesFeature(i,e)));s||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!S(n))return;const c=new k({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(m((()=>c.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(c))),ae),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach(((i,s)=>{const o=t.get(s);o?i.forEach((t=>{o.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(s))})):(i.removeAll(),e.delete(s))})),t.forEach(((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new se({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:e.feature}),terminalName:e.terminalName})})),e.set(n,l)}));const n=new AbortController;this._associationVMAbortController=n,await this._sortListObjectsByTitle(e,{signal:n.signal}),this._associationVMAbortController===n&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>_((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=x(e.featureViewModel),s=x(t.featureViewModel);return i.localeCompare(s,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!H(a))return;const p=new ie({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u((()=>p.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map)))],ne),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:se.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),y),re),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new C({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new E({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:D({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:D({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter((({fieldName:e})=>!!e&&(G(e)||q(e)||o.hasOwnProperty(e)))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new V(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new j(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=D({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new E(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?z(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return D({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Q({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Q({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r((async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:se.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then((e=>[t,R(e)])).catch((()=>[t,void 0]))):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}}))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=J({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=J({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:J({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})})),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,Z(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter((e=>!!e.fieldName&&q(e.fieldName)));if(!a?.length)return;t.forEach((e=>this._configureRelatedInfo(e,r)));const n=await W({relatedInfos:s,layer:r},i);Object.keys(n).forEach((e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await X({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach((e=>{Y(l[e]?.value,s.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=$(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||ee(o,t);a&&(te({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([b()],pe.prototype,"_error",void 0),e([b()],pe.prototype,"_graphicChangedTask",void 0),e([b()],pe.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],pe.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],pe.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],pe.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],pe.prototype,"_sourceLayer",null),e([b()],pe.prototype,"abilities",void 0),e([w("abilities")],pe.prototype,"castAbilities",null),e([b({readOnly:!0})],pe.prototype,"content",void 0),e([b({readOnly:!0})],pe.prototype,"contentViewModels",void 0),e([b()],pe.prototype,"description",void 0),e([b({type:Boolean})],pe.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],pe.prototype,"isTable",null),e([b({readOnly:!0})],pe.prototype,"state",null),e([b({readOnly:!0})],pe.prototype,"formattedAttributes",void 0),e([b({type:t,value:null})],pe.prototype,"graphic",null),e([b({readOnly:!0})],pe.prototype,"lastEditInfo",void 0),e([b({type:A})],pe.prototype,"location",void 0),e([b({readOnly:!0})],pe.prototype,"relatedInfos",void 0),e([b({type:I})],pe.prototype,"spatialReference",null),e([b()],pe.prototype,"timeZone",null),e([b({readOnly:!0})],pe.prototype,"title",void 0),e([b()],pe.prototype,"map",null),e([b({readOnly:!0})],pe.prototype,"waitingForContent",null),e([b()],pe.prototype,"view",void 0),pe=se=e([v("esri.widgets.Feature.FeatureViewModel")],pe);const ce=pe;export{ce as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import n from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,on as m,whenOnce as _,initial as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{cast as w}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import M from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as x}from"../../support/popupUtils.js";import{system as T}from"../../time/constants.js";import C from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import E from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import V from"./FeatureFields/FeatureFieldsViewModel.js";import j from"./FeatureMedia/FeatureMediaViewModel.js";import k from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as P,formatArcadeValue as R}from"./support/arcadeFeatureUtils.js";import{preLayerQueryCallback as L,preRequestCallback as O,createFieldInfoMap as U,getAllFieldInfos as N,getSourceLayer as Z,querySourceLayer as B,isRelatableFeatureSupportedLayer as S,isAssociatedFeatureSupportedLayer as H,substituteFieldsInLinksAndAttributes as D,isExpressionField as G,isRelatedField as q,formatEditInfo as z,graphicCallback as Q,formatAttributes as J,queryUpdatedFeature as K}from"./support/featureUtils.js";import{queryLayerInfos as W,queryRelatedFeatures as X,setRelatedFeatures as Y,getRelatedFieldInfo as $,createRelatedInfo as ee,updateRelatedInfo as te}from"./support/relatedFeatureUtils.js";import ie from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var se;const oe=1,re="content-view-models",ae="relationship-view-models",ne="association-view-models",le={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let pe=class extends(n.IdentifiableMixin(s)){static{se=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...le},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,(()=>this.notifyChange("waitingForContent")),oe,this),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||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,(()=>this.notifyChange("waitingForContent")),oe,this),this.addHandles([u((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),y),f((()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([e])=>this._evaluateExpressionAttributesThrottled(e)))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(L,O)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return U(N(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return Z(this.graphic)}castAbilities(e){return{...le,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof j&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await B({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r((async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await K({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),P(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}}))}_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):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(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))).filter(o):"string"==typeof e?this._compileText(new M({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(ae),this.removeHandles(re),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new se({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))})),e.forEach((i=>{const s=t?.find((e=>this._matchesFeature(i,e)));s||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!S(n))return;const c=new k({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(m((()=>c.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(c))),ae),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach(((i,s)=>{const o=t.get(s);o?i.forEach((t=>{o.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(s))})):(i.removeAll(),e.delete(s))})),t.forEach(((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new se({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:e.feature}),terminalName:e.terminalName})})),e.set(n,l)}));const n=new AbortController;this._associationVMAbortController=n,await this._sortListObjectsByTitle(e,{signal:n.signal}),this._associationVMAbortController===n&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>_((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=x(e.featureViewModel),s=x(t.featureViewModel);return i.localeCompare(s,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!H(a))return;const p=new ie({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u((()=>p.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map)))],ne),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:se.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),y),re),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new C({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new E({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:D({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:D({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter((({fieldName:e})=>!!e&&(G(e)||q(e)||o.hasOwnProperty(e)))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new V(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new j(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=D({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new E(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?z(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return D({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Q({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Q({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r((async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:se.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then((e=>[t,R(e)])).catch((()=>[t,void 0]))):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}}))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=J({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=J({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:J({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})})),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,N(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter((e=>!!e.fieldName&&q(e.fieldName)));if(!a?.length)return;t.forEach((e=>this._configureRelatedInfo(e,r)));const n=await W({relatedInfos:s,layer:r},i);Object.keys(n).forEach((e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await X({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach((e=>{Y(l[e]?.value,s.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=$(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||ee(o,t);a&&(te({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([b()],pe.prototype,"_error",void 0),e([b()],pe.prototype,"_graphicChangedTask",void 0),e([b()],pe.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],pe.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],pe.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],pe.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],pe.prototype,"_sourceLayer",null),e([b()],pe.prototype,"abilities",void 0),e([w("abilities")],pe.prototype,"castAbilities",null),e([b({readOnly:!0})],pe.prototype,"content",void 0),e([b({readOnly:!0})],pe.prototype,"contentViewModels",void 0),e([b()],pe.prototype,"description",void 0),e([b({type:Boolean})],pe.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],pe.prototype,"isTable",null),e([b({readOnly:!0})],pe.prototype,"state",null),e([b({readOnly:!0})],pe.prototype,"formattedAttributes",void 0),e([b({type:t,value:null})],pe.prototype,"graphic",null),e([b({readOnly:!0})],pe.prototype,"lastEditInfo",void 0),e([b({type:A})],pe.prototype,"location",void 0),e([b({readOnly:!0})],pe.prototype,"relatedInfos",void 0),e([b({type:I})],pe.prototype,"spatialReference",null),e([b()],pe.prototype,"timeZone",null),e([b({readOnly:!0})],pe.prototype,"title",void 0),e([b()],pe.prototype,"map",null),e([b({readOnly:!0})],pe.prototype,"waitingForContent",null),e([b()],pe.prototype,"view",void 0),pe=se=e([v("esri.widgets.Feature.FeatureViewModel")],pe);const ce=pe;export{ce 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.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../support/widgetUtils.js";import{tsx as t}from"../../support/jsxFactory.js";import{getFeatureTitle as e,getAssociationTitle as r}from"../../support/UtilityNetworkAssociations/utilityNetworkUtils.js";function o(t){const{feature:e,association:o,associationType:n,messages:i}=t,{attachment:s,connectivity:c,container:a,content:u,structure:l}=i,p=e.sourceLayer;if(!o&&!n)return;if(!o)switch(n){case"attachment":return s;case"container":return a;case"connectivity":return c;case"content":return u;case"structure":return l}if(!p)return;const f=e.attributes[p.globalIdField]===o.fromNetworkElement.globalId?"from":"to";return r(o,f,i)}function n(r){const{feature:n,heading:i}=r,s=i||e(n),c=o(r)??"";return t("calcite-block",{description:c,heading:s})}export{n as AssociationDetails};
5
+ import"../../support/widgetUtils.js";import{tsx as t}from"../../support/jsxFactory.js";import{getAssociationTitle as e}from"../../support/UtilityNetworkAssociations/utils/getAssociationTitle.js";import{getFeatureTitle as r}from"../../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";function o(t){const{feature:r,association:o,associationType:i,messages:s}=t,{attachment:n,connectivity:c,container:a,content:u,structure:l}=s,p=r.sourceLayer;if(!o&&!i)return;if(!o)switch(i){case"attachment":return n;case"container":return a;case"connectivity":return c;case"content":return u;case"structure":return l}if(!p)return;const m=r.attributes[p.globalIdField]===o.fromNetworkElement.globalId?"from":"to";return e(o,m,s)}function i(e){const{feature:i,heading:s}=e,n=s||r(i),c=o(e)??"";return t("calcite-block",{description:c,heading:n})}export{i as AssociationDetails};