@arcgis/core 5.1.0-next.113 → 5.1.0-next.114

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 (204) hide show
  1. package/Graphic.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{31a8bc25aa1441c70caa.js → 009250a7bded12099dd1.js} +1 -1
  4. package/assets/esri/core/workers/chunks/019a4fe7e085b2fc6ae9.js +1 -0
  5. package/assets/esri/core/workers/chunks/023837e5d9d2b6af66d8.js +1 -0
  6. package/assets/esri/core/workers/chunks/{a001e7e8a39f27284d87.js → 03c46880b69ce75a010f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0a530fbbb4486c670ea2.js +1 -0
  8. package/assets/esri/core/workers/chunks/{14b7b55c42af65ffa024.js → 0bd2b035c6ee89c725f9.js} +1 -1
  9. package/assets/esri/core/workers/chunks/0ded5c114cbb7574f2f4.js +1 -0
  10. package/assets/esri/core/workers/chunks/{b432a5a829e309837db6.js → 0e549d942d6cba1608cf.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{7dafe608c224b9d48ffa.js → 115664cb7d7b22a315bb.js} +1 -1
  12. package/assets/esri/core/workers/chunks/123a67e84ed68b96ac59.js +1 -0
  13. package/assets/esri/core/workers/chunks/14a241b07baa67743248.js +1 -0
  14. package/assets/esri/core/workers/chunks/{054ae729e7cefa2c7778.js → 170f8dc97614e9609443.js} +1 -1
  15. package/assets/esri/core/workers/chunks/179ffa2168c42615ccf2.js +1 -0
  16. package/assets/esri/core/workers/chunks/{4a65bc9091d7ea7e80df.js → 19f07c8d0f32ec889861.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{ca92176d5348e2c533d7.js → 224a9f39876aa426a9bc.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{0550dc63b6b1274242b8.js → 27d7c701306efeea6b82.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{8aac1155b8ac071cd2ad.js → 2855357a2c1f2ab03fb7.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{33329f5d88e60b4ec568.js → 2a8f198f6c272f92bad5.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{cb3004998eff7c60930e.js → 2b2a09ce14d00b4b1187.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{5d60253ea3d247cdb3d1.js → 2bdfae998371e3aa9f2d.js} +1 -1
  23. package/assets/esri/core/workers/chunks/2f99a95facddc44319a9.js +1 -0
  24. package/assets/esri/core/workers/chunks/{bd17ac2e6f1eb8cf7abf.js → 2fa080539d039c92ce08.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{ee635172be7fdea69367.js → 3109b05fe4fc40d4f25b.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{92db9a6d273ae2862883.js → 315bf08dff4757ffbed3.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{593772bd8b19ac664b29.js → 35527a01d61cabbfd33e.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{52a91c314afec70199bc.js → 39987c06636e757d1f00.js} +1 -1
  29. package/assets/esri/core/workers/chunks/41074d383af3662673ca.js +1 -0
  30. package/assets/esri/core/workers/chunks/49675e77a351abda2728.js +1 -0
  31. package/assets/esri/core/workers/chunks/4bfeac7338df9e0b7ce1.js +1 -0
  32. package/assets/esri/core/workers/chunks/4ffcca40e7aa24c8cc35.js +1 -0
  33. package/assets/esri/core/workers/chunks/534dd93c72ea448ee908.js +1 -0
  34. package/assets/esri/core/workers/chunks/{2dc2487d05381de07e3f.js → 548c34ea88f113d03c93.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{77ac243d4dcd901c2eec.js → 621d71d26bd20e296138.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{7e203e947846d40f897e.js → 67dffb896b6ef4b2038b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/6920e7f700a9ba280dba.js +1 -0
  38. package/assets/esri/core/workers/chunks/696967c8c6f53b94f851.js +1 -0
  39. package/assets/esri/core/workers/chunks/6b1f2b36bdc6b2ff2ea5.js +1 -0
  40. package/assets/esri/core/workers/chunks/7014e73dfd3c8baa704c.js +1 -0
  41. package/assets/esri/core/workers/chunks/75dfdd85abbac26ac899.js +1 -0
  42. package/assets/esri/core/workers/chunks/76a9b64fd573775bf6cd.js +1 -0
  43. package/assets/esri/core/workers/chunks/798c4d3201fcc9f2a42b.js +1 -0
  44. package/assets/esri/core/workers/chunks/{6c79e8e840c1d027fbb2.js → 7e0daf0864005cdd63c5.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{c0c693c2e0043ecba4a5.js → 817fd88fe9a48caf69fb.js} +1 -1
  46. package/assets/esri/core/workers/chunks/82f7d83a2073d1b0111c.js +1 -0
  47. package/assets/esri/core/workers/chunks/8795c4895df229cb471c.js +1 -0
  48. package/assets/esri/core/workers/chunks/{7bc746ea17f4e336e0b0.js → 8b5ee6be52e892fbd325.js} +1 -1
  49. package/assets/esri/core/workers/chunks/927c8ca7fd385b28a1b7.js +640 -0
  50. package/assets/esri/core/workers/chunks/942e527b9b92999886c7.js +1 -0
  51. package/assets/esri/core/workers/chunks/961995d8da45a9203255.js +1 -0
  52. package/assets/esri/core/workers/chunks/{eb1d6614eeac6d26bb9c.js → 9a3344f1dd22c425b8cc.js} +1 -1
  53. package/assets/esri/core/workers/chunks/9a6e62ef984e9c5babc4.js +1 -0
  54. package/assets/esri/core/workers/chunks/a0b6eef4890cc61609dc.js +1 -0
  55. package/assets/esri/core/workers/chunks/{f37be7e517f0892014e3.js → a320c69bc7528ff0d0cf.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{660713adb5a845dfa2ef.js → a40003dfe3c081d1a1d2.js} +1 -1
  57. package/assets/esri/core/workers/chunks/b5937ce657c1fff3864f.js +1 -0
  58. package/assets/esri/core/workers/chunks/{63ea9035dcf9ce45560c.js → b684ff4bc93bd60d6a19.js} +1 -1
  59. package/assets/esri/core/workers/chunks/b7a0a5b895ddd2d3d038.js +1 -0
  60. package/assets/esri/core/workers/chunks/{f3161c47a572194f6017.js → c06ae3a6ecc4a4fc67b2.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{970e91de5dfbbc247afb.js → c5b7ff8650235c464dbf.js} +1 -1
  62. package/assets/esri/core/workers/chunks/c8dedc010fcc2382af24.js +1 -0
  63. package/assets/esri/core/workers/chunks/cd2b2babcdc130b4c368.js +1 -0
  64. package/assets/esri/core/workers/chunks/{5a6523c903b11dea77d4.js → cdef9c3f80588ae45a04.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{e973cab79ec2541cb81b.js → d19600336cb6023d3e34.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{34c11e7c8762fe0c19fb.js → d39f5590022d910ee951.js} +1 -1
  67. package/assets/esri/core/workers/chunks/d412a43060441d347fb4.js +1 -0
  68. package/assets/esri/core/workers/chunks/{01c70c27aa3a955e2928.js → d41b847d08c42e5329d6.js} +2 -2
  69. package/assets/esri/core/workers/chunks/{10491b5b106bc5ad0b2b.js → d66f68a811c90739951a.js} +1 -1
  70. package/assets/esri/core/workers/chunks/d8c2bed12f937228c763.js +1 -0
  71. package/assets/esri/core/workers/chunks/de916dd0c11aefb6832e.js +1 -0
  72. package/assets/esri/core/workers/chunks/{63513e706fe55a1def15.js → e227ae2c1a63e30e62d9.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{e4c350dc65aae121171d.js → e29d182460564c2a52ad.js} +1 -1
  74. package/assets/esri/core/workers/chunks/e87d02af6d6b05e19d93.js +1 -0
  75. package/assets/esri/core/workers/chunks/f0b5c140a5ba174572b6.js +1 -0
  76. package/assets/esri/core/workers/chunks/{ce3b5b83237cf37ff523.js → f286680e363eefdf27df.js} +1 -1
  77. package/assets/esri/core/workers/chunks/f7698c855800e0af3038.js +1 -0
  78. package/assets/esri/core/workers/chunks/f931d560f3f14598f454.js +1 -0
  79. package/assets/esri/core/workers/chunks/{9890c85a238879490926.js → f9f331c76c96743d8522.js} +1 -1
  80. package/assets/esri/core/workers/chunks/fcbacca99c5a3ee5b69a.js +1 -0
  81. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  82. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  83. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery.json +1 -1
  84. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_en.json +1 -1
  85. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm.json +1 -1
  86. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_en.json +1 -1
  87. package/chunks/Path.glsl.js +22 -17
  88. package/config.js +1 -1
  89. package/geometry/support/DoubleArray.js +1 -1
  90. package/geometry/support/Indices.js +1 -1
  91. package/kernel.js +1 -1
  92. package/layers/DimensionLayer.d.ts +22 -0
  93. package/layers/FeatureLayer.d.ts +15 -12
  94. package/layers/FeatureLayer.js +1 -1
  95. package/layers/GaussianSplatLayer.d.ts +22 -0
  96. package/layers/LineOfSightLayer.d.ts +22 -0
  97. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  98. package/layers/PointCloudLayer.d.ts +22 -0
  99. package/layers/ViewshedLayer.d.ts +22 -0
  100. package/layers/support/Field.d.ts +1 -0
  101. package/layers/support/Field.js +1 -1
  102. package/layers/support/SceneModification.js +1 -1
  103. package/layers/support/types.d.ts +1 -1
  104. package/layers/types.d.ts +1 -0
  105. package/package.json +1 -1
  106. package/rest/support/Query.d.ts +1 -0
  107. package/support/revision.js +1 -1
  108. package/symbols/cim/animationUtils.js +1 -1
  109. package/symbols/cim/defaultCIMValues.js +1 -1
  110. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  111. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  112. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  113. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  114. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  115. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  116. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  117. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  118. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  119. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  120. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  121. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  122. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  123. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  124. package/views/2d/support/clippingUtils.js +1 -1
  125. package/views/2d/support/hitTestUtils.js +1 -1
  126. package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
  127. package/views/3d/input/SceneInputManager.js +1 -1
  128. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  129. package/views/3d/layers/IntegratedMesh3DTilesLayerWorkerHandle.js +1 -1
  130. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  131. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  132. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  133. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  134. package/views/3d/layers/graphics/extrudeUtils.js +1 -1
  135. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  136. package/views/3d/support/engineContent/line.js +1 -1
  137. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  138. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +3 -3
  139. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathEvaluate.glsl.js +233 -0
  140. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexInfo.glsl.js +19 -0
  141. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +64 -40
  142. package/views/3d/webgl-engine/core/shaderModules/Float2sPassUniform.js +2 -0
  143. package/views/3d/webgl-engine/core/shaderModules/IntegersPassUniform.js +2 -0
  144. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  145. package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
  146. package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
  147. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  148. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  149. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +1 -1
  150. package/views/3d/webgl-engine/materials/PathLayouts.js +1 -1
  151. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
  153. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  154. package/views/View2D.d.ts +1 -1
  155. package/views/draw/DrawTool.d.ts +34 -1
  156. package/views/input/EventMatch.js +1 -1
  157. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  158. package/widgets/BatchAttributeForm.js +1 -1
  159. package/widgets/Directions/DirectionsViewModel.js +1 -1
  160. package/widgets/Directions.js +1 -1
  161. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +7 -1
  162. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  163. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  164. package/widgets/FeatureTable/support/types.d.ts +11 -1
  165. package/widgets/FeatureTable.d.ts +7 -1
  166. package/widgets/FeatureTable.js +1 -1
  167. package/assets/esri/core/workers/chunks/02c0640005b09007bb70.js +0 -1
  168. package/assets/esri/core/workers/chunks/0c8e6ccb5a8174718d62.js +0 -640
  169. package/assets/esri/core/workers/chunks/13f0e08de2dfab07d212.js +0 -1
  170. package/assets/esri/core/workers/chunks/1c0e8808d14d8e6dde2c.js +0 -1
  171. package/assets/esri/core/workers/chunks/1c8c8050d60205cf2156.js +0 -1
  172. package/assets/esri/core/workers/chunks/23119a1b1310b7dab2aa.js +0 -1
  173. package/assets/esri/core/workers/chunks/282f3d364411efac7b80.js +0 -1
  174. package/assets/esri/core/workers/chunks/2ffffc1931b2e27c6617.js +0 -1
  175. package/assets/esri/core/workers/chunks/313a89b334e3518d30a4.js +0 -1
  176. package/assets/esri/core/workers/chunks/389e57aab12d52d72695.js +0 -1
  177. package/assets/esri/core/workers/chunks/3fed503185ea1913fb84.js +0 -1
  178. package/assets/esri/core/workers/chunks/4020f95d8131493f799e.js +0 -1
  179. package/assets/esri/core/workers/chunks/4255ad7601c7a7621b71.js +0 -1
  180. package/assets/esri/core/workers/chunks/453c3b265481c80fc625.js +0 -1
  181. package/assets/esri/core/workers/chunks/4a41f98210f1da3b5041.js +0 -1
  182. package/assets/esri/core/workers/chunks/4afe76de6e82e86fe697.js +0 -1
  183. package/assets/esri/core/workers/chunks/5a85cbc04c64091d7f46.js +0 -1
  184. package/assets/esri/core/workers/chunks/5e5c7cc74ff1c9603aff.js +0 -1
  185. package/assets/esri/core/workers/chunks/601edefd8da4eb2eda28.js +0 -1
  186. package/assets/esri/core/workers/chunks/6f02681bcaa9bef501fc.js +0 -1
  187. package/assets/esri/core/workers/chunks/7b66691d133dabd87ce6.js +0 -1
  188. package/assets/esri/core/workers/chunks/7c077e1a63ab97bf3e87.js +0 -1
  189. package/assets/esri/core/workers/chunks/7dc9ff66e1eceadbae24.js +0 -1
  190. package/assets/esri/core/workers/chunks/85a200aecc7a844c9566.js +0 -1
  191. package/assets/esri/core/workers/chunks/958617c3a9854ea04e06.js +0 -1
  192. package/assets/esri/core/workers/chunks/a5b9ae4c93f9af7589f2.js +0 -1
  193. package/assets/esri/core/workers/chunks/a93a058678c8c8996d54.js +0 -1
  194. package/assets/esri/core/workers/chunks/acb8cff06142f828fb78.js +0 -1
  195. package/assets/esri/core/workers/chunks/b4badbcf1bdb7823d825.js +0 -1
  196. package/assets/esri/core/workers/chunks/b891d95b7858665cd6c1.js +0 -1
  197. package/assets/esri/core/workers/chunks/c91d4f1b42cfe474df52.js +0 -1
  198. package/assets/esri/core/workers/chunks/d33a08e5f589355c57a3.js +0 -1
  199. package/assets/esri/core/workers/chunks/dd29fd1b3da90d3ca6b1.js +0 -1
  200. package/assets/esri/core/workers/chunks/e393fd61deb2e7f22ee6.js +0 -1
  201. package/assets/esri/core/workers/chunks/e8518bd3596543b387f8.js +0 -1
  202. package/assets/esri/core/workers/chunks/ee56290e600cbeb25a00.js +0 -1
  203. package/assets/esri/core/workers/chunks/f91a2c69a93295cf4de6.js +0 -1
  204. package/assets/esri/core/workers/chunks/fec3fffcf854a6226df4.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import{addEventListener as o}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{debounce as l,isAbortError as c}from"../core/promiseUtils.js";import{watch as d,initial as h,on as p}from"../core/reactiveUtils.js";import{escapeRegExpString as m}from"../core/string.js";import{property as u,subclass as v}from"../core/accessorSupport/decorators.js";import{onLocaleChange as g,getLocaleLanguage as _}from"../intl/locale.js";import w from"../portal/Portal.js";import{defaultUnitPropertyMetadata as y}from"../properties/defaultUnit.js";import b from"../rest/support/Stop.js";import S from"../symbols/SimpleMarkerSymbol.js";import f from"./Search.js";import k from"./Widget.js";import{css as C}from"./Directions/css.js";import{DirectionsSearchTool as D}from"./Directions/DirectionsSearchTool.js";import M from"./Directions/DirectionsViewModel.js";import I from"./Directions/DirectionsVisibleElements.js";import{formatDistance as P,formatDuration as T,DepartureTimeOption as F,getIconName as x}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as L,meteredArcGISLocatorUrl as E}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as A}from"./support/globalCss.js";import{messageBundle as N,tsx as O}from"./support/widget.js";function B(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,towardName:n}=e;if(null==s)return null;const l=[i,o,r,a,n].filter(t).sort((e,t)=>t.length-e.length).map(e=>m(e));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let h=0;const p=[];for(const{0:t,index:m}of d)p.push(s.slice(h,m),O("span",{class:C.labelEmphasize,key:`maneuver-${m}`},t)),h=m+t.length;return p.push(s.slice(h)),O("span",null,p)}const j="print-preview-closed";let $=class extends k{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new b,new b]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printPreviewDialog=null,this._sections=null,this._stopsToSearches=new Map,this._editNoticeClosed=!1,this._printPreviewDialogOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new M,this.visibleElements=new I,this._solveRouteDebounced=l(()=>this._solveRoute()),this.announceDeprecation=()=>{s(a.getLogger(this),"Directions","arcgis-directions",{version:"5.0"})}}initialize(){this.addHandles([d(()=>this.viewModel.layer,()=>{try{this.viewModel.load()}catch{}},h),d(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},h),d(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})])}loadDependencies(){return R({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(n)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get displayedStops(){return this.effectiveStops.toArray().filter(({locationType:e})=>"waypoint"!==e)}get effectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new f({icon:"",popupEnabled:!1,resultGraphicEnabled:!1,view:t,suppressDeprecationWarning:!0,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([p(()=>i.allSources,"change",()=>this._normalizeSearchSources(i)),i.on("search-clear",()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),i.on("select-result",()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),d(()=>i.searchTerm,t=>{e.name=t}),g(()=>this._normalizeSearchSources(i))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return O("div",{class:this.classes(C.base,A.widget,A.panel)},O("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=_(),t.locationType??="street",L(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=E))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:P(s,t,o),duration:T(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=P(s,t,o);return`${T(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find(({objectId:e})=>e===a);o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.toArray().filter(({directionPointId:t})=>t===e);0!==n.length&&o.directions.push({directionPoint:r,lines:n})}return s}_handleAddStopClick(){const e=new S;this.viewModel.layer?.stops.add(new b({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this.effectiveStops.remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditNoticeClose(){this._editNoticeClosed=!0}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new D({stop:e,view:t}),this.addHandles([this._searchTool.on("click",async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)}),r(()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)})],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,e&&this._removeWaypoints(),this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintPreviewDialogAfterCreate(e){document.body.appendChild(e),e.showModal(),this._printPreviewDialog=e,this.removeHandles(j),this.addHandles([o(e,"close",this._handlePrintPreviewDialogClosed.bind(this)),r(()=>{this._printPreviewDialog&&(document.body.removeChild(this._printPreviewDialog),this._printPreviewDialog=null,this._printPreviewDialogOpen=!1)})],j)}_handlePrintPreviewDialogClick(){this._printPreviewDialogOpen=!0}_handlePrintPreviewDialogCloseClick(){this._printPreviewDialog?.close()}_handlePrintPreviewDialogClosed(){this.removeHandles(j)}_handlePrintPreviewDialogPrintClick(){document.body.classList.add(C.printPreviewMedia),window.print(),document.body.classList.remove(C.printPreviewMedia),this._printPreviewDialog?.close()}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._removeWaypoints(),this.effectiveStops.reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=w.getDefault();try{await e.signIn()}catch(t){if(c(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find(({id:e})=>e===i);e.saveAs({title:t},{folder:s}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState="saving-error"})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._removeWaypoints(),this.effectiveStops.reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_removeWaypoints(){const e=this.viewModel.layer?.stops;if(e){const t=e.filter(({locationType:e})=>"waypoint"===e);e.removeMany(t)}}_renderClearRouteAction(e){return O("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return O("calcite-action",{icon:"trash",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop,onclick:this._handleDeleteStopClick.bind(this,e)})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=F;return O("calcite-label",{class:C.departureTime,key:"departure-time"},this.messages.departureTime,O("calcite-combobox",{bind:this,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleDepartureTimeOptionChange},O("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),O("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),O("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==F.DEPART_AT?null:O("div",{class:C.departureTimeOptions},O("calcite-input-date-picker",{bind:this,scale:"s",topLayerDisabled:this.topLayerDisabled,value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),O("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return O("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},O("div",{class:C.directionsHeader,slot:"header-content"},O("div",{class:C.headerStops},O("span",null,this.messages.from)," ",O("span",{class:C.directionsHeaderStopName},o),O("span",null,this.messages.to)," ",O("span",{class:C.directionsHeaderStopName},r)),O("div",{class:C.flexColumn},O("span",null,`${i} (${t})`),s?O("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),O("calcite-accordion",{class:C.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,a=this._getStopCostDescription(e);return O("calcite-accordion-item",{description:a,expanded:r,heading:o??"",key:`stop-${t}`},O("calcite-action",{icon:"zoom-to-object",slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop,onclick:this._handlePanToStopClick.bind(this,i)}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return O("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:a}=o,n=P(this.messagesUnits,r??0,this.unit),l=T(a??0),c=n&&l?`${n} | ${l}`:`${n||l}`,d=B(i),h=x(i.directionPointType);return O("calcite-list-item",{class:C.labelNoBottomMargin,key:`driving-direction-${t}`,onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o),onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this)},O("calcite-icon",{icon:h,slot:"content-start"}),O("div",{slot:"content"},O("calcite-label",{layout:"inline",scale:"s"},d),O("calcite-label",{layout:"inline",scale:"s"},c)))}))}_renderEditNotice(){return this._editNoticeClosed?null:O("div",{class:C.editInformationContainer},O("calcite-notice",{bind:this,closable:!0,kind:"info",open:!0,onCalciteNoticeClose:this._handleEditNoticeClose},O("calcite-label",{scale:"s",slot:"message"},this.messages.editInstructions)))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:O("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},O("div",{class:C.flexColumn,key:"edit-container"},this._renderEditNotice(),O("div",{class:C.editToolbarContainer},O("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,O("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),O("div",{class:C.editToolbar},O("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0,onclick:this._handleCreateStopClick}),O("calcite-action",{bind:this,icon:"line",scale:"s",text:this.messages.barrier,textEnabled:!0,onclick:this._handleCreatePolylineBarrierClick}),O("calcite-action",{bind:this,class:C.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",scale:"s",text:this.messages.solve,textEnabled:!0,onclick:this._handleResolveRouteClick}))),O("div",{class:C.selectedFeatureContainer},O("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>O("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},O("calcite-action",{icon:"trash",slot:"actions-end",text:this.messages.common.delete,onclick:this._handleDeleteNetworkFeatureClick.bind(this,e)}))))),O("div",{class:C.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():O("calcite-button",{appearance:"outline-fill",bind:this,width:"full",onclick:this._handleEditingDoneClick},this.messages.common.done)}_renderErrorNotice(){return O("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return O("div",{class:C.primaryFooter,key:"footer-missing-layer"},O("calcite-notice",{icon:"information",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return O("div",{class:C.primaryFooterCentered,key:"footer-sign-in"},O("calcite-label",null,this.messages.signInRequired),O("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return O("div",{class:this.classes(C.primaryFooter,C.primaryFooterLoader),key:"footer-routing"},O("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return O("div",{class:C.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return O("div",{class:C.primaryFooter,key:"footer-unsolved-route"},O("calcite-notice",{icon:"information",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return O("div",{class:C.primaryFooter,key:"footer-invalid-route"},O("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return O("div",{class:C.routeItem,key:"footer-directions-summary"},O("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:C.routeItemButton,title:this.messages.viewDrivingDirections,type:"button",onclick:this._handleViewDrivingDirectionsClick},O("div",{class:C.routeItemButtonContent},O("span",{class:C.routeItemLabel},`${i} (${t})`),O("span",{class:C.routeItemDescription},s)),O("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),O("calcite-action-menu",{label:"test"},O("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return O("div",{class:C.actionContainer,key:C.actionContainer},O("calcite-button",{appearance:"outline",bind:this,class:C.addStopButton,disabled:this.effectiveStops.length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,title:this.messages.addStop,width:"half",onclick:this._handleAddStopClick},this.messages.addStop),this.visibleElements.editRouteButton?O("calcite-button",{appearance:"outline",bind:this,class:C.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,title:this.messages.editRoute,width:"half",onclick:this._handleEditRouteClick},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.effectiveStops.indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return O("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap,onclick:this._handleLocateStopClick.bind(this,e)})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return O("calcite-block-section",{bind:this,class:C.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[O("calcite-label",{class:C.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,O("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),O("calcite-label",{class:C.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,O("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return O("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},O("calcite-panel",{class:C.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printPreviewDialogOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return O("dialog",{afterCreate:this._handlePrintPreviewDialogAfterCreate,bind:this,class:C.printPreviewDialog},O("div",{class:C.printPreviewContent},O("div",{class:C.printPreviewHeader},O("div",{class:C.printPreviewHeaderLabel},O("div",{class:C.headerStops},O("span",null,this.messages.from)," ",O("span",{class:C.directionsHeaderStopName},o),O("span",null,this.messages.to)," ",O("span",{class:C.directionsHeaderStopName},r))),O("div",{class:this.classes(C.printPreviewHeaderButtons,C.printPreviewHideOnPrint)},O("calcite-button",{autofocus:!0,bind:this,class:C.printPreviewDialogPrint,iconStart:"print",onclick:this._handlePrintPreviewDialogPrintClick},this.messages.common.print),O("calcite-button",{appearance:"outline",bind:this,class:C.printPreviewDialogClose,iconStart:"x-circle",onclick:this._handlePrintPreviewDialogCloseClick},this.messages.common.close))),O("div",{class:C.directionsHeader},O("span",null,`${i} (${t})`),s?O("span",null,s):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManeuver(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},a=P(this.messagesUnits,o??0,this.unit),n=T(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=B(i),d=x(i.directionPointType);return O("div",{class:this.classes(C.flexRow,C.printPreviewAvoidPageBreak),key:`direction-${t}`},O("calcite-icon",{icon:d,preload:!0}),O("div",{class:C.flexColumn},O("span",null,c),O("span",null,l)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;const t=!this.viewModel.layer?.routeInfo;return O("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintPreviewDialogClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return O("div",{class:C.printPreviewSection,key:`section-${i}`},O("span",{class:C.directionsHeaderStopName},e.name??""),t.map((e,t)=>this._renderPrintManeuver(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return O("div",{class:C.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return O("calcite-panel",{class:C.paddingMedium,key:"save-layer-error"},O("div",{class:C.saveError},O("calcite-icon",{class:C.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),O("calcite-label",{class:C.saveErrorLabel},e)),O("calcite-button",{appearance:"outline",bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveErrorCloseClick},this.messages.common.close))}_renderSaveInitialized(){return O("calcite-panel",{class:C.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:O("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return O("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return O("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[O("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:C.folderHome,selected:!0,value:C.folderHome}),...this._portalFolders.map(e=>O("calcite-combobox-item",{heading:e.title??"",key:`${C.folder}-${e.id}`,value:e.id}))];return O("calcite-panel",{key:"save-layer-panel"},O("div",{class:C.paddingMedium},O("calcite-label",null,this.messages.layerName,O("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),O("calcite-label",null,this.messages.saveInFolder,O("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled},i))),O("calcite-button",{bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveLayerButtonClick},this.messages.common.save),O("calcite-button",{appearance:"outline",bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveLayerCancelClick},this.messages.common.cancel))}_renderSaveProcessing(e){return O("calcite-panel",{class:C.marginInlineMedium,key:"save-layer-processing"},O("calcite-loader",{class:C.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return O("div",{class:C.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this.effectiveStops.length>2&&this._renderDeleteStopAction(e);return O("calcite-list-item",{key:e,value:e},i,s,O("div",{class:C.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.displayedStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return O("div",{class:C.stopContainer,key:C.stopContainer},O("calcite-list",{bind:this,class:C.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.map(e=>this._renderStop(e))),2===e.length&&O("calcite-action",{bind:this,icon:"arrow-up-down",text:this.messages.reverseStops,title:this.messages.reverseStops,onclick:this._handleReverseStopOrderClick}))}_renderTravelMode(e){const{id:t,name:i}=e;return O("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?O("calcite-label",{key:"travel-modes"},this.messages.mode,O("calcite-combobox",{bind:this,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?O("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if((this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2)this.viewModel.clearResults();else try{await this.viewModel.getDirections()}catch{}}};e([u()],$.prototype,"_editNoticeClosed",void 0),e([u()],$.prototype,"_printPreviewDialogOpen",void 0),e([u()],$.prototype,"_currentFlowItem",void 0),e([u()],$.prototype,"_saveState",void 0),e([u()],$.prototype,"_searchTool",void 0),e([u()],$.prototype,"apiKey",null),e([u(y)],$.prototype,"defaultUnit",void 0),e([u()],$.prototype,"goToOverride",null),e([u()],$.prototype,"headingLevel",void 0),e([u()],$.prototype,"displayedStops",null),e([u()],$.prototype,"effectiveStops",null),e([u()],$.prototype,"icon",null),e([u()],$.prototype,"label",null),e([u({readOnly:!0})],$.prototype,"lastRoute",null),e([u()],$.prototype,"layer",null),e([u()],$.prototype,"maxStops",null),e([u(),N("esri/widgets/Directions/t9n/Directions")],$.prototype,"messages",void 0),e([u(),N("esri/core/t9n/Units")],$.prototype,"messagesUnits",void 0),e([u()],$.prototype,"searchProperties",void 0),e([u()],$.prototype,"unit",null),e([u()],$.prototype,"view",null),e([u({type:M})],$.prototype,"viewModel",void 0),e([u({type:I,nonNullable:!0})],$.prototype,"visibleElements",void 0),$=e([v("esri.widgets.Directions")],$);const z=$;export{z as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{deprecateWidget as s}from"../core/deprecate.js";import{addEventListener as o}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{debounce as l,isAbortError as c}from"../core/promiseUtils.js";import{watch as d,initial as h,on as p}from"../core/reactiveUtils.js";import{escapeRegExpString as m}from"../core/string.js";import{property as u,subclass as v}from"../core/accessorSupport/decorators.js";import{onLocaleChange as g,getLocaleLanguage as _}from"../intl/locale.js";import w from"../portal/Portal.js";import{defaultUnitPropertyMetadata as y}from"../properties/defaultUnit.js";import b from"../rest/support/Stop.js";import S from"../symbols/SimpleMarkerSymbol.js";import f from"./Search.js";import k from"./Widget.js";import{css as C}from"./Directions/css.js";import{DirectionsSearchTool as D}from"./Directions/DirectionsSearchTool.js";import M from"./Directions/DirectionsViewModel.js";import I from"./Directions/DirectionsVisibleElements.js";import{formatDistance as P,formatDuration as T,DepartureTimeOption as F,getIconName as x}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as L,meteredArcGISLocatorUrl as E}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as A}from"./support/globalCss.js";import{messageBundle as N,tsx as O}from"./support/widget.js";function B(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,towardName:n}=e;if(null==s)return null;const l=[i,o,r,a,n].filter(t).sort((e,t)=>t.length-e.length).map(e=>m(e));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let h=0;const p=[];for(const{0:t,index:m}of d)p.push(s.slice(h,m),O("span",{class:C.labelEmphasize,key:`maneuver-${m}`},t)),h=m+t.length;return p.push(s.slice(h)),O("span",null,p)}const j="print-preview-closed";let $=class extends k{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new b,new b]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printPreviewDialog=null,this._sections=null,this._stopsToSearches=new Map,this._editNoticeClosed=!1,this._printPreviewDialogOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new M,this.visibleElements=new I,this._solveRouteDebounced=l(()=>this._solveRoute()),this.announceDeprecation=()=>{s(a.getLogger(this),"Directions","arcgis-directions",{version:"5.0"})}}initialize(){this.addHandles([d(()=>this.viewModel.layer,()=>{try{this.viewModel.load()}catch{}},h),d(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},h),d(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})])}loadDependencies(){return R({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(n)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get displayedStops(){return this.effectiveStops.toArray().filter(({locationType:e})=>"waypoint"!==e)}get effectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new f({icon:"",popupEnabled:!1,resultGraphicEnabled:!1,view:t,suppressDeprecationWarning:!0,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([p(()=>i.allSources,"change",()=>this._normalizeSearchSources(i)),i.on("search-clear",()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),i.on("select-result",()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),d(()=>i.searchTerm,t=>{e.name=t}),g(()=>this._normalizeSearchSources(i))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return O("div",{class:this.classes(C.base,A.widget,A.panel)},O("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=_(),t.locationType??="street",L(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=E))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:P(s,t,o),duration:T(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=P(s,t,o);return`${T(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find(({objectId:e})=>e===a);o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.toArray().filter(({directionPointId:t})=>t===e);0!==n.length&&o.directions.push({directionPoint:r,lines:n})}return s}_handleAddStopClick(){const e=new S;this.viewModel.layer?.stops.add(new b({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this.effectiveStops.remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditNoticeClose(){this._editNoticeClosed=!0}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new D({stop:e,view:t}),this.addHandles([this._searchTool.on("click",async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)}),r(()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)})],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,e&&this._removeWaypoints(),this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintPreviewDialogAfterCreate(e){document.body.appendChild(e),e.showModal(),this._printPreviewDialog=e,this.removeHandles(j),this.addHandles([o(e,"close",this._handlePrintPreviewDialogClosed.bind(this)),r(()=>{this._printPreviewDialog&&(document.body.removeChild(this._printPreviewDialog),this._printPreviewDialog=null,this._printPreviewDialogOpen=!1)})],j)}_handlePrintPreviewDialogClick(){this._printPreviewDialogOpen=!0}_handlePrintPreviewDialogCloseClick(){this._printPreviewDialog?.close()}_handlePrintPreviewDialogClosed(){this.removeHandles(j)}_handlePrintPreviewDialogPrintClick(){document.body.classList.add(C.printPreviewMedia),window.print(),document.body.classList.remove(C.printPreviewMedia),this._printPreviewDialog?.close()}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._removeWaypoints(),this.effectiveStops.reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=w.getDefault();try{await e.signIn()}catch(t){if(c(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find(({id:e})=>e===i);e.saveAs({title:t},{folder:s}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState="saving-error"})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._removeWaypoints(),this.effectiveStops.reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_removeWaypoints(){const e=this.viewModel.layer?.stops;if(e){const t=e.filter(({locationType:e})=>"waypoint"===e);e.removeMany(t)}}_renderClearRouteAction(e){return O("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return O("calcite-action",{icon:"trash",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop,onclick:this._handleDeleteStopClick.bind(this,e)})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=F;return O("calcite-label",{class:C.departureTime,key:"departure-time"},this.messages.departureTime,O("calcite-combobox",{bind:this,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleDepartureTimeOptionChange},O("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),O("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),O("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==F.DEPART_AT?null:O("div",{class:C.departureTimeOptions},O("calcite-input-date-picker",{bind:this,scale:"s",topLayerDisabled:this.topLayerDisabled,value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),O("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return O("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},O("div",{class:C.directionsHeader,slot:"header-content"},O("div",{class:C.headerStops},O("span",null,this.messages.from)," ",O("span",{class:C.directionsHeaderStopName},o),O("span",null,this.messages.to)," ",O("span",{class:C.directionsHeaderStopName},r)),O("div",{class:C.flexColumn},O("span",null,`${i} (${t})`),s?O("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),O("calcite-accordion",{class:C.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,a=this._getStopCostDescription(e);return O("calcite-accordion-item",{description:a,expanded:r,heading:o??"",key:`stop-${t}`},O("calcite-action",{icon:"zoom-to-object",slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop,onclick:this._handlePanToStopClick.bind(this,i)}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return O("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:a}=o,n=P(this.messagesUnits,r??0,this.unit),l=T(a??0),c=n&&l?`${n} | ${l}`:`${n||l}`,d=B(i),h=x(i.directionPointType);return O("calcite-list-item",{class:C.labelNoBottomMargin,key:`driving-direction-${t}`,onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o),onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this)},O("calcite-icon",{icon:h,slot:"content-start"}),O("div",{slot:"content"},O("calcite-label",{layout:"inline",scale:"s"},d),O("calcite-label",{layout:"inline",scale:"s"},c)))}))}_renderEditNotice(){return this._editNoticeClosed?null:O("div",{class:C.editInformationContainer,key:C.editInformationContainer},O("calcite-notice",{bind:this,closable:!0,kind:"info",open:!0,onCalciteNoticeClose:this._handleEditNoticeClose},O("calcite-label",{scale:"s",slot:"message"},this.messages.editInstructions)))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:O("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},O("div",{class:C.flexColumn,key:"edit-container"},this._renderEditNotice(),O("div",{class:C.editToolbarContainer},O("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,O("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),O("div",{class:C.editToolbar},O("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0,onclick:this._handleCreateStopClick}),O("calcite-action",{bind:this,icon:"line",scale:"s",text:this.messages.barrier,textEnabled:!0,onclick:this._handleCreatePolylineBarrierClick}),O("calcite-action",{bind:this,class:C.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",scale:"s",text:this.messages.solve,textEnabled:!0,onclick:this._handleResolveRouteClick}))),O("div",{class:C.selectedFeatureContainer},O("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>O("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},O("calcite-action",{icon:"trash",slot:"actions-end",text:this.messages.common.delete,onclick:this._handleDeleteNetworkFeatureClick.bind(this,e)}))))),O("div",{class:C.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():O("calcite-button",{appearance:"outline-fill",bind:this,width:"full",onclick:this._handleEditingDoneClick},this.messages.common.done)}_renderErrorNotice(){return O("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return O("div",{class:C.primaryFooter,key:"footer-missing-layer"},O("calcite-notice",{icon:"information",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return O("div",{class:C.primaryFooterCentered,key:"footer-sign-in"},O("calcite-label",null,this.messages.signInRequired),O("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return O("div",{class:this.classes(C.primaryFooter,C.primaryFooterLoader),key:"footer-routing"},O("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return O("div",{class:C.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return O("div",{class:C.primaryFooter,key:"footer-unsolved-route"},O("calcite-notice",{icon:"information",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return O("div",{class:C.primaryFooter,key:"footer-invalid-route"},O("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},O("calcite-label",{class:C.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return O("div",{class:C.routeItem,key:"footer-directions-summary"},O("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:C.routeItemButton,title:this.messages.viewDrivingDirections,type:"button",onclick:this._handleViewDrivingDirectionsClick},O("div",{class:C.routeItemButtonContent},O("span",{class:C.routeItemLabel},`${i} (${t})`),O("span",{class:C.routeItemDescription},s)),O("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),O("calcite-action-menu",{label:"test"},O("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return O("div",{class:C.actionContainer,key:C.actionContainer},O("calcite-button",{appearance:"outline",bind:this,class:C.addStopButton,disabled:this.effectiveStops.length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,title:this.messages.addStop,width:"half",onclick:this._handleAddStopClick},this.messages.addStop),this.visibleElements.editRouteButton?O("calcite-button",{appearance:"outline",bind:this,class:C.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,title:this.messages.editRoute,width:"half",onclick:this._handleEditRouteClick},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.effectiveStops.indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return O("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap,onclick:this._handleLocateStopClick.bind(this,e)})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return O("calcite-block-section",{bind:this,class:C.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[O("calcite-label",{class:C.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,O("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),O("calcite-label",{class:C.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,O("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return O("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},O("calcite-panel",{class:C.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printPreviewDialogOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return O("dialog",{afterCreate:this._handlePrintPreviewDialogAfterCreate,bind:this,class:C.printPreviewDialog},O("div",{class:C.printPreviewContent},O("div",{class:C.printPreviewHeader},O("div",{class:C.printPreviewHeaderLabel},O("div",{class:C.headerStops},O("span",null,this.messages.from)," ",O("span",{class:C.directionsHeaderStopName},o),O("span",null,this.messages.to)," ",O("span",{class:C.directionsHeaderStopName},r))),O("div",{class:this.classes(C.printPreviewHeaderButtons,C.printPreviewHideOnPrint)},O("calcite-button",{autofocus:!0,bind:this,class:C.printPreviewDialogPrint,iconStart:"print",onclick:this._handlePrintPreviewDialogPrintClick},this.messages.common.print),O("calcite-button",{appearance:"outline",bind:this,class:C.printPreviewDialogClose,iconStart:"x-circle",onclick:this._handlePrintPreviewDialogCloseClick},this.messages.common.close))),O("div",{class:C.directionsHeader},O("span",null,`${i} (${t})`),s?O("span",null,s):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManeuver(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},a=P(this.messagesUnits,o??0,this.unit),n=T(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=B(i),d=x(i.directionPointType);return O("div",{class:this.classes(C.flexRow,C.printPreviewAvoidPageBreak),key:`direction-${t}`},O("calcite-icon",{icon:d,preload:!0}),O("div",{class:C.flexColumn},O("span",null,c),O("span",null,l)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;const t=!this.viewModel.layer?.routeInfo;return O("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintPreviewDialogClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return O("div",{class:C.printPreviewSection,key:`section-${i}`},O("span",{class:C.directionsHeaderStopName},e.name??""),t.map((e,t)=>this._renderPrintManeuver(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return O("div",{class:C.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return O("calcite-panel",{class:C.paddingMedium,key:"save-layer-error"},O("div",{class:C.saveError},O("calcite-icon",{class:C.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),O("calcite-label",{class:C.saveErrorLabel},e)),O("calcite-button",{appearance:"outline",bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveErrorCloseClick},this.messages.common.close))}_renderSaveInitialized(){return O("calcite-panel",{class:C.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:O("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return O("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return O("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[O("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:C.folderHome,selected:!0,value:C.folderHome}),...this._portalFolders.map(e=>O("calcite-combobox-item",{heading:e.title??"",key:`${C.folder}-${e.id}`,value:e.id}))];return O("calcite-panel",{key:"save-layer-panel"},O("div",{class:C.paddingMedium},O("calcite-label",null,this.messages.layerName,O("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),O("calcite-label",null,this.messages.saveInFolder,O("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled},i))),O("calcite-button",{bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveLayerButtonClick},this.messages.common.save),O("calcite-button",{appearance:"outline",bind:this,slot:"footer-start",width:"full",onclick:this._handleSaveLayerCancelClick},this.messages.common.cancel))}_renderSaveProcessing(e){return O("calcite-panel",{class:C.marginInlineMedium,key:"save-layer-processing"},O("calcite-loader",{class:C.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return O("div",{class:C.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this.effectiveStops.length>2&&this._renderDeleteStopAction(e);return O("calcite-list-item",{key:e,value:e},i,s,O("div",{class:C.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.displayedStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return O("div",{class:C.stopContainer,key:C.stopContainer},O("calcite-list",{bind:this,class:C.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.map(e=>this._renderStop(e))),2===e.length&&O("calcite-action",{bind:this,icon:"arrow-up-down",text:this.messages.reverseStops,title:this.messages.reverseStops,onclick:this._handleReverseStopOrderClick}))}_renderTravelMode(e){const{id:t,name:i}=e;return O("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?O("calcite-label",{key:"travel-modes"},this.messages.mode,O("calcite-combobox",{bind:this,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?O("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if((this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2)this.viewModel.clearResults();else try{await this.viewModel.getDirections()}catch{}}};e([u()],$.prototype,"_editNoticeClosed",void 0),e([u()],$.prototype,"_printPreviewDialogOpen",void 0),e([u()],$.prototype,"_currentFlowItem",void 0),e([u()],$.prototype,"_saveState",void 0),e([u()],$.prototype,"_searchTool",void 0),e([u()],$.prototype,"apiKey",null),e([u(y)],$.prototype,"defaultUnit",void 0),e([u()],$.prototype,"goToOverride",null),e([u()],$.prototype,"headingLevel",void 0),e([u()],$.prototype,"displayedStops",null),e([u()],$.prototype,"effectiveStops",null),e([u()],$.prototype,"icon",null),e([u()],$.prototype,"label",null),e([u({readOnly:!0})],$.prototype,"lastRoute",null),e([u()],$.prototype,"layer",null),e([u()],$.prototype,"maxStops",null),e([u(),N("esri/widgets/Directions/t9n/Directions")],$.prototype,"messages",void 0),e([u(),N("esri/core/t9n/Units")],$.prototype,"messagesUnits",void 0),e([u()],$.prototype,"searchProperties",void 0),e([u()],$.prototype,"unit",null),e([u()],$.prototype,"view",null),e([u({type:M})],$.prototype,"viewModel",void 0),e([u({type:I,nonNullable:!0})],$.prototype,"visibleElements",void 0),$=e([v("esri.widgets.Directions")],$);const z=$;export{z as default};
@@ -32,7 +32,7 @@ import type { ExtentProperties } from "../../geometry/Extent.js";
32
32
  import type { TableTemplateProperties } from "./support/TableTemplate.js";
33
33
  import type { TimeExtentProperties } from "../../time/TimeExtent.js";
34
34
 
35
- export interface FeatureTableViewModelProperties extends Partial<Pick<FeatureTableViewModel, "actionColumnConfig" | "attachmentsEnabled" | "autoRefreshEnabled" | "autoSaveEnabled" | "columnPerformanceModeEnabled" | "columnReorderingEnabled" | "definitionExpression" | "editingEnabled" | "filterBySelectionEnabled" | "filterByViewExtent" | "highlightEnabled" | "initialSize" | "layer" | "layers" | "maxSize" | "menuConfig" | "multipleSelectionEnabled" | "multipleSortPriority" | "multiSortEnabled" | "outFields" | "pageIndex" | "pageSize" | "paginationEnabled" | "relatedRecordsEnabled" | "returnGeometryEnabled" | "returnMEnabled" | "returnZEnabled" | "selectionManager" | "syncTemplateOnChangesEnabled" | "syncViewSelection" | "tableController" | "tableParent" | "timeZone" | "view">> {
35
+ export interface FeatureTableViewModelProperties extends Partial<Pick<FeatureTableViewModel, "actionColumnConfig" | "attachmentsEnabled" | "autoRefreshEnabled" | "autoSaveEnabled" | "columnPerformanceModeEnabled" | "columnReorderingEnabled" | "definitionExpression" | "editingEnabled" | "filterByLayerScaleRange" | "filterBySelectionEnabled" | "filterByViewExtent" | "highlightEnabled" | "initialSize" | "layer" | "layers" | "maxSize" | "menuConfig" | "multipleSelectionEnabled" | "multipleSortPriority" | "multiSortEnabled" | "outFields" | "pageIndex" | "pageSize" | "paginationEnabled" | "relatedRecordsEnabled" | "returnGeometryEnabled" | "returnMEnabled" | "returnZEnabled" | "selectionManager" | "syncTemplateOnChangesEnabled" | "syncViewSelection" | "tableController" | "tableParent" | "timeZone" | "view">> {
36
36
  /**
37
37
  * Use this property to configure how columns display within the table in regard to visibility, column order, and sorting.
38
38
  *
@@ -494,6 +494,12 @@ export default class FeatureTableViewModel extends GridViewModel {
494
494
  * @since 4.33
495
495
  */
496
496
  get fieldColumns(): FieldColumn[];
497
+ /**
498
+ * Indicates the table should honor layer view scale visibility. If the layerView is out of scale, the table will be empty.
499
+ *
500
+ * @since 5.1
501
+ */
502
+ accessor filterByLayerScaleRange: boolean;
497
503
  /**
498
504
  * Indicates whether the table only displays rows that are considered selected. Row selection can be modified by adding or removing associated object IDs from [FeatureTable.highlightIds](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/#highlightIds). This will cause the store to fetch fresh features to ensure the expected sort order is honored.
499
505
  *
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as n}from"../../core/arrayUtils.js";import l from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import r from"../../core/Error.js";import a from"../../core/Logger.js";import{debounce as d,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as p,syncAndInitial as u}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,subclass as f}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as y}from"../../editing/fieldUtils.js";import{geometryTypes as T}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as w}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as C,isSubtypeGroupLayer as I}from"../../layers/support/layerUtils.js";import{createFieldInfos as v}from"../../support/popupUtils.js";import _ from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as E}from"../../tables/support/templateUtils.js";import S from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as A}from"../../views/support/selectionUtils.js";import F from"./ActionColumn.js";import j from"./AttachmentsColumn.js";import x from"./FieldColumn.js";import R from"./RelationshipColumn.js";import O from"./Grid/Column.js";import U from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import V from"./Grid/GroupColumn.js";import z from"./support/AttachmentsColumnTemplate.js";import W from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as B,isFieldColumn as G,isRelationshipColumn as M}from"./support/columnUtils.js";import{downloadAttachmentInfo as L,exportToCSV as k}from"./support/exportUtils.js";import N from"./support/FeatureStore.js";import D from"./support/FieldColumnTemplate.js";import H from"./support/RelationshipColumnTemplate.js";import $ from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isIFeatureTableSupportedLayerWithRelationships as q,findRelatedLayerInSources as Q,findRelationship as K,uniqueColumnNames as J,hasColumnForField as X,findField as Y,isIFeatureTableSupportedLayerWithAttachments as ee,getRelationshipIdsToShow as te}from"./support/tableUtils.js";import{goTo as ie}from"../support/goToUtils.js";import{messageBundle as se}from"../support/widget.js";const ne="80px";let le=class extends P{constructor(e){super(e),this._refreshDebounced=d(()=>this._refresh()),this._syncTemplateThrottled=g(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new W,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new l,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:n}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===n.length&&-1===n.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const l=this.paginationEnabled?this.pageIndex:e.page,o=await s.fetchItems({...e,page:l});t&&t(o)},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new l,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new N),this._set("grid",new U({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),m(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},c),m(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),m(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),m(()=>this.layer?.loaded,e=>e&&this._onLayerLoad()),m(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),m(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),m(()=>this.editingEnabled,()=>this.refreshCellContent()),m(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),m(()=>this.store.effectiveWhere,()=>"loaded"===this.store.state&&this.reset()),m(()=>this.layer?.timeExtent,(e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset()),p(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),p(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:n})=>{const l=t?.feature,o=l?.getObjectId(),r="cell-keydown"===n&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(n,{feature:l,index:e,native:i,type:n,fieldName:s??void 0,objectId:o}),(r||"cell-click"===n)&&this._onCellInteraction(o)}),m(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),m(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),m(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),m(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),m(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),m(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),m(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:n}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:n}}),p(()=>this.tableParent,"cell-click",async e=>{const{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),m(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),m(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),m(()=>this.effectiveSelectionManager,()=>this._syncSelection(),u),p(()=>this.effectiveSelectionManager,"selection-change",()=>this._syncSelection(),u)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return w(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return C(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,n=new l;return e&&n.push({type:"geometry",geometry:e}),i?n.push({type:"selection",objectIds:s.toArray()}):t.length&&n.push({type:"objectId",objectIds:t.toArray()}),n}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>B(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get fieldColumns(){return this.allColumns.filter(e=>G(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get("hiddenFields")??new l}set hiddenFields(e){this._set("hiddenFields",o(e,this._get("hiddenFields"),l))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return Z(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>M(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,n=this.store.relationshipInfos;if(n.length||!q(e)||!i?.length)return n;const l=[],o=s?.layers||t||[];return i.forEach(t=>{const i=Q(e,o,t);i&&(i.load(),l.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),l}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return"table"}set selectionSource(e){this.syncViewSelection="view"===e,this._overrideIfSome("selectionSource",e)}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.addAttachment(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:n}=t,{objectIdField:o}=i,r=K(i,n),a=i.displayField||r?.keyField||o;e.set({highlightIds:new l([s]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,n)});const d=e.hiddenFields;d.includes(J.action)||d.add(J.action),d.includes(J.attachments)||d.add(J.attachments),e.scrollLeft()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter(e=>!e.error).map(e=>e.objectId);i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await L(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([J.action,J.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await k({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){const t=this.layer;if(!t)return`${e}`;const i=`${t.objectIdField}: ${e}`;return null==e?i:this.store.featureTitleMap.get(e)??i}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.getFeatureStoreItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(J.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),h(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}async savePendingEdits(){!this.relatedTableHasPendingEdits||this.relatedTableHasInvalidPendingEdits?this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh()):await(this.relatedTable?.savePendingEdits())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const n=this._getDefaultLayerDisplayField(s),o=await this.store.getAttachmentsByObjectId(e,!0),r=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?"list":"file",objectId:e}),this.set({highlightIds:new l([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),i.includes(J.action)||i.add(J.action),null!=r&&this.scrollToIndex(r)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:n}=this,l=s.objectId===e;await n.updateAttachment(e,t,i).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),l&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await n.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const n=await e.queryFeatures(s);try{await ie(t,n.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:n}=this;!i||!t||!n&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId||E(t,this.columns.toArray(),this.activeSortOrders)}async _refresh(){await super.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&I(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,n=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=n),this.grid?.set("pageSize",n),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:i}=this,s=e?.columnTemplates;if(!i)return;const n=this._generateColumnsFromColumnTemplates(i,s)??this._generateColumnsFromAttributeTableTemplate(i,t)??this._generateDefaultFieldColumns(i);n.length&&(this.attachmentsEnabled&&!n.some(e=>B(e))&&n.push(this._generateDefaultAttachmentsColumn(i)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!n.some(e=>M(e))&&n.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&n.push(this._generateActionColumn()),n.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(n))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;const{elements:i,orderByFields:s}=t,l=v(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,i,s));const r=l.map(t=>{if(!t.fieldName||X(t.fieldName,o))return null;const{fieldName:i}=t,n=Y(e,i);return n?this._generateDefaultFieldColumn(e,n,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(n);return o.push(...r),this.attachmentsEnabled&&ee(e)&&!o.some(e=>B(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&q(e)&&e.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!o.some(t=>M(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,i){return t?.map((t,s)=>{switch(t.type){case"field":return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:i});case"group":return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:i});case"attachment":return this._createAttachmentColumnFromElement({layer:e,element:t,index:s});case"relationship":return this._createRelationshipColumnFromElement({element:t,index:s})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{fieldName:n}=i;if(null==n)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const l=Y(t,n);if(!l)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:o,label:r}=i,a=s?.findIndex(({field:e})=>e&&e===n)??-1,d=a>-1?s?.at(a)?.order:void 0,h=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b}=this;return new x({description:o,direction:d,field:l,fieldName:n,grid:m,initialSortPriority:h,label:r,layer:t,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{description:n,label:l}=i;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!i.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:o,messages:r,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new V({columns:this._generateColumnsFromAttributeTableElements(t,i.elements,s),description:n,grid:o,label:l,messages:r,messagesCommon:a,messagesURIUtils:d,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{layer:t,element:i,index:s}=e,{description:n,label:l}=i,{grid:o,messages:r,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new j({description:n,fieldName:`${J.attachments}-${s}`,grid:o,label:l,layer:t,messages:r,messagesCommon:a,messagesURIUtils:d,store:h,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:n,relationshipId:l}=t,o=this.relationshipInfos.find(e=>e.relationshipId===l);if(!o)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:r,messages:a,messagesCommon:d,messagesURIUtils:h,store:m}=this;return new R({description:s,fieldName:`${J.relationship}-${l}-${i}`,grid:r,label:n,messages:a,messagesCommon:d,messagesURIUtils:h,relationshipId:l,store:m,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:o,view:r}=this;if(!t?.length)return null;const a=[];return t.forEach((t,d)=>{const{autoWidth:h,description:m,direction:c,flexGrow:p,fieldName:u,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,resizable:E,sortable:S,textAlign:A,textWrap:F,timeZone:j,type:R,width:U}=t;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===t.visible;if("group"===R){if(!t.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!t.label)return void this._logTemplateWarning("Group columns require a label.");const o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),r=P||this._isFieldHidden(t.label);a.push(new V({autoWidth:h,columns:o,description:m,flexGrow:p,frozen:b,frozenToEnd:f,grid:i,hidden:r,icon:y,iconText:T,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,textAlign:A,textWrap:F,timeZone:j,width:U}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,t,d))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:e}=t;if(null==e)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(t=>t.relationshipId===e);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,t,d))}else if(!u)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const z=P||this._isFieldHidden(u);if("column"===R)a.push(new O({autoWidth:h,description:m,direction:c,fieldName:u,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,sortable:S,store:o,textAlign:A,textWrap:F,timeZone:j,width:U}));else if("field"===R){const d=Y(e,t.fieldName);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:u,required:R}=t;a.push(new x({autoWidth:h,description:m,direction:c,editable:u,field:d,fieldName:d.name,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,menuConfig:_,required:R,resizable:E,sortable:S,store:o,template:t,textAlign:A,textWrap:F,timeZone:j,width:U,view:r,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(n)??[]}_generateDefaultFieldColumn(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r,view:a}=this;if(!t.visible||"geometry"===t.type)return null;const d=i?.orderByFields,h=t.name,m=d?.findIndex(({field:e})=>e&&e===h)??-1,c=m>-1?d?.at(m)?.order:void 0,p=m>-1?m:void 0;return new x({direction:c,field:t,fieldName:h,grid:s,hidden:i?.hidden||this._isFieldHidden(h),initialSortPriority:p,layer:e,messages:n,messagesCommon:l,messagesURIUtils:o,store:r,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r}=this,{attachmentsViewEnabled:a,autoWidth:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,resizable:I,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:x,width:R}=t;return new j({attachmentsViewEnabled:a,autoWidth:d,description:h,fieldName:`${J.attachments}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:e,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:o,resizable:I,store:r,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:x,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:o}=this,r=J.attachments;return new j({fieldName:r,grid:i,hidden:t?.hidden||this._isFieldHidden(r),layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r}=this,{autoWidth:a,collapsed:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,relationshipId:I,resizable:v,textAlign:_,textWrap:E,timeZone:S,width:A}=t;return new R({autoWidth:a,collapsed:d,description:h,fieldName:`${J.relationship}-${I}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:o,relationshipId:I,resizable:v,store:r,textAlign:_,textWrap:E,timeZone:S,width:A,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:n}=t,l=e.find(e=>e.relationshipId===n);l&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:l}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:n}=e,{grid:l,messages:o,messagesCommon:r,messagesURIUtils:a,store:d}=this,{relationshipId:h}=n;return new R({...t,fieldName:`${J.relationship}-${h}-${s}`,grid:l,hidden:i,messages:o,messagesCommon:r,messagesURIUtils:a,layer:n.relatedLayer,relatedLayer:n.layer,relationshipId:h,store:d,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){return new F({hidden:this._isFieldHidden(J.action),store:this.store,...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){const{layer:e}=this;A(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._removeFromSelection(i),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){const{tableParent:t}=this;t&&null!=e&&t.highlightIds.add(e)}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(J.action)||s.add(J.action),s.includes(J.attachments)||s.add(J.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:te(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([J.action,J.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new $({columnTemplates:[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,n])=>({selected:s===t,label:n||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new H({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ne})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})),new $({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:n}=e,{_subtypes:l,layer:o}=this;if(!o||!l.length)return void t.cancel();const r=l.find(e=>e.code===n);if(!r)return void t.cancel();const a=Promise.withResolvers(),d=this._createSubtypeEditPrompt(s,r,a),h=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(d);const e=await a.promise,s=[{fieldName:t.fieldName,value:n}];switch(e){case"update-fields":for(const[e,t]of Object.entries(r.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:n,messages:l,messagesCommon:o}=this,r=n.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const d=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:i(l.subtypes.changeWarning,{originalType:r,newType:t.name}),radios:d,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:o.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:o.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new $({columnTemplates:[new D({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&y(s,i)]}):i?.fields.map(e=>[e.name,y(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([b()],le.prototype,"_defaultHiddenFields",null),e([b()],le.prototype,"_effectiveTableTemplate",null),e([b()],le.prototype,"_effectiveAttributeTableTemplate",null),e([b()],le.prototype,"_subtypes",null),e([b()],le.prototype,"activeFilters",null),e([b({readOnly:!0})],le.prototype,"activeSortOrders",null),e([b()],le.prototype,"allRelatedTablesVisible",null),e([b()],le.prototype,"attachmentsColumns",null),e([b()],le.prototype,"attachmentsEnabled",null),e([b()],le.prototype,"attachmentsViewOptions",void 0),e([b({type:_})],le.prototype,"attributeTableTemplate",void 0),e([b()],le.prototype,"autoRefreshEnabled",void 0),e([b()],le.prototype,"autoSaveEnabled",null),e([b()],le.prototype,"canAddRelatedFeature",null),e([b()],le.prototype,"clearPrompt",null),e([b({readOnly:!0})],le.prototype,"columns",void 0),e([b()],le.prototype,"dataProvider",void 0),e([b()],le.prototype,"defaultSelectionManager",null),e([b()],le.prototype,"definitionExpression",null),e([b()],le.prototype,"effectiveSelectionManager",null),e([b()],le.prototype,"fieldColumns",null),e([b()],le.prototype,"filterByViewExtent",null),e([b({types:T})],le.prototype,"filterGeometry",null),e([b()],le.prototype,"filterBySelectionEnabled",null),e([b({readOnly:!0})],le.prototype,"grid",void 0),e([b()],le.prototype,"hasContingentValues",null),e([b()],le.prototype,"hasInvalidPendingEdits",null),e([b()],le.prototype,"hasPendingEdits",null),e([b()],le.prototype,"hiddenFields",null),e([b()],le.prototype,"highlightEnabled",null),e([b()],le.prototype,"initialSize",null),e([b()],le.prototype,"isQueryingOrSyncing",null),e([b()],le.prototype,"isSyncingAttachments",null),e([b()],le.prototype,"layer",null),e([b()],le.prototype,"layers",void 0),e([b()],le.prototype,"layerFieldConfigurations",null),e([b()],le.prototype,"layerView",null),e([b()],le.prototype,"menuConfig",void 0),e([b()],le.prototype,"messages",void 0),e([b(),se("esri/t9n/common")],le.prototype,"messagesCommon",void 0),e([b(),se("esri/core/t9n/Units")],le.prototype,"messagesUnits",void 0),e([b(),se("esri/widgets/support/t9n/uriUtils")],le.prototype,"messagesURIUtils",void 0),e([b()],le.prototype,"outFields",null),e([b()],le.prototype,"pendingEditsCount",null),e([b()],le.prototype,"prompt",void 0),e([b()],le.prototype,"relatedRecordsEnabled",null),e([b()],le.prototype,"relatedTable",null),e([b()],le.prototype,"relatedTableHasContingentValues",null),e([b()],le.prototype,"relatedTables",void 0),e([b()],le.prototype,"relationship",null),e([b()],le.prototype,"relationshipColumnConfigs",void 0),e([b()],le.prototype,"relationshipColumns",null),e([b()],le.prototype,"relationshipConfig",null),e([b()],le.prototype,"relationshipInfos",null),e([b()],le.prototype,"relationships",null),e([b()],le.prototype,"returnGeometryEnabled",null),e([b()],le.prototype,"returnMEnabled",null),e([b()],le.prototype,"returnZEnabled",null),e([b()],le.prototype,"selectionManager",null),e([b()],le.prototype,"selectionSource",null),e([b()],le.prototype,"showAllRelatedTables",null),e([b()],le.prototype,"showPrompt",null),e([b()],le.prototype,"showRelatedTableCallback",void 0),e([b({readOnly:!0,type:N})],le.prototype,"store",void 0),e([b()],le.prototype,"supportsAttachments",null),e([b()],le.prototype,"supportsAddAttachments",null),e([b()],le.prototype,"supportsDeleteAttachments",null),e([b()],le.prototype,"supportsResizeAttachments",null),e([b()],le.prototype,"supportsUpdateAttachments",null),e([b()],le.prototype,"syncTemplateOnChangesEnabled",void 0),e([b()],le.prototype,"syncViewSelection",null),e([b()],le.prototype,"tableController",void 0),e([b()],le.prototype,"tableParent",void 0),e([b({type:$})],le.prototype,"tableTemplate",void 0),e([b()],le.prototype,"tableTemplateOverride",void 0),e([b({type:S})],le.prototype,"timeExtent",null),e([b()],le.prototype,"timeZone",null),e([b()],le.prototype,"view",null),le=e([f("esri.widgets.FeatureTable.FeatureTableViewModel")],le);const oe=le;export{oe as default};
2
+ import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../intl.js";import{isSome as n}from"../../core/arrayUtils.js";import l from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import r from"../../core/Error.js";import a from"../../core/Logger.js";import{debounce as d,ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as p,syncAndInitial as u}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,subclass as f}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as y}from"../../editing/fieldUtils.js";import{geometryTypes as T}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as w}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as C,isSubtypeGroupLayer as I}from"../../layers/support/layerUtils.js";import{createFieldInfos as v}from"../../support/popupUtils.js";import _ from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as E}from"../../tables/support/templateUtils.js";import S from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as A}from"../../views/support/selectionUtils.js";import F from"./ActionColumn.js";import j from"./AttachmentsColumn.js";import x from"./FieldColumn.js";import R from"./RelationshipColumn.js";import O from"./Grid/Column.js";import U from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import V from"./Grid/GroupColumn.js";import z from"./support/AttachmentsColumnTemplate.js";import W from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as B,isFieldColumn as L,isRelationshipColumn as G}from"./support/columnUtils.js";import{downloadAttachmentInfo as M,exportToCSV as k}from"./support/exportUtils.js";import N from"./support/FeatureStore.js";import D from"./support/FieldColumnTemplate.js";import H from"./support/RelationshipColumnTemplate.js";import $ from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as Z,isIFeatureTableSupportedLayerWithRelationships as q,findRelatedLayerInSources as Q,findRelationship as K,uniqueColumnNames as J,hasColumnForField as X,findField as Y,isIFeatureTableSupportedLayerWithAttachments as ee,getRelationshipIdsToShow as te}from"./support/tableUtils.js";import{goTo as ie}from"../support/goToUtils.js";import{messageBundle as se}from"../support/widget.js";const ne="80px";let le=class extends P{constructor(e){super(e),this._refreshDebounced=d(()=>this._refresh()),this._syncTemplateThrottled=g(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new W,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new l,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:n}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===n.length&&-1===n.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const l=this.paginationEnabled?this.pageIndex:e.page,o=await s.fetchItems({...e,page:l});t&&t(o)},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new l,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new N),this._set("grid",new U({viewModel:this}))}initialize(){const e=async()=>{this.messages=await s("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await s("esri/t9n/common"),this.messagesUnits=await s("esri/core/t9n/Units"),this.messagesURIUtils=await s("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),m(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},c),m(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),m(()=>this.layer,async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&null!=this.attachmentsViewOptions.objectId&&(this.attachmentsViewOptions.objectId=null)}),m(()=>this.layer?.loaded,e=>e&&this._onLayerLoad()),m(()=>this.store.state,e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())}),m(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),m(()=>this.editingEnabled,()=>this.refreshCellContent()),m(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),m(()=>this.store.effectiveWhere,()=>"loaded"===this.store.state&&this.reset()),m(()=>this.layer?.timeExtent,(e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset()),p(()=>this.layer,"refresh",e=>this._onLayerRefresh(e)),p(()=>this.grid,["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],({index:e,item:t,native:i,path:s,type:n})=>{const l=t?.feature,o=l?.getObjectId(),r="cell-keydown"===n&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(n,{feature:l,index:e,native:i,type:n,fieldName:s??void 0,objectId:o}),(r||"cell-click"===n)&&this._onCellInteraction(o)}),m(()=>this.actionColumnConfig,e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())}),m(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,"change",()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),m(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),m(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),m(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),m(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),m(()=>this.state,e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,"change",({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:n}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:n}}),p(()=>this.tableParent,"cell-click",async e=>{const{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),m(()=>this.attachmentsViewOptions.objectId,(e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}),m(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,"change",e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),m(()=>this.effectiveSelectionManager,()=>this._syncSelection(),u),p(()=>this.effectiveSelectionManager,"selection-change",()=>this._syncSelection(),u)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return w(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return C(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:i,highlightIds:s}=this,n=new l;return e&&n.push({type:"geometry",geometry:e}),i?n.push({type:"selection",objectIds:s.toArray()}):t.length&&n.push({type:"objectId",objectIds:t.toArray()}),n}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>B(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get fieldColumns(){return this.allColumns.filter(e=>L(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get("hiddenFields")??new l}set hiddenFields(e){this._set("hiddenFields",o(e,this._get("hiddenFields"),l))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerFieldConfigurations(){const e=this.layer;return Z(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>G(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){const{layer:e,layers:t,relationships:i,tableController:s}=this,n=this.store.relationshipInfos;if(n.length||!q(e)||!i?.length)return n;const l=[],o=s?.layers||t||[];return i.forEach(t=>{const i=Q(e,o,t);i&&(i.load(),l.push({layer:e,relatedLayer:i,relationshipId:t.id}))}),l}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return"table"}set selectionSource(e){this.syncViewSelection="view"===e,this._overrideIfSome("selectionSource",e)}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.addAttachment(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){const{relatedLayer:i,objectId:s,relationshipId:n}=t,{objectIdField:o}=i,r=K(i,n),a=i.displayField||r?.keyField||o;e.set({highlightIds:new l([s]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,a,n)});const d=e.hiddenFields;d.includes(J.action)||d.add(J.action),d.includes(J.attachments)||d.add(J.attachments),e.scrollLeft()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,n=i.objectId===e;await s.deleteAttachments(e,t).catch(e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)}),n&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter(e=>!e.error).map(e=>e.objectId);i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await M(i)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([J.action,J.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach(e=>e.destroy());const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await k({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){const t=this.layer;if(!t)return`${e}`;const i=`${t.objectIdField}: ${e}`;return null==e?i:this.store.featureTitleMap.get(e)??i}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.getFeatureStoreItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(J.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),h(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}async savePendingEdits(){!this.relatedTableHasPendingEdits||this.relatedTableHasInvalidPendingEdits?this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh()):await(this.relatedTable?.savePendingEdits())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:i,layer:s}=this;if(!this.attachmentsEnabled||!s)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await s.load();const n=this._getDefaultLayerDisplayField(s),o=await this.store.getAttachmentsByObjectId(e,!0),r=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?"list":"file",objectId:e}),this.set({highlightIds:new l([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)}),i.includes(J.action)||i.add(J.action),null!=r&&this.scrollToIndex(r)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:n}=this,l=s.objectId===e;await n.updateAttachment(e,t,i).catch(e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof r&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)}),l&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await n.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const n=await e.queryFeatures(s);try{await ie(t,n.features)}catch(l){"AbortError"!==l.name&&console.error(l)}}_syncAttributeTableTemplate(e=!1){const{_effectiveAttributeTableTemplate:t,layer:i,tableTemplateOverride:s,syncTemplateOnChangesEnabled:n}=this;!i||!t||!n&&!e||s||this.tableParent||this.relatedTable||null!==this.attachmentsViewOptions.objectId||E(t,this.columns.toArray(),this.activeSortOrders)}async _refresh(){await super.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach((t,i)=>{t||this.highlightIds.remove(e[i])})}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&I(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,n=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=n),this.grid?.set("pageSize",n),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:i}=this,s=e?.columnTemplates;if(!i)return;const n=this._generateColumnsFromColumnTemplates(i,s)??this._generateColumnsFromAttributeTableTemplate(i,t)??this._generateDefaultFieldColumns(i);n.length&&(this.attachmentsEnabled&&!n.some(e=>B(e))&&n.push(this._generateDefaultAttachmentsColumn(i)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!n.some(e=>G(e))&&n.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&n.push(this._generateActionColumn()),n.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(n))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;const{elements:i,orderByFields:s}=t,l=v(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,i,s));const r=l.map(t=>{if(!t.fieldName||X(t.fieldName,o))return null;const{fieldName:i}=t,n=Y(e,i);return n?this._generateDefaultFieldColumn(e,n,{hidden:!0,orderByFields:s}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)}).filter(n);return o.push(...r),this.attachmentsEnabled&&ee(e)&&!o.some(e=>B(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&q(e)&&e.relationships?.forEach(({id:e},t)=>{const i=this.relationshipInfos.find(t=>t.relationshipId===e);i&&!o.some(t=>G(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,i){return t?.map((t,s)=>{switch(t.type){case"field":return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:i});case"group":return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:i});case"attachment":return this._createAttachmentColumnFromElement({layer:e,element:t,index:s});case"relationship":return this._createRelationshipColumnFromElement({element:t,index:s})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{fieldName:n}=i;if(null==n)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const l=Y(t,n);if(!l)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:o,label:r}=i,a=s?.findIndex(({field:e})=>e&&e===n)??-1,d=a>-1?s?.at(a)?.order:void 0,h=a>-1?a:void 0,{grid:m,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b}=this;return new x({description:o,direction:d,field:l,fieldName:n,grid:m,initialSortPriority:h,label:r,layer:t,messages:c,messagesCommon:p,messagesURIUtils:u,store:g,view:b,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{layer:t,element:i,orderByFields:s}=e,{description:n,label:l}=i;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!i.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:o,messages:r,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new V({columns:this._generateColumnsFromAttributeTableElements(t,i.elements,s),description:n,grid:o,label:l,messages:r,messagesCommon:a,messagesURIUtils:d,store:h})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{layer:t,element:i,index:s}=e,{description:n,label:l}=i,{grid:o,messages:r,messagesCommon:a,messagesURIUtils:d,store:h}=this;return new j({description:n,fieldName:`${J.attachments}-${s}`,grid:o,label:l,layer:t,messages:r,messagesCommon:a,messagesURIUtils:d,store:h,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:n,relationshipId:l}=t,o=this.relationshipInfos.find(e=>e.relationshipId===l);if(!o)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:r,messages:a,messagesCommon:d,messagesURIUtils:h,store:m}=this;return new R({description:s,fieldName:`${J.relationship}-${l}-${i}`,grid:r,label:n,messages:a,messagesCommon:d,messagesURIUtils:h,relationshipId:l,store:m,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:o,view:r}=this;if(!t?.length)return null;const a=[];return t.forEach((t,d)=>{const{autoWidth:h,description:m,direction:c,flexGrow:p,fieldName:u,formatFunction:g,frozen:b,frozenToEnd:f,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,resizable:E,sortable:S,textAlign:A,textWrap:F,timeZone:j,type:R,width:U}=t;if(!R)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(b&&f)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===t.visible;if("group"===R){if(!t.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!t.label)return void this._logTemplateWarning("Group columns require a label.");const o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),r=P||this._isFieldHidden(t.label);a.push(new V({autoWidth:h,columns:o,description:m,flexGrow:p,frozen:b,frozenToEnd:f,grid:i,hidden:r,icon:y,iconText:T,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,textAlign:A,textWrap:F,timeZone:j,width:U}))}else if("attachment"===R){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");a.push(this._generateAttachmentsColumnFromTemplate(e,t,d))}else if("relationship"===R){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:e}=t;if(null==e)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this.relationshipInfos.find(t=>t.relationshipId===e);if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");a.push(this._generateRelationshipColumnFromTemplate(i,t,d))}else if(!u)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const z=P||this._isFieldHidden(u);if("column"===R)a.push(new O({autoWidth:h,description:m,direction:c,fieldName:u,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,menuConfig:_,messages:s,messagesCommon:n,messagesURIUtils:l,resizable:E,sortable:S,store:o,textAlign:A,textWrap:F,timeZone:j,width:U}));else if("field"===R){const d=Y(e,t.fieldName);if(!d)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:u,required:R}=t;a.push(new x({autoWidth:h,description:m,direction:c,editable:u,field:d,fieldName:d.name,flexGrow:p,formatFunction:g,frozen:b,frozenToEnd:f,grid:i,hidden:z,icon:y,iconText:T,initialSortPriority:w,invalid:C,label:I,labelTooltipText:v,layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,menuConfig:_,required:R,resizable:E,sortable:S,store:o,template:t,textAlign:A,textWrap:F,timeZone:j,width:U,view:r,onShowPromptCallback:this._onShowPromptCallback}))}}),a.length?a:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(n)??[]}_generateDefaultFieldColumn(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r,view:a}=this;if(!t.visible||"geometry"===t.type)return null;const d=i?.orderByFields,h=t.name,m=d?.findIndex(({field:e})=>e&&e===h)??-1,c=m>-1?d?.at(m)?.order:void 0,p=m>-1?m:void 0;return new x({direction:c,field:t,fieldName:h,grid:s,hidden:i?.hidden||this._isFieldHidden(h),initialSortPriority:p,layer:e,messages:n,messagesCommon:l,messagesURIUtils:o,store:r,view:a,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r}=this,{attachmentsViewEnabled:a,autoWidth:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,resizable:I,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:x,width:R}=t;return new j({attachmentsViewEnabled:a,autoWidth:d,description:h,fieldName:`${J.attachments}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,layer:e,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:o,resizable:I,store:r,textAlign:v,textWrap:_,thumbnailAppearance:E,thumbnailCount:S,thumbnailIconScale:A,thumbnailsEnabled:F,timeZone:x,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){const{grid:i,messages:s,messagesCommon:n,messagesURIUtils:l,store:o}=this,r=J.attachments;return new j({fieldName:r,grid:i,hidden:t?.hidden||this._isFieldHidden(r),layer:e,messages:s,messagesCommon:n,messagesURIUtils:l,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:n,messagesCommon:l,messagesURIUtils:o,store:r}=this,{autoWidth:a,collapsed:d,description:h,flexGrow:m,fieldName:c,formatFunction:p,frozen:u,frozenToEnd:g,icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,relationshipId:I,resizable:v,textAlign:_,textWrap:E,timeZone:S,width:A}=t;return new R({autoWidth:a,collapsed:d,description:h,fieldName:`${J.relationship}-${I}-${i}`,flexGrow:m,formatFunction:p,frozen:u,frozenToEnd:g,grid:s,hidden:!1===t.visible||this._isFieldHidden(T)||this._isFieldHidden(c),icon:b,iconText:f,invalid:y,label:T,labelTooltipText:w,menuConfig:C,messages:n,messagesCommon:l,messagesURIUtils:o,relationshipId:I,resizable:v,store:r,textAlign:_,textWrap:E,timeZone:S,width:A,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach((t,s)=>{const{relationshipId:n}=t,l=e.find(e=>e.relationshipId===n);l&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:l}))}):e.forEach((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e}))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:n}=e,{grid:l,messages:o,messagesCommon:r,messagesURIUtils:a,store:d}=this,{relationshipId:h}=n;return new R({...t,fieldName:`${J.relationship}-${h}-${s}`,grid:l,hidden:i,messages:o,messagesCommon:r,messagesURIUtils:a,layer:n.relatedLayer,relatedLayer:n.layer,relationshipId:h,store:d,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){const e=this.actionColumnConfig,t=!0!==e?.frozen&&(e?.frozenToEnd??!0);return new F({hidden:this._isFieldHidden(J.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){const{layer:e}=this;A(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){const t=this.layer;A(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._removeFromSelection(i),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){const{tableParent:t}=this;t&&null!=e&&t.highlightIds.add(e)}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(J.action)||s.add(J.action),s.includes(J.attachments)||s.add(J.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const i=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:te(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([J.action,J.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new $({columnTemplates:[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([s,n])=>({selected:s===t,label:n||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}}))},resizable:!1}),new H({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:ne})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new D({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}}))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})),new $({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:n}=e,{_subtypes:l,layer:o}=this;if(!o||!l.length)return void t.cancel();const r=l.find(e=>e.code===n);if(!r)return void t.cancel();const a=Promise.withResolvers(),d=this._createSubtypeEditPrompt(s,r,a),h=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(d);const e=await a.promise,s=[{fieldName:t.fieldName,value:n}];switch(e){case"update-fields":for(const[e,t]of Object.entries(r.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),h&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,s){const{_subtypes:n,messages:l,messagesCommon:o}=this,r=n.find(t=>t.code===e)?.name??`${e}`;let a="update-fields";const d=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:i(l.subtypes.changeWarning,{originalType:r,newType:t.name}),radios:d,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:o.apply,action:()=>s.resolve(a),type:"positive"},secondary:{label:o.cancel,type:"neutral",action:()=>s.resolve("undo")}},cancel:()=>s.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new $({columnTemplates:[new D({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new z({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:ne})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter(({type:e})=>"field"===e||"column"===e).map(({fieldName:e,label:t})=>{if(null!=t&&""!==t)return[e,t];const s=i?.fieldsIndex.get(e);return[e,s&&y(s,i)]}):i?.fields.map(e=>[e.name,y(e,i)])??[]}_getDefaultLayerDisplayField(e){const{displayField:t,objectIdField:i}=e;return t&&""!==t.trim()?t:i||(e.fields.length?e.fields[0].name:"")}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([b()],le.prototype,"_defaultHiddenFields",null),e([b()],le.prototype,"_effectiveTableTemplate",null),e([b()],le.prototype,"_effectiveAttributeTableTemplate",null),e([b()],le.prototype,"_subtypes",null),e([b()],le.prototype,"activeFilters",null),e([b({readOnly:!0})],le.prototype,"activeSortOrders",null),e([b()],le.prototype,"allRelatedTablesVisible",null),e([b()],le.prototype,"attachmentsColumns",null),e([b()],le.prototype,"attachmentsEnabled",null),e([b()],le.prototype,"attachmentsViewOptions",void 0),e([b({type:_})],le.prototype,"attributeTableTemplate",void 0),e([b()],le.prototype,"autoRefreshEnabled",void 0),e([b()],le.prototype,"autoSaveEnabled",null),e([b()],le.prototype,"canAddRelatedFeature",null),e([b()],le.prototype,"clearPrompt",null),e([b({readOnly:!0})],le.prototype,"columns",void 0),e([b()],le.prototype,"dataProvider",void 0),e([b()],le.prototype,"defaultSelectionManager",null),e([b()],le.prototype,"definitionExpression",null),e([b()],le.prototype,"effectiveSelectionManager",null),e([b()],le.prototype,"fieldColumns",null),e([b()],le.prototype,"filterByViewExtent",null),e([b()],le.prototype,"filterByLayerScaleRange",null),e([b({types:T})],le.prototype,"filterGeometry",null),e([b()],le.prototype,"filterBySelectionEnabled",null),e([b({readOnly:!0})],le.prototype,"grid",void 0),e([b()],le.prototype,"hasContingentValues",null),e([b()],le.prototype,"hasInvalidPendingEdits",null),e([b()],le.prototype,"hasPendingEdits",null),e([b()],le.prototype,"hiddenFields",null),e([b()],le.prototype,"highlightEnabled",null),e([b()],le.prototype,"initialSize",null),e([b()],le.prototype,"isQueryingOrSyncing",null),e([b()],le.prototype,"isSyncingAttachments",null),e([b()],le.prototype,"layer",null),e([b()],le.prototype,"layers",void 0),e([b()],le.prototype,"layerFieldConfigurations",null),e([b()],le.prototype,"layerView",null),e([b()],le.prototype,"menuConfig",void 0),e([b()],le.prototype,"messages",void 0),e([b(),se("esri/t9n/common")],le.prototype,"messagesCommon",void 0),e([b(),se("esri/core/t9n/Units")],le.prototype,"messagesUnits",void 0),e([b(),se("esri/widgets/support/t9n/uriUtils")],le.prototype,"messagesURIUtils",void 0),e([b()],le.prototype,"outFields",null),e([b()],le.prototype,"pendingEditsCount",null),e([b()],le.prototype,"prompt",void 0),e([b()],le.prototype,"relatedRecordsEnabled",null),e([b()],le.prototype,"relatedTable",null),e([b()],le.prototype,"relatedTableHasContingentValues",null),e([b()],le.prototype,"relatedTables",void 0),e([b()],le.prototype,"relationship",null),e([b()],le.prototype,"relationshipColumnConfigs",void 0),e([b()],le.prototype,"relationshipColumns",null),e([b()],le.prototype,"relationshipConfig",null),e([b()],le.prototype,"relationshipInfos",null),e([b()],le.prototype,"relationships",null),e([b()],le.prototype,"returnGeometryEnabled",null),e([b()],le.prototype,"returnMEnabled",null),e([b()],le.prototype,"returnZEnabled",null),e([b()],le.prototype,"selectionManager",null),e([b()],le.prototype,"selectionSource",null),e([b()],le.prototype,"showAllRelatedTables",null),e([b()],le.prototype,"showPrompt",null),e([b()],le.prototype,"showRelatedTableCallback",void 0),e([b({readOnly:!0,type:N})],le.prototype,"store",void 0),e([b()],le.prototype,"supportsAttachments",null),e([b()],le.prototype,"supportsAddAttachments",null),e([b()],le.prototype,"supportsDeleteAttachments",null),e([b()],le.prototype,"supportsResizeAttachments",null),e([b()],le.prototype,"supportsUpdateAttachments",null),e([b()],le.prototype,"syncTemplateOnChangesEnabled",void 0),e([b()],le.prototype,"syncViewSelection",null),e([b()],le.prototype,"tableController",void 0),e([b()],le.prototype,"tableParent",void 0),e([b({type:$})],le.prototype,"tableTemplate",void 0),e([b()],le.prototype,"tableTemplateOverride",void 0),e([b({type:S})],le.prototype,"timeExtent",null),e([b()],le.prototype,"timeZone",null),e([b()],le.prototype,"view",null),le=e([f("esri.widgets.FeatureTable.FeatureTableViewModel")],le);const oe=le;export{oe as default};