@arcgis/core 5.2.0-next.28 → 5.2.0-next.29

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 (206) hide show
  1. package/WebMap.js +1 -1
  2. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +40 -2
  3. package/applications/KnowledgeStudio/generalSharedKgUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0197e459fdb04dfb28ef.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f7344d855f1092383abe.js → 15aa9b85976069acf4f3.js} +1 -1
  7. package/assets/esri/core/workers/chunks/17b98787a0698f584882.js +1 -0
  8. package/assets/esri/core/workers/chunks/1b9c68e8431bb4608209.js +1 -0
  9. package/assets/esri/core/workers/chunks/1bbf5f5da5842b93f638.js +1 -0
  10. package/assets/esri/core/workers/chunks/1bd7b7f4ee7ea6cb7ef9.js +1 -0
  11. package/assets/esri/core/workers/chunks/1e386475937e02b3f523.js +1 -0
  12. package/assets/esri/core/workers/chunks/{24704e70d1ce01ca4081.js → 20ffeb09bb30400de110.js} +1 -1
  13. package/assets/esri/core/workers/chunks/21122f3f3e19a7fd7d33.js +1 -0
  14. package/assets/esri/core/workers/chunks/{25fd4d5d3af887536b3b.js → 2628136bf9f47d238a24.js} +1 -1
  15. package/assets/esri/core/workers/chunks/2b044c8fab2055a8818d.js +1 -0
  16. package/assets/esri/core/workers/chunks/2b2b042a6d6949b06127.js +1 -0
  17. package/assets/esri/core/workers/chunks/2c15c227d057292d4fa8.js +1 -0
  18. package/assets/esri/core/workers/chunks/2f02880a7f081eb210cd.js +1 -0
  19. package/assets/esri/core/workers/chunks/2fc3e43b64300014dddc.js +1 -0
  20. package/assets/esri/core/workers/chunks/{5363c622a0571134cadd.js → 32740b075d7a890d7888.js} +1 -1
  21. package/assets/esri/core/workers/chunks/38b69fba9ae4ccbae6b7.js +1 -0
  22. package/assets/esri/core/workers/chunks/3c342e662c13a05f4caf.js +1 -0
  23. package/assets/esri/core/workers/chunks/{8b452383ba972b638a0c.js → 3d1e5bfd88771d4a0bf6.js} +1 -1
  24. package/assets/esri/core/workers/chunks/43847d66726fd0bcbbb7.js +1 -0
  25. package/assets/esri/core/workers/chunks/4545cf12ad0824ce6b41.js +1 -0
  26. package/assets/esri/core/workers/chunks/45e4b9069263adeae394.js +1 -0
  27. package/assets/esri/core/workers/chunks/47290f27375c76bcc9c7.js +1 -0
  28. package/assets/esri/core/workers/chunks/{8aba35305368234c94f8.js → 5115059b012ef84407cf.js} +1 -1
  29. package/assets/esri/core/workers/chunks/5cccb8b06014ccef30f8.js +1 -0
  30. package/assets/esri/core/workers/chunks/{7f1babbb7ead78201ab3.js → 689673173ca1c0e098fe.js} +1 -1
  31. package/assets/esri/core/workers/chunks/6991ba1b204668e7d4da.js +1 -0
  32. package/assets/esri/core/workers/chunks/{ccffaba50674adba7a0f.js → 6b56971783bf4c31a563.js} +1 -1
  33. package/assets/esri/core/workers/chunks/70c94bcfa20453134037.js +1 -0
  34. package/assets/esri/core/workers/chunks/759686b896f51f0fe6a9.js +1 -0
  35. package/assets/esri/core/workers/chunks/7656900713e55036c3c1.js +1 -0
  36. package/assets/esri/core/workers/chunks/774615303c1cc9a77e20.js +1 -0
  37. package/assets/esri/core/workers/chunks/{6183a26837dc087663ad.js → 7ff37a4f315f7621462b.js} +1 -1
  38. package/assets/esri/core/workers/chunks/8ad5e80e911419c1685a.js +1 -0
  39. package/assets/esri/core/workers/chunks/{87011d2fe14c54e296af.js → 9fe71d49c888fd871312.js} +1 -1
  40. package/assets/esri/core/workers/chunks/a14e5607c5c091c77e3d.js +1 -0
  41. package/assets/esri/core/workers/chunks/{7c344c339743295d11d7.js → a2be8784f2cfdbb42681.js} +1 -1
  42. package/assets/esri/core/workers/chunks/a6379a8df8c08b729b9c.js +1 -0
  43. package/assets/esri/core/workers/chunks/a988fd54912969b812ce.js +1 -0
  44. package/assets/esri/core/workers/chunks/{11d1af758e2140095b10.js → aec82b94787821153d2b.js} +1 -1
  45. package/assets/esri/core/workers/chunks/b624796ff4a9d4c406bf.js +1 -0
  46. package/assets/esri/core/workers/chunks/bb1fad01d9f070e7d795.js +1 -0
  47. package/assets/esri/core/workers/chunks/{654a6dc13ff5be88c8b9.js → bcb2092c87d8d21c6458.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{3e94ed4d57ee7d870cba.js → c6f5688074ae89c37add.js} +1 -1
  49. package/assets/esri/core/workers/chunks/caf150028aeac91b8d80.js +1 -0
  50. package/assets/esri/core/workers/chunks/{a3ca0649edb646da0918.js → cb30e8a66d6dcfebd439.js} +1 -1
  51. package/assets/esri/core/workers/chunks/d7c0ab622caf495dbcef.js +1 -0
  52. package/assets/esri/core/workers/chunks/{fd629872b5c07853f695.js → e4015870412edd69453c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/e774303efefee31952d0.js +1 -0
  54. package/assets/esri/core/workers/chunks/e98a8f80023c6023e72c.js +1 -0
  55. package/assets/esri/core/workers/chunks/f10a339b16d84b650012.js +2 -0
  56. package/assets/esri/core/workers/chunks/fe42fa2144691b9186fd.js +1 -0
  57. package/chunks/GlowComposition.glsl.js +5 -5
  58. package/config.js +1 -1
  59. package/core/AsyncUpdate.js +1 -1
  60. package/core/date.js +1 -1
  61. package/core/workers/workerFactory.js +1 -1
  62. package/form/elements/AttachmentElement.d.ts +4 -1
  63. package/form/elements/inputs/attachments/AttachmentInput.d.ts +1 -0
  64. package/form/elements/inputs/attachments/AudioInput.d.ts +1 -0
  65. package/form/elements/inputs/attachments/DocumentInput.d.ts +3 -0
  66. package/form/elements/inputs/attachments/ImageInput.d.ts +1 -0
  67. package/form/elements/inputs/attachments/VideoInput.d.ts +1 -0
  68. package/kernel.js +1 -1
  69. package/layers/AnnotationFeatureLayer.d.ts +0 -2
  70. package/layers/AnnotationFeatureLayer.js +1 -1
  71. package/layers/DimensionFeatureLayer.d.ts +0 -2
  72. package/layers/DimensionFeatureLayer.js +1 -1
  73. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  74. package/layers/support/featureLayerUtils.js +1 -1
  75. package/layers/support/parquetUtils.js +1 -1
  76. package/linkChart/guards.js +2 -0
  77. package/linkChart/utils.js +1 -1
  78. package/networks/CircuitManager.d.ts +44 -0
  79. package/networks/support/CircuitExportJobInfo.d.ts +1 -1
  80. package/networks/support/CircuitVerifyJobInfo.d.ts +1 -1
  81. package/networks/support/jsonTypes.d.ts +2 -0
  82. package/package.json +3 -3
  83. package/rest/featureService/types.d.ts +4 -7
  84. package/rest/networks/circuits/support/CircuitVerifyResult.d.ts +1 -1
  85. package/rest/networks/circuits/support/ExportCircuitsParameters.d.ts +1 -1
  86. package/rest/networks/circuits/support/VerifyCircuitsParameters.d.ts +17 -3
  87. package/rest/networks/unitIdentifiers/support/UnitQueryResult.d.ts +1 -1
  88. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  89. package/support/revision.js +1 -1
  90. package/symbols/cim/CIMOperators.js +1 -1
  91. package/symbols/cim/utils.js +1 -1
  92. package/symbols/support/cimSymbolUtils.js +1 -1
  93. package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
  94. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  95. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  96. package/views/2d/engine/webgl/util/AnnotationMatcher.js +1 -1
  97. package/views/2d/engine/webgl/util/DictionaryMatcher.js +1 -1
  98. package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
  99. package/views/2d/engine/webgl/util/IntervalMatcher.js +1 -1
  100. package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
  101. package/views/2d/engine/webgl/util/MapMatcher.js +1 -1
  102. package/views/2d/engine/webgl/util/Matcher.js +1 -1
  103. package/views/2d/engine/webgl/util/createMatcher.js +1 -1
  104. package/views/2d/layers/LayerView2D.js +1 -1
  105. package/views/2d/layers/features/Processor.js +1 -1
  106. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  107. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  108. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  109. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  110. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  111. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  112. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  113. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  114. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  115. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  116. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  117. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  118. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  119. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  120. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  121. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  122. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  123. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  124. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  125. package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +2 -0
  126. package/views/2d/layers/support/annodime/PrivateDimensionEffect.js +1 -1
  127. package/views/2d/layers/support/annodime/PrivateMatcherGeometryOverrideEffect.js +2 -0
  128. package/views/2d/layers/support/annodime/TileObjectId.js +2 -0
  129. package/views/2d/layers/support/annodime/annotationGraphic.js +1 -1
  130. package/views/2d/layers/support/annodime/debugUtils.js +2 -0
  131. package/views/2d/layers/support/annodime/dimensionStyleDefaults.js +2 -0
  132. package/views/2d/layers/support/annodime/dimensionSymbols.js +1 -1
  133. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  134. package/views/2d/layers/support/annodime/utils.js +1 -1
  135. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  136. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  137. package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
  138. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  139. package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +1 -1
  140. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  141. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  142. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  143. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  144. package/views/draw/DrawTool.js +1 -1
  145. package/views/interactive/sketch/SketchLabelOptions.d.ts +0 -6
  146. package/views/layers/AnnotationFeatureLayerView.d.ts +0 -7
  147. package/views/layers/DimensionFeatureLayerView.d.ts +0 -7
  148. package/views/support/LayerViewManager.js +1 -1
  149. package/webdoc/support/webdocSaveUtils.js +1 -1
  150. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  151. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  152. package/widgets/Editor/EditorViewModel.d.ts +0 -12
  153. package/widgets/Editor.d.ts +0 -12
  154. package/widgets/Feature/FeatureViewModel.js +1 -1
  155. package/widgets/Feature.js +1 -1
  156. package/widgets/Features/FeaturesViewModel.js +1 -1
  157. package/widgets/Features.js +1 -1
  158. package/widgets/LayerList/LayerListViewModel.js +1 -1
  159. package/widgets/Popup/PopupViewModel.d.ts +0 -1
  160. package/widgets/Popup/PopupViewModel.js +1 -1
  161. package/widgets/Popup.js +1 -1
  162. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  163. package/widgets/Sketch/SketchViewModel.d.ts +0 -12
  164. package/widgets/Sketch.d.ts +0 -12
  165. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  166. package/assets/esri/core/workers/chunks/1893a4b344aa9b57aa8d.js +0 -1
  167. package/assets/esri/core/workers/chunks/1a7c0a1dc6ecc93ea03a.js +0 -1
  168. package/assets/esri/core/workers/chunks/29a7321fd069253c2521.js +0 -1
  169. package/assets/esri/core/workers/chunks/3b7060d264888bf298b1.js +0 -1
  170. package/assets/esri/core/workers/chunks/409bc7d69b95f7a1634c.js +0 -1
  171. package/assets/esri/core/workers/chunks/4fc32e60e63a9c8429b9.js +0 -1
  172. package/assets/esri/core/workers/chunks/548842f8ba9224b15ee4.js +0 -1
  173. package/assets/esri/core/workers/chunks/5728d8440aca205e4f53.js +0 -1
  174. package/assets/esri/core/workers/chunks/668d84dc512b3085a960.js +0 -1
  175. package/assets/esri/core/workers/chunks/67f44cab103d4411dcc5.js +0 -1
  176. package/assets/esri/core/workers/chunks/6db5ee9c589265b23b60.js +0 -1
  177. package/assets/esri/core/workers/chunks/78f68f7534716956f5bc.js +0 -1
  178. package/assets/esri/core/workers/chunks/7c34eb94e2c74602aeab.js +0 -1
  179. package/assets/esri/core/workers/chunks/7fcf4f3b9131c7516524.js +0 -1
  180. package/assets/esri/core/workers/chunks/86e61841df12dbe20a19.js +0 -1
  181. package/assets/esri/core/workers/chunks/8dbf9b1d8bb6817b19c1.js +0 -1
  182. package/assets/esri/core/workers/chunks/937e347d130d469518ce.js +0 -1
  183. package/assets/esri/core/workers/chunks/a195f569eada3a8736be.js +0 -1
  184. package/assets/esri/core/workers/chunks/a2357aae79bfbb91f125.js +0 -1
  185. package/assets/esri/core/workers/chunks/a8167ab9fd846d699be5.js +0 -1
  186. package/assets/esri/core/workers/chunks/b10f36658aa77bc3a6cf.js +0 -1
  187. package/assets/esri/core/workers/chunks/b87aca8ad281870ae970.js +0 -1
  188. package/assets/esri/core/workers/chunks/c46500cc95a84e2a5f7a.js +0 -1
  189. package/assets/esri/core/workers/chunks/cc46261e01a985df5aab.js +0 -1
  190. package/assets/esri/core/workers/chunks/ceb5bd9f2afaa2ea0808.js +0 -1
  191. package/assets/esri/core/workers/chunks/d07261f3fb67b9a99369.js +0 -1
  192. package/assets/esri/core/workers/chunks/d25c37f169577a33db46.js +0 -1
  193. package/assets/esri/core/workers/chunks/d61294dcc3ba41060d44.js +0 -1
  194. package/assets/esri/core/workers/chunks/d8ae5b61b5ae71f4796c.js +0 -1
  195. package/assets/esri/core/workers/chunks/db279d5d9c7deec554bb.js +0 -1
  196. package/assets/esri/core/workers/chunks/e1340232962cf576d37e.js +0 -1
  197. package/assets/esri/core/workers/chunks/e38d1ba15babc238b151.js +0 -1
  198. package/assets/esri/core/workers/chunks/f5125925f83c979edde7.js +0 -2
  199. package/assets/esri/core/workers/chunks/f68b84df093f2894210b.js +0 -1
  200. package/assets/esri/core/workers/chunks/f74b6952c888d92e479e.js +0 -1
  201. package/assets/esri/core/workers/chunks/fe20683f442294eb111b.js +0 -1
  202. package/views/2d/layers/features/layerAdapters/featureLayerAdapterUtils.js +0 -2
  203. package/views/2d/layers/features/support/FeatureSetReaderAnnotationJSON.js +0 -2
  204. package/views/2d/layers/features/support/FeatureSetReaderDimensionJSON.js +0 -2
  205. package/views/2d/layers/support/annodime/annotationUtils.js +0 -2
  206. /package/assets/esri/core/workers/chunks/{f5125925f83c979edde7.js.LICENSE.txt → f10a339b16d84b650012.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as l}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as p,isFeatureCollectionLayer as c}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import m from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as f,addTypeKeyword as y,typeKeyword as w,hasTypeKeyword as g,toggleTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import j from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as b,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as R}from"./resourceUtils.js";import{beforeSave as S,evaluateWriteErrors as W,hasCharts as I}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map(e=>e.toLowerCase());async function P(e,t,r){r??={},U(e,t),await o(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a,e.origin);return W(n,{errorName:`${e.name}:save`},r),await k(t,a),await ge(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),R(t.resourceReferences,n)]),a}async function O(e,t,o){const r=d(t,o,!0),a=e.write({},r);return await Promise.all(r.resources.pendingOperations),{json:a,jsonContext:r}}async function T(e,t,r,a){a??={};const i=E(e,r);await o(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const{json:n,jsonContext:s}=await O(t,i,e.origin);W(s,{errorName:`${e.name}:save`},a),await X(t,i);const l=t.getThumbnailState();return await he(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),R(t.resourceReferences,s)]),i}function U(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");C(t,o.portalItem)}function C(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function M(t,o){if("linkchart"!==t.name&&!o.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.")}function E(e,t){let o=m.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=u.getDefault()),C(e,o),o}function D(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then(()=>{})}async function k(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Y(e,t)}const x=w.JSAPI,G="CollectorDisabled",L="Collector",N="Data Editing",V="OfflineDisabled",B="Offline",$="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",K="Offline Map Areas",J="FieldMapsDisabled",q=w.DEVELOPER_BASEMAP,z="UtilityNetwork",Q="IPS";async function X(e,t){f(t,G),f(t,J),f(t,w.METADATA),f(t,V),f(t,K),f(t,H),f(t,$),f(t,F),await k(e,t)}async function Y(e,t){y(t,x),await Z(e),re(e,t),ae(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter((e,t,o)=>o.indexOf(e)===t))}function Z(e){const t=ee(e).map(e=>e.load()).toArray();return Promise.allSettled(t).then(()=>{})}function ee(e){return e.allLayers.concat(e.allTables)}function te(e){return ee(e).some(e=>e.loaded&&p(e)&&e.capabilities.operations.supportsEditing&&"editingEnabled"in e&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some(e=>e.editingEnabled)))}function oe(e){return ee(e).filter(e=>"group"!==e.type).every(t=>t.loaded&&de(e,t))}function re(e,t){g(t,G)||g(t,$)||g(t,F)||g(t,H)||!te(e)?f(t,L):y(t,L)}function ae(e,t){te(e)?y(t,N):f(t,N)}function ie(e,t){!g(t,V)&&oe(e)?y(t,B):f(t,B)}function ne(e,t){b(e.basemap)?y(t,q):f(t,q)}function se(e,t){e.utilityNetworks?.length?y(t,z):f(t,z)}function le(e,t){e.ipsInfo?y(t,Q):f(t,Q)}function pe(e,t){h(t,w.CHARTS,I(e))}async function ce(e,t){const o=t.clone().normalize();let r;if(o.length>1)for(const a of o)r?a.width>r.width&&(r=a):r=a;else r=o[0];return ue(e,r)}async function ue(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return s(t);const{getGeometryServiceURL:r}=await import("../../portal/support/geometryServiceUtils.js"),a=await r(e),i=new j({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function me(e){return c(e)||"map-notes"===e.type||"route"===e.type}function de(e,t){return p(t)&&t.capabilities.operations.supportsSync||me(t)&&!t.portalItem||fe(t)&&!ye(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function fe(e){return"imagery-tile"===e.type?e.supportsExportMapTiles():("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||we(e)||v(e))}function ye(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function we(e){return"tile"===e.type&&(l(e.url)&&A.some(t=>e.url?.toLowerCase().includes("/"+t+"/")))}async function ge(e,t,o,r,a){await o.update({data:r}),be(e,t,o,r,a)}async function he(t,o,r,a,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=r.portal;await p.signIn();const{copyAllowed:c,itemReloaded:u}=await _e(l,p);if(l.authenticated||=u,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m=await je(r,l,a,n);return o.portalItem=r,be(t,o,r,a,i),m}async function _e(e,t){const{item:o,authenticated:r}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(r||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function je(e,t,o,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&r(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const r=e.toJSON();await e.load(),e.read(r),await e.update({data:o})}else await i.user.addItem({item:e,folder:s,data:o});return p}function be(e,o,r,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?a(r.itemUrl):void 0}),i(s),o.resourceInfo=n}export{O as createJSON,je as initializeNewItem,_e as isCopyAllowed,P as save,T as saveAs};
2
+ import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as o,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as l}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as p,isFeatureCollectionLayer as c}from"../../layers/support/layerUtils.js";import m from"../../portal/Portal.js";import u from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as f,addTypeKeyword as y,typeKeyword as w,toggleTypeKeyword as g,hasTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as R}from"./resourceUtils.js";import{beforeSave as S,evaluateWriteErrors as W,hasCharts as I}from"./saveUtils.js";const P=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map(e=>e.toLowerCase());async function A(e,t,o){o??={},U(e,t),await r(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a,e.origin);return W(n,{errorName:`${e.name}:save`},o),await k(t,a),await me(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),R(t.resourceReferences,n)]),a}async function O(e,t,r){const o=d(t,r,!0),a=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:a,jsonContext:o}}async function T(e,t,o,a){a??={};const i=E(e,o);await r(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const{json:n,jsonContext:s}=await O(t,i,e.origin);W(s,{errorName:`${e.name}:save`},a),await Y(t,i);const l=t.getThumbnailState();return await ue(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),R(t.resourceReferences,s)]),i}function U(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");C(t,r.portalItem)}function C(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function M(t,r){if("linkchart"!==t.name&&!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.")}function E(e,t){let r=u.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=m.getDefault()),C(e,r),r}function D(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then(()=>{})}async function k(e,t){t.extent=await ae(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const x=w.JSAPI,G="CollectorDisabled",L="Collector",N="Data Editing",V="OfflineDisabled",B="Offline",$="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",K="Offline Map Areas",J="FieldMapsDisabled",q=w.DEVELOPER_BASEMAP,z="UtilityNetwork",Q="ParcelFabric",X="IPS";async function Y(e,t){f(t,G),f(t,J),f(t,w.METADATA),f(t,V),f(t,K),f(t,H),f(t,$),f(t,F),await k(e,t)}async function Z(e,t){y(t,x),await ee(e),g(t,L,!h(t,G)&&!h(t,$)&&!h(t,F)&&!h(t,H)&&re(e)),g(t,N,re(e)),g(t,B,!h(t,V)&&oe(e)),g(t,q,j(e.basemap)),g(t,z,!!e.utilityNetworks?.length),g(t,Q,!!e.parcelFabric),g(t,X,!!e.ipsInfo),g(t,w.CHARTS,I(e)),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}function ee(e){const t=te(e).map(e=>e.load()).toArray();return Promise.allSettled(t).then(()=>{})}function te(e){return e.allLayers.concat(e.allTables)}function re(e){return te(e).some(e=>e.loaded&&p(e)&&e.capabilities.operations.supportsEditing&&"editingEnabled"in e&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some(e=>e.editingEnabled)))}function oe(e){return te(e).filter(e=>"group"!==e.type).every(t=>t.loaded&&se(e,t))}async function ae(e,t){const r=t.clone().normalize();let o;if(r.length>1)for(const a of r)o?a.width>o.width&&(o=a):o=a;else o=r[0];return ie(e,o)}async function ie(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return s(t);const{getGeometryServiceURL:o}=await import("../../portal/support/geometryServiceUtils.js"),a=await o(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ne(e){return c(e)||"map-notes"===e.type||"route"===e.type}function se(e,t){return p(t)&&t.capabilities.operations.supportsSync||ne(t)&&!t.portalItem||le(t)&&!pe(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function le(e){return"imagery-tile"===e.type?e.supportsExportMapTiles():("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||ce(e)||v(e))}function pe(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function ce(e){return"tile"===e.type&&(l(e.url)&&P.some(t=>e.url?.toLowerCase().includes("/"+t+"/")))}async function me(e,t,r,o,a){await r.update({data:o}),ye(e,t,r,o,a)}async function ue(t,r,o,a,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=o.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await de(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await fe(o,l,a,n);return r.portalItem=o,ye(t,r,o,a,i),u}async function de(e,t){const{item:r,authenticated:o}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(o||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function fe(e,t,r,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&o(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const o=e.toJSON();await e.load(),e.read(o),await e.update({data:r})}else await i.user.addItem({item:e,folder:s,data:r});return p}function ye(e,r,o,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:o.itemUrl?a(o.itemUrl):void 0}),i(s),r.resourceInfo=n}export{O as createJSON,fe as initializeNewItem,de as isCopyAllowed,A as save,T as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{Loadable as i,isLoadable as s}from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as n,subclass as p}from"../../core/accessorSupport/decorators.js";import{canProjectWithoutEngine as c,isLoaded as m,load as l}from"../../geometry/projectionUtils.js";import{equals as u}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as d}from"../../linkChart/utils.js";import{basemapEnsureType as h}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as y,default2DCompatibility as v}from"./support/basemapCompatibilityUtils.js";import b from"./support/BasemapGalleryItem.js";import g from"./support/LocalBasemapsSource.js";import w from"./support/PortalBasemapsSource.js";const _=t.ofType(b);function B(e){return e&&"esri.portal.Portal"===e.declaredClass}function j(e){return e&&!(e instanceof w)&&(!!e.portal||!!e.query)}function I(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let R=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new _,this.view=null,this.source=new w}initialize(){const e=()=>this._recreateItems();this.addHandles([a(()=>"ready"===this.state?this.compatibilityFunction:null,()=>this._updateItems()),r(()=>this.source?.basemaps,"change",e,{onListenerAdd:e}),o(()=>this.view,()=>{this.source instanceof w&&(this.source.viewType=this.view?.type)},{once:!0})])}destroy(){const e=this.source.basemaps.find(e=>e===this.activeBasemap);e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!(e=h(e))||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const i=e.spatialReference||this.items?.find(t=>this.basemapEquals(e,t.basemap))?.spatialReference;if(i&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const s=t.spatialReference;if(null!=i&&!u(s,i)&&!c(t.spatialReference,i)&&!m())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void l().then(()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=i,this._clearOverride("activeBasemap"))},()=>{}).then(()=>{this._loadingProjectionEngine=!1});t.map.basemap=e,this._clearOverride("activeBasemap"),null==i||u(t.spatialReference,i)||(t.spatialReference=i)}else t.map.basemap=e,this._clearOverride("activeBasemap")}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?y:v}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}get source(){return this._get("source")}set source(e){(Array.isArray(e)||t.isCollection(e))&&(e=new g({basemaps:Array.isArray(e)?new t(e):e})),B(e)&&(e=new w({portal:e})),j(e)&&(e=new w(e)),I(e)||(e=null),this._set("source",e)}get state(){return this.view?.ready&&this.source?d(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(s(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,i=t.findIndex(t=>t.basemap===e);return-1===i?t.findIndex(t=>this.basemapEquals(t.basemap,e)):i}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:i}=this,s=new Map(this.items.map(e=>[e.basemap,e])),a=e.map(e=>{const a=s.get(e);return a?(s.delete(e),a):new b({basemap:e,compatibilityFunction:i,view:t})});this.items.removeAll(),this.items.addMany(a),s.forEach(e=>e.destroy())}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([n()],R.prototype,"_loadingProjectionEngine",void 0),e([n()],R.prototype,"activeBasemap",null),e([n({readOnly:!0})],R.prototype,"activeBasemapIndex",null),e([n()],R.prototype,"compatibilityFunction",null),e([n({readOnly:!0,type:_})],R.prototype,"items",void 0),e([n()],R.prototype,"source",null),e([n({readOnly:!0})],R.prototype,"state",null),e([n()],R.prototype,"view",void 0),R=e([p("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],R);const E=R;export{E as default};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{Loadable as i,isLoadable as s}from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as n,subclass as p}from"../../core/accessorSupport/decorators.js";import{canProjectWithoutEngine as c,isLoaded as m,load as l}from"../../geometry/projectionUtils.js";import{equals as u}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as d}from"../../linkChart/guards.js";import{basemapEnsureType as h}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as y,default2DCompatibility as v}from"./support/basemapCompatibilityUtils.js";import b from"./support/BasemapGalleryItem.js";import g from"./support/LocalBasemapsSource.js";import w from"./support/PortalBasemapsSource.js";const _=t.ofType(b);function B(e){return e&&"esri.portal.Portal"===e.declaredClass}function j(e){return e&&!(e instanceof w)&&(!!e.portal||!!e.query)}function I(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let R=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new _,this.view=null,this.source=new w}initialize(){const e=()=>this._recreateItems();this.addHandles([a(()=>"ready"===this.state?this.compatibilityFunction:null,()=>this._updateItems()),r(()=>this.source?.basemaps,"change",e,{onListenerAdd:e}),o(()=>this.view,()=>{this.source instanceof w&&(this.source.viewType=this.view?.type)},{once:!0})])}destroy(){const e=this.source.basemaps.find(e=>e===this.activeBasemap);e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!(e=h(e))||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const i=e.spatialReference||this.items?.find(t=>this.basemapEquals(e,t.basemap))?.spatialReference;if(i&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const s=t.spatialReference;if(null!=i&&!u(s,i)&&!c(t.spatialReference,i)&&!m())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void l().then(()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=i,this._clearOverride("activeBasemap"))},()=>{}).then(()=>{this._loadingProjectionEngine=!1});t.map.basemap=e,this._clearOverride("activeBasemap"),null==i||u(t.spatialReference,i)||(t.spatialReference=i)}else t.map.basemap=e,this._clearOverride("activeBasemap")}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?y:v}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}get source(){return this._get("source")}set source(e){(Array.isArray(e)||t.isCollection(e))&&(e=new g({basemaps:Array.isArray(e)?new t(e):e})),B(e)&&(e=new w({portal:e})),j(e)&&(e=new w(e)),I(e)||(e=null),this._set("source",e)}get state(){return this.view?.ready&&this.source?d(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(s(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,i=t.findIndex(t=>t.basemap===e);return-1===i?t.findIndex(t=>this.basemapEquals(t.basemap,e)):i}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:i}=this,s=new Map(this.items.map(e=>[e.basemap,e])),a=e.map(e=>{const a=s.get(e);return a?(s.delete(e),a):new b({basemap:e,compatibilityFunction:i,view:t})});this.items.removeAll(),this.items.addMany(a),s.forEach(e=>e.destroy())}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([n()],R.prototype,"_loadingProjectionEngine",void 0),e([n()],R.prototype,"activeBasemap",null),e([n({readOnly:!0})],R.prototype,"activeBasemapIndex",null),e([n()],R.prototype,"compatibilityFunction",null),e([n({readOnly:!0,type:_})],R.prototype,"items",void 0),e([n()],R.prototype,"source",null),e([n({readOnly:!0})],R.prototype,"state",null),e([n()],R.prototype,"view",void 0),R=e([p("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],R);const E=R;export{E as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../request.js";import a from"../../../core/Collection.js";import n from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import o from"../../../core/ReactiveSet.js";import{generateBracedUUID as d}from"../../../core/uuid.js";import{property as l,subclass as h}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import m from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentCategoryForFile as p,getAttachmentCategoryForAttachment as u}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentKey as g,getAttachmentUrl as y,preserveAttachmentFilenameExtension as f,attachmentValidationUtils as _}from"../attachmentUtils.js";import A from"./EditableInput.js";import U from"./SingleFeatureInputAdapter.js";let v=-1;const S=["maximum-audio-length","maximum-file-size","maximum-image-size","minimum-number-of-files","maximum-number-of-files","maximum-video-length"];let C=class extends A{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new U({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new a,this._stagedDeletes=new o,this._stagedUpdates=new r,this._failedStagedUpdateHydrations=new o,this._pendingStagedUpdateHydrations=new r,this._temporaryAttachmentUrls=new r,this._validationCriterionStates=new r,this._hasUnsupportedFileTypeValidationError=!1}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return!this.editable||null!=t&&e>=t}get effectiveAttachmentCount(){return this._initialAttachments.length-this._stagedDeletes.size+this._stagedAdds.length}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const t=new Set;for(const e of this._nestableInputs)w(t,e.type);return t}get _nestableInputs(){const{input:t}=this;return null==t?[]:"attachment"===t.type?t.inputTypes??[]:[t]}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get canUploadFiles(){const t=this._nestableInputs;return!t.length||t.some(F)}get hasCaptureInputs(){return this._nestableInputs.some(x)}get captureMediaType(){const t=new Set;for(const e of this._nestableInputs)if(x(e))switch(e.type){case"audio":t.add("audio");break;case"video":t.add("video");break;case"image":case"signature":t.add("image")}return 1===t.size?Array.from(t)[0]:null}get isCaptureOnly(){const t=this._nestableInputs;return!!t.length&&t.every(T)}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get hasInvalidAttachmentName(){return!!this.allowUserRename&&this.attachments.some(t=>0===t.name.trim().length)}get attachmentCount(){return this.attachments.length}get hasMinimumAttachmentCountNotMet(){const t=this.minAttachmentCount;return null!=t&&(this.effectiveAttachmentCount<t&&!this.isCaptureOnly)}get hasReachedAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e===t}get hasExceededAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e>t}get hasPendingAttachmentUpdateData(){return this._pendingStagedUpdateHydrations.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=c(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){return!(this._failedStagedUpdateHydrations.size>0||this.hasInvalidAttachmentName||this.hasExceededAttachmentLimit||this.hasMinimumAttachmentCountNotMet)}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._failedStagedUpdateHydrations.clear(),this._recomputeAttachments()}applyStashedEdits(t){const{adds:e,deletes:a,updates:n}=t;for(const i of e){const t=this._getAttachmentKey(i.info);this._stagedAdds.add({data:i.data,globalId:i.globalId??d(),info:i.info,key:t}),this._setTemporaryAttachmentUrl(t,i.data)}for(const i of n){const t=this._getAttachmentKey(i.info);this._stagedUpdates.set(t,{contentType:i.contentType,data:i.data,info:i.info,key:t,name:i.name,size:I(i)}),this._setTemporaryAttachmentUrl(t,i.data)}for(const i of a){const t=this._getAttachmentKey(i.info);this._stagedDeletes.add(t)}this._recomputeAttachments()}clearAttachmentChanges(){this.clearValidationCriteriaState(),this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._failedStagedUpdateHydrations.clear(),this._pendingStagedUpdateHydrations.clear(),this._recomputeAttachments()}clearValidationCriteriaState(){this._validationCriterionStates.clear(),this._hasUnsupportedFileTypeValidationError=!1}get hasInvalidValidationCriteria(){for(const t of this._validationCriterionStates.values())if("danger"===t)return!0;return!1}get hasUnsupportedFileTypeValidationError(){return this._hasUnsupportedFileTypeValidationError}get validationCriterionStates(){return this._validationCriterionStates}getValidationCriterionState(t){return this._validationCriterionStates.get(t)??null}stageAddAttachment(t){if(!this._assertEditable())throw new n("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false.");const{contentType:e,data:a,name:i}=t,s=t.globalId??d(),r=a instanceof Blob?a.size:void 0,o=i.trim(),l=new m({contentType:e??void 0,globalId:s,id:v--,keywords:this.attachmentKeyword??void 0,name:o,size:r});return this._setTemporaryAttachmentUrl(s,a),this._stagedAdds.add({key:s,globalId:s,info:l,data:a}),this._recomputeAttachments(),l}async stageAddAttachments(t,e){if(this.clearValidationCriteriaState(),!this._assertEditable())return[];const a=t.filter(t=>this.isFileAllowed(t));if(this._setUnsupportedFileTypeValidationError(a.length!==t.length),0===a.length)return[];const n=[],i=new Map,s=Date.now(),r={},o=this.effectiveAttachmentCount,d=o+a.length;if(null!=this.minAttachmentCount&&this.minAttachmentCount>0&&this._setValidationCriterionState(r,"minimum-number-of-files",d>=this.minAttachmentCount?"success":"danger"),null!=this.maxAttachmentCount){const t=d<=this.maxAttachmentCount;if(this._setValidationCriterionState(r,"maximum-number-of-files",t?"success":"danger"),!t)return this._setValidationCriteriaState(r),[]}for(let l=0;l<a.length;l++){const t=a[l];if(!await this._validateAttachmentFile(t,o+n.length+1,r))continue;const d=t instanceof File?t.name:`attachment-${s}_${l+1}`,h=await this._resolveAttachmentFilename(d,e),c=this._makeUniqueFilenameForOperation(i,h);n.push(this.stageAddAttachment({contentType:t.type,data:t,name:c}))}return this._setValidationCriteriaState(r),n}findAttachment(t){if(t)return this.attachments.find(e=>g(e)===t)}getAttachmentEditState(t){const e=this._getAttachmentKey(t),a=e?this._initialAttachments.find(t=>this._getAttachmentKey(t)===e):void 0,n=a?.name??null,i=e?this._stagedUpdates.get(e):void 0,s=i?.name??t.name??null;return{initialName:n,isDeleted:!!e&&this._stagedDeletes.has(e),isRenamed:null!=s&&null!=n&&s!==n,isReplaced:!0===i?.isReplacement}}getAttachmentPreviewUrl(t,e){const a=this._getAttachmentKey(t);return(a?this._temporaryAttachmentUrls.get(a):void 0)??y({attachment:t,supportsResizeAttachments:this.supportsResize,layer:this.layer,thumbnailSize:e})}async ensureStagedUpdateData(t){const e=this._getAttachmentKey(t);if(!e)return!1;const a=this._stagedUpdates.get(e);if(!a||a.data||this._stagedDeletes.has(e))return this._failedStagedUpdateHydrations.delete(e),!1;const n=this._pendingStagedUpdateHydrations.get(e);if(n)return await n;const i=this._hydrateStagedUpdateData(t);this._pendingStagedUpdateHydrations.set(e,i);try{return await i}finally{this._pendingStagedUpdateHydrations.get(e)===i&&this._pendingStagedUpdateHydrations.delete(e)}}async waitForPendingAttachmentUpdateData(){await Promise.allSettled(Array.from(this._pendingStagedUpdateHydrations.values()))}discardStagedEdits(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.delete(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}isFileAllowed(t){const{categories:e}=this;if(!e.size)return!0;const a=p(t);return null!=a&&e.has(a)}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.add(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}stageRenameAttachment(t,e){if(!this._assertEditable())return;const a=this._getAttachmentKey(t);if(!a)return;const n=this._stagedAdds.find(t=>t.key===a);if(n){const a=f(t.name,e);return n.info.name=a,void this._recomputeAttachments()}const i=this._stagedUpdates.get(a),s=this._getInitialAttachment(a)?.name??null,r=0===t.name.trim().length?s??t.name:t.name,o=f(r,e),d=null!=s&&o===s;if(d&&!0!==i?.isReplacement)return this._stagedUpdates.delete(a),this._failedStagedUpdateHydrations.delete(a),this._pendingStagedUpdateHydrations.delete(a),void this._recomputeAttachments();const l={key:a,...i,info:t};d?delete l.name:l.name=o,this._stagedUpdates.set(a,l),this._recomputeAttachments(),this.ensureStagedUpdateData(t)}async stageReplaceAttachment(t,e,a){if(this.clearValidationCriteriaState(),!this._assertEditable())return!1;if(!this._isReplacementFileAllowed(t,e))return this._setUnsupportedFileTypeValidationError(!0),!1;const n={},i=await this._validateAttachmentFile(e,void 0,n);if(this._setValidationCriteriaState(n),!i)return!1;const s=e instanceof File?e.name:t.name,r=await this._resolveAttachmentFilename(s,a);return this._stageReplaceAttachment(t,e,r),!0}toSubmitEdits(){const t=[],e=[],a=[],n=this.feature?.plainGraphic;if(!n||0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===this._stagedDeletes.size)return null;const i=this.attachmentKeyword;for(const s of this._stagedAdds)null!=s.data&&t.push({feature:n,contentType:s.info.contentType,data:s.data,info:s.info,globalId:s.info.globalId,keywords:i,name:s.info.name});for(const s of this._stagedUpdates.values()){const t=null==s.name||s.name.trim().length>0;null!=s.data&&t&&e.push({feature:n,contentType:s.contentType,data:s.data,globalId:s.info.globalId,id:s.info.id,info:s.info,keywords:i,name:s.name})}for(const s of this._stagedDeletes.values()){const t=this._getInitialAttachment(s);t&&a.push({feature:n,contentType:t.contentType,globalId:t.globalId,id:t.id,info:t,keywords:i,name:t.name})}return 0===t.length&&0===e.length&&0===a.length?null:{label:this.template.label,keywords:i,adds:t,deletes:a,updates:e}}_assertEditable(){return!!this.editable||(i.getLogger(this).error("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false."),!1)}_recomputeAttachments(){const t=[];for(const e of this._stagedAdds)t.push(e.info);for(const e of this._initialAttachments){const a=this._getAttachmentKey(e);if(a&&this._stagedUpdates.has(a)){const n=this._stagedUpdates.get(a),i=e.clone();null!=n.name&&(i.name=n.name),null!=n.contentType&&(i.contentType=n.contentType),null!=n.size&&(i.size=n.size),t.push(i);continue}t.push(e)}this.attachments=t}async _computeAttachmentFilename(t,e){const a=this.template.filenameExpressionExecutor;if(!a)return t;const n=this.single.feature,r=n?.plainGraphic,o=this._expressionLayer,{attachmentKeyword:d,description:l,label:h}=this.template,c={$originalfeature:n?.original,$editcontext:{editType:e.editType},$layer:o,$featureset:o,$datastore:o?.url,$feature:r,$map:e.map,$formElement:{attachmentKeyword:d,description:l,label:h}},m={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const e=a.isAsync?await a.executeAsync(c,m):a.execute(c,m);if("string"==typeof e&&e.trim().length>0){const{extension:a}=z(t);return R(e.trim(),a)}}catch(p){s(p)||i.getLogger(this).error("Failed evaluating attachment filename expression",p)}return t}async _resolveAttachmentFilename(t,e){return!1===this.useOriginalFilename?await this._computeAttachmentFilename(t,e):t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const{base:i,extension:s}=z(e);return R(`${i}_${n}`,s)}_setValidationCriteriaState(t){this._validationCriterionStates.clear();for(const e of S){const a=t[e];a&&this._validationCriterionStates.set(e,a)}}_setUnsupportedFileTypeValidationError(t){this._hasUnsupportedFileTypeValidationError!==t&&(this._hasUnsupportedFileTypeValidationError=t)}_setValidationCriterionState(t,e,a){"danger"!==t[e]&&(t[e]=a)}_isReplacementFileAllowed(t,e){const a=p(e);if(!this.isFileAllowed(e))return!1;const n=u(t);return null==n||n===a}async _validateAttachmentFile(t,e,a){let n=!0;const i=p(t);for(const s of this._nestableInputs){const e=_.getAttachmentCategoryForInputType(s.type);if(null==i||e===i){if("document"===s.type&&null!=s.maxFileSize){const e=t.size<=1048576*s.maxFileSize;this._setValidationCriterionState(a,"maximum-file-size",e?"success":"danger"),n=n&&e}if(("audio"===s.type||"video"===s.type)&&null!=s.maxDuration){const e=await _.getMediaDurationInSeconds(t,s.type),i=null!=e&&e<=s.maxDuration;this._setValidationCriterionState(a,"audio"===s.type?"maximum-audio-length":"maximum-video-length",i?"success":"danger"),n=n&&i}if("image"===s.type&&null!=s.maxImageSize){const e=await _.getImageDimensionsInPixels(t),i=e?Math.max(e.width,e.height):null,r=null==i||i<=s.maxImageSize;this._setValidationCriterionState(a,"maximum-image-size",r?"success":"danger"),n=n&&r}}}if(null!=e&&null!=this.maxAttachmentCount){const t=e<=this.maxAttachmentCount;this._setValidationCriterionState(a,"maximum-number-of-files",t?"success":"danger"),n=n&&t}return n}_stageReplaceAttachment(t,e,a){const n=this._getAttachmentKey(t);if(!n)return;const i=this._stagedAdds.find(t=>t.key===n);if(i)return i.data=e,i.info.name=a,i.info.contentType=e.type,i.info.size=e.size,this._setTemporaryAttachmentUrl(n,e),void this._recomputeAttachments();const s=this._stagedUpdates.get(n);this._setTemporaryAttachmentUrl(n,e),this._failedStagedUpdateHydrations.delete(n),this._pendingStagedUpdateHydrations.delete(n),this._stagedUpdates.set(n,{...s,key:n,info:t,isReplacement:!0,contentType:e.type||s?.contentType||t.contentType,data:e,name:a,size:e.size}),this._recomputeAttachments()}_getInitialAttachment(t){return this._initialAttachments.find(e=>this._getAttachmentKey(e)===t)}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}_getAttachmentKey(t){return g(t)}_clearStagedUpdateTracking(t){this._stagedUpdates.delete(t),this._failedStagedUpdateHydrations.delete(t),this._pendingStagedUpdateHydrations.delete(t)}async _hydrateStagedUpdateData(t){const a=this._getAttachmentKey(t),n=t.url;if(!a||!n)return!1;try{const{data:i}=await e(n,{responseType:"blob"});this._failedStagedUpdateHydrations.delete(a);const s=this._stagedUpdates.get(a);return!(!s||s.data||this._stagedDeletes.has(a))&&(this._stagedUpdates.set(a,{...s,info:t,isReplacement:s.isReplacement??!1,contentType:s.contentType??t.contentType??i.type,data:i}),!0)}catch(r){const t=this._stagedUpdates.get(a);return!t||t.data||this._stagedDeletes.has(a)||this._failedStagedUpdateHydrations.add(a),s(r)||i.getLogger(this).error("Failed to fetch attachment data for staged update",r),!1}}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([l()],C.prototype,"allowUserRename",null),t([l()],C.prototype,"addDisabled",null),t([l()],C.prototype,"effectiveAttachmentCount",null),t([l()],C.prototype,"accept",null),t([l()],C.prototype,"categories",null),t([l()],C.prototype,"attachmentKeyword",null),t([l()],C.prototype,"attachments",void 0),t([l()],C.prototype,"displayFilename",null),t([l({readOnly:!0})],C.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([l()],C.prototype,"canUploadFiles",null),t([l()],C.prototype,"hasCaptureInputs",null),t([l()],C.prototype,"captureMediaType",null),t([l()],C.prototype,"isCaptureOnly",null),t([l({readOnly:!0})],C.prototype,"defaultPageAttachments",null),t([l()],C.prototype,"displayCount",void 0),t([l()],C.prototype,"feature",null),t([l()],C.prototype,"group",void 0),t([l()],C.prototype,"hasAttachmentChanges",null),t([l()],C.prototype,"hasInvalidAttachmentName",null),t([l()],C.prototype,"attachmentCount",null),t([l()],C.prototype,"hasMinimumAttachmentCountNotMet",null),t([l()],C.prototype,"hasReachedAttachmentLimit",null),t([l()],C.prototype,"hasExceededAttachmentLimit",null),t([l({readOnly:!0})],C.prototype,"hasPendingAttachmentUpdateData",null),t([l()],C.prototype,"input",null),t([l()],C.prototype,"layer",null),t([l()],C.prototype,"maxAttachmentCount",null),t([l()],C.prototype,"minAttachmentCount",null),t([l({readOnly:!0})],C.prototype,"single",void 0),t([l({readOnly:!0})],C.prototype,"type",void 0),t([l({readOnly:!0})],C.prototype,"supportsResize",null),t([l()],C.prototype,"useOriginalFilename",null),t([l({readOnly:!0})],C.prototype,"valid",null),t([l()],C.prototype,"_initialAttachments",void 0),t([l()],C.prototype,"_expressionLayer",null),t([l()],C.prototype,"_stagedAdds",void 0),t([l()],C.prototype,"_stagedDeletes",void 0),t([l()],C.prototype,"_stagedUpdates",void 0),t([l()],C.prototype,"_failedStagedUpdateHydrations",void 0),t([l()],C.prototype,"_pendingStagedUpdateHydrations",void 0),t([l()],C.prototype,"_temporaryAttachmentUrls",void 0),t([l()],C.prototype,"_hasUnsupportedFileTypeValidationError",void 0),t([l()],C.prototype,"hasInvalidValidationCriteria",null),t([l()],C.prototype,"hasUnsupportedFileTypeValidationError",null),t([l()],C.prototype,"validationCriterionStates",null),C=t([h("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],C);const b=C;function w(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}function T(t){return"document"!==t.type&&"capture"===t.inputMethod}function x(t){return T(t)}function F(t){return"document"===t.type||"capture"!==t.inputMethod}function I(t){return t.data&&"string"!=typeof t.data?t.data.size:t.info.size}function z(t){const e=t.lastIndexOf(".");return-1===e?{base:t,extension:null}:{base:t.slice(0,e),extension:t.slice(e+1)}}function R(t,e){return e?`${t}.${e}`:t}export{b as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../request.js";import a from"../../../core/Collection.js";import n from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import r from"../../../core/ReactiveMap.js";import o from"../../../core/ReactiveSet.js";import{generateBracedUUID as l}from"../../../core/uuid.js";import{property as d,subclass as h}from"../../../core/accessorSupport/decorators.js";import{getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import m from"../../../rest/query/support/AttachmentInfo.js";import{getAttachmentCategoryForFile as p,getAttachmentCategoryForAttachment as u}from"../../Attachments/support/attachmentUtils.js";import{getAttachmentKey as g,getAttachmentUrl as y,preserveAttachmentFilenameExtension as f,attachmentValidationUtils as _}from"../attachmentUtils.js";import A from"./EditableInput.js";import U from"./SingleFeatureInputAdapter.js";let v=-1;const S=["maximum-audio-length","maximum-file-size","maximum-image-size","minimum-number-of-files","maximum-number-of-files","maximum-video-length"];let C=class extends A{constructor(t){super(t),this.attachments=[],this.displayCount=3,this.group=null,this.single=new U({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new a,this._stagedDeletes=new o,this._stagedUpdates=new r,this._failedStagedUpdateHydrations=new o,this._pendingStagedUpdateHydrations=new r,this._temporaryAttachmentUrls=new r,this._validationCriterionStates=new r,this._hasUnsupportedFileTypeValidationError=!1}get allowUserRename(){return this.template.allowUserRename}get addDisabled(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return!this.editable||null!=t&&e>=t}get effectiveAttachmentCount(){return this._initialAttachments.length-this._stagedDeletes.size+this._stagedAdds.length}get accept(){const{categories:t}=this;if(!t.size)return;const e=[];return t.has("image")&&e.push("image/*"),t.has("audio")&&e.push("audio/*"),t.has("video")&&e.push("video/*"),t.has("document")&&e.push("text/*","application/*","model/*"),e.length>0?e.join(","):void 0}get categories(){const t=new Set;for(const e of this._nestableInputs)w(t,e.type);return t}get _nestableInputs(){const{input:t}=this;return null==t?[]:"attachment"===t.type?t.inputTypes??[]:[t]}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get allAttachmentsVisibleOnDefaultPage(){return this.defaultPageAttachments.length===this.attachments.length}get canUploadFiles(){const t=this._nestableInputs;return!t.length||t.some(F)}get hasCaptureInputs(){return this._nestableInputs.some(x)}get captureMediaType(){const t=new Set;for(const e of this._nestableInputs)if(x(e))switch(e.type){case"audio":t.add("audio");break;case"video":t.add("video");break;case"image":case"signature":t.add("image")}return 1===t.size?Array.from(t)[0]:null}get isCaptureOnly(){const t=this._nestableInputs;return!!t.length&&t.every(T)}get defaultPageAttachments(){return this.attachments.slice(0,this.displayCount)}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get hasInvalidAttachmentName(){return!!this.allowUserRename&&this.attachments.some(t=>0===t.name.trim().length)}get attachmentCount(){return this.attachments.length}get hasMinimumAttachmentCountNotMet(){const t=this.minAttachmentCount;return null!=t&&(this.effectiveAttachmentCount<t&&!this.isCaptureOnly)}get hasReachedAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e===t}get hasExceededAttachmentLimit(){const t=this.maxAttachmentCount,e=this.effectiveAttachmentCount;return null!=t&&e>t}get hasPendingAttachmentUpdateData(){return this._pendingStagedUpdateHydrations.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get supportsResize(){const{layer:t}=this;if(!t)return!1;const e=c(t);return!!e&&("attachment"in e&&!!e.attachment?.supportsResize)}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){return!(this._failedStagedUpdateHydrations.size>0||this.hasInvalidAttachmentName||this.hasExceededAttachmentLimit||this.hasMinimumAttachmentCountNotMet)}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}destroy(){this._clearTemporaryAttachmentUrls()}applyFetchedAttachments(t){for(const e of t)this._normalizeAttachmentName(e);this._initialAttachments=t,this._failedStagedUpdateHydrations.clear(),this._recomputeAttachments()}applyStashedEdits(t){const{adds:e,deletes:a,updates:n}=t;for(const i of e){const t=this._getAttachmentKey(i.info);this._stagedAdds.add({data:i.data,globalId:i.globalId??l(),info:i.info,key:t}),this._setTemporaryAttachmentUrl(t,i.data)}for(const i of n){const t=this._getAttachmentKey(i.info);this._stagedUpdates.set(t,{contentType:i.contentType,data:i.data,info:i.info,key:t,name:i.name,size:I(i)}),this._setTemporaryAttachmentUrl(t,i.data)}for(const i of a){const t=this._getAttachmentKey(i.info);this._stagedDeletes.add(t)}this._recomputeAttachments()}clearAttachmentChanges(){this.clearValidationCriteriaState(),this._clearTemporaryAttachmentUrls(),this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._failedStagedUpdateHydrations.clear(),this._pendingStagedUpdateHydrations.clear(),this._recomputeAttachments()}clearValidationCriteriaState(){this._validationCriterionStates.clear(),this._hasUnsupportedFileTypeValidationError=!1}get hasInvalidValidationCriteria(){for(const t of this._validationCriterionStates.values())if("danger"===t)return!0;return!1}get hasUnsupportedFileTypeValidationError(){return this._hasUnsupportedFileTypeValidationError}get validationCriterionStates(){return this._validationCriterionStates}getValidationCriterionState(t){return this._validationCriterionStates.get(t)??null}stageAddAttachment(t){if(!this._assertEditable())throw new n("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false.");const{contentType:e,data:a,name:i}=t,s=t.globalId??l(),r=a instanceof Blob?a.size:void 0,o=i.trim(),d=new m({contentType:e??void 0,globalId:s,id:v--,keywords:this.attachmentKeyword??void 0,name:o,size:r});return this._setTemporaryAttachmentUrl(s,a),this._stagedAdds.add({key:s,globalId:s,info:d,data:a}),this._recomputeAttachments(),d}async stageAddAttachments(t,e){if(this.clearValidationCriteriaState(),!this._assertEditable())return[];const a=t.filter(t=>this.isFileAllowed(t));if(this._setUnsupportedFileTypeValidationError(a.length!==t.length),0===a.length)return[];const n=[],i=new Map,s=Date.now(),r={},o=this.effectiveAttachmentCount,l=o+a.length;if(null!=this.minAttachmentCount&&this.minAttachmentCount>0&&this._setValidationCriterionState(r,"minimum-number-of-files",l>=this.minAttachmentCount?"success":"danger"),null!=this.maxAttachmentCount){const t=l<=this.maxAttachmentCount;if(this._setValidationCriterionState(r,"maximum-number-of-files",t?"success":"danger"),!t)return this._setValidationCriteriaState(r),[]}let d=!0;for(let h=0;h<a.length;h++){const t=a[h];await this._validateAttachmentFile(t,o+h+1,r)||(d=!1)}if(!d)return this._setValidationCriteriaState(r),[];for(let h=0;h<a.length;h++){const t=a[h],r=t instanceof File?t.name:`attachment-${s}_${h+1}`,o=await this._resolveAttachmentFilename(r,e),l=this._makeUniqueFilenameForOperation(i,o);n.push(this.stageAddAttachment({contentType:t.type,data:t,name:l}))}return this._setValidationCriteriaState(r),n}findAttachment(t){if(t)return this.attachments.find(e=>g(e)===t)}getAttachmentEditState(t){const e=this._getAttachmentKey(t),a=e?this._initialAttachments.find(t=>this._getAttachmentKey(t)===e):void 0,n=a?.name??null,i=e?this._stagedUpdates.get(e):void 0,s=i?.name??t.name??null;return{initialName:n,isDeleted:!!e&&this._stagedDeletes.has(e),isRenamed:null!=s&&null!=n&&s!==n,isReplaced:!0===i?.isReplacement}}getAttachmentPreviewUrl(t,e){const a=this._getAttachmentKey(t);return(a?this._temporaryAttachmentUrls.get(a):void 0)??y({attachment:t,supportsResizeAttachments:this.supportsResize,layer:this.layer,thumbnailSize:e})}async ensureStagedUpdateData(t){const e=this._getAttachmentKey(t);if(!e)return!1;const a=this._stagedUpdates.get(e);if(!a||a.data||this._stagedDeletes.has(e))return this._failedStagedUpdateHydrations.delete(e),!1;const n=this._pendingStagedUpdateHydrations.get(e);if(n)return await n;const i=this._hydrateStagedUpdateData(t);this._pendingStagedUpdateHydrations.set(e,i);try{return await i}finally{this._pendingStagedUpdateHydrations.get(e)===i&&this._pendingStagedUpdateHydrations.delete(e)}}async waitForPendingAttachmentUpdateData(){await Promise.allSettled(Array.from(this._pendingStagedUpdateHydrations.values()))}discardStagedEdits(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.delete(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}isFileAllowed(t){const{categories:e}=this;if(!e.size)return!0;const a=p(t);return null!=a&&e.has(a)}isStagedAttachmentAddition(t){return"number"==typeof t.id&&t.id<0}stageDeleteAttachment(t){if(!this._assertEditable())return;const e=this._getAttachmentKey(t);if(!e)return;const a=this._stagedAdds.findIndex(t=>t.key===e);if(a>-1)return this._clearTemporaryAttachmentUrl(e),this._stagedAdds.removeAt(a),this._failedStagedUpdateHydrations.delete(e),this._pendingStagedUpdateHydrations.delete(e),void this._recomputeAttachments();this._clearTemporaryAttachmentUrl(e),this._stagedDeletes.add(e),this._clearStagedUpdateTracking(e),this._recomputeAttachments()}stageRenameAttachment(t,e){if(!this._assertEditable())return;const a=this._getAttachmentKey(t);if(!a)return;const n=this._stagedAdds.find(t=>t.key===a);if(n){const a=f(t.name,e);return n.info.name=a,void this._recomputeAttachments()}const i=this._stagedUpdates.get(a),s=this._getInitialAttachment(a)?.name??null,r=0===t.name.trim().length?s??t.name:t.name,o=!0===i?.isReplacement&&null!=s&&e===s?s:f(r,e),l=null!=s&&o===s;if(l&&!0!==i?.isReplacement)return this._stagedUpdates.delete(a),this._failedStagedUpdateHydrations.delete(a),this._pendingStagedUpdateHydrations.delete(a),void this._recomputeAttachments();const d={key:a,...i,info:t};l?delete d.name:d.name=o,this._stagedUpdates.set(a,d),this._recomputeAttachments(),this.ensureStagedUpdateData(t)}async stageReplaceAttachment(t,e,a){if(this.clearValidationCriteriaState(),!this._assertEditable())return!1;if(!this._isReplacementFileAllowed(t,e))return this._setUnsupportedFileTypeValidationError(!0),!1;const n={},i=await this._validateAttachmentFile(e,void 0,n);if(this._setValidationCriteriaState(n),!i)return!1;const s=e instanceof File?e.name:t.name,r=await this._resolveAttachmentFilename(s,a);return this._stageReplaceAttachment(t,e,r),!0}toSubmitEdits(){const t=[],e=[],a=[],n=this.feature?.plainGraphic;if(!n||0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===this._stagedDeletes.size)return null;const i=this.attachmentKeyword;for(const s of this._stagedAdds)null!=s.data&&t.push({feature:n,contentType:s.info.contentType,data:s.data,info:s.info,globalId:s.info.globalId,keywords:i,name:s.info.name});for(const s of this._stagedUpdates.values()){const t=null==s.name||s.name.trim().length>0;if(null==s.data||!t)continue;const a=s.name??this._getInitialAttachment(s.key)?.name??s.info.name;e.push({feature:n,contentType:s.contentType,data:s.data,globalId:s.info.globalId,id:s.info.id,info:s.info,keywords:i,name:a})}for(const s of this._stagedDeletes.values()){const t=this._getInitialAttachment(s);t&&a.push({feature:n,contentType:t.contentType,globalId:t.globalId,id:t.id,info:t,keywords:i,name:t.name})}return 0===t.length&&0===e.length&&0===a.length?null:{label:this.template.label,keywords:i,adds:t,deletes:a,updates:e}}_assertEditable(){return!!this.editable||(i.getLogger(this).error("batch-attribute-form:not-editable","Cannot modify attachments when editableExpression is false."),!1)}_recomputeAttachments(){const t=[];for(const e of this._stagedAdds)t.push(e.info);for(const e of this._initialAttachments){const a=this._getAttachmentKey(e);if(a&&this._stagedUpdates.has(a)){const n=this._stagedUpdates.get(a),i=e.clone();null!=n.name&&(i.name=n.name),null!=n.contentType&&(i.contentType=n.contentType),null!=n.size&&(i.size=n.size),t.push(i);continue}t.push(e)}this.attachments=t}async _computeAttachmentFilename(t,e){const a=this.template.filenameExpressionExecutor;if(!a)return t;const n=this.single.feature,r=n?.plainGraphic,o=this._expressionLayer,{attachmentKeyword:l,description:d,label:h}=this.template,c={$originalfeature:n?.original,$editcontext:{editType:e.editType},$layer:o,$featureset:o,$datastore:o?.url,$feature:r,$map:e.map,$formElement:{attachmentKeyword:l,description:d,label:h}},m={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const e=a.isAsync?await a.executeAsync(c,m):a.execute(c,m);if("string"==typeof e&&e.trim().length>0){const{extension:a}=z(t);return R(e.trim(),a)}}catch(p){s(p)||i.getLogger(this).error("Failed evaluating attachment filename expression",p)}return t}async _resolveAttachmentFilename(t,e){return!1===this.useOriginalFilename?await this._computeAttachmentFilename(t,e):t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const{base:i,extension:s}=z(e);return R(`${i}_${n}`,s)}_setValidationCriteriaState(t){this._validationCriterionStates.clear();for(const e of S){const a=t[e];a&&this._validationCriterionStates.set(e,a)}}_setUnsupportedFileTypeValidationError(t){this._hasUnsupportedFileTypeValidationError!==t&&(this._hasUnsupportedFileTypeValidationError=t)}_setValidationCriterionState(t,e,a){"danger"!==t[e]&&(t[e]=a)}_isReplacementFileAllowed(t,e){const a=p(e);if(!this.isFileAllowed(e))return!1;const n=u(t);return null==n||n===a}async _validateAttachmentFile(t,e,a){let n=!0;const i=p(t);for(const s of this._nestableInputs){const e=_.getAttachmentCategoryForInputType(s.type);if(null==i||e===i){if("document"===s.type&&null!=s.maxFileSize){const e=t.size<=1048576*s.maxFileSize;this._setValidationCriterionState(a,"maximum-file-size",e?"success":"danger"),n=n&&e}if(("audio"===s.type||"video"===s.type)&&null!=s.maxDuration){const e=await _.getMediaDurationInSeconds(t,s.type),i=null!=e&&e<=s.maxDuration;this._setValidationCriterionState(a,"audio"===s.type?"maximum-audio-length":"maximum-video-length",i?"success":"danger"),n=n&&i}if("image"===s.type&&null!=s.maxImageSize){const e=await _.getImageDimensionsInPixels(t),i=e?Math.max(e.width,e.height):null,r=null==i||i<=s.maxImageSize;this._setValidationCriterionState(a,"maximum-image-size",r?"success":"danger"),n=n&&r}}}if(null!=e&&null!=this.maxAttachmentCount){const t=e<=this.maxAttachmentCount;this._setValidationCriterionState(a,"maximum-number-of-files",t?"success":"danger"),n=n&&t}return n}_stageReplaceAttachment(t,e,a){const n=this._getAttachmentKey(t);if(!n)return;const i=this._stagedAdds.find(t=>t.key===n);if(i)return i.data=e,i.info.name=a,i.info.contentType=e.type,i.info.size=e.size,this._setTemporaryAttachmentUrl(n,e),void this._recomputeAttachments();const s=this._stagedUpdates.get(n);this._setTemporaryAttachmentUrl(n,e),this._failedStagedUpdateHydrations.delete(n),this._pendingStagedUpdateHydrations.delete(n),this._stagedUpdates.set(n,{...s,key:n,info:t,isReplacement:!0,contentType:e.type||s?.contentType||t.contentType,data:e,name:a,size:e.size}),this._recomputeAttachments()}_getInitialAttachment(t){return this._initialAttachments.find(e=>this._getAttachmentKey(e)===t)}_normalizeAttachmentName(t){const{name:e}=t;"string"==typeof e&&(t.name=e.trim())}_getAttachmentKey(t){return g(t)}_clearStagedUpdateTracking(t){this._stagedUpdates.delete(t),this._failedStagedUpdateHydrations.delete(t),this._pendingStagedUpdateHydrations.delete(t)}async _hydrateStagedUpdateData(t){const a=this._getAttachmentKey(t),n=t.url;if(!a||!n)return!1;try{const{data:i}=await e(n,{responseType:"blob"});this._failedStagedUpdateHydrations.delete(a);const s=this._stagedUpdates.get(a);return!(!s||s.data||this._stagedDeletes.has(a))&&(this._stagedUpdates.set(a,{...s,info:t,isReplacement:s.isReplacement??!1,contentType:s.contentType??t.contentType??i.type,data:i}),!0)}catch(r){const t=this._stagedUpdates.get(a);return!t||t.data||this._stagedDeletes.has(a)||this._failedStagedUpdateHydrations.add(a),s(r)||i.getLogger(this).error("Failed to fetch attachment data for staged update",r),!1}}_setTemporaryAttachmentUrl(t,e){if(this._clearTemporaryAttachmentUrl(t),!(e instanceof Blob))return;const a=URL.createObjectURL(e);return this._temporaryAttachmentUrls.set(t,a),a}_clearTemporaryAttachmentUrl(t){const e=this._temporaryAttachmentUrls.get(t);e&&(URL.revokeObjectURL(e),this._temporaryAttachmentUrls.delete(t))}_clearTemporaryAttachmentUrls(){for(const t of this._temporaryAttachmentUrls.values())URL.revokeObjectURL(t);this._temporaryAttachmentUrls.clear()}};t([d()],C.prototype,"allowUserRename",null),t([d()],C.prototype,"addDisabled",null),t([d()],C.prototype,"effectiveAttachmentCount",null),t([d()],C.prototype,"accept",null),t([d()],C.prototype,"categories",null),t([d()],C.prototype,"attachmentKeyword",null),t([d()],C.prototype,"attachments",void 0),t([d()],C.prototype,"displayFilename",null),t([d({readOnly:!0})],C.prototype,"allAttachmentsVisibleOnDefaultPage",null),t([d()],C.prototype,"canUploadFiles",null),t([d()],C.prototype,"hasCaptureInputs",null),t([d()],C.prototype,"captureMediaType",null),t([d()],C.prototype,"isCaptureOnly",null),t([d({readOnly:!0})],C.prototype,"defaultPageAttachments",null),t([d()],C.prototype,"displayCount",void 0),t([d()],C.prototype,"feature",null),t([d()],C.prototype,"group",void 0),t([d()],C.prototype,"hasAttachmentChanges",null),t([d()],C.prototype,"hasInvalidAttachmentName",null),t([d()],C.prototype,"attachmentCount",null),t([d()],C.prototype,"hasMinimumAttachmentCountNotMet",null),t([d()],C.prototype,"hasReachedAttachmentLimit",null),t([d()],C.prototype,"hasExceededAttachmentLimit",null),t([d({readOnly:!0})],C.prototype,"hasPendingAttachmentUpdateData",null),t([d()],C.prototype,"input",null),t([d()],C.prototype,"layer",null),t([d()],C.prototype,"maxAttachmentCount",null),t([d()],C.prototype,"minAttachmentCount",null),t([d({readOnly:!0})],C.prototype,"single",void 0),t([d({readOnly:!0})],C.prototype,"type",void 0),t([d({readOnly:!0})],C.prototype,"supportsResize",null),t([d()],C.prototype,"useOriginalFilename",null),t([d({readOnly:!0})],C.prototype,"valid",null),t([d()],C.prototype,"_initialAttachments",void 0),t([d()],C.prototype,"_expressionLayer",null),t([d()],C.prototype,"_stagedAdds",void 0),t([d()],C.prototype,"_stagedDeletes",void 0),t([d()],C.prototype,"_stagedUpdates",void 0),t([d()],C.prototype,"_failedStagedUpdateHydrations",void 0),t([d()],C.prototype,"_pendingStagedUpdateHydrations",void 0),t([d()],C.prototype,"_temporaryAttachmentUrls",void 0),t([d()],C.prototype,"_hasUnsupportedFileTypeValidationError",void 0),t([d()],C.prototype,"hasInvalidValidationCriteria",null),t([d()],C.prototype,"hasUnsupportedFileTypeValidationError",null),t([d()],C.prototype,"validationCriterionStates",null),C=t([h("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],C);const b=C;function w(t,e){switch(e){case"audio":t.add("audio");break;case"document":t.add("document");break;case"image":case"signature":t.add("image");break;case"video":t.add("video")}}function T(t){return"document"!==t.type&&"capture"===t.inputMethod}function x(t){return T(t)}function F(t){return"document"===t.type||"capture"!==t.inputMethod}function I(t){return t.data&&"string"!=typeof t.data?t.data.size:t.info.size}function z(t){const e=t.lastIndexOf(".");return-1===e?{base:t,extension:null}:{base:t.slice(0,e),extension:t.slice(e+1)}}function R(t,e){return e?`${t}.${e}`:t}export{b as default};
@@ -36,12 +36,6 @@ export interface EditorViewModelProperties extends Partial<Pick<EditorViewModel,
36
36
  /**
37
37
  * Options to configure the labels shown next to each segment of the geometry being created or updated.
38
38
  *
39
- * > [!WARNING]
40
- * >
41
- * > **Known Limitation**
42
- * >
43
- * > Sketch labels are currently only supported when working with a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
44
- *
45
39
  * @since 4.24
46
40
  */
47
41
  labelOptions?: SketchLabelOptionsProperties;
@@ -212,12 +206,6 @@ export default class EditorViewModel extends EventedAccessor {
212
206
  /**
213
207
  * Options to configure the labels shown next to each segment of the geometry being created or updated.
214
208
  *
215
- * > [!WARNING]
216
- * >
217
- * > **Known Limitation**
218
- * >
219
- * > Sketch labels are currently only supported when working with a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
220
- *
221
209
  * @since 4.24
222
210
  */
223
211
  get labelOptions(): SketchLabelOptions;
@@ -41,12 +41,6 @@ export interface EditorProperties extends WidgetProperties, Partial<Pick<Editor,
41
41
  /**
42
42
  * Options to configure the sketch labels shown next to each segment of the geometry being created or updated.
43
43
  *
44
- * > [!WARNING]
45
- * >
46
- * > **Known Limitation**
47
- * >
48
- * > Sketch labels are currently only supported when working with a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
49
- *
50
44
  * @since 4.24
51
45
  */
52
46
  labelOptions?: SketchLabelOptionsProperties;
@@ -444,12 +438,6 @@ export default class Editor extends Widget {
444
438
  /**
445
439
  * Options to configure the sketch labels shown next to each segment of the geometry being created or updated.
446
440
  *
447
- * > [!WARNING]
448
- * >
449
- * > **Known Limitation**
450
- * >
451
- * > Sketch labels are currently only supported when working with a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
452
- *
453
441
  * @since 4.24
454
442
  */
455
443
  get labelOptions(): SketchLabelOptions;
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";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{deprecatedModule as n}from"../../core/deprecate.js";import{IdentifiableMixin as l}from"../../core/Identifiable.js";import p from"../../core/Logger.js";import{abortMaybe as c}from"../../core/maybe.js";import{eachAlways as d,isAbortError as h,throwIfAborted as u}from"../../core/promiseUtils.js";import{watch as f,initial as m,when as _,on as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,cast as w,subclass as v}from"../../core/accessorSupport/decorators.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import x from"../../popup/content/TextContent.js";import{compileExpressionInfos as M,formatArcadeValue as T}from"../../popup/support/arcadeFeatureUtils.js";import{preLayerQueryCallback as F,preRequestCallback as C,createFieldInfoMap as E,getAllFieldInfos as V,getSourceLayer as k,querySourceLayer as j,queryUpdatedFeature as P,isRelatableFeatureSupportedLayer as R,isAssociatedFeatureSupportedLayer as L,substituteFieldsInLinksAndAttributes as O,isExpressionField as U,isRelatedField as N,formatEditInfo as Z,graphicCallback as D,formatAttributes as B}from"../../popup/support/featureUtils.js";import{queryLayerInfos as H,queryRelatedFeatures as S,setRelatedFeatures as G,getRelatedFieldInfo as W,createRelatedInfo as q,updateRelatedInfo as z}from"../../popup/support/relatedFeatureUtils.js";import{system as K}from"../../time/constants.js";import Q from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import J from"./FeatureContent/FeatureContentViewModel.js";import X from"./FeatureExpression/FeatureExpressionViewModel.js";import Y from"./FeatureFields/FeatureFieldsViewModel.js";import $ from"./FeatureMedia/FeatureMediaViewModel.js";import ee from"./FeatureRelationship/FeatureRelationshipViewModel.js";import te from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var ie;const se=1,oe="content-view-models",re="relationship-view-models",ae="association-view-models",ne={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let le=class extends(l(s)){static{ie=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={...ne},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,()=>this.notifyChange("waitingForContent"),se,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"),se,this),e?.suppressDeprecationWarning||n(p.getLogger(this),"esri.widgets.Feature.FeatureViewModel",{version:"5.1",replacement:"Use the Feature component or the @arcgis/core/popup/Feature module instead.",warnOnce:!0}),this.addHandles([f(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),m),_(()=>{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))])}normalizeCtorArgs(e){const{suppressDeprecationWarning:t,...i}=e??{};return i}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=c(this._graphicChangedTask),this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(F,C)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(V(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return k(this.graphic)}castAbilities(e){return{...ne,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??K}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 $&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof $&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof $&&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 j({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=c(this._evaluateExpressionAttributesTask),this._graphicChangedTask=c(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 P({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await d([this._getContent(),this._getTitle()]),[,{value:n}]=await d([this._checkForRelatedFeatures({signal:e}),M(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw h(i)||(this._error=i,p.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 x({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(re),this.removeHandles(oe),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 ie({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t,suppressDeprecationWarning:!0}))}),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(!R(n))return;const c=new ee({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(y(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),re),e}_matchesGlobalFeature(e,t){return e.association.equals(t.association)}_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,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new ie({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n,suppressDeprecationWarning:!0}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!L(a))return;const p=new te({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([f(()=>p.associationFeatures.values(),()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map))],ae),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new X({expressionInfo:i,graphic:s,interceptor:ie.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(f(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),m),oe),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r,attachmentKeywords:a,attachmentTypes:n}=e;return this.contentViewModels[t]=new Q({attachmentKeywords:a,attachmentTypes:n,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 J({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:O({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:O({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,a=e?.fieldInfos||i?.fieldInfos,n=a?.filter(({fieldName:e})=>!!e&&(U(e)||N(e)||o.hasOwnProperty(e))),l=i?.expressionInfos,{description:p,title:c}=e;return{attributes:o,expressionInfos:l,fieldInfos:n,isContentFieldInfos:r,graphic:this.graphic,layer:this._sourceLayer,...this._compileTitleAndDesc({title:c,description:p})}}_compileFields(e,t){const i=e.clone(),s=new Y(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,graphic:s,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 $(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=O({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 J(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 O({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?D({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?D({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r(async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:l}=this;try{if(!o)return;let p;if(null!=i){const e=[];for(const[t,p]of i.expressions.entries())null!=p?e.push(p.evaluate({graphic:o,interceptor:ie.interceptor,location:l,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?T(e):e]).catch(()=>[t,void 0])):e.push(Promise.resolve([t,void 0]));p=Object.fromEntries(await Promise.all(e)),u(s)}this._expressionAttributes=p,this._graphicExpressionAttributes={...o.attributes,...p},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){h(c)||(this._error=c,p.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]=B({attributes:{...l,...e.attributes},fieldInfoMap:n,fieldInfos:s?.fieldInfos,graphic:o,layer:a,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]=B({attributes:{...n,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:s,isContentFieldInfos:!0,layer:r,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:B({attributes:a,fieldInfoMap:r,fieldInfos:l,graphic:i,layer:o,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,V(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&&N(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await H({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 S({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{G(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=W(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||q(o,t);a&&(z({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([b()],le.prototype,"_error",void 0),e([b()],le.prototype,"_graphicChangedTask",void 0),e([b()],le.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],le.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],le.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],le.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],le.prototype,"_sourceLayer",null),e([b()],le.prototype,"abilities",void 0),e([w("abilities")],le.prototype,"castAbilities",null),e([b({readOnly:!0})],le.prototype,"content",void 0),e([b({readOnly:!0})],le.prototype,"contentViewModels",void 0),e([b()],le.prototype,"description",void 0),e([b({type:Boolean})],le.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],le.prototype,"isFeatureFromTable",null),e([b({readOnly:!0})],le.prototype,"state",null),e([b({readOnly:!0})],le.prototype,"formattedAttributes",void 0),e([b({type:t})],le.prototype,"graphic",void 0),e([b({readOnly:!0})],le.prototype,"lastEditInfo",void 0),e([b({type:A})],le.prototype,"location",void 0),e([b({readOnly:!0})],le.prototype,"relatedInfos",void 0),e([b({type:I})],le.prototype,"spatialReference",null),e([b()],le.prototype,"timeZone",null),e([b({readOnly:!0})],le.prototype,"title",void 0),e([b()],le.prototype,"map",null),e([b({readOnly:!0})],le.prototype,"waitingForContent",null),e([b()],le.prototype,"view",void 0),le=ie=e([v("esri.widgets.Feature.FeatureViewModel")],le);export{le as default};
2
+ import{__decorate as e}from"tslib";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{IdentifiableMixin as 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,initial as f,when as m,on as _}from"../../core/reactiveUtils.js";import{throttle as y}from"../../core/throttle.js";import{property as g,cast as b,subclass as v}from"../../core/accessorSupport/decorators.js";import w from"../../geometry/Point.js";import A from"../../geometry/SpatialReference.js";import I from"../../popup/content/TextContent.js";import{compileExpressionInfos as x,formatArcadeValue as M}from"../../popup/support/arcadeFeatureUtils.js";import{preLayerQueryCallback as T,preRequestCallback as F,createFieldInfoMap as C,getAllFieldInfos as E,getSourceLayer as V,querySourceLayer as k,queryUpdatedFeature as j,isRelatableFeatureSupportedLayer as P,isAssociatedFeatureSupportedLayer as R,substituteFieldsInLinksAndAttributes as L,isExpressionField as O,isRelatedField as N,formatEditInfo as U,graphicCallback as Z,formatAttributes as B}from"../../popup/support/featureUtils.js";import{queryLayerInfos as H,queryRelatedFeatures as S,setRelatedFeatures as D,getRelatedFieldInfo as G,createRelatedInfo as q,updateRelatedInfo as K}from"../../popup/support/relatedFeatureUtils.js";import{system as z}from"../../time/constants.js";import Q from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import J from"./FeatureContent/FeatureContentViewModel.js";import W from"./FeatureExpression/FeatureExpressionViewModel.js";import X from"./FeatureFields/FeatureFieldsViewModel.js";import Y from"./FeatureMedia/FeatureMediaViewModel.js";import $ from"./FeatureRelationship/FeatureRelationshipViewModel.js";import ee from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var te;const ie=1,se="content-view-models",oe="relationship-view-models",re="association-view-models",ae={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let ne=class extends(n(s)){static{te=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={...ae},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=y(this._graphicChanged,()=>this.notifyChange("waitingForContent"),ie,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=y(this._evaluateExpressionAttributes,()=>this.notifyChange("waitingForContent"),ie,this),this.addHandles([u(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),f),m(()=>{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(T,F)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return C(E(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return V(this.graphic)}castAbilities(e){return{...ae,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??z}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 Y&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof Y&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof Y&&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 k({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 j({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}),x(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 I({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(oe),this.removeHandles(se),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 te({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(!P(n))return;const c=new $({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(_(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),oe),e}_matchesGlobalFeature(e,t){return e.association.equals(t.association)}_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,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new te({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!R(a))return;const p=new ee({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))],re),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new W({expressionInfo:i,graphic:s,interceptor:te.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),f),se),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r,attachmentKeywords:a,attachmentTypes:n}=e;return this.contentViewModels[t]=new Q({attachmentKeywords:a,attachmentTypes:n,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 J({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:L({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:L({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,a=e?.fieldInfos||i?.fieldInfos,n=a?.filter(({fieldName:e})=>!!e&&(O(e)||N(e)||o.hasOwnProperty(e))),l=i?.expressionInfos,{description:p,title:c}=e;return{attributes:o,expressionInfos:l,fieldInfos:n,isContentFieldInfos:r,graphic:this.graphic,layer:this._sourceLayer,...this._compileTitleAndDesc({title:c,description:p})}}_compileFields(e,t){const i=e.clone(),s=new X(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,graphic:s,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 Y(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=L({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 J(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?U(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 L({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Z({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Z({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:te.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?M(e):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]=B({attributes:{...l,...e.attributes},fieldInfoMap:n,fieldInfos:s?.fieldInfos,graphic:o,layer:a,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]=B({attributes:{...n,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:s,isContentFieldInfos:!0,layer:r,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:B({attributes:a,fieldInfoMap:r,fieldInfos:l,graphic:i,layer:o,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,E(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&&N(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await H({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 S({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{D(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=G(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||q(o,t);a&&(K({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([g()],ne.prototype,"_error",void 0),e([g()],ne.prototype,"_graphicChangedTask",void 0),e([g()],ne.prototype,"_evaluateExpressionAttributesTask",void 0),e([g()],ne.prototype,"_associationVMAbortController",void 0),e([g({readOnly:!0})],ne.prototype,"_effectivePopupTemplate",null),e([g({readOnly:!0})],ne.prototype,"_fieldInfoMap",null),e([g({readOnly:!0})],ne.prototype,"_sourceLayer",null),e([g()],ne.prototype,"abilities",void 0),e([b("abilities")],ne.prototype,"castAbilities",null),e([g({readOnly:!0})],ne.prototype,"content",void 0),e([g({readOnly:!0})],ne.prototype,"contentViewModels",void 0),e([g()],ne.prototype,"description",void 0),e([g({type:Boolean})],ne.prototype,"defaultPopupTemplateEnabled",void 0),e([g({readOnly:!0})],ne.prototype,"isFeatureFromTable",null),e([g({readOnly:!0})],ne.prototype,"state",null),e([g({readOnly:!0})],ne.prototype,"formattedAttributes",void 0),e([g({type:t})],ne.prototype,"graphic",void 0),e([g({readOnly:!0})],ne.prototype,"lastEditInfo",void 0),e([g({type:w})],ne.prototype,"location",void 0),e([g({readOnly:!0})],ne.prototype,"relatedInfos",void 0),e([g({type:A})],ne.prototype,"spatialReference",null),e([g()],ne.prototype,"timeZone",null),e([g({readOnly:!0})],ne.prototype,"title",void 0),e([g()],ne.prototype,"map",null),e([g({readOnly:!0})],ne.prototype,"waitingForContent",null),e([g()],ne.prototype,"view",void 0),ne=te=e([v("esri.widgets.Feature.FeatureViewModel")],ne);export{ne as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import{substitute as i}from"../intl.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{watch as r,initial as o}from"../core/reactiveUtils.js";import{property as l,cast as d,subclass as a}from"../core/accessorSupport/decorators.js";import c from"../geometry/Point.js";import p from"./Widget.js";import u from"./Feature/FeatureAttachments.js";import m from"./Feature/FeatureContent.js";import h from"./Feature/FeatureExpression.js";import y from"./Feature/FeatureFields.js";import v from"./Feature/FeatureMedia.js";import g from"./Feature/FeatureRelationship.js";import w from"./Feature/FeatureUtilityNetworkAssociations.js";import f from"./Feature/FeatureViewModel.js";import{css as _}from"./Feature/resources.js";import{FeatureContentMixin as M}from"./Feature/support/FeatureContentMixin.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as F}from"./support/Heading.js";import{tsx as W,messageBundle as C}from"./support/widget.js";const j={title:!0,content:!0,lastEditedInfo:!0};let k=class extends(M(p)){constructor(e,t){super(e,t),this._contentWidgets=[],this.flowType="feature",this.flowItems=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.visibleElements={...j},this.viewModel=new f({suppressDeprecationWarning:!0}),!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{s(n.getLogger(this),"Feature","arcgis-feature",{version:"4.34"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles(r(()=>this.viewModel?.contentViewModels,()=>this._setupContentWidgets(),o))}loadDependencies(){return E({notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyContentWidgets()}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get isTable(){return this.viewModel.isFeatureFromTable}get icon(){return"polygon"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get title(){return this.viewModel.title}castVisibleElements(e){return{...j,...e}}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}setActiveMedia(e,t){return this.viewModel.setActiveMedia(e,t)}nextMedia(e){return this.viewModel.nextMedia(e)}previousMedia(e){return this.viewModel.previousMedia(e)}render(){const{state:e}=this.viewModel,t=W("div",{class:_.container,key:"container"},this._renderTitle(),"error"===e?this._renderError():"loading"===e?this._renderLoading():this._renderContentContainer());return W("div",{class:this.classes(_.base,b.widget)},t)}_renderError(){const{messagesCommon:e,messages:t,visibleElements:i}=this;return W("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0,scale:"s"},i.title?W("div",{key:"error-title",slot:"title"},e.errorMessage):null,W("div",{key:"error-message",slot:"message"},t.loadingError))}_renderLoading(){return W("div",{class:_.loadingSpinnerContainer,key:"loading-container"},W("calcite-loader",{inline:!0,label:""}))}_renderContentContainer(){const{visibleElements:e}=this;return e.content?W("div",{class:_.main},[this._renderContent(),this._renderLastEditInfo()]):null}_renderTitle(){const{visibleElements:e,title:t}=this;return e.title?W(F,{class:_.title,innerHTML:t,level:this.headingLevel}):null}_renderContent(){const e=this.viewModel.content,t="content";if(!e)return null;if(Array.isArray(e))return e.length?W("div",{class:_.contentNode,key:`${t}-content-elements`},e.map(this._renderContentElement,this)):null;if("string"==typeof e){const e=this._contentWidgets[0];return!e||e.destroyed?null:W("div",{class:this.classes(_.contentNode,_.contentNodeText),key:`${t}-content`},e.render())}return this.renderNodeContent(e)}_renderContentElement(e,t){const{visibleElements:i}=this;if("boolean"!=typeof i.content&&!i.content?.[e.type])return null;switch(e.type){case"attachments":return this._renderAttachments(t);case"custom":return this._renderCustom(e,t);case"fields":return this._renderFields(t);case"media":return this._renderMedia(t);case"text":return this._renderText(e,t);case"expression":return this._renderExpression(t);case"relationship":return this._renderRelationship(t);case"utility-network-associations":return this._renderAssociation(t);default:return null}}_renderAttachments(e){const t=this._contentWidgets[e];if(!t||t.destroyed)return null;const{state:i,attachmentInfos:s}=t.viewModel;return"loading"===i||s.length>0?W("div",{class:this.classes(_.contentElement),key:this._buildKey("attachments-element",e)},t.render()):null}_renderRelationship(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("relationship-element",e)},t.render()):null}_renderAssociation(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("utility-network-association-element",e)},t.render()):null}_renderExpression(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&t.viewModel.contentElement?W("div",{class:_.contentElement,key:this._buildKey("expression-element",e)},t.render()):null}_renderCustom(e,t){const{creator:i}=e,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:_.contentElement,key:this._buildKey("custom-element",t)},s.render()):null}_renderFields(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("fields-element",e)},t.render())}_renderMedia(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("media-element",e)},t.render())}_renderLastEditInfo(){const{visibleElements:e,messages:t}=this,{lastEditInfo:s}=this.viewModel;if(!s||!e.lastEditedInfo)return null;const{date:n,user:r}=s,o="edit"===s.type?r?t.lastEditedByUser:t.lastEdited:r?t.lastCreatedByUser:t.lastCreated,l=i(o,{date:n,user:r});return W("div",{class:this.classes(_.lastEditedInfo,_.contentElement),key:"edit-info-element"},l)}_renderText(e,t){const i=e.text,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:this.classes(_.contentElement,_.text),key:this._buildKey("text-element",t)},s.render()):null}_buildKey(e,...t){return`${e}__${this.viewModel?.graphic?.uid||"0"}-${t.join("-")}`}_destroyContentWidget(e){e&&(e.viewModel=null,!e.destroyed&&e.destroy())}_destroyContentWidgets(){this._contentWidgets.forEach(e=>this._destroyContentWidget(e)),this._contentWidgets=[]}_setupContentWidgets(){this._destroyContentWidgets();const{headingLevel:e,visibleElements:t,flowItems:i,viewModel:s}=this,n=s?.content,{contentViewModels:r}=s;if(Array.isArray(n))n.forEach((n,o)=>{if("attachments"===n.type&&(this._contentWidgets[o]=new u({displayType:n.displayType,headingLevel:t.title&&e<6?e+1:e,viewModel:r[o]})),"fields"===n.type&&(this._contentWidgets[o]=new y({viewModel:r[o]})),"media"===n.type&&(this._contentWidgets[o]=new v({viewModel:r[o]})),"text"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"custom"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"expression"===n.type&&(this._contentWidgets[o]=new h({viewModel:r[o]})),"relationship"===n.type){const e=new g({flowItems:i,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=e}if("utility-network-associations"===n.type){const e=async e=>{const{viewModel:n,listType:r,title:o}=e;if(!i)return;n.activeAssociationType=r;const{default:l}=await import("./Feature/FeatureUtilityNetworkAssociationList.js"),d=new l({viewModel:n,parentFeatureViewModel:s,listType:r,title:o,featureVisibleElements:t,description:s.title,flowItems:i});i.push(d)},n=new w({flowItems:i,onSelectAssociationType:e,parentFeatureViewModel:s,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=n}},this);else{const e=r[0];e&&!e.destroyed&&(this._contentWidgets[0]=new m({viewModel:e}))}this.scheduleRender()}};e([l()],k.prototype,"flowType",void 0),e([l({type:t})],k.prototype,"graphic",null),e([l()],k.prototype,"defaultPopupTemplateEnabled",null),e([l()],k.prototype,"flowItems",void 0),e([l()],k.prototype,"headingLevel",void 0),e([l({readOnly:!0})],k.prototype,"isTable",null),e([l()],k.prototype,"icon",null),e([l()],k.prototype,"label",null),e([l({type:c})],k.prototype,"location",null),e([l(),C("esri/widgets/Feature/t9n/Feature")],k.prototype,"messages",void 0),e([l(),C("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([l()],k.prototype,"spatialReference",null),e([l()],k.prototype,"timeZone",null),e([l({readOnly:!0})],k.prototype,"title",null),e([l()],k.prototype,"visibleElements",void 0),e([d("visibleElements")],k.prototype,"castVisibleElements",null),e([l()],k.prototype,"map",null),e([l()],k.prototype,"view",null),e([l({type:f})],k.prototype,"viewModel",void 0),k=e([a("esri.widgets.Feature")],k);export{k as default};
2
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import{substitute as i}from"../intl.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{watch as r,initial as o}from"../core/reactiveUtils.js";import{property as l,cast as d,subclass as a}from"../core/accessorSupport/decorators.js";import c from"../geometry/Point.js";import p from"./Widget.js";import u from"./Feature/FeatureAttachments.js";import m from"./Feature/FeatureContent.js";import h from"./Feature/FeatureExpression.js";import y from"./Feature/FeatureFields.js";import v from"./Feature/FeatureMedia.js";import g from"./Feature/FeatureRelationship.js";import w from"./Feature/FeatureUtilityNetworkAssociations.js";import f from"./Feature/FeatureViewModel.js";import{css as _}from"./Feature/resources.js";import{FeatureContentMixin as M}from"./Feature/support/FeatureContentMixin.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as F}from"./support/Heading.js";import{tsx as W,messageBundle as C}from"./support/widget.js";const j={title:!0,content:!0,lastEditedInfo:!0};let k=class extends(M(p)){constructor(e,t){super(e,t),this._contentWidgets=[],this.flowType="feature",this.flowItems=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.visibleElements={...j},this.viewModel=new f,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{s(n.getLogger(this),"Feature","arcgis-feature",{version:"4.34"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles(r(()=>this.viewModel?.contentViewModels,()=>this._setupContentWidgets(),o))}loadDependencies(){return E({notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyContentWidgets()}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get isTable(){return this.viewModel.isFeatureFromTable}get icon(){return"polygon"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get title(){return this.viewModel.title}castVisibleElements(e){return{...j,...e}}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}setActiveMedia(e,t){return this.viewModel.setActiveMedia(e,t)}nextMedia(e){return this.viewModel.nextMedia(e)}previousMedia(e){return this.viewModel.previousMedia(e)}render(){const{state:e}=this.viewModel,t=W("div",{class:_.container,key:"container"},this._renderTitle(),"error"===e?this._renderError():"loading"===e?this._renderLoading():this._renderContentContainer());return W("div",{class:this.classes(_.base,b.widget)},t)}_renderError(){const{messagesCommon:e,messages:t,visibleElements:i}=this;return W("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0,scale:"s"},i.title?W("div",{key:"error-title",slot:"title"},e.errorMessage):null,W("div",{key:"error-message",slot:"message"},t.loadingError))}_renderLoading(){return W("div",{class:_.loadingSpinnerContainer,key:"loading-container"},W("calcite-loader",{inline:!0,label:""}))}_renderContentContainer(){const{visibleElements:e}=this;return e.content?W("div",{class:_.main},[this._renderContent(),this._renderLastEditInfo()]):null}_renderTitle(){const{visibleElements:e,title:t}=this;return e.title?W(F,{class:_.title,innerHTML:t,level:this.headingLevel}):null}_renderContent(){const e=this.viewModel.content,t="content";if(!e)return null;if(Array.isArray(e))return e.length?W("div",{class:_.contentNode,key:`${t}-content-elements`},e.map(this._renderContentElement,this)):null;if("string"==typeof e){const e=this._contentWidgets[0];return!e||e.destroyed?null:W("div",{class:this.classes(_.contentNode,_.contentNodeText),key:`${t}-content`},e.render())}return this.renderNodeContent(e)}_renderContentElement(e,t){const{visibleElements:i}=this;if("boolean"!=typeof i.content&&!i.content?.[e.type])return null;switch(e.type){case"attachments":return this._renderAttachments(t);case"custom":return this._renderCustom(e,t);case"fields":return this._renderFields(t);case"media":return this._renderMedia(t);case"text":return this._renderText(e,t);case"expression":return this._renderExpression(t);case"relationship":return this._renderRelationship(t);case"utility-network-associations":return this._renderAssociation(t);default:return null}}_renderAttachments(e){const t=this._contentWidgets[e];if(!t||t.destroyed)return null;const{state:i,attachmentInfos:s}=t.viewModel;return"loading"===i||s.length>0?W("div",{class:this.classes(_.contentElement),key:this._buildKey("attachments-element",e)},t.render()):null}_renderRelationship(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("relationship-element",e)},t.render()):null}_renderAssociation(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("utility-network-association-element",e)},t.render()):null}_renderExpression(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&t.viewModel.contentElement?W("div",{class:_.contentElement,key:this._buildKey("expression-element",e)},t.render()):null}_renderCustom(e,t){const{creator:i}=e,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:_.contentElement,key:this._buildKey("custom-element",t)},s.render()):null}_renderFields(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("fields-element",e)},t.render())}_renderMedia(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("media-element",e)},t.render())}_renderLastEditInfo(){const{visibleElements:e,messages:t}=this,{lastEditInfo:s}=this.viewModel;if(!s||!e.lastEditedInfo)return null;const{date:n,user:r}=s,o="edit"===s.type?r?t.lastEditedByUser:t.lastEdited:r?t.lastCreatedByUser:t.lastCreated,l=i(o,{date:n,user:r});return W("div",{class:this.classes(_.lastEditedInfo,_.contentElement),key:"edit-info-element"},l)}_renderText(e,t){const i=e.text,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:this.classes(_.contentElement,_.text),key:this._buildKey("text-element",t)},s.render()):null}_buildKey(e,...t){return`${e}__${this.viewModel?.graphic?.uid||"0"}-${t.join("-")}`}_destroyContentWidget(e){e&&(e.viewModel=null,!e.destroyed&&e.destroy())}_destroyContentWidgets(){this._contentWidgets.forEach(e=>this._destroyContentWidget(e)),this._contentWidgets=[]}_setupContentWidgets(){this._destroyContentWidgets();const{headingLevel:e,visibleElements:t,flowItems:i,viewModel:s}=this,n=s?.content,{contentViewModels:r}=s;if(Array.isArray(n))n.forEach((n,o)=>{if("attachments"===n.type&&(this._contentWidgets[o]=new u({displayType:n.displayType,headingLevel:t.title&&e<6?e+1:e,viewModel:r[o]})),"fields"===n.type&&(this._contentWidgets[o]=new y({viewModel:r[o]})),"media"===n.type&&(this._contentWidgets[o]=new v({viewModel:r[o]})),"text"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"custom"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"expression"===n.type&&(this._contentWidgets[o]=new h({viewModel:r[o]})),"relationship"===n.type){const e=new g({flowItems:i,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=e}if("utility-network-associations"===n.type){const e=async e=>{const{viewModel:n,listType:r,title:o}=e;if(!i)return;n.activeAssociationType=r;const{default:l}=await import("./Feature/FeatureUtilityNetworkAssociationList.js"),d=new l({viewModel:n,parentFeatureViewModel:s,listType:r,title:o,featureVisibleElements:t,description:s.title,flowItems:i});i.push(d)},n=new w({flowItems:i,onSelectAssociationType:e,parentFeatureViewModel:s,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=n}},this);else{const e=r[0];e&&!e.destroyed&&(this._contentWidgets[0]=new m({viewModel:e}))}this.scheduleRender()}};e([l()],k.prototype,"flowType",void 0),e([l({type:t})],k.prototype,"graphic",null),e([l()],k.prototype,"defaultPopupTemplateEnabled",null),e([l()],k.prototype,"flowItems",void 0),e([l()],k.prototype,"headingLevel",void 0),e([l({readOnly:!0})],k.prototype,"isTable",null),e([l()],k.prototype,"icon",null),e([l()],k.prototype,"label",null),e([l({type:c})],k.prototype,"location",null),e([l(),C("esri/widgets/Feature/t9n/Feature")],k.prototype,"messages",void 0),e([l(),C("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([l()],k.prototype,"spatialReference",null),e([l()],k.prototype,"timeZone",null),e([l({readOnly:!0})],k.prototype,"title",null),e([l()],k.prototype,"visibleElements",void 0),e([d("visibleElements")],k.prototype,"castVisibleElements",null),e([l()],k.prototype,"map",null),e([l()],k.prototype,"view",null),e([l({type:f})],k.prototype,"viewModel",void 0),k=e([a("esri.widgets.Feature")],k);export{k as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import{deprecatedModule as s}from"../../core/deprecate.js";import r from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import a from"../../core/Logger.js";import{debounce as n,isAbortError as l}from"../../core/promiseUtils.js";import u from"../../core/ReactiveSet.js";import{watch as c,when as h,sync as p}from"../../core/reactiveUtils.js";import{property as d,subclass as g}from"../../core/accessorSupport/decorators.js";import f from"../../geometry/Point.js";import{initializeProjection as m,project as y}from"../../geometry/projectionUtils.js";import w from"../../geometry/SpatialReference.js";import{geographicToWebMercator as F}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as _}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as C}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as P}from"../../views/support/layerViewUtils.js";import L from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToFeature as A,zoomToClusteredFeatures as E,browseClusteredFeatures as V}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as I,getSelectedTarget as x,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as O,browseAggregateFeatures as T}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as U}from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[A.clone()],G=()=>[E.clone(),V.clone()];let z=null;function D(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let Z=class extends(S(U(o))){constructor(e){super(e),this._pendingPromises=new u,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=n(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})}),e?.suppressDeprecationWarning||s(a.getLogger(this),"esri.widgets.Features.FeaturesViewModel",{version:"5.1",replacement:"Use the Features component or the @arcgis/core/popup/Features module instead.",warnOnce:!0})}normalizeCtorArgs(e){const{suppressDeprecationWarning:t,...i}=e??{};return i}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),c(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),c(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),c(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),c(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>j({event:e,viewModel:this,view:this.view}).catch(()=>{})),h(()=>!this.waitingForResult,()=>this._waitingForResultChange(),p),c(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),c(()=>this.view?.scale,()=>this._viewScaleChange()),h(()=>!this.visible,()=>this.browseClusterEnabled=!1),c(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(I(this.selectedFeature)?G():H()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=F(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=x(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:s}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:s}}).catch(e=>{l(e)||a.getLogger(this).error(e)}):Promise.reject(new r("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new r("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location).catch(()=>{});const s=["actionsMenuOpen","collapsed","shouldFocus"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?I(t)?(await O(this),await T(this)):a.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):a.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(A.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(I(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),I(e))return;return e.symbol=await C(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await C(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(I(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let c=null;if(l.some((e,i)=>(e&&e.graphic===t&&(c=e,l.splice(i,1)),!!c)),c)u[i]=c;else{const l=new L({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a,suppressDeprecationWarning:!0});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await m(r,i,null,t),s.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).finally(()=>{this._fetchFeaturesController===s&&(this._fetchFeaturesController=null)}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(B),this.addHandles([c(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{l(e)||a.getLogger(this).error(e)})),h(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}async _locationUpdate(e,t){const{spatialReference:i}=this,s=this.selectedFeature?.geometry?.type,r=this.location??e;if(s&&"mesh"!==s&&i&&r&&this.selectedFeature){if("point"===s){const e=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let s=e.geometry;const o=this._getHighlightLayer(e),a=e.getObjectId();if(!o||!this.view)return;if(a){const e=this.view?.allLayerViews.find(e=>e.layer.uid===o.uid);if(!e||!("queryFeatures"in e))return;const r=e.createQuery();r.outSpatialReference=i,r.objectIds=[a],r.returnGeometry=!0;const{features:n}=await e.queryFeatures(r,t);s=n[0]?.geometry}if(!s||"mesh"===s.type)return;s=y(s,i),z||(z=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=z;if(!n.execute(s,r)){const t=l.getNearestCoordinate(s,r).coordinate??r;this.selectedFeature===e&&(this.location=t)}}catch(o){l(o)||a.getLogger(this).error(o)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(D(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||_:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&P(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],Z.prototype,"_fetchFeaturesController",void 0),e([d({type:M})],Z.prototype,"actions",void 0),e([d({readOnly:!0})],Z.prototype,"active",null),e([d()],Z.prototype,"activeFeature",void 0),e([d({readOnly:!0})],Z.prototype,"allActions",null),e([d()],Z.prototype,"autoCloseEnabled",void 0),e([d()],Z.prototype,"browseClusterEnabled",void 0),e([d()],Z.prototype,"content",void 0),e([d({type:M,readOnly:!0})],Z.prototype,"defaultActions",null),e([d({type:Boolean})],Z.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],Z.prototype,"featureCount",null),e([d()],Z.prototype,"featurePage",void 0),e([d({value:[]})],Z.prototype,"features",null),e([d()],Z.prototype,"featuresPerPage",void 0),e([d()],Z.prototype,"featureMenuOpen",void 0),e([d()],Z.prototype,"featureMenuTitle",void 0),e([d()],Z.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],Z.prototype,"featureViewModels",void 0),e([d()],Z.prototype,"highlightEnabled",void 0),e([d()],Z.prototype,"includeDefaultActions",void 0),e([d()],Z.prototype,"initialDisplayMode",void 0),e([d({type:f})],Z.prototype,"location",null),e([d()],Z.prototype,"map",null),e([d({readOnly:!0})],Z.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],Z.prototype,"promiseCount",null),e([d()],Z.prototype,"promises",null),e([d({readOnly:!0})],Z.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],Z.prototype,"selectedFeature",null),e([d({value:-1})],Z.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],Z.prototype,"selectedFeatureViewModel",null),e([d({type:w})],Z.prototype,"spatialReference",null),e([d({readOnly:!0})],Z.prototype,"state",null),e([d()],Z.prototype,"timeZone",null),e([d()],Z.prototype,"title",void 0),e([d()],Z.prototype,"updateLocationEnabled",void 0),e([d()],Z.prototype,"view",void 0),e([d()],Z.prototype,"visible",void 0),e([d({readOnly:!0})],Z.prototype,"waitingForContents",null),e([d({readOnly:!0})],Z.prototype,"waitingForResult",null),e([d()],Z.prototype,"zoomFactor",void 0),e([d()],Z.prototype,"zoomToLocation",void 0),e([d()],Z.prototype,"centerAtLocation",null),Z=e([g("esri.widgets.Features.FeaturesViewModel")],Z);export{Z as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as a,isAbortError as n}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as h,sync as c}from"../../core/reactiveUtils.js";import{property as d,subclass as p}from"../../core/accessorSupport/decorators.js";import g from"../../geometry/Point.js";import{initializeProjection as f,project as m}from"../../geometry/projectionUtils.js";import y from"../../geometry/SpatialReference.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import _ from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as v}from"../../symbols/support/symbolUtils.js";import{system as C}from"../../time/constants.js";import{highlightsSupported as b}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as L,zoomToFeature as M,zoomToClusteredFeatures as A,browseClusteredFeatures as E}from"../Popup/actions.js";import{triggerAction as V,isClusterFeature as j,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as x,displayClusterExtent as R,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as T}from"../support/AnchorElementViewModel.js";import{GoTo as U}from"../support/GoTo.js";const S="location-scale-handle",B=()=>[M.clone()],H=()=>[A.clone(),E.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(U(T(r))){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new L,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new _({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=a(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>V({event:e,viewModel:this,view:this.view}).catch(()=>{})),h(()=>!this.waitingForResult,()=>this._waitingForResultChange(),c),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),h(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new L;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new L;return e.removeAll(),e.addMany(j(this.selectedFeature)?H():B()),e}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._get("promises")!==e&&(this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get screenLocation(){return super.screenLocation}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??C}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:r}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{n(e)||o.getLogger(this).error(e)}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location).catch(()=>{});const s=["actionsMenuOpen","collapsed","shouldFocus"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){x(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?j(t)?(await R(this),await O(this)):o.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):o.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(M.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(j(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),j(e))return;return e.symbol=await v(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await v(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(j(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).finally(()=>{this._fetchFeaturesController===s&&(this._fetchFeaturesController=null)}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;this.removeHandles(S),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{n(e)||o.getLogger(this).error(e)})),h(()=>!this.visible,()=>{this.removeHandles(S)},{once:!0})],S);const{pendingFeatures:s}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});return{location:t??void 0,promises:s}}async _locationUpdate(e,t){const{spatialReference:i}=this,s=this.selectedFeature?.geometry?.type,r=this.location??e;if(s&&"mesh"!==s&&i&&r&&this.selectedFeature){if("point"===s){const e=await import("../../geometry/operators/labelPointOperator.js");return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let s=e.geometry;const o=this._getHighlightLayer(e),a=e.getObjectId();if(!o||!this.view)return;if(a){const e=this.view?.allLayerViews.find(e=>e.layer.uid===o.uid);if(!e||!("queryFeatures"in e))return;const r=e.createQuery();r.outSpatialReference=i,r.objectIds=[a],r.returnGeometry=!0;const{features:n}=await e.queryFeatures(r,t);s=n[0]?.geometry}if(!s||"mesh"===s.type)return;s=m(s,i),G||(G=await Promise.all([import("../../geometry/operators/intersectsOperator.js"),import("../../geometry/operators/proximityOperator.js")]));const[n,l]=G;if(!n.execute(s,r)){const t=l.getNearestCoordinate(s,r).coordinate??r;this.selectedFeature===e&&(this.location=t)}}catch(a){n(a)||o.getLogger(this).error(a)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&b(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([d()],z.prototype,"_fetchFeaturesController",void 0),e([d({type:L})],z.prototype,"actions",void 0),e([d({readOnly:!0})],z.prototype,"active",null),e([d()],z.prototype,"activeFeature",void 0),e([d({readOnly:!0})],z.prototype,"allActions",null),e([d()],z.prototype,"autoCloseEnabled",void 0),e([d()],z.prototype,"browseClusterEnabled",void 0),e([d()],z.prototype,"content",void 0),e([d({type:L,readOnly:!0})],z.prototype,"defaultActions",null),e([d({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([d({readOnly:!0})],z.prototype,"featureCount",null),e([d()],z.prototype,"featurePage",void 0),e([d({value:[]})],z.prototype,"features",null),e([d()],z.prototype,"featuresPerPage",void 0),e([d()],z.prototype,"featureMenuOpen",void 0),e([d()],z.prototype,"featureMenuTitle",void 0),e([d()],z.prototype,"featureViewModelAbilities",void 0),e([d({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([d()],z.prototype,"highlightEnabled",void 0),e([d()],z.prototype,"includeDefaultActions",void 0),e([d()],z.prototype,"initialDisplayMode",void 0),e([d({type:g})],z.prototype,"location",null),e([d()],z.prototype,"map",null),e([d({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([d({readOnly:!0})],z.prototype,"promiseCount",null),e([d()],z.prototype,"promises",null),e([d({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([d({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([d({value:-1})],z.prototype,"selectedFeatureIndex",null),e([d({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([d({type:y})],z.prototype,"spatialReference",null),e([d({readOnly:!0})],z.prototype,"state",null),e([d()],z.prototype,"timeZone",null),e([d()],z.prototype,"title",void 0),e([d()],z.prototype,"updateLocationEnabled",void 0),e([d()],z.prototype,"view",void 0),e([d()],z.prototype,"visible",void 0),e([d({readOnly:!0})],z.prototype,"waitingForContents",null),e([d({readOnly:!0})],z.prototype,"waitingForResult",null),e([d()],z.prototype,"zoomFactor",void 0),e([d()],z.prototype,"zoomToLocation",void 0),e([d()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};