@arcgis/core 4.28.0-next.20231002 → 4.28.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/02120d192eafd7612475.js +1 -0
  3. package/assets/esri/core/workers/chunks/{4d967e98d229f18d61f5.js → 09e8babe75407c2e64c4.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0beebbb0c6dad0e742d7.js +1 -0
  5. package/assets/esri/core/workers/chunks/0d8ca51043c7784aed96.js +1 -0
  6. package/assets/esri/core/workers/chunks/112e89da628bdea5355c.js +1 -0
  7. package/assets/esri/core/workers/chunks/{5e9edd06e624f385fa4b.js → 121a9e148509f2fe2210.js} +1 -1
  8. package/assets/esri/core/workers/chunks/1856d16d738f44f58084.js +1 -0
  9. package/assets/esri/core/workers/chunks/{0526d623d0b4c12929bd.js → 18ab9cc85a1a7988fdfd.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{7c960a2694c4c3123acf.js → 1a36703ebe934749646e.js} +1 -1
  11. package/assets/esri/core/workers/chunks/24a0cf405195421c0d06.js +1 -0
  12. package/assets/esri/core/workers/chunks/24ff267cf253feac22de.js +1 -0
  13. package/assets/esri/core/workers/chunks/{3c8613596659801fd6ab.js → 29cab345819ec02ed60a.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{169a61c6e128b8a16021.js → 2c560a075d9ef2069ed1.js} +1 -1
  15. package/assets/esri/core/workers/chunks/2f8e71dac98135bbc3e6.js +1 -0
  16. package/assets/esri/core/workers/chunks/341fb51b2165522963b3.js +1 -0
  17. package/assets/esri/core/workers/chunks/{ad8e0f82cb1feafa9e2f.js → 36ab90fb34b9716a9983.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{2688213bbff536da7917.js → 3ea0b872436fce84b927.js} +1 -1
  19. package/assets/esri/core/workers/chunks/40633064c290dc2af9ea.js +1 -0
  20. package/assets/esri/core/workers/chunks/42ec4c80b0c2944cd65c.js +1 -0
  21. package/assets/esri/core/workers/chunks/44b870cb53ba68b17c32.js +1 -0
  22. package/assets/esri/core/workers/chunks/{8a7fa4e8b0d14da7c9eb.js → 4cc680fe4c9c39d2f853.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{6730c9f0890191a95fdb.js → 4d81aa50d90f5701a343.js} +1 -1
  24. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +1 -0
  25. package/assets/esri/core/workers/chunks/4e6bf1efe3b0b474cbb4.js +1 -0
  26. package/assets/esri/core/workers/chunks/52cef7cd3aaaa4f45c94.js +1 -0
  27. package/assets/esri/core/workers/chunks/{4e04242e707c0eb3aa4a.js → 5a3ccc0a19ac8fa9e524.js} +1 -1
  28. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +1 -0
  29. package/assets/esri/core/workers/chunks/66ba749ab0a631bbfdec.js +1 -0
  30. package/assets/esri/core/workers/chunks/6b14d89d689a21014aec.js +1 -0
  31. package/assets/esri/core/workers/chunks/6b1856303d1562f05100.js +1 -0
  32. package/assets/esri/core/workers/chunks/{576269fd1f9049876aa1.js → 6b7b5544ed1f9a84623f.js} +1 -1
  33. package/assets/esri/core/workers/chunks/710a6268de62003af825.js +1 -0
  34. package/assets/esri/core/workers/chunks/77923afde29ae1ff10ca.js +1 -0
  35. package/assets/esri/core/workers/chunks/784ffd52315a4d55d683.js +1 -0
  36. package/assets/esri/core/workers/chunks/7cf7f2b991a7cbdad2ce.js +1 -0
  37. package/assets/esri/core/workers/chunks/{70dffbf49b0633b1a5f1.js → 8f3680fee85a05839489.js} +1 -1
  38. package/assets/esri/core/workers/chunks/97aecf210938015cc7a3.js +1 -0
  39. package/assets/esri/core/workers/chunks/{c7ebd5d431fb996bfcee.js → 9f8207c82a17508a87a8.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{557305b91f77569ce664.js → a01ffe03b1465c21b9e6.js} +1 -1
  41. package/assets/esri/core/workers/chunks/a298c9031962951e55a9.js +1 -0
  42. package/assets/esri/core/workers/chunks/{329669a9beda89b028dd.js → a5a7bbdd8298016535bc.js} +1 -1
  43. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +1 -0
  44. package/assets/esri/core/workers/chunks/ad38e456a7cee940a165.js +1 -0
  45. package/assets/esri/core/workers/chunks/adfbc168be8c49b51e1b.js +1 -0
  46. package/assets/esri/core/workers/chunks/b0526633a93ef69ec47b.js +1 -0
  47. package/assets/esri/core/workers/chunks/b99bc08a01e9250b0a31.js +1 -0
  48. package/assets/esri/core/workers/chunks/{36c4b4c3eca57417da2c.js → c260ad3434bb00ba64a7.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{39922ce232338de076ae.js → c459c8d8630eb4b955b1.js} +1 -1
  50. package/assets/esri/core/workers/chunks/c92e75b79aff7b505b31.js +1 -0
  51. package/assets/esri/core/workers/chunks/ca85e88dad30b5f2956b.js +1 -0
  52. package/assets/esri/core/workers/chunks/{8e56d40691b6bf75d7cc.js → ce409944221a784ddb61.js} +1 -1
  53. package/assets/esri/core/workers/chunks/d13f75f233cf313e5a1d.js +1 -0
  54. package/assets/esri/core/workers/chunks/d60d5f006375f7fcc88c.js +1 -0
  55. package/assets/esri/core/workers/chunks/{77958089748dc31757cf.js → d6ded127949160103f69.js} +1 -1
  56. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +1 -0
  57. package/assets/esri/core/workers/chunks/{304c81f6297ecba3a324.js → d95eed98316e59f8f35d.js} +1 -1
  58. package/assets/esri/core/workers/chunks/df7267892b6e0493e1d7.js +1 -0
  59. package/assets/esri/core/workers/chunks/{52dca349e1a45555954d.js → e52d5a48e83d8df36f92.js} +1 -1
  60. package/assets/esri/core/workers/chunks/e8688b6cc3b3c1010b43.js +1 -0
  61. package/assets/esri/core/workers/chunks/e8c7cc974420c0b92d0e.js +1 -0
  62. package/assets/esri/core/workers/chunks/{b7ef554b1213307499fc.js → e93442c6d92229f3a4b0.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{ef5772ca1848d6d01b88.js → eda86faa708cfe4c9f9a.js} +1 -1
  64. package/assets/esri/core/workers/chunks/f2718e260f594537f7fd.js +1 -0
  65. package/assets/esri/core/workers/chunks/f6b7036114b1d754fdd9.js +1 -0
  66. package/assets/esri/core/workers/chunks/{c4631241dc777ca77aaa.js → f6c0680c535c5a3c73ee.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{a0ea1d3e22d52b8a59a8.js → fa6103e3d4e857b0035b.js} +9 -9
  68. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +1 -0
  69. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  70. package/assets/esri/t9n/common.json +1 -1
  71. package/assets/esri/t9n/common_ar.json +1 -1
  72. package/assets/esri/t9n/common_bg.json +1 -1
  73. package/assets/esri/t9n/common_bs.json +1 -1
  74. package/assets/esri/t9n/common_ca.json +1 -1
  75. package/assets/esri/t9n/common_cs.json +1 -1
  76. package/assets/esri/t9n/common_da.json +1 -1
  77. package/assets/esri/t9n/common_de.json +1 -1
  78. package/assets/esri/t9n/common_el.json +1 -1
  79. package/assets/esri/t9n/common_en.json +1 -1
  80. package/assets/esri/t9n/common_es.json +1 -1
  81. package/assets/esri/t9n/common_et.json +1 -1
  82. package/assets/esri/t9n/common_fi.json +1 -1
  83. package/assets/esri/t9n/common_fr.json +1 -1
  84. package/assets/esri/t9n/common_he.json +1 -1
  85. package/assets/esri/t9n/common_hr.json +1 -1
  86. package/assets/esri/t9n/common_hu.json +1 -1
  87. package/assets/esri/t9n/common_id.json +1 -1
  88. package/assets/esri/t9n/common_it.json +1 -1
  89. package/assets/esri/t9n/common_ja.json +1 -1
  90. package/assets/esri/t9n/common_ko.json +1 -1
  91. package/assets/esri/t9n/common_lt.json +1 -1
  92. package/assets/esri/t9n/common_lv.json +1 -1
  93. package/assets/esri/t9n/common_nb.json +1 -1
  94. package/assets/esri/t9n/common_nl.json +1 -1
  95. package/assets/esri/t9n/common_pl.json +1 -1
  96. package/assets/esri/t9n/common_pt-BR.json +1 -1
  97. package/assets/esri/t9n/common_pt-PT.json +1 -1
  98. package/assets/esri/t9n/common_ro.json +1 -1
  99. package/assets/esri/t9n/common_ru.json +1 -1
  100. package/assets/esri/t9n/common_sk.json +1 -1
  101. package/assets/esri/t9n/common_sl.json +1 -1
  102. package/assets/esri/t9n/common_sr.json +1 -1
  103. package/assets/esri/t9n/common_sv.json +1 -1
  104. package/assets/esri/t9n/common_th.json +1 -1
  105. package/assets/esri/t9n/common_tr.json +1 -1
  106. package/assets/esri/t9n/common_uk.json +1 -1
  107. package/assets/esri/t9n/common_vi.json +1 -1
  108. package/assets/esri/t9n/common_zh-CN.json +1 -1
  109. package/assets/esri/t9n/common_zh-HK.json +1 -1
  110. package/assets/esri/t9n/common_zh-TW.json +1 -1
  111. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +2 -1
  112. package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -1
  113. package/assets/esri/themes/dark/main.css +1 -1
  114. package/assets/esri/themes/light/main.css +1 -1
  115. package/assets/esri/themes/light/view.css +1 -1
  116. package/chunks/pe-wasm.js +1 -1
  117. package/config.js +1 -1
  118. package/core/pbf.js +1 -1
  119. package/geometry/support/WKIDUnitConversion.js +1 -1
  120. package/geometry/support/plane.js +1 -1
  121. package/interfaces.d.ts +37 -39
  122. package/kernel.js +1 -1
  123. package/layers/GroupLayer.js +1 -1
  124. package/layers/SceneLayer.js +1 -1
  125. package/layers/graphics/data/QueryEngine.js +1 -1
  126. package/layers/graphics/data/QueryEngineResult.js +1 -1
  127. package/layers/graphics/editingSupport.js +1 -1
  128. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  129. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  130. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  131. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  132. package/layers/mixins/OperationalLayer.js +1 -1
  133. package/layers/save/featureLayerUtils.js +1 -1
  134. package/layers/save/groupLayerUtils.js +5 -0
  135. package/layers/save/utils.js +1 -1
  136. package/layers/support/LayerLoadContext.js +5 -0
  137. package/layers/support/featureLayerUtils.js +1 -1
  138. package/layers/support/labelFormatUtils.js +1 -1
  139. package/layers/support/layersCreator.js +1 -1
  140. package/layers/support/versionUtils.js +1 -1
  141. package/networks/UtilityNetwork.js +1 -1
  142. package/package.json +1 -1
  143. package/portal/schemas/definitions.js +1 -1
  144. package/portal/support/jsonContext.js +1 -1
  145. package/portal/support/layersLoader.js +1 -1
  146. package/portal/support/loadUtils.js +5 -0
  147. package/portal/support/portalItemUtils.js +1 -1
  148. package/portal/support/portalLayers.js +1 -1
  149. package/renderers/support/RasterSymbolizer.js +1 -1
  150. package/rest/print.js +1 -1
  151. package/support/basemapUtils.js +1 -1
  152. package/support/revision.js +1 -1
  153. package/symbols/PolygonSymbol3D.js +1 -1
  154. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  155. package/views/2d/engine/imagery/colorizer/shadedrelief.js +1 -1
  156. package/views/2d/engine/imagery/colorizer/stretch.js +1 -1
  157. package/views/2d/input/handlers/KeyPan.js +1 -1
  158. package/views/2d/input/handlers/KeyRotate.js +1 -1
  159. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  160. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  161. package/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js +1 -1
  162. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  163. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  164. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  165. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  167. package/views/3d/layers/i3s/featureEditing.js +1 -1
  168. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  169. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  170. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  171. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  172. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  173. package/views/DOMContainer.js +1 -1
  174. package/views/draw/DrawGraphicTool.js +1 -1
  175. package/views/draw/DrawOperation.js +1 -1
  176. package/views/draw/support/Box.js +1 -1
  177. package/views/draw/support/Reshape.js +1 -1
  178. package/views/input/VisibilityChange.js +5 -0
  179. package/views/interactive/sketch/constraints.js +1 -1
  180. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  181. package/views/interactive/snapping/FeatureSnappingSourceInfo.js +5 -0
  182. package/views/interactive/snapping/SnappingContext.js +1 -1
  183. package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
  184. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  185. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  186. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js +1 -1
  187. package/views/interactive/snapping/snappingUtils.js +1 -1
  188. package/webdoc/support/saveUtils.js +1 -1
  189. package/webdoc/webdocSaveUtils.js +1 -1
  190. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  191. package/widgets/DirectionalPad/constants.js +1 -1
  192. package/widgets/DirectionalPad.js +1 -1
  193. package/widgets/Editor/Upload.js +1 -1
  194. package/widgets/Editor/workflowUtils.js +1 -1
  195. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  196. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  197. package/widgets/FeatureForm/FieldInput.js +1 -1
  198. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  199. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  200. package/widgets/FeatureForm.js +1 -1
  201. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  202. package/widgets/FeatureTable/FieldColumn.js +1 -1
  203. package/widgets/FeatureTable/Grid/Column.js +1 -1
  204. package/widgets/FeatureTable.js +1 -1
  205. package/widgets/ScaleRangeSlider.js +1 -1
  206. package/widgets/support/DatePicker.js +1 -1
  207. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  208. package/widgets/support/Selector2D/SelectionOperation2D.js +1 -1
  209. package/widgets/support/Selector2D.js +1 -1
  210. package/widgets/support/TimePicker.js +1 -1
  211. package/widgets/support/dateUtils.js +1 -1
  212. package/assets/esri/core/workers/chunks/027f8b57565c65fbccda.js +0 -1
  213. package/assets/esri/core/workers/chunks/048265fb5953350e3e33.js +0 -1
  214. package/assets/esri/core/workers/chunks/0b9cf14f8aafb76c578b.js +0 -1
  215. package/assets/esri/core/workers/chunks/0ebf58c927bfc4c9d4fe.js +0 -1
  216. package/assets/esri/core/workers/chunks/10fd951bd296b2beeeba.js +0 -1
  217. package/assets/esri/core/workers/chunks/1224475f3eefdfd59c76.js +0 -1
  218. package/assets/esri/core/workers/chunks/162b0220e24e9ba72655.js +0 -1
  219. package/assets/esri/core/workers/chunks/1e611cad53b745ee146f.js +0 -1
  220. package/assets/esri/core/workers/chunks/24b1bf1a5d80f43a6c9a.js +0 -1
  221. package/assets/esri/core/workers/chunks/29ed31fd4f9d5cf53686.js +0 -1
  222. package/assets/esri/core/workers/chunks/2b6d1c8e4ed759767827.js +0 -1
  223. package/assets/esri/core/workers/chunks/34b44b0fab88f838885c.js +0 -1
  224. package/assets/esri/core/workers/chunks/364f55294a1d7bf163d7.js +0 -1
  225. package/assets/esri/core/workers/chunks/3714ab435dd5ccf9e694.js +0 -1
  226. package/assets/esri/core/workers/chunks/3788009a5ece453011f3.js +0 -1
  227. package/assets/esri/core/workers/chunks/3aafe8160b3bfbaa6935.js +0 -1
  228. package/assets/esri/core/workers/chunks/41c002e4c42c581cda8d.js +0 -1
  229. package/assets/esri/core/workers/chunks/47be4c75dd6372b96fe4.js +0 -1
  230. package/assets/esri/core/workers/chunks/4e8d1e6051f6654a5e83.js +0 -1
  231. package/assets/esri/core/workers/chunks/53746e9976758630159b.js +0 -1
  232. package/assets/esri/core/workers/chunks/5449fdd69e12e5cbd12a.js +0 -1
  233. package/assets/esri/core/workers/chunks/57ce4ece0147afb0d43c.js +0 -1
  234. package/assets/esri/core/workers/chunks/5e83d21400a5dec05c81.js +0 -1
  235. package/assets/esri/core/workers/chunks/6047f4487dcd37cca98e.js +0 -1
  236. package/assets/esri/core/workers/chunks/6967d2b3721678b38774.js +0 -1
  237. package/assets/esri/core/workers/chunks/6ac5ca7de651e3d672a1.js +0 -1
  238. package/assets/esri/core/workers/chunks/6b7ee9164149428edb9e.js +0 -1
  239. package/assets/esri/core/workers/chunks/6c495077cc79e1898927.js +0 -1
  240. package/assets/esri/core/workers/chunks/6d43648d5326e01b4474.js +0 -1
  241. package/assets/esri/core/workers/chunks/74fb07de0f990d45af89.js +0 -1
  242. package/assets/esri/core/workers/chunks/8e9a52062ce059153a89.js +0 -1
  243. package/assets/esri/core/workers/chunks/919a57d372419785cd5e.js +0 -1
  244. package/assets/esri/core/workers/chunks/939f0a1a7d605e389e45.js +0 -1
  245. package/assets/esri/core/workers/chunks/9932f23ba6589df14a3d.js +0 -1
  246. package/assets/esri/core/workers/chunks/a25a38c9f338e0beffef.js +0 -1
  247. package/assets/esri/core/workers/chunks/a97581e584336b46ede7.js +0 -1
  248. package/assets/esri/core/workers/chunks/b1cb932cfadc4dc3f1e4.js +0 -1
  249. package/assets/esri/core/workers/chunks/be3fb6113b0b27b94537.js +0 -1
  250. package/assets/esri/core/workers/chunks/c37119f5692e19aa1ce2.js +0 -1
  251. package/assets/esri/core/workers/chunks/c685f16435d9861bbbd0.js +0 -1
  252. package/assets/esri/core/workers/chunks/d5dfc03673aec8aa57e2.js +0 -1
  253. package/assets/esri/core/workers/chunks/e6416a2684866d677b3e.js +0 -1
  254. package/assets/esri/core/workers/chunks/eb01f4cdb9b918cc61e7.js +0 -1
  255. package/assets/esri/core/workers/chunks/eb4aed4fdb44495a4fe6.js +0 -1
  256. package/assets/esri/core/workers/chunks/ec8258c9dc1491e97fc8.js +0 -1
  257. package/assets/esri/core/workers/chunks/eeac53da496de4cd4182.js +0 -1
package/interfaces.d.ts CHANGED
@@ -3795,7 +3795,7 @@ declare namespace __esri {
3795
3795
  *
3796
3796
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-inputs-DateTimeOffsetPickerInput.html#timeResolution)
3797
3797
  */
3798
- timeResolution: string;
3798
+ timeResolution: "minutes" | "seconds" | "milliseconds";
3799
3799
  /**
3800
3800
  * The type of form element input.
3801
3801
  *
@@ -3845,7 +3845,7 @@ declare namespace __esri {
3845
3845
  *
3846
3846
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-inputs-DateTimeOffsetPickerInput.html#timeResolution)
3847
3847
  */
3848
- timeResolution?: string;
3848
+ timeResolution?: "minutes" | "seconds" | "milliseconds";
3849
3849
  }
3850
3850
 
3851
3851
  export interface DateTimePickerInput extends Accessor, JSONSupport {
@@ -4121,7 +4121,7 @@ declare namespace __esri {
4121
4121
  *
4122
4122
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-inputs-TimePickerInput.html#timeResolution)
4123
4123
  */
4124
- timeResolution: "hours" | "minutes" | "minutes";
4124
+ timeResolution: "minutes" | "seconds" | "milliseconds";
4125
4125
  /**
4126
4126
  * The type of form element input.
4127
4127
  *
@@ -4163,7 +4163,7 @@ declare namespace __esri {
4163
4163
  *
4164
4164
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-inputs-TimePickerInput.html#timeResolution)
4165
4165
  */
4166
- timeResolution?: "hours" | "minutes" | "minutes";
4166
+ timeResolution?: "minutes" | "seconds" | "milliseconds";
4167
4167
  }
4168
4168
 
4169
4169
  /**
@@ -18593,6 +18593,12 @@ declare namespace __esri {
18593
18593
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OGCFeatureLayer.html)
18594
18594
  */
18595
18595
  constructor(properties?: OGCFeatureLayerProperties);
18596
+ /**
18597
+ * Creates a popup template for the layer, populated with all the fields of the layer.
18598
+ *
18599
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OGCFeatureLayer.html#createPopupTemplate)
18600
+ */
18601
+ createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate;
18596
18602
  /**
18597
18603
  * Returns the [Field](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html) instance for a field name (case-insensitive).
18598
18604
  *
@@ -23214,7 +23220,7 @@ declare namespace __esri {
23214
23220
  */
23215
23221
  get(fieldName: string): Field;
23216
23222
  /**
23217
- * Returns the time zone for a field.
23223
+ * Returns the [IANA time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for a field.
23218
23224
  *
23219
23225
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FieldsIndex.html#getTimeZone)
23220
23226
  */
@@ -87655,14 +87661,6 @@ declare namespace __esri {
87655
87661
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#iconClass)
87656
87662
  */
87657
87663
  iconClass: string;
87658
- /**
87659
- * When `true`, adds the map's current basemap (at the time of the widget's instantiation) to the gallery if it's not found in the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#source).
87660
- *
87661
- * @default false
87662
- *
87663
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#includeCurrentBasemap)
87664
- */
87665
- includeCurrentBasemap: boolean;
87666
87664
  /**
87667
87665
  * The source for basemaps that the widget will display.
87668
87666
  *
@@ -87720,14 +87718,6 @@ declare namespace __esri {
87720
87718
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#iconClass)
87721
87719
  */
87722
87720
  iconClass?: string;
87723
- /**
87724
- * When `true`, adds the map's current basemap (at the time of the widget's instantiation) to the gallery if it's not found in the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#source).
87725
- *
87726
- * @default false
87727
- *
87728
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#includeCurrentBasemap)
87729
- */
87730
- includeCurrentBasemap?: boolean;
87731
87721
  /**
87732
87722
  * The source for basemaps that the widget will display.
87733
87723
  *
@@ -87759,14 +87749,6 @@ declare namespace __esri {
87759
87749
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#activeBasemap)
87760
87750
  */
87761
87751
  activeBasemap: Basemap;
87762
- /**
87763
- * When `true`, adds the map's current basemap (at the time of the widget's instantiation) to the gallery if it's not found in the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#source).
87764
- *
87765
- * @default false
87766
- *
87767
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#includeCurrentBasemap)
87768
- */
87769
- includeCurrentBasemap: boolean;
87770
87752
  /**
87771
87753
  * A collection of [BasemapGalleryItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html)s representing basemaps.
87772
87754
  *
@@ -87814,14 +87796,6 @@ declare namespace __esri {
87814
87796
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#activeBasemap)
87815
87797
  */
87816
87798
  activeBasemap?: BasemapProperties;
87817
- /**
87818
- * When `true`, adds the map's current basemap (at the time of the widget's instantiation) to the gallery if it's not found in the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#source).
87819
- *
87820
- * @default false
87821
- *
87822
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#includeCurrentBasemap)
87823
- */
87824
- includeCurrentBasemap?: boolean;
87825
87799
  /**
87826
87800
  * A collection of [BasemapGalleryItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html)s representing basemaps.
87827
87801
  *
@@ -94936,9 +94910,9 @@ declare namespace __esri {
94936
94910
  *
94937
94911
  * @default false
94938
94912
  *
94939
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FieldInput.html#includeTimestamp)
94913
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FieldInput.html#includeTimeOffset)
94940
94914
  */
94941
- readonly includeTimestamp: boolean;
94915
+ readonly includeTimeOffset: boolean;
94942
94916
  /**
94943
94917
  * The type of editor used when working with `string` fields.
94944
94918
  *
@@ -96116,6 +96090,12 @@ declare namespace __esri {
96116
96090
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#tableTemplate)
96117
96091
  */
96118
96092
  tableTemplate: TableTemplate;
96093
+ /**
96094
+ * Dates and times displayed in the widget will be in terms of this time zone.
96095
+ *
96096
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#timeZone)
96097
+ */
96098
+ timeZone: string;
96119
96099
  /**
96120
96100
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
96121
96101
  *
@@ -96358,6 +96338,12 @@ declare namespace __esri {
96358
96338
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#tableTemplate)
96359
96339
  */
96360
96340
  tableTemplate?: TableTemplateProperties;
96341
+ /**
96342
+ * Dates and times displayed in the widget will be in terms of this time zone.
96343
+ *
96344
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#timeZone)
96345
+ */
96346
+ timeZone?: string;
96361
96347
  /**
96362
96348
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
96363
96349
  *
@@ -96496,6 +96482,12 @@ declare namespace __esri {
96496
96482
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#tableTemplate)
96497
96483
  */
96498
96484
  tableTemplate: TableTemplate;
96485
+ /**
96486
+ * Dates and times displayed in the widget will be in terms of this time zone.
96487
+ *
96488
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#timeZone)
96489
+ */
96490
+ timeZone: string;
96499
96491
  /**
96500
96492
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
96501
96493
  *
@@ -96689,6 +96681,12 @@ declare namespace __esri {
96689
96681
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#tableTemplate)
96690
96682
  */
96691
96683
  tableTemplate?: TableTemplateProperties;
96684
+ /**
96685
+ * Dates and times displayed in the widget will be in terms of this time zone.
96686
+ *
96687
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#timeZone)
96688
+ */
96689
+ timeZone?: string;
96692
96690
  /**
96693
96691
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
96694
96692
  *
package/kernel.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,n=r;n=`${"4.28.0"}-next.${s}`;function i(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,n as fullVersion,t as id,e as revision,i as setId,r as version};
5
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as r}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="4.28";let t,i=e;i="4.28.0-rc.0";function n(o){t=o}function m(s){const r=t?.findCredential(s);return r?.token?o(s,"token",r.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,r as revision,n as setId,e as version};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import i from"../core/CollectionFlattener.js";import{loadAll as t}from"../core/loadAll.js";import r from"../core/Logger.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{watch as o,syncAndInitial as l,on as a,sync as n}from"../core/reactiveUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as d}from"../core/accessorSupport/utils.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import c from"./Layer.js";import{BlendLayer as m}from"./mixins/BlendLayer.js";import{OperationalLayer as u}from"./mixins/OperationalLayer.js";import{PortalLayer as b}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as v}from"./mixins/ScaleRangeLayer.js";import{layerLookupMap as f}from"./support/lazyLayerLoader.js";import{createFlattenedTablesCollection as j}from"../support/collectionUtils.js";import{LayersMixin as L}from"../support/LayersMixin.js";import{TablesMixin as g}from"../support/TablesMixin.js";import{WebSceneTag as w}from"../support/tagSymbols.js";import{getLayerJSON as _}from"../webdoc/support/writeUtils.js";let O=class extends(m(v(u(b(g(L(s(c)))))))){constructor(e){super(e),this.allLayers=new i({getCollections:()=>[this.layers],getChildrenFunction:e=>"layers"in e?e.layers:null}),this.allTables=j(this),this.fullExtent=void 0,this.operationalLayerType="GroupLayer",this.spatialReference=void 0,this.type="group"}initialize(){this._enforceVisibility(this.visibilityMode,this.visible),this.addHandles([o((()=>{let e=this.parent;for(;e&&"parent"in e&&e.parent;)e=e.parent;return e&&w in e}),(e=>{const i="prevent-adding-tables";this.removeHandles(i),e&&(this.tables.removeAll(),this.addHandles(a((()=>this.tables),"before-add",(e=>{e.preventDefault(),r.getLogger(this).errorOnce("tables","tables in group layers in a webscene are not supported. Please move the tables from the group layer to the webscene if you want to persist them.")})),i))}),l),o((()=>this.visible),this._onVisibilityChange.bind(this),n)])}destroy(){this.allLayers.destroy(),this.allTables.destroy()}_writeLayers(e,i,t,r){const s=[];if(!e)return s;e.forEach((e=>{const i=_(e,r.webmap?r.webmap.getLayerJSONFromResourceInfo(e):null,r);i?.layerType&&s.push(i)})),i.layers=s}set portalItem(e){this._set("portalItem",e)}set visibilityMode(e){const i=this._get("visibilityMode")!==e;this._set("visibilityMode",e),i&&this._enforceVisibility(e,this.visible)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection","Scene Service"],layerModuleTypeMap:f},e)),Promise.resolve(this)}async loadAll(){return t(this,(e=>{e(this.layers,this.tables)}))}layerAdded(e){e.visible&&"exclusive"===this.visibilityMode?this._turnOffOtherLayers(e):"inherited"===this.visibilityMode&&(e.visible=this.visible),this.hasHandles(e.uid)?console.error(`Layer readded to Grouplayer: uid=${e.uid}`):this.addHandles(o((()=>e.visible),(i=>this._onChildVisibilityChange(e,i)),n),e.uid)}layerRemoved(e){this.removeHandles(e.uid),this._enforceVisibility(this.visibilityMode,this.visible)}_turnOffOtherLayers(e){this.layers.forEach((i=>{i!==e&&(i.visible=!1)}))}_enforceVisibility(e,i){if(!d(this).initialized)return;const t=this.layers;let r=t.find((e=>e.visible));switch(e){case"exclusive":t.length&&!r&&(r=t.at(0),r.visible=!0),this._turnOffOtherLayers(r);break;case"inherited":t.forEach((e=>{e.visible=i}))}}_onVisibilityChange(e){"inherited"===this.visibilityMode&&this.layers.forEach((i=>{i.visible=e}))}_onChildVisibilityChange(e,i){switch(this.visibilityMode){case"exclusive":i?this._turnOffOtherLayers(e):this._isAnyLayerVisible()||(e.visible=!0);break;case"inherited":e.visible=this.visible}}_isAnyLayerVisible(){return this.layers.some((e=>e.visible))}};e([p({readOnly:!0,dependsOn:[]})],O.prototype,"allLayers",void 0),e([p({readOnly:!0})],O.prototype,"allTables",void 0),e([p()],O.prototype,"fullExtent",void 0),e([p({json:{read:!0,write:!0}})],O.prototype,"blendMode",void 0),e([p({json:{read:!1,write:{ignoreOrigin:!0}}})],O.prototype,"layers",void 0),e([h("layers")],O.prototype,"_writeLayers",null),e([p({type:["GroupLayer"]})],O.prototype,"operationalLayerType",void 0),e([p({json:{origins:{"web-document":{read:!1,write:!1}}}})],O.prototype,"portalItem",null),e([p()],O.prototype,"spatialReference",void 0),e([p({json:{read:!1},readOnly:!0,value:"group"})],O.prototype,"type",void 0),e([p({type:["independent","inherited","exclusive"],value:"independent",json:{write:!0,origins:{"web-map":{type:["independent","exclusive"],write:(e,i,t)=>{"inherited"!==e&&(i[t]=e)}}}}})],O.prototype,"visibilityMode",null),O=e([y("esri.layers.GroupLayer")],O);const M=O;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import i from"../core/CollectionFlattener.js";import{loadAll as r}from"../core/loadAll.js";import t from"../core/Logger.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{debounce as o,throwIfAbortError as a}from"../core/promiseUtils.js";import{watch as l,syncAndInitial as p,on as n,sync as d}from"../core/reactiveUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as c}from"../core/accessorSupport/utils.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{writer as u}from"../core/accessorSupport/decorators/writer.js";import{OriginId as b}from"../core/accessorSupport/PropertyOrigin.js";import v from"./Layer.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as w}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as L}from"./mixins/ScaleRangeLayer.js";import{layerLookupMap as g}from"./support/lazyLayerLoader.js";import S from"../portal/PortalItem.js";import{createFlattenedTablesCollection as _}from"../support/collectionUtils.js";import{LayersMixin as O}from"../support/LayersMixin.js";import{TablesMixin as I}from"../support/TablesMixin.js";import{WebSceneTag as M}from"../support/tagSymbols.js";import{SaveOperationType as x}from"../webdoc/interfaces.js";import{beforeSave as A}from"../webdoc/support/saveUtils.js";import{getLayerJSON as V}from"../webdoc/support/writeUtils.js";let P=class extends(f(L(j(w(I(O(s(v)))))))){constructor(e){super(e),this.allLayers=new i({getCollections:()=>[this.layers],getChildrenFunction:e=>"layers"in e?e.layers:null}),this.allTables=_(this),this.fullExtent=void 0,this.operationalLayerType="GroupLayer",this.spatialReference=void 0,this.type="group",this._debouncedSaveOperations=o((async(e,i,r)=>{const{save:t,saveAs:s}=await import("./save/groupLayerUtils.js");switch(e){case x.SAVE:return t(this,i);case x.SAVE_AS:return s(this,r,i)}}))}initialize(){this._enforceVisibility(this.visibilityMode,this.visible),this.addHandles([l((()=>{let e=this.parent;for(;e&&"parent"in e&&e.parent;)e=e.parent;return e&&M in e}),(e=>{const i="prevent-adding-tables";this.removeHandles(i),e&&(this.tables.removeAll(),this.addHandles(n((()=>this.tables),"before-add",(e=>{e.preventDefault(),t.getLogger(this).errorOnce("tables","tables in group layers in a webscene are not supported. Please move the tables from the group layer to the webscene if you want to persist them.")})),i))}),p),l((()=>this.visible),this._onVisibilityChange.bind(this),d)])}destroy(){this.allLayers.destroy(),this.allTables.destroy()}_writeLayers(e,i,r,t){const s=[];if(!e)return s;e.forEach((e=>{const i=V(e,t.webmap?t.webmap.getLayerJSONFromResourceInfo(e):null,t);i?.layerType&&s.push(i)})),i.layers=s}set portalItem(e){this._set("portalItem",e)}readPortalItem(e,i,r){const{itemId:t,layerType:s}=i;if("GroupLayer"===s&&t)return new S({id:t,portal:r?.portal})}writePortalItem(e,i){e?.id&&(i.itemId=e.id)}set visibilityMode(e){const i=this._get("visibilityMode")!==e;this._set("visibilityMode",e),i&&this._enforceVisibility(e,this.visible)}async beforeSave(){return A(this)}load(e){const i=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection","Group Layer","Scene Service"],layerModuleTypeMap:g},e).catch((e=>{if(a(e),this.originIdOf("portalItem")===b.USER)throw e}));return this.addResolvingPromise(i),Promise.resolve(this)}async loadAll(){return r(this,(e=>{e(this.layers,this.tables)}))}layerAdded(e){e.visible&&"exclusive"===this.visibilityMode?this._turnOffOtherLayers(e):"inherited"===this.visibilityMode&&(e.visible=this.visible),this.hasHandles(e.uid)?console.error(`Layer readded to Grouplayer: uid=${e.uid}`):this.addHandles(l((()=>e.visible),(i=>this._onChildVisibilityChange(e,i)),d),e.uid)}layerRemoved(e){this.removeHandles(e.uid),this._enforceVisibility(this.visibilityMode,this.visible)}async save(e){return this._debouncedSaveOperations(x.SAVE,e)}async saveAs(e,i){return this._debouncedSaveOperations(x.SAVE_AS,i,e)}_turnOffOtherLayers(e){this.layers.forEach((i=>{i!==e&&(i.visible=!1)}))}_enforceVisibility(e,i){if(!c(this).initialized)return;const r=this.layers;let t=r.find((e=>e.visible));switch(e){case"exclusive":r.length&&!t&&(t=r.at(0),t.visible=!0),this._turnOffOtherLayers(t);break;case"inherited":r.forEach((e=>{e.visible=i}))}}_onVisibilityChange(e){"inherited"===this.visibilityMode&&this.layers.forEach((i=>{i.visible=e}))}_onChildVisibilityChange(e,i){switch(this.visibilityMode){case"exclusive":i?this._turnOffOtherLayers(e):this._isAnyLayerVisible()||(e.visible=!0);break;case"inherited":e.visible=this.visible}}_isAnyLayerVisible(){return this.layers.some((e=>e.visible))}};e([y({readOnly:!0,dependsOn:[]})],P.prototype,"allLayers",void 0),e([y({readOnly:!0})],P.prototype,"allTables",void 0),e([y()],P.prototype,"fullExtent",void 0),e([y({json:{read:!0,write:!0}})],P.prototype,"blendMode",void 0),e([y({json:{read:!1,write:{ignoreOrigin:!0}}})],P.prototype,"layers",void 0),e([u("layers")],P.prototype,"_writeLayers",null),e([y({type:["GroupLayer"]})],P.prototype,"operationalLayerType",void 0),e([y({json:{origins:{"web-map":{read:!1,write:{overridePolicy:e=>({enabled:"Group Layer"===e?.type})}},"web-scene":{read:!1,write:!1}}}})],P.prototype,"portalItem",null),e([h("web-map","portalItem",["itemId"])],P.prototype,"readPortalItem",null),e([u("web-map","portalItem",{itemId:{type:String}})],P.prototype,"writePortalItem",null),e([y()],P.prototype,"spatialReference",void 0),e([y({json:{read:!1},readOnly:!0,value:"group"})],P.prototype,"type",void 0),e([y({type:["independent","inherited","exclusive"],value:"independent",json:{write:!0,origins:{"web-map":{type:["independent","exclusive"],write:(e,i,r)=>{"inherited"!==e&&(i[r]=e)}}}}})],P.prototype,"visibilityMode",null),P=e([m("esri.layers.GroupLayer")],P);const E=P;export{E as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import"../renderers/support/jsonUtils.js";import{webSceneRendererTypes as i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"./Layer.js";import{APIKeyMixin as w}from"./mixins/APIKeyMixin.js";import{ArcGISService as I}from"./mixins/ArcGISService.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as F}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as _,SaveOperationType as E}from"./mixins/SceneService.js";import{isHostedAgolService as O}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as A}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as P}from"./support/capabilities.js";import{elevationInfo as T,labelsVisible as D,legendEnabled as U,popupEnabled as x,screenSizePerspectiveEnabled as R}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as q}from"./support/featureLayerUtils.js";import{FeatureReduction as C}from"./support/FeatureReduction.js";import G from"./support/FeatureReductionSelection.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import N from"./support/FieldsIndex.js";import{fixRendererFields as k,unpackFieldNames as V}from"./support/fieldUtils.js";import{I3SNodePageDefinition as K,I3SMaterialDefinition as H,I3STextureSetDefinition as M,I3SGeometryDefinition as $}from"./support/I3SLayerDefinitions.js";import z from"./support/LabelClass.js";import{reader as W}from"./support/labelingInfo.js";import B from"./support/LayerFloorInfo.js";import{layerLookupMap as Z}from"./support/lazyLayerLoader.js";import{RangeInfo as J}from"./support/RangeInfo.js";import X from"./support/SceneFilter.js";import{loadStyleRenderer as Y}from"../renderers/support/styleUtils.js";import ee from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as te,elevationModeUnsupportedMessage as re,featureExpressionUnsupportedMessage as ie}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as se}from"../support/featureFlags.js";import{createPopupTemplate as oe}from"../support/popupUtils.js";import{queryAttributesFromCachedAttributesId as ae}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as ne,getFetchPopupTemplate as le}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as pe}from"../webdoc/support/opacityUtils.js";const de=new Set(["3DObject","Point"]),ye=Q();let ue=class extends(L(_(I(j(F(S(p(w(o(b)))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new a,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new N(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:K.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&q(this.associatedLayer)}get geometryType(){return he[this.profile]||"mesh"}set renderer(e){k(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:P;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,w=!!this.associatedLayer?.infoFor3D&&se();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:w&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:w&&c&&b,supportsDelete:w&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&ce[r]?ce[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await Y(this,{origin:"service"},t),k(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new ee;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=V(this.fieldsIndex,await ne(this,le(this)));return ae(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return oe(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new n("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(E.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(E.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");if(await this.load(),!this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),r(this,this.associatedLayer.source,e,t)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!de.has(e.layerType))throw new n("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new n("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new n("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new n("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!se()||null==this.associatedLayer?.infoFor3D||!r||!O(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await A(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,apiKey:this.apiKey,signal:e}),s=await Z.FeatureLayer();this.associatedLayer=new s({url:t,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&te(l.getLogger(this),re("Mesh scene layers","relative-to-scene",e)),te(l.getLogger(this),ie("Scene layers",e))}};e([h({types:{key:"type",base:C,typeMap:{selection:G}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ue.prototype,"featureReduction",void 0),e([h({type:[J],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ue.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],ue.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],ue.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],ue.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],ue.prototype,"type",void 0),e([h({...ye.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"fields",void 0),e([h()],ue.prototype,"types",null),e([h()],ue.prototype,"typeIdField",null),e([h()],ue.prototype,"templates",null),e([h()],ue.prototype,"formTemplate",null),e([h({readOnly:!0})],ue.prototype,"fieldsIndex",null),e([h({type:B,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ue.prototype,"floorInfo",void 0),e([h(ye.outFields)],ue.prototype,"outFields",void 0),e([h({type:K,readOnly:!0,json:{read:!1}})],ue.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],ue.prototype,"readNodePages",null),e([h({type:[H],readOnly:!0})],ue.prototype,"materialDefinitions",void 0),e([h({type:[M],readOnly:!0})],ue.prototype,"textureSetDefinitions",void 0),e([h({type:[$],readOnly:!0})],ue.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],ue.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],ue.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],ue.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ue.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ue.prototype,"definitionExpression",void 0),e([h({type:X,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ue.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ue.prototype,"path",void 0),e([h(T)],ue.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],ue.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],ue.prototype,"effectiveEditingEnabled",null),e([h({type:String})],ue.prototype,"geometryType",null),e([h(D)],ue.prototype,"labelsVisible",void 0),e([h({type:[z],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:W},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:W},write:!0}})],ue.prototype,"labelingInfo",void 0),e([h(U)],ue.prototype,"legendEnabled",void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?pe(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ue.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ue.prototype,"renderer",null),e([h({json:{read:!1}})],ue.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],ue.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],ue.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],ue.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ue.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ue.prototype,"relationships",null),e([h(x)],ue.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],ue.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],ue.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],ue.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],ue.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],ue.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],ue.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],ue.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],ue.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],ue.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ue.prototype,"normalReferenceFrame",void 0),e([h(R)],ue.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"serviceItemId",void 0),ue=e([g("esri.layers.SceneLayer")],ue);const ce={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},he={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},fe=ue;export{fe as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import"../renderers/support/jsonUtils.js";import{webSceneRendererTypes as i}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import a from"../core/Collection.js";import n from"../core/Error.js";import l from"../core/Logger.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,isAbortError as y}from"../core/promiseUtils.js";import{whenOnce as u}from"../core/reactiveUtils.js";import{join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as v}from"../core/accessorSupport/PropertyOrigin.js";import b from"./Layer.js";import{APIKeyMixin as I}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as F}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as _,SaveOperationType as O}from"./mixins/SceneService.js";import{isHostedAgolService as E}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as A}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as P}from"./support/capabilities.js";import{elevationInfo as T,labelsVisible as D,legendEnabled as U,popupEnabled as x,screenSizePerspectiveEnabled as R}from"./support/commonProperties.js";import{computeEffectiveEditingEnabled as q,getGlobalIdToObjectIdMap as C}from"./support/featureLayerUtils.js";import{FeatureReduction as G}from"./support/FeatureReduction.js";import Q from"./support/FeatureReductionSelection.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import k from"./support/FieldsIndex.js";import{fixRendererFields as V,unpackFieldNames as K}from"./support/fieldUtils.js";import{I3SNodePageDefinition as H,I3SMaterialDefinition as M,I3STextureSetDefinition as $,I3SGeometryDefinition as z}from"./support/I3SLayerDefinitions.js";import W from"./support/LabelClass.js";import{reader as B}from"./support/labelingInfo.js";import Z from"./support/LayerFloorInfo.js";import{layerLookupMap as J}from"./support/lazyLayerLoader.js";import{RangeInfo as X}from"./support/RangeInfo.js";import Y from"./support/SceneFilter.js";import{loadStyleRenderer as ee}from"../renderers/support/styleUtils.js";import te from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as re,elevationModeUnsupportedMessage as ie,featureExpressionUnsupportedMessage as se}from"../support/elevationInfoUtils.js";import{sceneLayerEditingEnabled as oe}from"../support/featureFlags.js";import{createPopupTemplate as ae}from"../support/popupUtils.js";import{queryAttributesFromCachedAttributesId as ne}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as le,getFetchPopupTemplate as pe}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as de}from"../webdoc/support/opacityUtils.js";const ye=new Set(["3DObject","Point"]),ue=N();let ce=class extends(L(_(w(j(F(S(p(I(o(b)))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new a,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new k(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:H.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&q(this.associatedLayer)}get geometryType(){return fe[this.profile]||"mesh"}set renderer(e){V(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:P;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,I=!!this.associatedLayer?.infoFor3D&&oe();return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:I&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:I&&c&&b,supportsDelete:I&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&he[r]?he[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=null!=e?e.signal:null;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await ee(this,{origin:"service"},t),V(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new te;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=K(this.fieldsIndex,await le(this,pe(this)));return ne(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new n("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return ae(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new n("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new n("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new n("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new n("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const i of this.statisticsInfo)if(i.name===r.name){const e=c(this.parsedUrl.path,i.href);return s(e,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new n("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(O.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(O.SAVE,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s;return E(s.url)&&s.infoFor3D&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await C(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new n(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!ye.has(e.layerType))throw new n("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new n("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new n("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new n("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new n("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new n("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=f(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===v.SERVICE||o===v.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.editingInfo?.lastEditDate,t=this.associatedLayer?.serverGens,r=this.associatedLayer?.getAtOrigin("fullExtent","service");if(!oe()||null==this.associatedLayer?.infoFor3D||!r||!E(this.associatedLayer?.url)||!e||this.serviceUpdateTimeStamp?.lastUpdate===e.getTime()||!this.serviceUpdateTimeStamp&&t?.minServerGen===t?.serverGen)return;f(this).setAtOrigin("fullExtent",r.clone(),v.SERVICE)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await A(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,apiKey:this.apiKey,signal:e}),s=await J.FeatureLayer();this.associatedLayer=new s({url:t,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await u((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&re(l.getLogger(this),ie("Mesh scene layers","relative-to-scene",e)),re(l.getLogger(this),se("Scene layers",e))}};e([h({types:{key:"type",base:G,typeMap:{selection:Q}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ce.prototype,"featureReduction",void 0),e([h({type:[X],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ce.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],ce.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],ce.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],ce.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],ce.prototype,"type",void 0),e([h({...ue.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"fields",void 0),e([h()],ce.prototype,"types",null),e([h()],ce.prototype,"typeIdField",null),e([h()],ce.prototype,"templates",null),e([h()],ce.prototype,"formTemplate",null),e([h({readOnly:!0})],ce.prototype,"fieldsIndex",null),e([h({type:Z,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ce.prototype,"floorInfo",void 0),e([h(ue.outFields)],ce.prototype,"outFields",void 0),e([h({type:H,readOnly:!0,json:{read:!1}})],ce.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],ce.prototype,"readNodePages",null),e([h({type:[M],readOnly:!0})],ce.prototype,"materialDefinitions",void 0),e([h({type:[$],readOnly:!0})],ce.prototype,"textureSetDefinitions",void 0),e([h({type:[z],readOnly:!0})],ce.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],ce.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],ce.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],ce.prototype,"statisticsInfo",void 0),e([h({type:a.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ce.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ce.prototype,"definitionExpression",void 0),e([h({type:Y,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ce.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ce.prototype,"path",void 0),e([h(T)],ce.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],ce.prototype,"effectiveEditingEnabled",null),e([h({type:String})],ce.prototype,"geometryType",null),e([h(D)],ce.prototype,"labelsVisible",void 0),e([h({type:[W],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:B},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:B},write:!0}})],ce.prototype,"labelingInfo",void 0),e([h(U)],ce.prototype,"legendEnabled",void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?de(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ce.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"semantic",void 0),e([h({types:i,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ce.prototype,"renderer",null),e([h({json:{read:!1}})],ce.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],ce.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],ce.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],ce.prototype,"relationships",null),e([h(x)],ce.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],ce.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],ce.prototype,"defaultPopupTemplate",null),e([h({type:String,json:{read:!1}})],ce.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],ce.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],ce.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],ce.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],ce.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],ce.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ce.prototype,"normalReferenceFrame",void 0),e([h(R)],ce.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],ce.prototype,"serviceItemId",void 0),ce=e([g("esri.layers.SceneLayer")],ce);const he={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},fe={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},me=ce;export{me as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{PositionHint as e,indexOf as t}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import{isSerializable as s}from"../../../core/JSONSupport.js";import{clone as r}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{MemCacheStorage as u,MemCache as o}from"../../../core/MemCache.js";import{throwIfAborted as l}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as c}from"../../../core/unitUtils.js";import{getTransformation as h}from"../../../geometry/projection.js";import{set as m,negativeInfinity as p,create as f,expandWithAABB as y}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as d,create as g}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as x}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as w,isPolygon as S}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as F}from"../../../geometry/support/normalizeUtils.js";import{equals as R,isValid as Q}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as E,validateFields as j,validateFieldTypes as A,validateWhere as b,validateHaving as P,validNumericTypesKebabDict as q,validDateTypesKebabDict as T,hasInvalidFieldType as C}from"./attributeSupport.js";import{checkProjectionSupport as B,project as k,projectMany as v}from"./projectionSupport.js";import{queryCapabilities as z}from"./QueryEngineCapabilities.js";import{QueryEngineResult as M}from"./QueryEngineResult.js";import{getSpatialQueryOperator as O,canQueryWithRBush as G,checkSpatialQuerySupport as N}from"./spatialQuerySupport.js";import{getTimeExtent as U,getTimeOperator as Z}from"./timeSupport.js";import{queryEngineEmptyResult as V,normalizeQueryLike as H,cleanFromGeometryEngine as J,normalizeQuery as L,getGeometry as D}from"./utils.js";import $ from"../../support/FieldsIndex.js";import{loadArcade as W}from"../../../support/arcadeOnDemand.js";import{noBudget as K}from"../../../views/support/Scheduler.js";function X(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}const Y="feature-store:unsupported-query";class ee{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const te=new u(2e6);let ie=0;class se{constructor(e){this._geometryQueryCache=null,this._changeHandle=null,this.capabilities={query:z},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new o(ie+++"$$",te)),this.fieldsIndex=s(e.fieldsIndex)?e.fieldsIndex:$.fromJSON(e.fieldsIndex),e.scheduler&&e.priority&&(this._frameTask=e.scheduler.registerTask(e.priority))}destroy(){this._frameTask=a(this._frameTask),this.clearCache(),n(this._geometryQueryCache),this._changeHandle=a(this._changeHandle)}get featureAdapter(){return this.featureStore.featureAdapter}clearCache(){this._geometryQueryCache?.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async executeQuery(e,t){try{return(await this._executeQuery(e,{},t)).createQueryResponse()}catch(i){if(i!==V)throw i;return new M([],e,this).createQueryResponse()}}async executeQueryForCount(e={},t){try{return(await this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null},t)).createQueryResponseForCount()}catch(i){if(i!==V)throw i;return 0}}async executeQueryForExtent(e,t){const i=e.outSR;try{const s=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},t),r=s.size;if(!r)return{count:0,extent:null};return{count:r,extent:await this._getBounds(s.items,s.spatialReference,i||this.spatialReference)}}catch(s){if(s===V)return{count:0,extent:null};throw s}}async executeQueryForIds(e,t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e,t){try{const i=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},t),s=i.items,r=new Set;return await this._reschedule((()=>{for(const e of s)r.add(i.featureAdapter.getObjectId(e))}),t),r}catch(i){if(i===V)return new Set;throw i}}async executeQueryForSnapping(e,t){const{point:i,distance:s,returnEdge:a,returnVertex:n}=e;if(!a&&!n)return{candidates:[]};let u=r(e.query);u=await this._schedule((()=>H(u,this.definitionExpression,this.spatialReference)),t),u=await this._reschedule((()=>this._checkQuerySupport(u)),t);const o=!R(i.spatialReference,this.spatialReference);o&&await B(i.spatialReference,this.spatialReference);const l="number"==typeof s?s:s.x,c="number"==typeof s?s:s.y,h={xmin:i.x-l,xmax:i.x+l,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},m=o?k(h,this.spatialReference):h;if(!m)return{candidates:[]};const p=(await F(_(i),null,{signal:t}))[0],f=(await F(_(m),null,{signal:t}))[0];if(null==p||null==f)return{candidates:[]};const y=new M(await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(f.toJSON()))),t),u,this);await this._reschedule((()=>this._executeObjectIdsQuery(y)),t),await this._reschedule((()=>this._executeTimeQuery(y)),t),await this._reschedule((()=>this._executeAttributesQuery(y)),t),await this._reschedule((()=>this._executeGeometryQueryForSnapping(y,t)),t);const d=p.toJSON(),g=o?k(d,this.spatialReference):d,x=o?Math.max(m.xmax-m.xmin,m.ymax-m.ymin)/2:s;return y.createSnappingResponse({...e,point:g,distance:x},i.spatialReference)}async executeQueryForLatestObservations(e,t){if(!this.timeInfo?.trackIdField)throw new i(Y,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});try{const i=await this._executeQuery(e,{},t);return await this._reschedule((()=>this._filterLatest(i)),t),i.createQueryResponse()}catch(s){if(s!==V)throw s;return new M([],e,this).createQueryResponse()}}async executeQueryForSummaryStatistics(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createSummaryStatisticsResponse(t)}async executeQueryForUniqueValues(e={},t,i){const{field:s,field2:r,field3:a,valueExpression:n}=t;return(await this._getQueryEngineResultForStats(e,{field:s,field2:r,field3:a,valueExpression:n},i)).createUniqueValuesResponse(t)}async executeQueryForClassBreaks(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createClassBreaksResponse(t)}async executeQueryForHistogram(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createHistogramResponse(t)}async fetchRecomputedExtents(e){this._timeExtentPromise||=U(this.timeInfo,this.featureStore);const[t,i]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return l(e),{fullExtent:t,timeExtent:i}}async _getBounds(e,t,i){const s=m(f(),p);await this.featureStore.forEachBounds(e,(e=>y(s,e)));const r={xmin:s[0],ymin:s[1],xmax:s[3],ymax:s[4],spatialReference:J(this.spatialReference)};this.hasZ&&isFinite(s[2])&&isFinite(s[5])&&(r.zmin=s[2],r.zmax=s[5]);const a=k(r,t,i);if(a.spatialReference=J(i),a.xmax-a.xmin==0){const e=c(a.spatialReference);a.xmin-=e,a.xmax+=e}if(a.ymax-a.ymin==0){const e=c(a.spatialReference);a.ymin-=e,a.ymax+=e}if(this.hasZ&&null!=a.zmin&&null!=a.zmax&&a.zmax-a.zmin==0){const e=c(a.spatialReference);a.zmin-=e,a.zmax+=e}return a}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then((e=>this._getBounds(e,this.spatialReference,this.spatialReference))),this._fullExtentPromise}async _schedule(e,t){return null!=this._frameTask?this._frameTask.schedule(e,t):e(K)}async _reschedule(e,t){return null!=this._frameTask?this._frameTask.reschedule(e,t):e(K)}async _getAllFeaturesQueryEngineResult(e){return new M(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>{await this.featureStore.forEach((t=>e.push(t)))})().then((()=>e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async _executeQuery(e,t,i){e=r(e),e=await this._schedule((()=>L(e,this.definitionExpression,this.spatialReference)),i),e=await this._reschedule((()=>this._checkQuerySupport(e)),i),e={...e,...t};const s=await this._reschedule((()=>this._executeSceneFilterQuery(e,i)),i),a=await this._reschedule((()=>this._executeGeometryQuery(e,s,i)),i);return await this._reschedule((()=>this._executeAggregateIdsQuery(a)),i),await this._reschedule((()=>this._executeObjectIdsQuery(a)),i),await this._reschedule((()=>this._executeTimeQuery(a)),i),await this._reschedule((()=>this._executeAttributesQuery(a)),i),a}async _executeSceneFilterQuery(e,t){if(null==e.sceneFilter)return null;const{outSR:i,returnGeometry:s,returnCentroid:r}=e,a=this.featureStore.featureSpatialReference,n=e.sceneFilter.geometry,u=null==a||R(a,n.spatialReference)?n:k(n,a);if(!u)return null;const o=s||r,l=Q(i)&&!R(this.spatialReference,i)&&o?async e=>this._project(e,i):e=>e,c=this.featureAdapter,h=await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(u))),t);if("disjoint"===e.sceneFilter.spatialRelationship){if(!h.length)return null;const i=new Set;for(const e of h)i.add(c.getObjectId(e));const s=await this._reschedule((()=>this._getAllFeatures()),t),r=await this._reschedule((async()=>{const r=await O("esriSpatialRelDisjoint",u,this.geometryType,this.hasZ,this.hasM),a=e=>!i.has(c.getObjectId(e))||r(c.getGeometry(e)),n=await this._runSpatialFilter(s,a,t);return new M(n,e,this)}),t);return l(r)}if(!h.length)return new M([],e,this);if(this._canExecuteSinglePass(u,e))return l(new M(h,e,this));const m=await O("esriSpatialRelContains",u,this.geometryType,this.hasZ,this.hasM),p=await this._runSpatialFilter(h,(e=>m(c.getGeometry(e))),t);return l(new M(p,e,this))}async _executeGeometryQuery(i,s,r){if(null!=s&&0===s.items.length)return s;i=null!=s?s.query:i;const{geometry:a,outSR:n,spatialRel:u,returnGeometry:o,returnCentroid:l}=i,c=this.featureStore.featureSpatialReference,h=!a||null==c||R(c,a.spatialReference)?a:k(a,c),m=o||l,p=Q(n)&&!R(this.spatialReference,n),f=this._geometryQueryCache&&null==s?p&&m?JSON.stringify({originalFilterGeometry:a,spatialRelationship:u,outSpatialReference:n}):JSON.stringify({originalFilterGeometry:a,spatialRelationship:u}):null,y=f?this._geometryQueryCache.get(f):null;if(null!=y)return new M(y,i,this);const d=async e=>(p&&m&&await this._project(e,n),f&&this._geometryQueryCache.put(f,e.items,e.items.length+1),e);if(!h)return d(null!=s?s:await this._getAllFeaturesQueryEngineResult(i));const g=this.featureAdapter;let x=await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(a))),r);if("esriSpatialRelDisjoint"===u){if(!x.length)return d(null!=s?s:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of x)e.add(g.getObjectId(i));const t=null!=s?s.items:await this._reschedule((()=>this._getAllFeatures()),r),a=await this._reschedule((async()=>{const s=await O(u,h,this.geometryType,this.hasZ,this.hasM),a=t=>!e.has(g.getObjectId(t))||s(g.getGeometry(t)),n=await this._runSpatialFilter(t,a,r);return new M(n,i,this)}),r);return d(a)}if(null!=s){const i=new e;x=x.filter((e=>t(s.items,e,s.items.length,i)>=0))}if(!x.length){const e=new M([],i,this);return f&&this._geometryQueryCache.put(f,e.items,1),e}if(this._canExecuteSinglePass(h,i))return d(new M(x,i,this));const _=await O(u,h,this.geometryType,this.hasZ,this.hasM),w=await this._runSpatialFilter(x,(e=>_(g.getGeometry(e))),r);return d(new M(w,i,this))}async _executeGeometryQueryForSnapping(e,t){const{query:i}=e,{spatialRel:s}=i;if(!e?.items?.length||!i.geometry||!s)return;const r=await O(s,i.geometry,this.geometryType,this.hasZ,this.hasM),a=await this._runSpatialFilter(e.items,(e=>r(e.geometry)),t);e.items=a}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const s of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(s).forEach((e=>t.add(e)))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter((e=>t.has(i(e))))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter((e=>t.has(i(e))))}_executeTimeQuery(e){if(0===e.items.length)return;const t=Z(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=E(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter((e=>t.testFeature(e,this.featureAdapter)))}}async _runSpatialFilter(e,t,i){if(!t)return e;if(null==this._frameTask)return e.filter((e=>t(e)));let s=0;const r=new Array,a=async n=>{for(;s<e.length;){const u=e[s++];t(u)&&(r.push(u),n.madeProgress()),n.done&&await this._reschedule((e=>a(e)),i)}};return this._reschedule((e=>a(e)),i).then((()=>r))}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:s}=this.timeInfo,r=s||i,a=new Map,n=this.featureAdapter.getAttribute;for(const u of e.items){const e=n(u,t),i=n(u,r),s=a.get(e);(!s||i>n(s,r))&&a.set(e,u)}e.items=Array.from(a.values())}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return G(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||R(this.spatialReference,t))return e;const i=this.featureAdapter;let s;try{const e=await this._getFullExtent();s=h(this.spatialReference,t,e)}catch{}const r=await v(e.items.map((e=>D(this.geometryType,this.hasZ,this.hasM,i.getGeometry(e)))),this.spatialReference,t,s);return e.items=r.map(((t,s)=>i.cloneWithGeometry(e.items[s],I(t,this.hasZ,this.hasM)))),e}_getQueryBBoxes(e){if(G(e)){if(w(e))return[d(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(S(e))return e.rings.map((e=>d(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[x(g(),e)]}async _searchFeatures(e){const t=new Set;await Promise.all(e.map((e=>this.featureStore.forEachInBounds(e,(e=>t.add(e))))));const i=Array.from(t.values());return t.clear(),i}async _checkStatisticsSupport(e,t){if((e.distance??0)<0||null!=e.geometryPrecision||e.multipatchOption||e.pixelSize||e.relationParam||e.text||e.outStatistics||e.groupByFieldsForStatistics||e.having||e.orderByFields)throw new i(Y,"Unsupported query options",{query:e});return this._checkAttributesQuerySupport(e),Promise.all([this._checkStatisticsParamsSupport(t,e),N(e,this.geometryType,this.spatialReference),B(this.spatialReference,e.outSR)]).then((()=>e))}async _checkStatisticsParamsSupport(e,t){let s=[];if(e.valueExpression){const{arcadeUtils:t}=await W();s=t.extractFieldNames(e.valueExpression)}if(e.field&&s.push(e.field),e.field2&&s.push(e.field2),e.field3&&s.push(e.field3),e.normalizationField&&s.push(e.normalizationField),!s.length&&!e.valueExpression)throw new i(Y,"field or valueExpression is required",{params:e});j(this.fieldsIndex,s,{errorMessage:"Cannot calculate statistics for missing fields",query:t}),A(this.fieldsIndex,s,{expressionName:"statistics",query:t})}async _checkQuerySupport(e){if((e.distance??0)<0||null!=e.geometryPrecision||e.multipatchOption||e.pixelSize||e.relationParam||e.text)throw new i(Y,"Unsupported query options",{query:e});return this._checkAttributesQuerySupport(e),this._checkStatisticsQuerySupport(e),Promise.all([N(e,this.geometryType,this.spatialReference),B(this.spatialReference,e.outSR)]).then((()=>e))}_checkAttributesQuerySupport(e){const{outFields:t,orderByFields:s,returnDistinctValues:r,outStatistics:a}=e,n=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(s&&s.length>0){const t=" asc",i=" desc",r=s.map((e=>{const s=e.toLowerCase();return s.includes(t)?s.split(t)[0]:s.includes(i)?s.split(i)[0]:e})).filter((e=>!n.includes(e)));j(this.fieldsIndex,r,{expressionName:"orderByFields",query:e})}if(t&&t.length>0)j(this.fieldsIndex,t,{expressionName:"outFields",query:e});else if(r)throw new i(Y,"outFields should be specified for returnDistinctValues",{query:e});b(this.fieldsIndex,e.where,e)}_checkStatisticsQuerySupport(e){const{outStatistics:t,groupByFieldsForStatistics:s,having:r}=e,a=s?.length,n=t?.length;if(r){if(!a||!n)throw new i(Y,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:e});P(this.fieldsIndex,r,t,e)}if(n){if(!X(t))return;const r=t.map((e=>e.onStatisticField)).filter(Boolean);j(this.fieldsIndex,r,{expressionName:"onStatisticFields",query:e}),a&&j(this.fieldsIndex,s,{expressionName:"groupByFieldsForStatistics",query:e});const n=new Set([...q.jsonValues,...T.jsonValues]),u=new Intl.ListFormat("en-US",{type:"conjunction"}).format([...q.apiValues,...T.apiValues]);for(const s of t){const{onStatisticField:t,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:t}=s;if(!t)throw new i(Y,"statisticParameters should be set for percentile type",{definition:s,query:e})}else if("count"!==r&&"min"!==r&&"max"!==r&&t&&C(t,this.fieldsIndex,n))throw new i(Y,`outStatistics with '${r}' statistic type, only supports ${u} field types`,{definition:s,query:e})}}}async _getQueryEngineResultForStats(e,t,i){e=r(e);try{e=await this._schedule((()=>L(e,this.definitionExpression,this.spatialReference)),i),e=await this._reschedule((()=>this._checkStatisticsSupport(e,t)),i);const s=await this._reschedule((()=>this._executeSceneFilterQuery(e,i)),i),r=await this._reschedule((()=>this._executeGeometryQuery(e,s,i)),i);return await this._reschedule((()=>this._executeAggregateIdsQuery(r)),i),await this._reschedule((()=>this._executeObjectIdsQuery(r)),i),await this._reschedule((()=>this._executeTimeQuery(r)),i),await this._reschedule((()=>this._executeAttributesQuery(r)),i),r}catch(s){if(s!==V)throw s;return new M([],e,this)}}}export{ee as Feature,se as QueryEngine};
5
+ import{PositionHint as e,indexOf as t}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import{isSerializable as s}from"../../../core/JSONSupport.js";import{clone as r}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{MemCacheStorage as o,MemCache as u}from"../../../core/MemCache.js";import{throwIfAborted as l}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as c}from"../../../core/unitUtils.js";import{getTransformation as h}from"../../../geometry/projection.js";import{set as m,negativeInfinity as p,create as f,expandWithAABB as y}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as d,create as g}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as x}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as w,isPolygon as S}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as F}from"../../../geometry/support/normalizeUtils.js";import{equals as R,isValid as Q}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as E,validateFields as j,validateFieldTypes as A,validateWhere as b,validateHaving as P,validNumericTypesKebabDict as q,validDateTypesKebabDict as T,hasInvalidFieldType as C}from"./attributeSupport.js";import{checkProjectionSupport as B,project as k,projectMany as v}from"./projectionSupport.js";import{queryCapabilities as M}from"./QueryEngineCapabilities.js";import{QueryEngineResult as z}from"./QueryEngineResult.js";import{getSpatialQueryOperator as O,canQueryWithRBush as G,checkSpatialQuerySupport as N}from"./spatialQuerySupport.js";import{getTimeExtent as U,getTimeOperator as Z}from"./timeSupport.js";import{queryEngineEmptyResult as V,normalizeQueryLike as H,cleanFromGeometryEngine as J,normalizeQuery as L,getGeometry as D}from"./utils.js";import $ from"../../support/FieldsIndex.js";import{loadArcade as W}from"../../../support/arcadeOnDemand.js";import{noBudget as K}from"../../../views/support/Scheduler.js";function X(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}const Y="feature-store:unsupported-query";class ee{constructor(e,t=null,i,s,r){this.attributes=e,this.geometry=i,this.centroid=s,this.filterFlags=r,this.groupId=-1,this.displayId=t}}const te=new o(2e6);let ie=0;class se{constructor(e){this._geometryQueryCache=null,this._changeHandle=null,this.capabilities={query:M},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.objectIdField=e.objectIdField,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._changeHandle=this.featureStore.events.on("changed",(()=>this.clearCache())),this.timeInfo=e.timeInfo,e.cacheSpatialQueries&&(this._geometryQueryCache=new u(ie+++"$$",te)),this.fieldsIndex=s(e.fieldsIndex)?e.fieldsIndex:$.fromJSON(e.fieldsIndex),e.scheduler&&e.priority&&(this._frameTask=e.scheduler.registerTask(e.priority))}destroy(){this._frameTask=a(this._frameTask),this.clearCache(),n(this._geometryQueryCache),this._changeHandle=a(this._changeHandle)}get featureAdapter(){return this.featureStore.featureAdapter}clearCache(){this._geometryQueryCache?.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async executeQuery(e,t){try{return(await this._executeQuery(e,{},t)).createQueryResponse()}catch(i){if(i!==V)throw i;return new z([],e,this).createQueryResponse()}}async executeQueryForCount(e={},t){try{return(await this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null},t)).createQueryResponseForCount()}catch(i){if(i!==V)throw i;return 0}}async executeQueryForExtent(e,t){const i=e.outSR;try{const s=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},t),r=s.size;if(!r)return{count:0,extent:null};return{count:r,extent:await this._getBounds(s.items,s.spatialReference,i||this.spatialReference)}}catch(s){if(s===V)return{count:0,extent:null};throw s}}async executeQueryForIds(e,t){return this.executeQueryForIdSet(e,t).then((e=>Array.from(e)))}async executeQueryForIdSet(e,t){try{const i=await this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null},t),s=i.items,r=new Set;return await this._reschedule((()=>{for(const e of s)r.add(i.featureAdapter.getObjectId(e))}),t),r}catch(i){if(i===V)return new Set;throw i}}async executeQueryForSnapping(e,t){const{point:i,distance:s,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let o=r(e.query);o=await this._schedule((()=>H(o,this.definitionExpression,this.spatialReference)),t),o=await this._reschedule((()=>this._checkQuerySupport(o)),t);const u=!R(i.spatialReference,this.spatialReference);u&&await B(i.spatialReference,this.spatialReference);const l="number"==typeof s?s:s.x,c="number"==typeof s?s:s.y,h={xmin:i.x-l,xmax:i.x+l,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},m=u?k(h,this.spatialReference):h;if(!m)return{candidates:[]};const p=(await F(_(i),null,{signal:t}))[0],f=(await F(_(m),null,{signal:t}))[0];if(null==p||null==f)return{candidates:[]};const y=new z(await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(f.toJSON()))),t),o,this);await this._reschedule((()=>this._executeObjectIdsQuery(y)),t),await this._reschedule((()=>this._executeTimeQuery(y)),t),await this._reschedule((()=>this._executeAttributesQuery(y)),t),await this._reschedule((()=>this._executeGeometryQueryForSnapping(y,t)),t);const d=p.toJSON(),g=u?k(d,this.spatialReference):d,x=u?Math.max(m.xmax-m.xmin,m.ymax-m.ymin)/2:s;return y.createSnappingResponse({...e,point:g,distance:x},i.spatialReference)}async executeQueryForLatestObservations(e,t){if(!this.timeInfo?.trackIdField)throw new i(Y,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});try{const i=await this._executeQuery(e,{},t);return await this._reschedule((()=>this._filterLatest(i)),t),i.createQueryResponse()}catch(s){if(s!==V)throw s;return new z([],e,this).createQueryResponse()}}async executeQueryForSummaryStatistics(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createSummaryStatisticsResponse(t)}async executeQueryForUniqueValues(e={},t,i){const{field:s,field2:r,field3:a,valueExpression:n}=t;return(await this._getQueryEngineResultForStats(e,{field:s,field2:r,field3:a,valueExpression:n},i)).createUniqueValuesResponse(t)}async executeQueryForClassBreaks(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createClassBreaksResponse(t)}async executeQueryForHistogram(e={},t,i){const{field:s,normalizationField:r,valueExpression:a}=t;return(await this._getQueryEngineResultForStats(e,{field:s,normalizationField:r,valueExpression:a},i)).createHistogramResponse(t)}async fetchRecomputedExtents(e){this._timeExtentPromise||=U(this.timeInfo,this.featureStore);const[t,i]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return l(e),{fullExtent:t,timeExtent:i}}async _getBounds(e,t,i){const s=m(f(),p);await this.featureStore.forEachBounds(e,(e=>y(s,e)));const r={xmin:s[0],ymin:s[1],xmax:s[3],ymax:s[4],spatialReference:J(this.spatialReference)};this.hasZ&&isFinite(s[2])&&isFinite(s[5])&&(r.zmin=s[2],r.zmax=s[5]);const a=k(r,t,i);if(a.spatialReference=J(i),a.xmax-a.xmin==0){const e=c(a.spatialReference);a.xmin-=e,a.xmax+=e}if(a.ymax-a.ymin==0){const e=c(a.spatialReference);a.ymin-=e,a.ymax+=e}if(this.hasZ&&null!=a.zmin&&null!=a.zmax&&a.zmax-a.zmin==0){const e=c(a.spatialReference);a.zmin-=e,a.zmax+=e}return a}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then((e=>this._getBounds(e,this.spatialReference,this.spatialReference))),this._fullExtentPromise}async _schedule(e,t){return null!=this._frameTask?this._frameTask.schedule(e,t):e(K)}async _reschedule(e,t){return null!=this._frameTask?this._frameTask.reschedule(e,t):e(K)}async _getAllFeaturesQueryEngineResult(e){return new z(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>{await this.featureStore.forEach((t=>e.push(t)))})().then((()=>e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async _executeQuery(e,t,i){e=r(e),e=await this._schedule((()=>L(e,this.definitionExpression,this.spatialReference)),i),e=await this._reschedule((()=>this._checkQuerySupport(e)),i),e={...e,...t};const s=await this._reschedule((()=>this._executeSceneFilterQuery(e,i)),i),a=await this._reschedule((()=>this._executeGeometryQuery(e,s,i)),i);return await this._reschedule((()=>this._executeAggregateIdsQuery(a)),i),await this._reschedule((()=>this._executeObjectIdsQuery(a)),i),await this._reschedule((()=>this._executeTimeQuery(a)),i),await this._reschedule((()=>this._executeAttributesQuery(a)),i),a}async _executeSceneFilterQuery(e,t){if(null==e.sceneFilter)return null;const{outSR:i,returnGeometry:s,returnCentroid:r}=e,a=this.featureStore.featureSpatialReference,n=e.sceneFilter.geometry,o=null==a||R(a,n.spatialReference)?n:k(n,a);if(!o)return null;const u=s||r,l=Q(i)&&!R(this.spatialReference,i)&&u?async e=>this._project(e,i):e=>e,c=this.featureAdapter,h=await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(o))),t);if("disjoint"===e.sceneFilter.spatialRelationship){if(!h.length)return null;const i=new Set;for(const e of h)i.add(c.getObjectId(e));const s=await this._reschedule((()=>this._getAllFeatures()),t),r=await this._reschedule((async()=>{const r=await O("esriSpatialRelDisjoint",o,this.geometryType,this.hasZ,this.hasM),a=e=>!i.has(c.getObjectId(e))||r(c.getGeometry(e)),n=await this._runSpatialFilter(s,a,t);return new z(n,e,this)}),t);return l(r)}if(!h.length)return new z([],e,this);if(this._canExecuteSinglePass(o,e))return l(new z(h,e,this));const m=await O("esriSpatialRelContains",o,this.geometryType,this.hasZ,this.hasM),p=await this._runSpatialFilter(h,(e=>m(c.getGeometry(e))),t);return l(new z(p,e,this))}async _executeGeometryQuery(i,s,r){if(null!=s&&0===s.items.length)return s;i=null!=s?s.query:i;const{geometry:a,outSR:n,spatialRel:o,returnGeometry:u,returnCentroid:l}=i,c=this.featureStore.featureSpatialReference,h=!a||null==c||R(c,a.spatialReference)?a:k(a,c),m=u||l,p=Q(n)&&!R(this.spatialReference,n),f=this._geometryQueryCache&&null==s?p&&m?JSON.stringify({originalFilterGeometry:a,spatialRelationship:o,outSpatialReference:n}):JSON.stringify({originalFilterGeometry:a,spatialRelationship:o}):null,y=f?this._geometryQueryCache.get(f):null;if(null!=y)return new z(y,i,this);const d=async e=>(p&&m&&await this._project(e,n),f&&this._geometryQueryCache.put(f,e.items,e.items.length+1),e);if(!h)return d(null!=s?s:await this._getAllFeaturesQueryEngineResult(i));const g=this.featureAdapter;let x=await this._reschedule((()=>this._searchFeatures(this._getQueryBBoxes(a))),r);if("esriSpatialRelDisjoint"===o){if(!x.length)return d(null!=s?s:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of x)e.add(g.getObjectId(i));const t=null!=s?s.items:await this._reschedule((()=>this._getAllFeatures()),r),a=await this._reschedule((async()=>{const s=await O(o,h,this.geometryType,this.hasZ,this.hasM),a=t=>!e.has(g.getObjectId(t))||s(g.getGeometry(t)),n=await this._runSpatialFilter(t,a,r);return new z(n,i,this)}),r);return d(a)}if(null!=s){const i=new e;x=x.filter((e=>t(s.items,e,s.items.length,i)>=0))}if(!x.length){const e=new z([],i,this);return f&&this._geometryQueryCache.put(f,e.items,1),e}if(this._canExecuteSinglePass(h,i))return d(new z(x,i,this));const _=await O(o,h,this.geometryType,this.hasZ,this.hasM),w=await this._runSpatialFilter(x,(e=>_(g.getGeometry(e))),r);return d(new z(w,i,this))}async _executeGeometryQueryForSnapping(e,t){const{query:i}=e,{spatialRel:s}=i;if(!e?.items?.length||!i.geometry||!s)return;const r=await O(s,i.geometry,this.geometryType,this.hasZ,this.hasM),a=await this._runSpatialFilter(e.items,(e=>r(e.geometry)),t);e.items=a}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const s of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(s).forEach((e=>t.add(e)))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter((e=>t.has(i(e))))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter((e=>t.has(i(e))))}_executeTimeQuery(e){if(0===e.items.length)return;const t=Z(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=E(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter((e=>t.testFeature(e,this.featureAdapter)))}}async _runSpatialFilter(e,t,i){if(!t)return e;if(null==this._frameTask)return e.filter((e=>t(e)));let s=0;const r=new Array,a=async n=>{for(;s<e.length;){const o=e[s++];t(o)&&(r.push(o),n.madeProgress()),n.done&&await this._reschedule((e=>a(e)),i)}};return this._reschedule((e=>a(e)),i).then((()=>r))}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:s}=this.timeInfo,r=s||i,a=new Map,n=this.featureAdapter.getAttribute;for(const o of e.items){const e=n(o,t),i=n(o,r),s=a.get(e);(!s||i>n(s,r))&&a.set(e,o)}e.items=Array.from(a.values())}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return G(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||R(this.spatialReference,t))return e;const i=this.featureAdapter;let s;try{const e=await this._getFullExtent();s=h(this.spatialReference,t,e)}catch{}const r=await v(e.items.map((e=>D(this.geometryType,this.hasZ,this.hasM,i.getGeometry(e)))),this.spatialReference,t,s);return e.items=r.map(((t,s)=>i.cloneWithGeometry(e.items[s],I(t,this.hasZ,this.hasM)))),e}_getQueryBBoxes(e){if(G(e)){if(w(e))return[d(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(S(e))return e.rings.map((e=>d(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1]))))}return[x(g(),e)]}async _searchFeatures(e){const t=new Set;await Promise.all(e.map((e=>this.featureStore.forEachInBounds(e,(e=>t.add(e))))));const i=Array.from(t.values());return t.clear(),i}async _checkStatisticsSupport(e,t){if((e.distance??0)<0||null!=e.geometryPrecision||e.multipatchOption||e.pixelSize||e.relationParam||e.text||e.outStatistics||e.groupByFieldsForStatistics||e.having||e.orderByFields)throw new i(Y,"Unsupported query options",{query:e});return this._checkAttributesQuerySupport(e),Promise.all([this._checkStatisticsParamsSupport(t,e),N(e,this.geometryType,this.spatialReference),B(this.spatialReference,e.outSR)]).then((()=>e))}async _checkStatisticsParamsSupport(e,t){let s=[];if(e.valueExpression){const{arcadeUtils:t}=await W();s=t.extractFieldNames(e.valueExpression)}if(e.field&&s.push(e.field),e.field2&&s.push(e.field2),e.field3&&s.push(e.field3),e.normalizationField&&s.push(e.normalizationField),!s.length&&!e.valueExpression)throw new i(Y,"field or valueExpression is required",{params:e});j(this.fieldsIndex,s,{errorMessage:"Cannot calculate statistics for missing fields",query:t}),A(this.fieldsIndex,s,{expressionName:"statistics",query:t})}async _checkQuerySupport(e){if((e.distance??0)<0||null!=e.geometryPrecision||e.multipatchOption||e.pixelSize||e.relationParam||e.text)throw new i(Y,"Unsupported query options",{query:e});return this._checkAttributesQuerySupport(e),this._checkStatisticsQuerySupport(e),Promise.all([N(e,this.geometryType,this.spatialReference),B(this.spatialReference,e.outSR)]).then((()=>e))}_checkAttributesQuerySupport(e){const{outFields:t,orderByFields:s,returnDistinctValues:r,outStatistics:a}=e,n=a?a.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(s&&s.length>0){const t=" asc",i=" desc",r=s.map((e=>{const s=e.toLowerCase();return s.includes(t)?s.split(t)[0]:s.includes(i)?s.split(i)[0]:e})).filter((e=>!n.includes(e)));j(this.fieldsIndex,r,{expressionName:"orderByFields",query:e})}if(t&&t.length>0)j(this.fieldsIndex,t,{expressionName:"outFields",query:e});else if(r)throw new i(Y,"outFields should be specified for returnDistinctValues",{query:e});b(this.fieldsIndex,e.where,e)}_checkStatisticsQuerySupport(e){const{outStatistics:t,groupByFieldsForStatistics:s,having:r}=e,a=s?.length,n=t?.length;if(r){if(!a||!n)throw new i(Y,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:e});P(this.fieldsIndex,r,t,e)}if(n){if(!X(t))return;const r=t.map((e=>e.onStatisticField)).filter(Boolean);j(this.fieldsIndex,r,{expressionName:"onStatisticFields",query:e}),a&&j(this.fieldsIndex,s,{expressionName:"groupByFieldsForStatistics",query:e});const n=new Set([...q.jsonValues,...T.jsonValues]),o=new Intl.ListFormat("en-US",{type:"conjunction"}).format([...q.apiValues,...T.apiValues]);for(const s of t){const{onStatisticField:t,statisticType:r}=s;if(("percentile_disc"===r||"percentile_cont"===r)&&"statisticParameters"in s){const{statisticParameters:t}=s;if(!t)throw new i(Y,"statisticParameters should be set for percentile type",{definition:s,query:e})}else if("count"!==r&&"min"!==r&&"max"!==r&&t&&C(t,this.fieldsIndex,n))throw new i(Y,`outStatistics with '${r}' statistic type, only supports ${o} field types`,{definition:s,query:e})}}}async _getQueryEngineResultForStats(e,t,i){e=r(e);try{e=await this._schedule((()=>L(e,this.definitionExpression,this.spatialReference)),i),e=await this._reschedule((()=>this._checkStatisticsSupport(e,t)),i);const s=await this._reschedule((()=>this._executeSceneFilterQuery(e,i)),i),r=await this._reschedule((()=>this._executeGeometryQuery(e,s,i)),i);return await this._reschedule((()=>this._executeAggregateIdsQuery(r)),i),await this._reschedule((()=>this._executeObjectIdsQuery(r)),i),await this._reschedule((()=>this._executeTimeQuery(r)),i),await this._reschedule((()=>this._executeAttributesQuery(r)),i),r}catch(s){if(s!==V)throw s;return new z([],e,this)}}}export{ee as Feature,se as QueryEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{polygonCentroid as e,extentCentroid as t}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as s}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as a}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as n}from"../../../geometry/support/spatialReferenceUtils.js";import o from"./AttributesBuilder.js";import{project as l}from"./projectionSupport.js";import{makeEdgeCandidate as u,makeVertexCandidate as c}from"./SnappingCandidate.js";import{cleanFromGeometryEngine as d,getGeometry as m,transformCentroid as h}from"./utils.js";import{isStringField as g}from"../../support/fieldUtils.js";import{isNullCountSupported as f,calculateStringStatistics as p,calculateStatistics as y,processSummaryStatisticsResult as x,calculateUniqueValuesCount as I,createUVResult as T,calculateClassBreaks as V,resolveCBResult as F,calculateHistogram as S,getAttributeComparator as _,calculatePercentile as v}from"../../../statistics/utils.js";class z{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasM=i.hasM,this.hasZ=i.hasZ,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new o(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,l=new Set;for(const o of s){const{statisticType:s}=o,a="exceedslimit"!==s?o.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||l.add(r)}}return l.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!n(t.spatialReference,this.query.outSR)?e.queryGeometry=d({spatialReference:this.query.outSR,...l(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=d({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const i=this.featureAdapter,s=b(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},d="esriGeometryPolygon"===this.geometryType,m=this._getPointCreator(r,this.spatialReference,t),h=new A(null,0),g=new A(null,0),f={x:0,y:0,z:0};for(const p of this.items){const t=i.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(h.coords=r,g.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=s){const c=h;if(c.coordsIndex=e,t!==r-1){const t=g;t.coordsIndex=e+s;const r=f;R(f,a,c,t);const d=(a.x-r.x)/n,h=(a.y-r.y)/o,y=d*d+h*h;y<=1&&l.candidates.push(u(i.getObjectId(p),m(r),Math.sqrt(y),m(c),m(t)))}}}}if(e.returnVertex){const e=d?r.length-s:r.length;for(let t=0;t<e;t+=s){const e=h;e.coordsIndex=t;const s=(a.x-e.x)/n,r=(a.y-e.y)/o,u=s*s+r*r;u<=1&&l.candidates.push(c(i.getObjectId(p),m(e),Math.sqrt(u)))}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,i){const s=null==i||n(t,i)?e=>e:e=>l(e,t,i),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:i})=>s({x:e,y:t,z:i}):({x:e,y:t})=>s({x:e,y:t,z:r}):({x:e,y:t})=>s({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.isDateField(t),d=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),m=f({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),h=this.fieldsIndex.get(t),I={value:.5,fieldType:h?.type},T=g(h)?p({values:d,supportsNullCount:m,percentileParams:I}):y({values:d,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:m,percentileParams:I});return x(T,c)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n}),l=I(o);return T(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),g=V(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return F(g,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return S(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.reverse()){const t=s.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=_(r?.type,n);e.sort(((e,t)=>{const s=i(e,a,r),n=i(t,a,r);return o(s,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:i,hasM:s,hasZ:r,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:h,returnZ:g,returnM:f}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:i,hasM:s&&f,hasZ:r&&g,objectIdFieldName:n,spatialReference:d(u||o),transform:c&&a(c)||null}}_createFeatures(e,t){const i=new o(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:r}=this,{orderByFields:n,quantizationParameters:l,returnGeometry:u,returnCentroid:c,maxAllowableOffset:d,resultOffset:g,resultRecordCount:f,returnZ:p=!1,returnM:y=!1}=e,x=r&&p,I=s&&y;let T=[],V=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,s)=>i.getFieldValue(e,t,s))),u||c){const e=a(l)??void 0;if(u&&!c)for(const t of F)T[V++]={attributes:i.getAttributes(t),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,x,I)};else if(!u&&c)for(const t of F)T[V++]={attributes:i.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)T[V++]={attributes:i.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,x,I)}}else for(const a of F){const e=i.getAttributes(a);e&&(T[V++]={attributes:e})}const S=g||0;if(null!=f){const e=S+f;T=T.slice(S,Math.min(T.length,e))}return T}_createExceedsLimitQueryResponse(e){let t=!1,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){i=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,s=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>i;else if(this.items.length>s)t=!0;else{const e=b(this.hasZ,this.hasM),i=this.featureAdapter;t=this.items.reduce(((e,t)=>{const s=i.getGeometry(t);return e+(null!=s&&s.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},i=[],s=new Map,a=new Map,r=new Map,n=new Map,l=new o(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m}=e,h=c?.length,g=!!h,f=g?c[0]:null,p=g&&!this.fieldsIndex.get(f);for(const o of u??[]){const{outStatisticFieldName:e,statisticType:u}=o,m=o,y="exceedslimit"!==u?o.onStatisticField:void 0,x="percentile_disc"===u||"percentile_cont"===u,I="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,T=g&&1===h&&(y===f||p)&&"count"===u;if(g){if(!r.has(y)){const e=[];for(const t of c){const i=this._getAttributeValues(l,t,s);e.push(i)}r.set(y,this._calculateUniqueValues(e,!I&&l.returnDistinctValues))}const t=r.get(y);for(const i in t){const{count:a,data:r,items:o,itemPositions:u}=t[i],h=r.join(",");if(!d||l.validateItems(o,d)){const t=n.get(h)||{attributes:{}};if(I){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(m,o);t.aggregateGeometries[i]=e}else{let i=null;if(T)i=a;else{const e=this._getAttributeValues(l,y,s),t=u.map((t=>e[t]));i=x&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,l.returnDistinctValues)}t.attributes[e]=i}let i=0;c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++i]=r[s])),n.set(h,t)}}}else if(I){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,y,s);t.attributes[e]=x&&"statisticParameters"in m?this._getPercentileValue(m,i):this._getStatisticValue(m,i,a,l.returnDistinctValues)}i.push({name:e,alias:e,type:"esriFieldTypeDouble"})}const y=g?Array.from(n.values()):[t];return this._sortFeatures(y,m,((e,t)=>e.attributes[t])),{fields:i,features:y}}async _getAggregateGeometry(a,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=a,{featureAdapter:c,spatialReference:d,geometryType:h,hasZ:g,hasM:f}=this,p=r.map((e=>m(h,g,f,c.getGeometry(e)))),y=n(d,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?i(y):s(o(d,p));x.aggregateGeometries={...e,spatialReference:d},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const i=y?e(y):t(s(o(d,p)));x.aggregateGeometries={x:i[0],y:i[1],spatialReference:d},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):g(this.fieldsIndex.get(a))?p({values:t,returnDistinct:s}):y({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return v(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i){if(i.has(t))return i.get(t);const s=this.fieldsIndex.get(t),a=this.items.map((i=>e.getFieldValue(i,t,s)));return i.set(t,a),a}_calculateUniqueValues(e,t){const i={},s=this.items,a=s.length;for(let r=0;r<a;r++){const a=s[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==i[o]?i[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(r))}return i}async _getDataValues(e){const t=new o(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:i,scale:s,timeZone:a}=e;return i?t.getExpressionValues(this.items,i,{viewingMode:"map",scale:s,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},a):t.getDataValues(this.items,{field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal})}}function R(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=a*a+r*r,o=(t.x-i.x)*a+(t.y-i.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=i.x+a*l,e.y=i.y+r*l}function b(e,t){return e?t?4:3:t?3:2}class A{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{z as QueryEngineResult};
5
+ import{polygonCentroid as e,extentCentroid as t}from"../../../geometry/support/centroid.js";import{getPolygonExtent as s,getGeometryExtent as i}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as a}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as n}from"../../../geometry/support/spatialReferenceUtils.js";import o from"./AttributesBuilder.js";import{project as l}from"./projectionSupport.js";import{makeEdgeCandidate as u,makeVertexCandidate as c}from"./SnappingCandidate.js";import{cleanFromGeometryEngine as d,getGeometry as m,transformCentroid as h}from"./utils.js";import{isStringField as f}from"../../support/fieldUtils.js";import{isNullCountSupported as g,calculateStringStatistics as p,calculateStatistics as y,processSummaryStatisticsResult as x,calculateUniqueValuesCount as I,createUVResult as T,calculateClassBreaks as V,resolveCBResult as F,calculateHistogram as S,getAttributeComparator as v,calculatePercentile as _}from"../../../statistics/utils.js";class z{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new o(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,l=new Set;for(const o of i){const{statisticType:i}=o,a="exceedslimit"!==i?o.onStatisticField:void 0;if(!n.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,r);s.push(t)}n.set(a,this._calculateUniqueValues(s,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:i,items:a}=u[t],r=i.join(",");s&&!e.validateItems(a,s)||l.add(r)}}return l.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!n(t.spatialReference,this.query.outSR)?e.queryGeometry=d({spatialReference:this.query.outSR,...l(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=d({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const s=this.featureAdapter,i=R(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},d="esriGeometryPolygon"===this.geometryType,m=this._getPointCreator(r,this.spatialReference,t),h=new A(null,0),f=new A(null,0),g={x:0,y:0,z:0};for(const p of this.items){const t=s.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(h.coords=r,f.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=i){const c=h;if(c.coordsIndex=e,t!==r-1){const t=f;t.coordsIndex=e+i;const r=g;b(g,a,c,t);const d=(a.x-r.x)/n,h=(a.y-r.y)/o,y=d*d+h*h;y<=1&&l.candidates.push(u(s.getObjectId(p),m(r),Math.sqrt(y),m(c),m(t)))}}}}if("none"!==e.vertexMode){const t=d?r.length-i:r.length;if("all"===e.vertexMode)for(let e=0;e<t;e+=i){const t=h;t.coordsIndex=e;const i=(a.x-t.x)/n,r=(a.y-t.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(c(s.getObjectId(p),m(t),Math.sqrt(u)))}else if("ends"===e.vertexMode){const e=[0];d||e.push(r.length-i);for(const t of e){const e=h;e.coordsIndex=t;const i=(a.x-e.x)/n,r=(a.y-e.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(c(s.getObjectId(p),m(e),Math.sqrt(u)))}}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,s){const i=null==s||n(t,s)?e=>e:e=>l(e,t,s),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:r}):({x:e,y:t})=>i({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.isDateField(t),d=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),m=g({normalizationType:a,normalizationField:i,minValue:n,maxValue:o}),h=this.fieldsIndex.get(t),I={value:.5,fieldType:h?.type},T=f(h)?p({values:d,supportsNullCount:m,percentileParams:I}):y({values:d,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:m,percentileParams:I});return x(T,c)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:r,timeZone:n}),l=I(o);return T(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),f=V(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return F(f,n)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return S(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.reverse()){const t=i.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=v(r?.type,n);e.sort(((e,t)=>{const i=s(e,a,r),n=s(t,a,r);return o(i,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:s,hasM:i,hasZ:r,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:h,returnZ:f,returnM:g}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:s,hasM:i&&g,hasZ:r&&f,objectIdFieldName:n,spatialReference:d(u||o),transform:c&&a(c)||null}}_createFeatures(e,t){const s=new o(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:r}=this,{orderByFields:n,quantizationParameters:l,returnGeometry:u,returnCentroid:c,maxAllowableOffset:d,resultOffset:f,resultRecordCount:g,returnZ:p=!1,returnM:y=!1}=e,x=r&&p,I=i&&y;let T=[],V=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,i)=>s.getFieldValue(e,t,i))),u||c){const e=a(l)??void 0;if(u&&!c)for(const t of F)T[V++]={attributes:s.getAttributes(t),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,x,I)};else if(!u&&c)for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:h(this,this.featureAdapter.getCentroid(t,this),e),geometry:m(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),d,e,x,I)}}else for(const a of F){const e=s.getAttributes(a);e&&(T[V++]={attributes:e})}const S=f||0;if(null!=g){const e=S+g;T=T.slice(S,Math.min(T.length,e))}return T}_createExceedsLimitQueryResponse(e){let t=!1,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){s=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,i=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>s;else if(this.items.length>i)t=!0;else{const e=R(this.hasZ,this.hasM),s=this.featureAdapter;t=this.items.reduce(((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,a=new Map,r=new Map,n=new Map,l=new o(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m}=e,h=c?.length,f=!!h,g=f?c[0]:null,p=f&&!this.fieldsIndex.get(g);for(const o of u??[]){const{outStatisticFieldName:e,statisticType:u}=o,m=o,y="exceedslimit"!==u?o.onStatisticField:void 0,x="percentile_disc"===u||"percentile_cont"===u,I="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,T=f&&1===h&&(y===g||p)&&"count"===u;if(f){if(!r.has(y)){const e=[];for(const t of c){const s=this._getAttributeValues(l,t,i);e.push(s)}r.set(y,this._calculateUniqueValues(e,!I&&l.returnDistinctValues))}const t=r.get(y);for(const s in t){const{count:a,data:r,items:o,itemPositions:u}=t[s],h=r.join(",");if(!d||l.validateItems(o,d)){const t=n.get(h)||{attributes:{}};if(I){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,o);t.aggregateGeometries[s]=e}else{let s=null;if(T)s=a;else{const e=this._getAttributeValues(l,y,i),t=u.map((t=>e[t]));s=x&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,l.returnDistinctValues)}t.attributes[e]=s}let s=0;c.forEach(((e,i)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++s]=r[i])),n.set(h,t)}}}else if(I){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(l,y,i);t.attributes[e]=x&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,a,l.returnDistinctValues)}s.push({name:e,alias:e,type:"esriFieldTypeDouble"})}const y=f?Array.from(n.values()):[t];return this._sortFeatures(y,m,((e,t)=>e.attributes[t])),{fields:s,features:y}}async _getAggregateGeometry(a,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=a,{featureAdapter:c,spatialReference:d,geometryType:h,hasZ:f,hasM:g}=this,p=r.map((e=>m(h,f,g,c.getGeometry(e)))),y=n(d,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?s(y):i(o(d,p));x.aggregateGeometries={...e,spatialReference:d},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const s=y?e(y):t(i(o(d,p)));x.aggregateGeometries={x:s[0],y:s[1],spatialReference:d},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:r}=e;let n=null;n=s?.has(a)?s.get(a):f(this.fieldsIndex.get(a))?p({values:t,returnDistinct:i}):y({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:r,orderBy:n}=i,o=this.fieldsIndex.get(s);return _(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),a=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,a),a}_calculateUniqueValues(e,t){const s={},i=this.items,a=i.length;for(let r=0;r<a;r++){const a=i[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(e){const t=new o(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:s,scale:i,timeZone:a}=e;return s?t.getExpressionValues(this.items,s,{viewingMode:"map",scale:i,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},a):t.getDataValues(this.items,{field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal})}}function b(e,t,s,i){const a=i.x-s.x,r=i.y-s.y,n=a*a+r*r,o=(t.x-s.x)*a+(t.y-s.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=s.x+a*l,e.y=s.y+r*l}function R(e,t){return e?t?4:3:t?3:2}class A{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{z as QueryEngineResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import s from"../../core/Logger.js";import{createResolver as i}from"../../core/promiseUtils.js";import{dataComponents as n}from"../../core/urlUtils.js";import{generateBracedUUID as o}from"../../core/uuid.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";import{isEditBusLayer as l,emitApplyEditsEvent as u}from"../mixins/EditBusLayer.js";import{isValidFieldValue as p}from"../support/fieldUtils.js";import{getMimeTypeFormatId as c,getFilenameFormatId as h}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as m,getEffectiveLayerCapabilities as f}from"../support/layerUtils.js";function y(e){return null!=e?.applyEdits}function g(e){return"object"==typeof e&&null!=e&&"objectId"in e&&!!e.objectId}function b(e){return e.every(g)}function w(e){return"object"==typeof e&&null!=e&&"globalId"in e&&!!e.globalId}function F(e){return e.every(w)}async function A(e,t,a,s={}){let n;if(l(e)&&e.url)n=u(e.url,e.layerId,s.gdbVersion,"original-and-current-features"===s.returnServiceEditsOption);else{n=i(),n.promise.then((t=>{(t.addedFeatures.length||t.updatedFeatures.length||t.deletedFeatures.length||t.addedAttachments.length||t.updatedAttachments.length||t.deletedAttachments.length)&&e.emit("edits",t)}));const t={result:n.promise};e.emit("apply-edits",t)}try{const{results:i,edits:o}=await v(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:o,addedFeatures:d(i.addFeatureResults),updatedFeatures:d(i.updateFeatureResults),deletedFeatures:d(i.deleteFeatureResults),addedAttachments:d(i.addAttachmentResults),updatedAttachments:d(i.updateAttachmentResults),deletedAttachments:d(i.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:i.editMoment?new Date(i.editMoment):null};return i.editedFeatureResults?.length&&(l.editedFeatures=i.editedFeatureResults),n.resolve(l),i}catch(o){throw n.reject(o),o}}async function v(e,t,r,s){if(await e.load(),!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!m(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:i,options:n}=await I(e,r,s);return i.addFeatures?.length||i.updateFeatures?.length||i.deleteFeatures?.length||i.addAttachments?.length||i.updateAttachments?.length||i.deleteAttachments?.length?{edits:i,results:await t.applyEdits(i,n)}:{edits:i,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function I(e,t,r){const i=f(e),n=t&&(t.addFeatures||t.updateFeatures||t.deleteFeatures),o=t&&(t.addAttachments||t.updateAttachments||t.deleteAttachments),d=null!=e.infoFor3D;if(D(t,i,r,!!n,!!o,`${e.type}-layer`),!i.data.isVersioned&&r?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!i.editing.supportsRollbackOnFailure&&r?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");const l={...r};if(null!=l.rollbackOnFailureEnabled||i.editing.supportsRollbackOnFailure||(l.rollbackOnFailureEnabled=!0),l.rollbackOnFailureEnabled||"original-and-current-features"!==l.returnServiceEditsOption||(!1===l.rollbackOnFailureEnabled&&s.getLogger("esri.layers.graphics.editingSupport").warn(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true, but 'rollBackOnFailure' was set to false. 'rollBackOnFailure' has been overwrritten and set to true."),l.rollbackOnFailureEnabled=!0),!i.editing.supportsReturnServiceEditsInSourceSpatialReference&&l.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(l.returnServiceEditsInSourceSR&&"original-and-current-features"!==l.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsInSourceSR' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const u=B(t,i,`${e.type}-layer`),p=r?.globalIdUsed||d,c=e.fields.filter((e=>"big-integer"===e.type||"oid"===e.type&&e.length>=8));if(p){const{globalIdField:t}=e;if(null==t)throw new a(`${e.type}-layer:invalid-parameter`,"Layer does not specify a global id field.");u.addFeatures.forEach((e=>U(e,t)))}u.addFeatures.forEach((t=>S(t,e,p,c))),u.updateFeatures.forEach((t=>j(t,e,p,c))),u.deleteFeatures.forEach((t=>R(t,e,p,c))),u.addAttachments.forEach((t=>O(t,e))),u.updateAttachments.forEach((t=>O(t,e))),d&&await T(u,e);return{edits:await L(u),options:l}}function $(e,t,r,s){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,`Feature should have '${t.globalIdField}' when 'globalIdUsed' is true`);if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"`'globalId' of the feature should be passed when 'globalIdUsed' is true")}if(s.length&&"attributes"in e)for(const i of s){const r=e.attributes[i.name];if(void 0!==r&&!p(i,r))throw new a(`${t.type}-layer:invalid-parameter`,`Big-integer field '${i.name}' of the feature must be less than ${Number.MAX_SAFE_INTEGER}`,{feature:e})}if("geometry"in e&&null!=e.geometry){if(e.geometry.hasZ&&!1===t.capabilities?.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities?.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function E(e,t){if("geometry"in e&&"mesh"===e.geometry?.type&&null!=t.infoFor3D){const{geometry:r}=e;if(r.vertexSpace.isGeoreferenced)throw new a(`${t.type}-layer:georeferenced-mesh-unsupported`,"Uploading georeferenced meshes to a layer is not supported.")}}function S(e,t,a,r){$(e,t,a,r),E(e,t)}function R(e,t,a,r){$(e,t,a,r)}function j(e,t,r,s){$(e,t,r,s),E(e,t);const i=f(t);if("geometry"in e&&null!=e.geometry&&!i?.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function O(e,t){const{feature:r,attachment:s}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!s.data&&!s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(s.data instanceof File&&!!s.data.name)&&!s.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities?.editing.supportsUploadWithItemId&&s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof s.data){const e=n(s.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}function U(e,t){const{attributes:a}=e;null==a[t]&&(a[t]=o())}async function L(e){const t=e.addFeatures??[],a=e.updateFeatures??[],r=t.concat(a).map((e=>e.geometry)),s=await d(r),i=t.length,n=a.length;return s.slice(0,i).forEach(((e,a)=>t[a].geometry=e)),s.slice(i,i+n).forEach(((e,t)=>a[t].geometry=e)),e}function k(e){return{addFeatures:Array.from(e?.addFeatures??[]),updateFeatures:Array.from(e?.updateFeatures??[]),deleteFeatures:e&&t.isCollection(e.deleteFeatures)?e.deleteFeatures.toArray():e.deleteFeatures||[],addAttachments:e.addAttachments||[],updateAttachments:e.updateAttachments||[],deleteAttachments:e.deleteAttachments||[]}}function B(e,t,r){const s=k(e);if(s.addFeatures?.length&&!t.operations.supportsAdd)throw new a(`${r}:unsupported-operation`,"Layer does not support adding features.");if(s.updateFeatures?.length&&!t.operations.supportsUpdate)throw new a(`${r}:unsupported-operation`,"Layer does not support updating features.");if(s.deleteFeatures?.length&&!t.operations.supportsDelete)throw new a(`${r}:unsupported-operation`,"Layer does not support deleting features.");return s.addFeatures=s.addFeatures.map(G),s.updateFeatures=s.updateFeatures.map(G),s.addAssetFeatures=[],s}function D(e,t,r,s,i,n){if(!e||!s&&!i)throw new a(`${n}:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!t.editing.supportsGlobalId&&r?.globalIdUsed)throw new a(`${n}:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!t.editing.supportsGlobalId&&i)throw new a(`${n}:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!r?.globalIdUsed&&i)throw new a(`${n}:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true")}function G(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function T(e,t){if(null==t.infoFor3D)return;const{infoFor3D:r}=t,s=c("model/gltf-binary",r.supportedFormats)??h("glb",r.supportedFormats);if(!(!!s&&r.editFormats.includes(s)))throw new a(`${t.type}-layer:binary-gltf-asset-not-supported`,"3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");e.addAssetFeatures??=[];const{addAssetFeatures:i}=e;for(const a of e.addFeatures??[])M(a)&&i.push(a);for(const a of e.updateFeatures??[])M(a)&&i.push(a)}function M(e){return"mesh"===e?.geometry?.type}function V(e,t,r,s){if(!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!t.uploadAssets)throw new a(`${e.type}-layer:no-asset-upload-support`,"Layer source does not support uploadAssets capability",{layer:e});return t.uploadAssets(r,s)}export{A as applyEdits,D as checkEditingCapabilities,F as isFeatureIdentifierArrayWithGlobalId,b as isFeatureIdentifierArrayWithObjectId,w as isFeatureIdentifierWithGlobalId,g as isFeatureIdentifierWithObjectId,k as normalizeCollections,B as normalizeEdits,L as normalizeGeometries,G as shallowCloneFeature,V as uploadAssets};
5
+ import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import s from"../../core/Logger.js";import{createResolver as o}from"../../core/promiseUtils.js";import{dataComponents as i}from"../../core/urlUtils.js";import{generateBracedUUID as n}from"../../core/uuid.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";import{isEditBusLayer as l,emitApplyEditsEvent as u}from"../mixins/EditBusLayer.js";import{isValidFieldValue as p}from"../support/fieldUtils.js";import{getMimeTypeFormatId as c,getFilenameFormatId as h}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as m,getEffectiveLayerCapabilities as f}from"../support/layerUtils.js";function y(e){return null!=e?.applyEdits}function g(e){return"object"==typeof e&&null!=e&&"objectId"in e&&!!e.objectId}function b(e){return e.every(g)}function w(e){return"object"==typeof e&&null!=e&&"globalId"in e&&!!e.globalId}function F(e){return e.every(w)}async function A(e,t,a,s={}){let i;if(l(e)&&e.url)i=u(e.url,e.layerId,s.gdbVersion,"original-and-current-features"===s.returnServiceEditsOption);else{i=o(),i.promise.then((t=>{(t.addedFeatures.length||t.updatedFeatures.length||t.deletedFeatures.length||t.addedAttachments.length||t.updatedAttachments.length||t.deletedAttachments.length)&&e.emit("edits",t)}));const t={result:i.promise};e.emit("apply-edits",t)}try{const{results:o,edits:n}=await v(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:n,addedFeatures:d(o.addFeatureResults),updatedFeatures:d(o.updateFeatureResults),deletedFeatures:d(o.deleteFeatureResults),addedAttachments:d(o.addAttachmentResults),updatedAttachments:d(o.updateAttachmentResults),deletedAttachments:d(o.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:o.editMoment?new Date(o.editMoment):null,globalIdToObjectId:s.globalIdToObjectId};return o.editedFeatureResults?.length&&(l.editedFeatures=o.editedFeatureResults),i.resolve(l),o}catch(n){throw i.reject(n),n}}async function v(e,t,r,s){if(await e.load(),!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!m(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:o,options:i}=await I(e,r,s);return o.addFeatures?.length||o.updateFeatures?.length||o.deleteFeatures?.length||o.addAttachments?.length||o.updateAttachments?.length||o.deleteAttachments?.length?{edits:o,results:await t.applyEdits(o,i)}:{edits:o,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function I(e,t,r){const o=f(e),i=t&&(t.addFeatures||t.updateFeatures||t.deleteFeatures),n=t&&(t.addAttachments||t.updateAttachments||t.deleteAttachments),d=null!=e.infoFor3D;if(T(t,o,r,!!i,!!n,`${e.type}-layer`),!o.data.isVersioned&&r?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!o.editing.supportsRollbackOnFailure&&r?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");const l={...r};if(null!=l.rollbackOnFailureEnabled||o.editing.supportsRollbackOnFailure||(l.rollbackOnFailureEnabled=!0),l.rollbackOnFailureEnabled||"original-and-current-features"!==l.returnServiceEditsOption||(!1===l.rollbackOnFailureEnabled&&s.getLogger("esri.layers.graphics.editingSupport").warn(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true, but 'rollBackOnFailure' was set to false. 'rollBackOnFailure' has been overwrritten and set to true."),l.rollbackOnFailureEnabled=!0),!o.editing.supportsReturnServiceEditsInSourceSpatialReference&&l.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(l.returnServiceEditsInSourceSR&&"original-and-current-features"!==l.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsInSourceSR' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const u=B(t,o,`${e.type}-layer`),p=r?.globalIdUsed||d,c=e.fields.filter((e=>"big-integer"===e.type||"oid"===e.type&&e.length>=8));if(p){const{globalIdField:t}=e;if(null==t)throw new a(`${e.type}-layer:invalid-parameter`,"Layer does not specify a global id field.");u.addFeatures.forEach((e=>U(e,t)))}u.addFeatures.forEach((t=>S(t,e,p,c))),u.updateFeatures.forEach((t=>j(t,e,p,c))),u.deleteFeatures.forEach((t=>R(t,e,p,c))),u.addAttachments.forEach((t=>O(t,e))),u.updateAttachments.forEach((t=>O(t,e))),d&&await G(u,e);return{edits:await L(u),options:l}}function $(e,t,r,s){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,`Feature should have '${t.globalIdField}' when 'globalIdUsed' is true`);if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"`'globalId' of the feature should be passed when 'globalIdUsed' is true")}if(s.length&&"attributes"in e)for(const o of s){const r=e.attributes[o.name];if(void 0!==r&&!p(o,r))throw new a(`${t.type}-layer:invalid-parameter`,`Big-integer field '${o.name}' of the feature must be less than ${Number.MAX_SAFE_INTEGER}`,{feature:e})}if("geometry"in e&&null!=e.geometry){if(e.geometry.hasZ&&!1===t.capabilities?.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities?.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function E(e,t){if("geometry"in e&&"mesh"===e.geometry?.type&&null!=t.infoFor3D){const{geometry:r}=e;if(r.vertexSpace.isGeoreferenced)throw new a(`${t.type}-layer:georeferenced-mesh-unsupported`,"Uploading georeferenced meshes to a layer is not supported.")}}function S(e,t,a,r){$(e,t,a,r),E(e,t)}function R(e,t,a,r){$(e,t,a,r)}function j(e,t,r,s){$(e,t,r,s),E(e,t);const o=f(t);if("geometry"in e&&null!=e.geometry&&!o?.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function O(e,t){const{feature:r,attachment:s}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!s.data&&!s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(s.data instanceof File&&!!s.data.name)&&!s.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities?.editing.supportsUploadWithItemId&&s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof s.data){const e=i(s.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}function U(e,t){const{attributes:a}=e;null==a[t]&&(a[t]=n())}async function L(e){const t=e.addFeatures??[],a=e.updateFeatures??[],r=t.concat(a).map((e=>e.geometry)),s=await d(r),o=t.length,i=a.length;return s.slice(0,o).forEach(((e,a)=>t[a].geometry=e)),s.slice(o,o+i).forEach(((e,t)=>a[t].geometry=e)),e}function k(e){return{addFeatures:Array.from(e?.addFeatures??[]),updateFeatures:Array.from(e?.updateFeatures??[]),deleteFeatures:e&&t.isCollection(e.deleteFeatures)?e.deleteFeatures.toArray():e.deleteFeatures||[],addAttachments:e.addAttachments||[],updateAttachments:e.updateAttachments||[],deleteAttachments:e.deleteAttachments||[]}}function B(e,t,r){const s=k(e);if(s.addFeatures?.length&&!t.operations.supportsAdd)throw new a(`${r}:unsupported-operation`,"Layer does not support adding features.");if(s.updateFeatures?.length&&!t.operations.supportsUpdate)throw new a(`${r}:unsupported-operation`,"Layer does not support updating features.");if(s.deleteFeatures?.length&&!t.operations.supportsDelete)throw new a(`${r}:unsupported-operation`,"Layer does not support deleting features.");return s.addFeatures=s.addFeatures.map(D),s.updateFeatures=s.updateFeatures.map(D),s.addAssetFeatures=[],s}function T(e,t,r,s,o,i){if(!e||!s&&!o)throw new a(`${i}:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!t.editing.supportsGlobalId&&r?.globalIdUsed)throw new a(`${i}:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!t.editing.supportsGlobalId&&o)throw new a(`${i}:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!r?.globalIdUsed&&o)throw new a(`${i}:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true")}function D(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function G(e,t){if(null==t.infoFor3D)return;const{infoFor3D:r}=t,s=c("model/gltf-binary",r.supportedFormats)??h("glb",r.supportedFormats);if(!(!!s&&r.editFormats.includes(s)))throw new a(`${t.type}-layer:binary-gltf-asset-not-supported`,"3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");e.addAssetFeatures??=[];const{addAssetFeatures:o}=e;for(const a of e.addFeatures??[])M(a)&&o.push(a);for(const a of e.updateFeatures??[])M(a)&&o.push(a)}function M(e){return"mesh"===e?.geometry?.type}function V(e,t,r,s){if(!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!t.uploadAssets)throw new a(`${e.type}-layer:no-asset-upload-support`,"Layer source does not support uploadAssets capability",{layer:e});return t.uploadAssets(r,s)}export{A as applyEdits,T as checkEditingCapabilities,F as isFeatureIdentifierArrayWithGlobalId,b as isFeatureIdentifierArrayWithObjectId,w as isFeatureIdentifierWithGlobalId,g as isFeatureIdentifierWithObjectId,k as normalizeCollections,B as normalizeEdits,L as normalizeGeometries,D as shallowCloneFeature,V as uploadAssets};