@arcgis/core 5.1.0-next.20 → 5.1.0-next.22

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 (356) hide show
  1. package/analysis/VolumeMeasurement/VolumeMeasurementCutFillOptions.d.ts +1 -0
  2. package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.d.ts +1 -0
  3. package/analysis/VolumeMeasurement/VolumeMeasurementInputUnits.d.ts +1 -0
  4. package/analysis/VolumeMeasurementAnalysis.d.ts +3 -2
  5. package/applications/Components/OrientedImageryViewer/galleryUtils.d.ts +45 -15
  6. package/applications/Components/QuantityFormatter.d.ts +11 -11
  7. package/applications/Components/SelectionOperation.d.ts +11 -11
  8. package/applications/Components/SketchTooltipControls.d.ts +9 -9
  9. package/applications/Components/actionUtils.d.ts +2 -1
  10. package/applications/Components/analysisUtils.d.ts +27 -26
  11. package/applications/Components/applySetUtils.d.ts +40 -40
  12. package/applications/Components/arcadeEditorUtils.d.ts +3 -3
  13. package/applications/Components/arcadeFeatureUtils.d.ts +12 -12
  14. package/applications/Components/baUtils.d.ts +8 -8
  15. package/applications/Components/basemapUtils.d.ts +2 -2
  16. package/applications/Components/clipboard.d.ts +14 -14
  17. package/applications/Components/drawUtils.d.ts +3 -3
  18. package/applications/Components/editUtils.d.ts +14 -14
  19. package/applications/Components/featureUtils.d.ts +10 -10
  20. package/applications/Components/fieldFormatUtils.d.ts +2 -2
  21. package/applications/Components/fontUtils.d.ts +2 -2
  22. package/applications/Components/formatUtils.d.ts +2 -2
  23. package/applications/Components/getDefaultUnits.d.ts +2 -2
  24. package/applications/Components/gfxUtils.d.ts +5 -1
  25. package/applications/Components/imageryUtils.d.ts +35 -35
  26. package/applications/Components/layerOriginUtils.d.ts +5 -5
  27. package/applications/Components/layersEffectsJsonUtils.d.ts +2 -2
  28. package/applications/Components/previewSymbol2D.d.ts +2 -2
  29. package/applications/Components/rasterFunctionEditorUtils.d.ts +40 -40
  30. package/applications/Components/reactiveUtils.d.ts +14 -13
  31. package/applications/Components/sanitizerUtils.d.ts +2 -2
  32. package/applications/Components/stringUtils.d.ts +5 -5
  33. package/applications/Components/styleUtils.d.ts +2 -2
  34. package/applications/Components/svgUtils.d.ts +4 -4
  35. package/applications/Components/symbolUtils.d.ts +47 -11
  36. package/applications/Components/templateUtils.d.ts +73 -17
  37. package/applications/Components/templateUtils.js +1 -1
  38. package/applications/Components/testUtils.d.ts +3 -3
  39. package/applications/Components/unitUtils.d.ts +1 -1
  40. package/applications/Components/viewUtils.d.ts +2 -2
  41. package/applications/Components/webStyleSymbolUtils.d.ts +2 -2
  42. package/applications/Excalibur/imageryLayerUtils.d.ts +3 -3
  43. package/applications/Excalibur/videoViewUtils.d.ts +8 -8
  44. package/applications/Excalibur/widgetUtils.d.ts +2 -2
  45. package/applications/ExperienceBuilder/sketchUtils.d.ts +7 -7
  46. package/applications/KnowledgeStudio/dataModelVisualization.d.ts +20 -8
  47. package/applications/KnowledgeStudio/generalSdkInternalAccess.d.ts +21 -21
  48. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +35 -35
  49. package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +9 -9
  50. package/applications/KnowledgeStudio/reshape.d.ts +40 -40
  51. package/applications/KnowledgeStudio/resourceSerializationUtils.d.ts +11 -11
  52. package/applications/MapViewer/layerUtils.d.ts +2 -2
  53. package/applications/MapViewer/mediaUtils.d.ts +13 -13
  54. package/applications/MapViewer/templateUtils.d.ts +20 -20
  55. package/applications/PortalApp/layerUtils.d.ts +2 -2
  56. package/applications/SceneViewer/colorUtils.d.ts +2 -2
  57. package/applications/SceneViewer/devEnvironmentUtils.d.ts +4 -3
  58. package/applications/SceneViewer/layerUtils.d.ts +3 -3
  59. package/applications/SceneViewer/sceneViewerUtils.d.ts +34 -34
  60. package/applications/SceneViewer/symbolUtils.d.ts +2 -2
  61. package/applications/Urban/LineImagePattern3D.d.ts +3 -2
  62. package/applications/Urban/imagePatternUtils.d.ts +4 -4
  63. package/applications/Urban/meshUtils.d.ts +2 -2
  64. package/applications/WebEditor/sketchUtils.d.ts +8 -8
  65. package/assets/esri/core/workers/RemoteClient.js +1 -1
  66. package/assets/esri/core/workers/chunks/03d11c7056fea763cbac.js +1 -0
  67. package/assets/esri/core/workers/chunks/05e5b9082c0a396df7e5.js +1 -0
  68. package/assets/esri/core/workers/chunks/08445fcba84ed7c23b3f.js +1 -0
  69. package/assets/esri/core/workers/chunks/0c706cdff6eac940eaab.js +1 -0
  70. package/assets/esri/core/workers/chunks/10a8612e7b2c74a8ce9a.js +1 -0
  71. package/assets/esri/core/workers/chunks/{df321c37b61099f6e4c2.js → 11058e660139c427c3e7.js} +1 -1
  72. package/assets/esri/core/workers/chunks/{2ddb8bb00b3af83ebd7c.js → 14792047c5519dd89828.js} +1 -1
  73. package/assets/esri/core/workers/chunks/1a1e57267306c07e5bdb.js +1 -0
  74. package/assets/esri/core/workers/chunks/1bb5aa1e3693e0c68b18.js +1 -0
  75. package/assets/esri/core/workers/chunks/1cd091fa567fc4026356.js +1 -0
  76. package/assets/esri/core/workers/chunks/1dcd057695f8db79eca2.js +1 -0
  77. package/assets/esri/core/workers/chunks/{3ed7f19f77a11fa4d047.js → 2063b49607a03f7718ee.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{74a6d840813ac29b0bda.js → 209acb3ad16c99bb506c.js} +1 -1
  79. package/assets/esri/core/workers/chunks/21decfc1e477fb769204.js +1 -0
  80. package/assets/esri/core/workers/chunks/21e04705cad9fef1b01b.js +1 -0
  81. package/assets/esri/core/workers/chunks/23cb0611abe1031c513c.js +1 -0
  82. package/assets/esri/core/workers/chunks/285f3b07de852bfc1604.js +1 -0
  83. package/assets/esri/core/workers/chunks/2c61a53962093a331225.js +1 -0
  84. package/assets/esri/core/workers/chunks/2ecfd6edab796194bf88.js +1 -0
  85. package/assets/esri/core/workers/chunks/2f23af31b1190754ce13.js +1 -0
  86. package/assets/esri/core/workers/chunks/31eb59eae4c89b76e302.js +1 -0
  87. package/assets/esri/core/workers/chunks/3e61e7805dc6ff284831.js +1 -0
  88. package/assets/esri/core/workers/chunks/4150774059d67a8def74.js +1 -0
  89. package/assets/esri/core/workers/chunks/416c57df61fbd193078b.js +1 -0
  90. package/assets/esri/core/workers/chunks/46d28a0c20263012faff.js +1 -0
  91. package/assets/esri/core/workers/chunks/{43c8b1473695574c663e.js → 4754610760f3f634adf9.js} +2 -2
  92. package/assets/esri/core/workers/chunks/{f5cebeaad3e7d87d7997.js → 4fc6dd1423075e145b29.js} +1 -1
  93. package/assets/esri/core/workers/chunks/{3861644c06cfebe8f40c.js → 527547fa10d52cb3a7b1.js} +2 -2
  94. package/assets/esri/core/workers/chunks/5480d4cc342a2669a8ab.js +1 -0
  95. package/assets/esri/core/workers/chunks/{e8495c655a0a4f534636.js → 551fee27bf3abf0c41fd.js} +1 -1
  96. package/assets/esri/core/workers/chunks/568d32ceee1409809e5a.js +1 -0
  97. package/assets/esri/core/workers/chunks/576995021660e8b34705.js +1 -0
  98. package/assets/esri/core/workers/chunks/57e375d8a8db9fa57193.js +1 -0
  99. package/assets/esri/core/workers/chunks/5cbc12545f42a32fb960.js +1 -0
  100. package/assets/esri/core/workers/chunks/61ebbae0773fccc1f2bf.js +1 -0
  101. package/assets/esri/core/workers/chunks/63c297b6b7438f49e7ee.js +1 -0
  102. package/assets/esri/core/workers/chunks/6b56c8ba978ec6edd6b8.js +1 -0
  103. package/assets/esri/core/workers/chunks/{53f8c1d56ef3b24d2226.js → 6c853fd89f0e9f102c6e.js} +1 -1
  104. package/assets/esri/core/workers/chunks/{946698d9cefffdb63082.js → 6e32e7b2ea2ea1a1fc04.js} +1 -1
  105. package/assets/esri/core/workers/chunks/6f12854c5846edfe3239.js +1 -0
  106. package/assets/esri/core/workers/chunks/{b586f1021a27c5e1551a.js → 7189e03cc24f5c10865a.js} +2 -2
  107. package/assets/esri/core/workers/chunks/7b59ddad3c73f5f44b4d.js +1 -0
  108. package/assets/esri/core/workers/chunks/7c417d2bf432e4055b3d.js +30 -0
  109. package/assets/esri/core/workers/chunks/8021cb732f8136d87048.js +1 -0
  110. package/assets/esri/core/workers/chunks/84124c1a41a96192f81c.js +1 -0
  111. package/assets/esri/core/workers/chunks/845bbd82ddacbb62ad28.js +1 -0
  112. package/assets/esri/core/workers/chunks/868c8a152cb1452b9a94.js +1 -0
  113. package/assets/esri/core/workers/chunks/879ce85c50b0348056b2.js +1 -0
  114. package/assets/esri/core/workers/chunks/87a7d405a0b9a541d7f2.js +1 -0
  115. package/assets/esri/core/workers/chunks/9522430d34d29c1ffb1a.js +1 -0
  116. package/assets/esri/core/workers/chunks/9647f3983f955da21093.js +1 -0
  117. package/assets/esri/core/workers/chunks/9694b4b85168a38ca24b.js +1 -0
  118. package/assets/esri/core/workers/chunks/{83d913dab3c2b0d6a7cc.js → 9736299a4ac0e21f08a7.js} +1 -1
  119. package/assets/esri/core/workers/chunks/{e7bee85f28d7ec03825a.js → 973e3743cb7fdaa27f80.js} +1 -1
  120. package/assets/esri/core/workers/chunks/9b2d0d36ee6c04c347df.js +1 -0
  121. package/assets/esri/core/workers/chunks/{2662750d5761ed2d0eb7.js → 9e7eea56e96f012f9ff4.js} +1 -1
  122. package/assets/esri/core/workers/chunks/{3f812b0a28afb47aaaf0.js → a35d1be700ebd3109397.js} +2 -2
  123. package/assets/esri/core/workers/chunks/a4919dd9963f853a0077.js +1 -0
  124. package/assets/esri/core/workers/chunks/a4a4ce33de6432ba4dc3.js +1 -0
  125. package/assets/esri/core/workers/chunks/{aece665144aed2065ffc.js → a78ac951c00f090d9024.js} +1 -1
  126. package/assets/esri/core/workers/chunks/a7dbd38bc216713044fc.js +1 -0
  127. package/assets/esri/core/workers/chunks/{0debabe324c873066885.js → aa3bdfd00f666c6cc521.js} +1 -1
  128. package/assets/esri/core/workers/chunks/{db5bbc240a1b8cd5af52.js → abc2471cfa9430ca5645.js} +1 -1
  129. package/assets/esri/core/workers/chunks/b2a67fe89f6505498bc3.js +1 -0
  130. package/assets/esri/core/workers/chunks/{b8b2f160518e3a225d99.js → b364ec104dd59faa41b6.js} +1 -1
  131. package/assets/esri/core/workers/chunks/b4254fcb2051c873f2ba.js +1 -0
  132. package/assets/esri/core/workers/chunks/{a53fa34681efff8fc024.js → b859d98fa1c39f8e4099.js} +1 -1
  133. package/assets/esri/core/workers/chunks/c09bc36347e8eb9fff00.js +1 -0
  134. package/assets/esri/core/workers/chunks/c2cda93905f0a49a6931.js +1 -0
  135. package/assets/esri/core/workers/chunks/c3e4f8664988e50bda55.js +1 -0
  136. package/assets/esri/core/workers/chunks/{3d0aa5f2db79c022243e.js → c794f7be868e53ca4a8c.js} +1 -1
  137. package/assets/esri/core/workers/chunks/cada79c174027f7a0df8.js +1 -0
  138. package/assets/esri/core/workers/chunks/cf100c80b75ba74b479c.js +1 -0
  139. package/assets/esri/core/workers/chunks/d10c65cde3565d399275.js +1 -0
  140. package/assets/esri/core/workers/chunks/d44217de4c73475f9c66.js +1 -0
  141. package/assets/esri/core/workers/chunks/d587b7842091affdaac3.js +1 -0
  142. package/assets/esri/core/workers/chunks/d70678598f4080adfb39.js +1 -0
  143. package/assets/esri/core/workers/chunks/dad9c25f1b7cacf7b052.js +1 -0
  144. package/assets/esri/core/workers/chunks/{0facd2c143a04cc7c4ff.js → deee88e3f1641c6ef5db.js} +1 -1
  145. package/assets/esri/core/workers/chunks/e063cce778944fe97dd3.js +1 -0
  146. package/assets/esri/core/workers/chunks/e37e7ae2de974cef9a90.js +1 -0
  147. package/assets/esri/core/workers/chunks/e44ed205f74df34adb8b.js +1 -0
  148. package/assets/esri/core/workers/chunks/e6220c1fa887e21ffbbd.js +1 -0
  149. package/assets/esri/core/workers/chunks/{13d1cb50232ae761425b.js → eaeb95be8d4032513247.js} +2 -2
  150. package/assets/esri/core/workers/chunks/{93515f52d9b5fa12bd04.js → eb4934d3a3b82316c7c6.js} +1 -1
  151. package/assets/esri/core/workers/chunks/{23c856265dd24ce54fdb.js → f1c1f7583fa13dff9b5c.js} +1 -1
  152. package/assets/esri/core/workers/chunks/f27bbb4e26297d3c68de.js +1 -0
  153. package/assets/esri/core/workers/chunks/f4480636a910eaa4c531.js +1 -0
  154. package/assets/esri/core/workers/chunks/{5b991b0d4ca257291cb0.js → f5c5a9e771074f780fc8.js} +1 -1
  155. package/assets/esri/core/workers/chunks/f82a95c46f0d579d5bf5.js +1 -0
  156. package/assets/esri/core/workers/chunks/fb3a42cdd0d3105ec551.js +1 -0
  157. package/chunks/Clouds.glsl.js +1 -1
  158. package/config.js +1 -1
  159. package/core/MultiOriginJSONSupport.d.ts +1 -1
  160. package/core/ReadOnlyMultiOriginJSONSupport.d.ts +5 -4
  161. package/geometry/FlatGeometry.js +1 -1
  162. package/geometry/support/curves/curveUtils.js +1 -1
  163. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  164. package/graphic/graphicOriginUtils.js +1 -1
  165. package/kernel.js +1 -1
  166. package/layers/FeatureLayer.d.ts +7 -9
  167. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  168. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  169. package/layers/WMTSLayer.js +1 -1
  170. package/layers/graphics/data/QueryEngineResult.js +1 -1
  171. package/layers/graphics/editingSupport.js +1 -1
  172. package/layers/raster/datasets/MRFRaster.js +1 -1
  173. package/layers/support/SceneModification.js +1 -1
  174. package/layers/support/Sublayer.d.ts +3 -0
  175. package/package.json +2 -2
  176. package/renderers/VectorFieldRenderer.js +1 -1
  177. package/renderers/support/DictionaryControlString.js +1 -1
  178. package/renderers/support/DictionaryLoader.js +1 -1
  179. package/rest/featureService/FeatureService.js +1 -1
  180. package/smartMapping/support/utils.js +1 -1
  181. package/support/revision.js +1 -1
  182. package/symbols/cim/CIMSymbolHelper.js +1 -1
  183. package/symbols/cim/GeometryWalker.js +1 -1
  184. package/symbols/cim/SDFHelper.js +1 -1
  185. package/symbols/cim/animationUtils.js +1 -1
  186. package/symbols/cim/cimAnalyzer.js +1 -1
  187. package/symbols/cim/effects/EffectDashes.js +1 -1
  188. package/symbols/cim/effects/EffectDonut.js +1 -1
  189. package/symbols/cim/effects/EffectOffset.js +1 -1
  190. package/symbols/cim/effects/EffectWave.js +1 -1
  191. package/symbols/cim/placements/PlacementAlongLineSameSize.js +1 -1
  192. package/symbols/cim/placements/PlacementAtExtremities.js +1 -1
  193. package/symbols/cim/placements/PlacementAtRatioPositions.js +1 -1
  194. package/symbols/cim/placements/PlacementOnLine.js +1 -1
  195. package/symbols/cim/rasterizingUtils.js +1 -1
  196. package/symbols/cim/types.d.ts +220 -117
  197. package/views/2d/layers/features/schema/processor/symbols/utils.js +1 -1
  198. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementError.d.ts +1 -0
  199. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementResult.d.ts +1 -0
  200. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.d.ts +1 -0
  201. package/views/3d/environment/CloudsRenderer.js +1 -1
  202. package/views/3d/environment/Fog.js +1 -1
  203. package/views/3d/environment/FogTechnique.js +1 -1
  204. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  205. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  206. package/views/3d/layers/Lyr3DWorker.js +1 -1
  207. package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
  208. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  209. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  210. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  211. package/views/3d/layers/support/patternUtils.js +1 -1
  212. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  213. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  214. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  215. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  216. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  217. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  218. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  219. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  220. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  221. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  222. package/views/3d/webgl-engine/lib/Material.js +1 -1
  223. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  224. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  225. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  226. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  227. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  228. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  229. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  230. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  231. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  232. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  233. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  234. package/views/3d/webgl-engine/materials/renderers/IndexBufferCache.js +2 -0
  235. package/views/3d/webgl-engine/materials/renderers/IndexLayout.js +2 -0
  236. package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
  237. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  238. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  239. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  240. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  241. package/views/SelectionManager.d.ts +9 -9
  242. package/views/SelectionManager.js +1 -1
  243. package/views/View.d.ts +13 -2
  244. package/views/draw/support/Reshape.js +1 -1
  245. package/views/draw/support/reshapeUtils.js +1 -1
  246. package/views/draw/support/types.d.ts +8 -1
  247. package/views/interactive/support/utils.js +1 -1
  248. package/views/layers/FeatureLikeLayerView.d.ts +24 -24
  249. package/views/webgl/BufferObject.js +1 -1
  250. package/widgets/Attribution/AttributionViewModel.d.ts +3 -1
  251. package/widgets/Attribution/AttributionViewModel.js +1 -1
  252. package/widgets/Attribution.d.ts +1 -1
  253. package/widgets/Attribution.js +1 -1
  254. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  255. package/widgets/Editor/EditorViewModel.d.ts +2 -22
  256. package/widgets/Editor/EditorViewModel.js +1 -1
  257. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  258. package/widgets/Editor/UpdateWorkflow.js +1 -1
  259. package/widgets/Editor/Workflow.js +1 -1
  260. package/widgets/Editor/support/SketchController.js +1 -1
  261. package/widgets/Editor/workflowUtils.js +1 -1
  262. package/widgets/Editor.d.ts +10 -15
  263. package/widgets/Editor.js +1 -1
  264. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +0 -15
  265. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  266. package/widgets/FeatureTable/support/types.d.ts +0 -1
  267. package/widgets/FeatureTable.d.ts +1 -19
  268. package/widgets/FeatureTable.js +1 -1
  269. package/widgets/FeatureTemplates.d.ts +1 -1
  270. package/widgets/FeatureTemplates.js +1 -1
  271. package/widgets/HistogramRangeSlider.d.ts +1 -1
  272. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  273. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  274. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  275. package/widgets/PanoramicVideoViewer.js +1 -1
  276. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  277. package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
  278. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  279. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  280. package/widgets/PanoramicViewer/utils.js +1 -1
  281. package/widgets/Sketch/SketchViewModel.d.ts +4 -22
  282. package/widgets/Sketch/SketchViewModel.js +1 -1
  283. package/widgets/Sketch/support/PluginManager.js +1 -1
  284. package/widgets/Sketch/support/sketchUtils.js +1 -1
  285. package/widgets/Sketch.d.ts +10 -17
  286. package/widgets/Sketch.js +1 -1
  287. package/assets/esri/core/workers/chunks/026c00ee272c64e53daf.js +0 -1
  288. package/assets/esri/core/workers/chunks/0883c4e63424d6746ada.js +0 -1
  289. package/assets/esri/core/workers/chunks/0987cb20148f65222b44.js +0 -1
  290. package/assets/esri/core/workers/chunks/0a1f88cf16bcbb53b371.js +0 -1
  291. package/assets/esri/core/workers/chunks/0bb3beedae1b73beb1fc.js +0 -1
  292. package/assets/esri/core/workers/chunks/0ca405ca26676137a4be.js +0 -1
  293. package/assets/esri/core/workers/chunks/0ce968c89c35535da63e.js +0 -1
  294. package/assets/esri/core/workers/chunks/0d56e3b3265a4470aaa6.js +0 -1
  295. package/assets/esri/core/workers/chunks/144c719d5ba9e3a30961.js +0 -1
  296. package/assets/esri/core/workers/chunks/1503ca177e2466ec0e87.js +0 -1
  297. package/assets/esri/core/workers/chunks/1597d7b380d510ff5252.js +0 -1
  298. package/assets/esri/core/workers/chunks/1880c3b293cdfa804625.js +0 -1
  299. package/assets/esri/core/workers/chunks/1bea32b02d35ddb9b118.js +0 -1
  300. package/assets/esri/core/workers/chunks/1d78ec98eef7fef08f86.js +0 -1
  301. package/assets/esri/core/workers/chunks/1e6271524602e159dbad.js +0 -1
  302. package/assets/esri/core/workers/chunks/1f96d597ba736e088168.js +0 -1
  303. package/assets/esri/core/workers/chunks/26e41b08efe77d247409.js +0 -1
  304. package/assets/esri/core/workers/chunks/297b58f29c496923e1f3.js +0 -1
  305. package/assets/esri/core/workers/chunks/2a2a9fa62969644ea200.js +0 -1
  306. package/assets/esri/core/workers/chunks/2b296378d21e4e3c11d4.js +0 -1
  307. package/assets/esri/core/workers/chunks/2cbcf34cf896a438999b.js +0 -1
  308. package/assets/esri/core/workers/chunks/394b645d51e7bf799382.js +0 -1
  309. package/assets/esri/core/workers/chunks/50ab9a3f8bbb268fae59.js +0 -1
  310. package/assets/esri/core/workers/chunks/5a8b3e5977c233d5c9d0.js +0 -1
  311. package/assets/esri/core/workers/chunks/5b2dd164dd84fd1ca4f7.js +0 -1
  312. package/assets/esri/core/workers/chunks/62c228ca16fdc7a2c695.js +0 -1
  313. package/assets/esri/core/workers/chunks/639202a461b17840a13f.js +0 -1
  314. package/assets/esri/core/workers/chunks/693d269637135047a0c4.js +0 -1
  315. package/assets/esri/core/workers/chunks/6a14ec2d2de6778a4e7a.js +0 -1
  316. package/assets/esri/core/workers/chunks/6d3467997b5d01630b08.js +0 -1
  317. package/assets/esri/core/workers/chunks/6dfcb0c804e63e87e311.js +0 -1
  318. package/assets/esri/core/workers/chunks/778ab9e4c3928b0d7d74.js +0 -1
  319. package/assets/esri/core/workers/chunks/8012fdc49a7a10982f78.js +0 -1
  320. package/assets/esri/core/workers/chunks/85e0fd618625a639387f.js +0 -1
  321. package/assets/esri/core/workers/chunks/86465d4bb185d7460087.js +0 -1
  322. package/assets/esri/core/workers/chunks/87e7378b242debbfd575.js +0 -1
  323. package/assets/esri/core/workers/chunks/90b19e60c056f32623e7.js +0 -1
  324. package/assets/esri/core/workers/chunks/9461f7225c42cf15a114.js +0 -1
  325. package/assets/esri/core/workers/chunks/978649cb6df99ee728be.js +0 -1
  326. package/assets/esri/core/workers/chunks/9f5f4da954228d876219.js +0 -1
  327. package/assets/esri/core/workers/chunks/a2323c957c8b2fe225b4.js +0 -1
  328. package/assets/esri/core/workers/chunks/a36a33f43610c3cd985b.js +0 -1
  329. package/assets/esri/core/workers/chunks/a381932eef77f4d80292.js +0 -1
  330. package/assets/esri/core/workers/chunks/b089947c9a492c96ca27.js +0 -1
  331. package/assets/esri/core/workers/chunks/b6e4c35b76379088035c.js +0 -1
  332. package/assets/esri/core/workers/chunks/bbf2afa05314e267893f.js +0 -1
  333. package/assets/esri/core/workers/chunks/bd2f577cae61facdde4a.js +0 -1
  334. package/assets/esri/core/workers/chunks/bf2bfc0d78be8c185d58.js +0 -1
  335. package/assets/esri/core/workers/chunks/c4a78ab84186c7be599a.js +0 -1
  336. package/assets/esri/core/workers/chunks/c6e0ada6f2ad74fddfec.js +0 -1
  337. package/assets/esri/core/workers/chunks/c9d600dc6b6b5aafff1c.js +0 -1
  338. package/assets/esri/core/workers/chunks/ca33847a997ccfe8ddc2.js +0 -1
  339. package/assets/esri/core/workers/chunks/cca19c9564be2d02a277.js +0 -1
  340. package/assets/esri/core/workers/chunks/ccc2f2b3db008d8a495f.js +0 -1
  341. package/assets/esri/core/workers/chunks/d9f900975ac915a0f24f.js +0 -1
  342. package/assets/esri/core/workers/chunks/dcc8363faa22e6211351.js +0 -1
  343. package/assets/esri/core/workers/chunks/dd5d66f067e2386e0514.js +0 -1
  344. package/assets/esri/core/workers/chunks/e081d6f21a2c01ccaf61.js +0 -1
  345. package/assets/esri/core/workers/chunks/eb4ffb72c9360062141c.js +0 -1
  346. package/assets/esri/core/workers/chunks/ebae903845643d60b44a.js +0 -1
  347. package/assets/esri/core/workers/chunks/ebb0372e8da0f75c09dd.js +0 -1
  348. package/assets/esri/core/workers/chunks/f349f64f683620bdf9b5.js +0 -30
  349. package/assets/esri/core/workers/chunks/f6fb87092bdf6bbf0769.js +0 -1
  350. package/assets/esri/core/workers/chunks/f76c2b09e6ba9d107898.js +0 -1
  351. package/assets/esri/core/workers/chunks/fcf962f3dec6b5440983.js +0 -1
  352. /package/assets/esri/core/workers/chunks/{43c8b1473695574c663e.js.LICENSE.txt → 4754610760f3f634adf9.js.LICENSE.txt} +0 -0
  353. /package/assets/esri/core/workers/chunks/{3861644c06cfebe8f40c.js.LICENSE.txt → 527547fa10d52cb3a7b1.js.LICENSE.txt} +0 -0
  354. /package/assets/esri/core/workers/chunks/{b586f1021a27c5e1551a.js.LICENSE.txt → 7189e03cc24f5c10865a.js.LICENSE.txt} +0 -0
  355. /package/assets/esri/core/workers/chunks/{3f812b0a28afb47aaaf0.js.LICENSE.txt → a35d1be700ebd3109397.js.LICENSE.txt} +0 -0
  356. /package/assets/esri/core/workers/chunks/{13d1cb50232ae761425b.js.LICENSE.txt → eaeb95be8d4032513247.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__addDisposableResource as t,__disposeResources as e}from"tslib";import{baseTypedSubArrayMemory as r}from"../core/memoryEstimations.js";import s from"./SpatialReference.js";import{empty as n,expandWithExtent as i}from"./support/aaBoundingBox.js";import{empty as a,expandExtentInPlace as o}from"./support/aaBoundingRect.js";import{isPoint as u,isMultipoint as h,isPolyline as l,isGeometryWithM as c,isGeometryWithZ as g}from"./support/jsonTypeUtils.js";import{equals as f}from"./support/spatialReferenceUtils.js";import{interpolateCircle as m}from"./support/curves/circleUtils.js";import{deriveCircleFromCircularArc as p}from"./support/curves/circularArcUtils.js";import{curveExtent as x}from"./support/curves/curveExtent.js";import{getEndpoint as v,isCurvedGeometry as d,isEllipticArc7 as y,isEllipticArc4 as C,isCircularArc as M,isBezierCurve as E}from"./support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as O}from"./support/curves/ellipticArc4Utils.js";import{deriveEllipse as F,interpolateEllipse as P}from"./support/curves/ellipticArc7Utils.js";import S from"../layers/graphics/OptimizedGeometry.js";class _{constructor({type:t,spatialReference:e,vertexCount:r,vertexXY:s,vertexZ:n,vertexM:i,partCount:a,partOffsets:o,partFlags:u,segmentFlags:h,segmentIndices:l,segmentParams:c,segmentCountArc:g,segmentCountBezier:f}){this.segmentCountArc=0,this.segmentCountBezier=0,this.type=t,this.spatialReference=e,this.vertexCount=r,this.vertexXY=s,this.vertexZ=n,this.vertexM=i,this.partCount=a,this.partOffsets=o,this.partFlags=u,this.segmentFlags=h,this.segmentIndices=l,this.segmentParams=c,this.segmentCountArc=g,this.segmentCountBezier=f}get segmentParamCount(){return 10*this.segmentCountArc+4*this.segmentCountBezier}get segmentCountLine(){const{segmentCount:t,segmentCountArc:e,segmentCountBezier:r}=this;return t&&t-e-r}get segmentCount(){return"polyline"===this.type?this.vertexCount-this.partCount:"polygon"===this.type?this.vertexCount:0}get hasZ(){return null!=this.vertexZ}get hasM(){return null!=this.vertexM}hasCurves(){return null!=this.segmentFlags}isMultipart(){return"polyline"===this.type||"polygon"===this.type}get usedMemory(){function t(t){return t?r+t.byteLength:0}return t(this.vertexXY)+t(this.vertexZ)+t(this.vertexM)+t(this.partOffsets)+t(this.partFlags)+t(this.segmentFlags)+t(this.segmentIndices)+t(this.segmentParams)}clone(){const{type:t,vertexCount:e,partCount:r,hasZ:s,hasM:n,segmentCountArc:i,segmentCountBezier:a}=this,o=U(t,e,r,s,n,this.hasCurves(),i,a);o.spatialReference=this.spatialReference;const{vertexXY:u,vertexZ:h,vertexM:l}=this;if(o.vertexXY.set(u.subarray(0,2*e),0),o.vertexZ?.set(h.subarray(0,e),0),o.vertexM?.set(l.subarray(0,e),0),this.isMultipart()){const{partOffsets:t,partFlags:e}=this;o.partFlags.set(e.subarray(0,r+1)),o.partOffsets.set(t.subarray(0,r+1))}if(this.hasCurves()){const{segmentFlags:t,segmentIndices:r,segmentParams:s,segmentParamCount:n}=this;o.segmentFlags.set(t.subarray(0,e),0),o.segmentIndices.set(r.subarray(0,e),0),o.segmentParams.set(s.subarray(0,n),0)}return o}equals(t){return this.equalsWithinTolerance(t,0)}equalsWithinTolerance(t,e){if(null==t)return!1;if(this===t)return!0;if(!f(this.spatialReference,t.spatialReference))return!1;if(this.vertexCount!==t.vertexCount||this.partCount!==t.partCount)return!1;if(this.hasZ!==t.hasZ||this.hasM!==t.hasM)return!1;if(this.hasCurves()!==t.hasCurves()||this.segmentCountArc!==t.segmentCountArc||this.segmentCountBezier!==t.segmentCountBezier)return!1;const r=0===e?(t,e)=>t!==e||isNaN(t)!==isNaN(e):(t,r)=>Math.abs(t-r)>e||isNaN(t)!==isNaN(r);for(let s=0;s<this.vertexCount;++s)if(r(this.vertexXY[2*s],t.vertexXY[2*s])||r(this.vertexXY[2*s+1],t.vertexXY[2*s+1]))return!1;if(this.hasZ)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexZ[s],t.vertexZ[s]))return!1;if(this.hasM)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexM[s],t.vertexM[s]))return!1;for(let s=0;s<this.partCount;++s)if(this.partFlags[s]!==t.partFlags[s]||this.partOffsets[s]!==t.partOffsets[s])return!1;if(this.hasCurves()){for(let e=0;e<this.vertexCount;++e)if(this.segmentFlags[e]!==t.segmentFlags[e]||this.segmentIndices[e]!==t.segmentIndices[e])return!1;for(let e=0;e<this.segmentParamCount;++e)if(r(this.segmentParams[e],t.segmentParams[e]))return!1}return!0}get parts(){return new Z(this)}}class Z{constructor(t){this.geometry=t,this.value=new A(t)}get done(){return this.value.index>=this.geometry.partCount}next(){return++this.value.index,this}[Symbol.iterator](){return this}}class A{constructor(t){this.geometry=t,this.index=-1,this._readVertex=j(t),this._segments=new R(this)}get segments(){return this._segments.reset(),this._segments}get startVertex(){return this._readVertex(this.geometry.partOffsets[this.index])}get vertexCount(){const t=this.geometry.partOffsets;return t[this.index+1]-t[this.index]}}class R{constructor(t){this._part=t,this._partStart=0,this._partEnd=0,this._isPolygon="polygon"===t.geometry.type,this.value=new V(t.geometry)}get done(){return this.value.indexOfStartVertex>this._partEnd}next(){++this.value.indexOfStartVertex;const t=this.value.indexOfStartVertex>=this._partEnd;return this.value.indexOfEndVertex=t&&this._isPolygon?this._partStart:this.value.indexOfStartVertex+1,this}[Symbol.iterator](){return this}reset(){const{index:t}=this._part,e=this._part.geometry.partOffsets;this._partStart=e[t],this._partEnd=e[t+1]-(this._isPolygon?1:2),this.value.indexOfStartVertex=this._partStart-1}}class V{constructor(t){this.geometry=t,this.indexOfStartVertex=-1,this.indexOfEndVertex=-1,this._readVertex=j(t)}get xStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex]}get yStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex+1]}get zStart(){return this.geometry.vertexZ[this.indexOfStartVertex]}get mStart(){return this.geometry.vertexM[this.indexOfStartVertex]}get xEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex]}get yEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex+1]}get zEnd(){return this.geometry.vertexZ[this.indexOfEndVertex]}get mEnd(){return this.geometry.vertexM[this.indexOfEndVertex]}get start(){return this._readVertex(this.indexOfStartVertex)}get end(){return this._readVertex(this.indexOfEndVertex)}get curve(){const t=this.geometry.segmentFlags?.[this.indexOfStartVertex]??1;if(1===t)return this.end;const e=this.geometry.segmentParams;let r=this.geometry.segmentIndices[this.indexOfStartVertex];if(2===t){const t=e[r++],s=e[r++],n=e[r++],i=e[r++];return{b:[this.end,[t,s],[n,i]]}}const s=e[r++],n=e[r++],i=e[r++],a=e[r++],o=e[r++],u=e[r++];r++,r++;const h=e[r++],l=e[r++];if(!Boolean(4&s)&&1===i)return{c:[this.end,[h,l]]};const c=2&s?0:1,g=1&s?0:1;return{a:[this.end,[o,u],c,g,a,n,i]}}}function Y(r){let s;const{vertexCount:n,vertexXY:i,vertexZ:o,vertexM:u}=r,h=z(r);if(r.hasCurves()){const n={stack:[],error:void 0,hasError:!1};try{t(n,new k(r,["vertexZ","vertexM"]),!1);const e=a();for(const t of r.parts){let r=t.startVertex;for(const{curve:s}of t.segments)x(e,r,s),r=v(s)}const[i,o,u,l]=e;s={xmin:i,ymin:o,xmax:u,ymax:l,spatialReference:h}}catch(l){n.error=l,n.hasError=!0}finally{e(n)}}else{let t,e,r,a;t=e=1/0,r=a=-1/0;for(let s=0;s<n;++s){const n=i[2*s],o=i[2*s+1];t=Math.min(t,n),r=Math.max(r,n),e=Math.min(e,o),a=Math.max(a,o)}s={xmin:t,ymin:e,xmax:r,ymax:a,spatialReference:h}}if(o){let t=1/0,e=-1/0;for(const r of o)t=Math.min(t,r),e=Math.max(e,r);s.zmin=t,s.zmax=e}if(u){let t=1/0,e=-1/0;for(const r of u)t=Math.min(t,r),e=Math.max(e,r);s.mmin=t,s.mmax=e}return s}function b(r,s){const n={stack:[],error:void 0,hasError:!1};try{s??=a();t(n,new k(r,["vertexZ","vertexM","spatialReference"]),!1);return o(s,Y(r)),s}catch(i){n.error=i,n.hasError=!0}finally{e(n)}}function w(r,s){const a={stack:[],error:void 0,hasError:!1};try{s??=n();t(a,new k(r,["vertexM","spatialReference"]),!1);return i(s,Y(r)),s}catch(o){a.error=o,a.hasError=!0}finally{e(a)}}function I(t){let e,r,s;if(u(t)){s="point";const{x:n,y:i,z:a,m:o}=t,u=[n,i];null!=a&&u.push(a),null!=o&&u.push(o),r=[[u]],e=1}else h(t)?(s="multipoint",r=[t.points],e=t.points.length):l(t)?(s="polyline",r=t.curvePaths??t.paths,e=r.reduce((t,e)=>t+e.length,0)):(s="polygon",r=t.curveRings??t.rings,e=r.reduce((t,e)=>(0===e.length||(t+=e.length,W(e[0],v(e.at(-1)))&&--t),t),0));const n=U(s,e,s.includes("point")?0:r.length,g(t),c(t),d(t)),{hasZ:i,hasM:a,vertexXY:o,vertexZ:f,vertexM:m}=n;function p(t){o[2*O]=t[0],o[2*O+1]=t[1],i&&(f[O]=t[2]),a&&(m[O]=t[x]),++O}n.spatialReference=t.spatialReference??void 0;const x=n.hasZ?3:2;let O=0;if(!n.isMultipart()){if(!i&&!a){for(const[t,e]of r[0])o[2*O]=t,o[2*O+1]=e,++O;return n}for(const t of r[0])p(t);return n}const F="polygon"===s,{partOffsets:P}=n;let S=0;if(!n.hasCurves()){for(const t of r){if(P[S++]=O,0===t.length)continue;let e=t.length;if(F&&W(t[0],t.at(-1))&&--e,i||a)for(let r=0;r<e;++r)p(t[r]);else for(let r=0;r<e;++r){const[e,s]=t[r];o[2*O]=e,o[2*O+1]=s,++O}}return P[S]=O,n}function _(t){const e=Z+t;if(e<=(n.segmentParams?.length??0))return;let r=e*K;r=20*Math.ceil(r/20);const s=n.segmentParams;n.segmentParams=new Float64Array(r),null!=s&&n.segmentParams.set(s)}let Z=0;for(const u of r){if(n.partOffsets[S++]=O,0===u.length)continue;const t=u[0];let e=t;for(let r=1;r<u.length;++r){const t=u[r];p(e);const s=O-1;y(t)?(_(10),++n.segmentCountArc,Z=D(e,t,n,s,Z),e=t.a[0]):C(t)?(_(10),++n.segmentCountArc,Z=q(e,t,n,s,Z),e=t.a[0]):M(t)?(_(10),++n.segmentCountArc,Z=G(e,t,n,s,Z),e=t.c[0]):E(t)?(_(4),++n.segmentCountBezier,Z=H(e,t,n,s,Z),e=t.b[0]):e=t}F&&W(t,e)||p(e)}return n.partOffsets[S]=O,n}function X(t){const e=j(t),{vertexCount:r,partCount:s,hasZ:n,hasM:i}=t,a=z(t);if("point"===t.type){const[e,r]=t.vertexXY,s=t.vertexZ?.[0],n=t.vertexM?.[0];return{x:e,y:r,z:s,m:n,spatialReference:a}}let o=0;if("multipoint"===t.type){const t=[];for(;o<r;)t.push(e(o++));return{points:t,spatialReference:a,hasZ:n,hasM:i}}const u="polygon"===t.type;if(!t.hasCurves()){const r=new Array;for(let n=0;n<s;++n){const s=t.partOffsets[n+1],i=new Array;for(;o<s;)i.push(e(o++));u&&i.length>0&&i.push(i[0]),r.push(i)}return u?{rings:r,hasZ:n,hasM:i,spatialReference:a}:{paths:r,hasZ:n,hasM:i,spatialReference:a}}const h=new Array;for(const{segments:l,startVertex:c}of t.parts){const t=[c];for(const{curve:e}of l)t.push(e);h.push(t)}return u?{rings:[],curveRings:h,hasZ:n,hasM:i,spatialReference:a}:{paths:[],curvePaths:h,hasZ:n,hasM:i,spatialReference:a}}function B(t,{lengths:e,coords:r,hasZ:s,hasM:n},i){const a=t.includes("point")?0:e.length,o="polygon"===t,u="point"===t?1:e.reduce((t,e)=>t+e,0)-(o?a:0);s??=!1,n??=!1;const h=U(t,u,a,s,n,!1,0,0);if(h.spatialReference=i??void 0,!h.isMultipart()){for(let t=0,e=0;t<u;++t)h.vertexXY[2*t]=r[e++],h.vertexXY[2*t+1]=r[e++],s&&(h.vertexZ[t]=r[e++]),n&&(h.vertexM[t]=r[e++]);return h}const l=2+Number(s)+Number(n);let c=0,g=0;h.partOffsets[0]=0;for(const f of e){const t=h.partOffsets[g],e=t+f-Number(o);h.partOffsets[++g]=e;for(let i=t;i<e;++i)h.vertexXY[2*i]=r[c++],h.vertexXY[2*i+1]=r[c++],s&&(h.vertexZ[i]=r[c++]),n&&(h.vertexM[i]=r[c++]);o&&(c+=l)}return h}function L({type:t,vertexCount:e,vertexXY:r,vertexZ:s,vertexM:n,partCount:i,partOffsets:a,hasZ:o,hasM:u}){const h=new S([],[],o,u);i=Math.max(i,1);const l="polygon"===t;let c=0;for(let g=0;g<i;++g){const t=a?.[g+1]??e,i=h.coords.length;for(let e=c;e<t;++e)h.coords.push(r[2*e],r[2*e+1]),o&&h.coords.push(s[e]),u&&h.coords.push(n[e]);if(l){const t=c;h.coords.push(r[2*t],r[2*t+1]),o&&h.coords.push(s[t]),u&&h.coords.push(n[t])}h.lengths.push((h.coords.length-i)/h.stride),c=t}return"point"===t&&(h.lengths.length=0),h}function N(t,e){return"getSpatialReference"in t&&(e=T(t.getSpatialReference()),t=t.getGeometry()),new _({...t.toFlatGeometry(),spatialReference:e})}function T(t){if(null==t)return;const e=t.getText()||void 0,r=t.isCustomWkid()?0:t.getOldID();if(r<=0)return{wkt:e};let s=t.getLatestID();(s<=0||s===r)&&(s=void 0);const n=t.getVCS();if(null==n)return{wkid:r,latestWkid:s,wkt:e};const i=n.isCustomWkid()?0:n.getOldID();if(i<=0)return{wkt:e};let a=t.getLatestVerticalID();return(a<=0||a===i)&&(a=void 0),{wkid:r,wkt:e,latestWkid:s,vcsWkid:i,latestVcsWkid:a}}class k{constructor(t,e){this.target=t,this.keys=e,this.oldValues=e.map(e=>t[e]);for(const r of e)t[r]=void 0}[Symbol.dispose](){this.keys.map((t,e)=>{this.target[t]=this.oldValues[e]})}}function z({spatialReference:t}){return t instanceof s?t.toJSON():t}function j({vertexXY:t,vertexZ:e,vertexM:r}){return e?r?s=>[t[2*s],t[2*s+1],e[s],r[s]]:r=>[t[2*r],t[2*r+1],e[r]]:r?e=>[t[2*e],t[2*e+1],r[e]]:e=>[t[2*e],t[2*e+1]]}function W(t,e){return t.every((t,r)=>t===e[r])}function U(t,e,r,s,n,i,a,o){a??=0,o??=0;const u=new _({type:t,vertexCount:e,vertexXY:null,vertexZ:void 0,vertexM:void 0,partCount:r,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:a,segmentCountBezier:o});let h=2*Float64Array.BYTES_PER_ELEMENT*e;s&&(h+=Float64Array.BYTES_PER_ELEMENT*e),n&&(h+=Float64Array.BYTES_PER_ELEMENT*e),u.isMultipart()&&(h+=(r+1)*Int32Array.BYTES_PER_ELEMENT,h+=(r+1)*Int8Array.BYTES_PER_ELEMENT),i&&(h+=e*Int8Array.BYTES_PER_ELEMENT,h+=e*Int32Array.BYTES_PER_ELEMENT,h+=u.segmentParamCount*Float64Array.BYTES_PER_ELEMENT);const l=new ArrayBuffer(h);let c=0;return u.vertexXY=new Float64Array(l,c,2*e),c+=u.vertexXY.byteLength,s&&(u.vertexZ=new Float64Array(l,c,e),c+=u.vertexZ.byteLength),n&&(u.vertexM=new Float64Array(l,c,e),c+=u.vertexM.byteLength),i&&(u.segmentParams=new Float64Array(l,c,u.segmentParamCount),c+=u.segmentParams.byteLength,u.segmentIndices=new Int32Array(l,c,e),u.segmentIndices.fill(Q),c+=u.segmentIndices.byteLength),u.isMultipart()&&(u.partOffsets=new Int32Array(l,c,r+1),c+=u.partOffsets.byteLength,u.partFlags=new Int8Array(l,c,r+1),c+=u.partFlags.byteLength,"polygon"===u.type&&u.partFlags.subarray(0,r).fill(1)),i&&(u.segmentFlags=new Int8Array(l,c,e),u.segmentFlags.fill(1),c+=u.segmentFlags.byteLength),u}function D(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const[o,[u,h],l,c,g,f,m]=e.a;let p=4;c||(p|=1),l||(p|=2);const x=F(t,e),[v,d]=P(x,.5);return n[a++]=p,n[a++]=f,n[a++]=m,n[a++]=g,n[a++]=u,n[a++]=h,n[a++]=x.u2-x.u1,n[a++]=x.u1,n[a++]=v,n[a++]=d,a}function q(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const o=O(t,e);return J(o,4,...m(o,.5),n,a)}function G(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;return J(p(t,e),0,...e.c[1],n,a)}function J(t,e,r,s,n,i){const{cx:a,cy:o,thetaStart:u,thetaEnd:h,radius:l}=t;u>h||(e|=1);return Math.abs(h-u)<=Math.PI||(e|=2),n[i++]=e,n[i++]=l,n[i++]=1,n[i++]=0,n[i++]=a,n[i++]=o,n[i++]=h-u,n[i++]=u,n[i++]=r,n[i++]=s,i}function H(t,{b:[e,[r,s],[n,i]]},{segmentFlags:a,segmentIndices:o,segmentParams:u},h,l){return a[h]=2,o[h]=l,u[l++]=r,u[l++]=s,u[l++]=n,u[l++]=i,l}const K=1.61803,Q=-1;export{_ as FlatGeometry,U as allocateFlatGeometry,X as convertFlatToGeometryJSON,L as convertFlatToOptimizedGeometry,I as convertGeometryToFlat,N as convertGeometryxToFlat,B as convertOptimizedGeometryToFlat,w as getBoundingBox,b as getBoundingRect,Y as getExtentJSON,H as writeBezierCurveSegment,G as writeCircularArcSegment,q as writeEllipticArc4Segment,D as writeEllipticArc7Segment};
2
+ import{__addDisposableResource as t,__disposeResources as e}from"tslib";import{baseTypedSubArrayMemory as r}from"../core/memoryEstimations.js";import s from"./SpatialReference.js";import{empty as n,expandWithExtent as i}from"./support/aaBoundingBox.js";import{empty as a,expandExtentInPlace as o}from"./support/aaBoundingRect.js";import{isPoint as u,isMultipoint as h,isPolyline as l,isGeometryWithM as c,isGeometryWithZ as g}from"./support/jsonTypeUtils.js";import{equals as f}from"./support/spatialReferenceUtils.js";import{interpolateCircle as m}from"./support/curves/circleUtils.js";import{deriveCircleFromCircularArc as p}from"./support/curves/circularArcUtils.js";import{curveExtent as x}from"./support/curves/curveExtent.js";import{getEndpoint as v,isCurvedGeometry as d,isEllipticArc7 as y,isEllipticArc4 as C,isCircularArc as M,isBezierCurve as E}from"./support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as O}from"./support/curves/ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as F}from"./support/curves/ellipticArc7Utils.js";import P from"../layers/graphics/OptimizedGeometry.js";class _{constructor({type:t,spatialReference:e,vertexCount:r,vertexXY:s,vertexZ:n,vertexM:i,partCount:a,partOffsets:o,partFlags:u,segmentFlags:h,segmentIndices:l,segmentParams:c,segmentCountArc:g,segmentCountBezier:f}){this.segmentCountArc=0,this.segmentCountBezier=0,this.type=t,this.spatialReference=e,this.vertexCount=r,this.vertexXY=s,this.vertexZ=n,this.vertexM=i,this.partCount=a,this.partOffsets=o,this.partFlags=u,this.segmentFlags=h,this.segmentIndices=l,this.segmentParams=c,this.segmentCountArc=g,this.segmentCountBezier=f}get segmentParamCount(){return 10*this.segmentCountArc+4*this.segmentCountBezier}get segmentCountLine(){const{segmentCount:t,segmentCountArc:e,segmentCountBezier:r}=this;return t&&t-e-r}get segmentCount(){return"polyline"===this.type?this.vertexCount-this.partCount:"polygon"===this.type?this.vertexCount:0}get hasZ(){return null!=this.vertexZ}get hasM(){return null!=this.vertexM}hasCurves(){return null!=this.segmentFlags}isMultipart(){return"polyline"===this.type||"polygon"===this.type}get usedMemory(){function t(t){return t?r+t.byteLength:0}return t(this.vertexXY)+t(this.vertexZ)+t(this.vertexM)+t(this.partOffsets)+t(this.partFlags)+t(this.segmentFlags)+t(this.segmentIndices)+t(this.segmentParams)}clone(){const{type:t,vertexCount:e,partCount:r,hasZ:s,hasM:n,segmentCountArc:i,segmentCountBezier:a}=this,o=U(t,e,r,s,n,this.hasCurves(),i,a);o.spatialReference=this.spatialReference;const{vertexXY:u,vertexZ:h,vertexM:l}=this;if(o.vertexXY.set(u.subarray(0,2*e),0),o.vertexZ?.set(h.subarray(0,e),0),o.vertexM?.set(l.subarray(0,e),0),this.isMultipart()){const{partOffsets:t,partFlags:e}=this;o.partFlags.set(e.subarray(0,r+1)),o.partOffsets.set(t.subarray(0,r+1))}if(this.hasCurves()){const{segmentFlags:t,segmentIndices:r,segmentParams:s,segmentParamCount:n}=this;o.segmentFlags.set(t.subarray(0,e),0),o.segmentIndices.set(r.subarray(0,e),0),o.segmentParams.set(s.subarray(0,n),0)}return o}equals(t){return this.equalsWithinTolerance(t,0)}equalsWithinTolerance(t,e){if(null==t)return!1;if(this===t)return!0;if(!f(this.spatialReference,t.spatialReference))return!1;if(this.vertexCount!==t.vertexCount||this.partCount!==t.partCount)return!1;if(this.hasZ!==t.hasZ||this.hasM!==t.hasM)return!1;if(this.hasCurves()!==t.hasCurves()||this.segmentCountArc!==t.segmentCountArc||this.segmentCountBezier!==t.segmentCountBezier)return!1;const r=0===e?(t,e)=>t!==e||isNaN(t)!==isNaN(e):(t,r)=>Math.abs(t-r)>e||isNaN(t)!==isNaN(r);for(let s=0;s<this.vertexCount;++s)if(r(this.vertexXY[2*s],t.vertexXY[2*s])||r(this.vertexXY[2*s+1],t.vertexXY[2*s+1]))return!1;if(this.hasZ)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexZ[s],t.vertexZ[s]))return!1;if(this.hasM)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexM[s],t.vertexM[s]))return!1;for(let s=0;s<this.partCount;++s)if(this.partFlags[s]!==t.partFlags[s]||this.partOffsets[s]!==t.partOffsets[s])return!1;if(this.hasCurves()){for(let e=0;e<this.vertexCount;++e)if(this.segmentFlags[e]!==t.segmentFlags[e]||this.segmentIndices[e]!==t.segmentIndices[e])return!1;for(let e=0;e<this.segmentParamCount;++e)if(r(this.segmentParams[e],t.segmentParams[e]))return!1}return!0}get parts(){return this.isMultipart()?new Z(this):[][Symbol.iterator]()}}class Z{constructor(t){this.geometry=t,this.value=new A(t)}get done(){return this.value.index>=this.geometry.partCount}next(){return++this.value.index,this}[Symbol.iterator](){return this}}class A{constructor(t){this.geometry=t,this.index=-1,this._readVertex=j(t),this._segments=new R(this)}get segments(){return this._segments.reset(),this._segments}get startVertex(){return this._readVertex(this.geometry.partOffsets[this.index])}get vertexCount(){const t=this.geometry.partOffsets;return t[this.index+1]-t[this.index]}}class R{constructor(t){this._part=t,this._partStart=0,this._partEnd=0,this._isPolygon="polygon"===t.geometry.type,this.value=new V(t.geometry)}get done(){return this.value.indexOfStartVertex>this._partEnd}next(){++this.value.indexOfStartVertex;const t=this.value.indexOfStartVertex>=this._partEnd;return this.value.indexOfEndVertex=t&&this._isPolygon?this._partStart:this.value.indexOfStartVertex+1,this}[Symbol.iterator](){return this}reset(){const{index:t}=this._part,e=this._part.geometry.partOffsets;this._partStart=e[t],this._partEnd=e[t+1]-(this._isPolygon?1:2),this.value.indexOfStartVertex=this._partStart-1}}class V{constructor(t){this.geometry=t,this.indexOfStartVertex=-1,this.indexOfEndVertex=-1,this._readVertex=j(t)}get xStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex]}get yStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex+1]}get zStart(){return this.geometry.vertexZ[this.indexOfStartVertex]}get mStart(){return this.geometry.vertexM[this.indexOfStartVertex]}get xEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex]}get yEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex+1]}get zEnd(){return this.geometry.vertexZ[this.indexOfEndVertex]}get mEnd(){return this.geometry.vertexM[this.indexOfEndVertex]}get start(){return this._readVertex(this.indexOfStartVertex)}get end(){return this._readVertex(this.indexOfEndVertex)}get curve(){const t=this.geometry.segmentFlags?.[this.indexOfStartVertex]??1;if(1===t)return this.end;const e=this.geometry.segmentParams;let r=this.geometry.segmentIndices[this.indexOfStartVertex];if(2===t){const t=e[r++],s=e[r++],n=e[r++],i=e[r++];return{b:[this.end,[t,s],[n,i]]}}const s=e[r++],n=e[r++],i=e[r++],a=e[r++],o=e[r++],u=e[r++];r++,r++;const h=e[r++],l=e[r++];if(!Boolean(4&s)&&1===i)return{c:[this.end,[h,l]]};const c=2&s?0:1,g=1&s?0:1;return{a:[this.end,[o,u],c,g,a,n,i]}}}function Y(r){let s;const{vertexCount:n,vertexXY:i,vertexZ:o,vertexM:u}=r,h=z(r);if(r.hasCurves()){const n={stack:[],error:void 0,hasError:!1};try{t(n,new k(r,["vertexZ","vertexM"]),!1);const e=a();for(const t of r.parts){let r=t.startVertex;for(const{curve:s}of t.segments)x(e,r,s),r=v(s)}const[i,o,u,l]=e;s={xmin:i,ymin:o,xmax:u,ymax:l,spatialReference:h}}catch(l){n.error=l,n.hasError=!0}finally{e(n)}}else{let t,e,r,a;t=e=1/0,r=a=-1/0;for(let s=0;s<n;++s){const n=i[2*s],o=i[2*s+1];t=Math.min(t,n),r=Math.max(r,n),e=Math.min(e,o),a=Math.max(a,o)}s={xmin:t,ymin:e,xmax:r,ymax:a,spatialReference:h}}if(o){let t=1/0,e=-1/0;for(const r of o)t=Math.min(t,r),e=Math.max(e,r);s.zmin=t,s.zmax=e}if(u){let t=1/0,e=-1/0;for(const r of u)t=Math.min(t,r),e=Math.max(e,r);s.mmin=t,s.mmax=e}return s}function b(r,s){const n={stack:[],error:void 0,hasError:!1};try{s??=a();t(n,new k(r,["vertexZ","vertexM","spatialReference"]),!1);return o(s,Y(r)),s}catch(i){n.error=i,n.hasError=!0}finally{e(n)}}function w(r,s){const a={stack:[],error:void 0,hasError:!1};try{s??=n();t(a,new k(r,["vertexM","spatialReference"]),!1);return i(s,Y(r)),s}catch(o){a.error=o,a.hasError=!0}finally{e(a)}}function I(t){let e,r,s;if(u(t)){s="point";const{x:n,y:i,z:a,m:o}=t,u=[n,i];null!=a&&u.push(a),null!=o&&u.push(o),r=[[u]],e=1}else h(t)?(s="multipoint",r=[t.points],e=t.points.length):l(t)?(s="polyline",r=t.curvePaths??t.paths,e=r.reduce((t,e)=>t+e.length,0)):(s="polygon",r=t.curveRings??t.rings,e=r.reduce((t,e)=>(0===e.length||(t+=e.length,W(e[0],v(e.at(-1)))&&--t),t),0));const n=U(s,e,s.includes("point")?0:r.length,g(t),c(t),d(t)),{hasZ:i,hasM:a,vertexXY:o,vertexZ:f,vertexM:m}=n;function p(t){o[2*O]=t[0],o[2*O+1]=t[1],i&&(f[O]=t[2]),a&&(m[O]=t[x]),++O}n.spatialReference=t.spatialReference??void 0;const x=n.hasZ?3:2;let O=0;if(!n.isMultipart()){if(!i&&!a){for(const[t,e]of r[0])o[2*O]=t,o[2*O+1]=e,++O;return n}for(const t of r[0])p(t);return n}const S="polygon"===s,{partOffsets:F}=n;let P=0;if(!n.hasCurves()){for(const t of r){if(F[P++]=O,0===t.length)continue;let e=t.length;if(S&&W(t[0],t.at(-1))&&--e,i||a)for(let r=0;r<e;++r)p(t[r]);else for(let r=0;r<e;++r){const[e,s]=t[r];o[2*O]=e,o[2*O+1]=s,++O}}return F[P]=O,n}function _(t){const e=Z+t;if(e<=(n.segmentParams?.length??0))return;let r=e*K;r=20*Math.ceil(r/20);const s=n.segmentParams;n.segmentParams=new Float64Array(r),null!=s&&n.segmentParams.set(s)}let Z=0;for(const u of r){if(n.partOffsets[P++]=O,0===u.length)continue;const t=u[0];let e=t;for(let r=1;r<u.length;++r){const t=u[r];p(e);const s=O-1;y(t)?(_(10),++n.segmentCountArc,Z=D(e,t,n,s,Z),e=t.a[0]):C(t)?(_(10),++n.segmentCountArc,Z=q(e,t,n,s,Z),e=t.a[0]):M(t)?(_(10),++n.segmentCountArc,Z=G(e,t,n,s,Z),e=t.c[0]):E(t)?(_(4),++n.segmentCountBezier,Z=H(e,t,n,s,Z),e=t.b[0]):e=t}S&&W(t,e)||p(e)}return n.partOffsets[P]=O,n}function X(t){const e=j(t),{vertexCount:r,partCount:s,hasZ:n,hasM:i}=t,a=z(t);if("point"===t.type){const[e,r]=t.vertexXY,s=t.vertexZ?.[0],n=t.vertexM?.[0];return{x:e,y:r,z:s,m:n,spatialReference:a}}let o=0;if("multipoint"===t.type){const t=[];for(;o<r;)t.push(e(o++));return{points:t,spatialReference:a,hasZ:n,hasM:i}}const u="polygon"===t.type;if(!t.hasCurves()){const r=new Array;for(let n=0;n<s;++n){const s=t.partOffsets[n+1],i=new Array;for(;o<s;)i.push(e(o++));u&&i.length>0&&i.push(i[0]),r.push(i)}return u?{rings:r,hasZ:n,hasM:i,spatialReference:a}:{paths:r,hasZ:n,hasM:i,spatialReference:a}}const h=new Array;for(const{segments:l,startVertex:c}of t.parts){const t=[c];for(const{curve:e}of l)t.push(e);h.push(t)}return u?{rings:[],curveRings:h,hasZ:n,hasM:i,spatialReference:a}:{paths:[],curvePaths:h,hasZ:n,hasM:i,spatialReference:a}}function B(t,{lengths:e,coords:r,hasZ:s,hasM:n},i){const a=t.includes("point")?0:e.length,o="polygon"===t,u="point"===t?1:e.reduce((t,e)=>t+e,0)-(o?a:0);s??=!1,n??=!1;const h=U(t,u,a,s,n,!1,0,0);if(h.spatialReference=i??void 0,!h.isMultipart()){for(let t=0,e=0;t<u;++t)h.vertexXY[2*t]=r[e++],h.vertexXY[2*t+1]=r[e++],s&&(h.vertexZ[t]=r[e++]),n&&(h.vertexM[t]=r[e++]);return h}const l=2+Number(s)+Number(n);let c=0,g=0;h.partOffsets[0]=0;for(const f of e){const t=h.partOffsets[g],e=t+f-Number(o);h.partOffsets[++g]=e;for(let i=t;i<e;++i)h.vertexXY[2*i]=r[c++],h.vertexXY[2*i+1]=r[c++],s&&(h.vertexZ[i]=r[c++]),n&&(h.vertexM[i]=r[c++]);o&&(c+=l)}return h}function L({type:t,vertexCount:e,vertexXY:r,vertexZ:s,vertexM:n,partCount:i,partOffsets:a,hasZ:o,hasM:u}){const h=new P([],[],o,u);i=Math.max(i,1);const l="polygon"===t;let c=0;for(let g=0;g<i;++g){const t=a?.[g+1]??e,i=h.coords.length;for(let e=c;e<t;++e)h.coords.push(r[2*e],r[2*e+1]),o&&h.coords.push(s[e]),u&&h.coords.push(n[e]);if(l){const t=c;h.coords.push(r[2*t],r[2*t+1]),o&&h.coords.push(s[t]),u&&h.coords.push(n[t])}h.lengths.push((h.coords.length-i)/h.stride),c=t}return"point"===t&&(h.lengths.length=0),h}function N(t,e){return"getSpatialReference"in t&&(e=T(t.getSpatialReference()),t=t.getGeometry()),new _({...t.toFlatGeometry(),spatialReference:e})}function T(t){if(null==t)return;const e=t.getText()||void 0,r=t.isCustomWkid()?0:t.getOldID();if(r<=0)return{wkt:e};let s=t.getLatestID();(s<=0||s===r)&&(s=void 0);const n=t.getVCS();if(null==n)return{wkid:r,latestWkid:s,wkt:e};const i=n.isCustomWkid()?0:n.getOldID();if(i<=0)return{wkt:e};let a=t.getLatestVerticalID();return(a<=0||a===i)&&(a=void 0),{wkid:r,wkt:e,latestWkid:s,vcsWkid:i,latestVcsWkid:a}}class k{constructor(t,e){this.target=t,this.keys=e,this.oldValues=e.map(e=>t[e]);for(const r of e)t[r]=void 0}[Symbol.dispose](){this.keys.map((t,e)=>{this.target[t]=this.oldValues[e]})}}function z({spatialReference:t}){return t instanceof s?t.toJSON():t}function j({vertexXY:t,vertexZ:e,vertexM:r}){return e?r?s=>[t[2*s],t[2*s+1],e[s],r[s]]:r=>[t[2*r],t[2*r+1],e[r]]:r?e=>[t[2*e],t[2*e+1],r[e]]:e=>[t[2*e],t[2*e+1]]}function W(t,e){return t.every((t,r)=>t===e[r])}function U(t,e,r,s,n,i,a,o){a??=0,o??=0;const u=new _({type:t,vertexCount:e,vertexXY:null,vertexZ:void 0,vertexM:void 0,partCount:r,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:a,segmentCountBezier:o});let h=2*Float64Array.BYTES_PER_ELEMENT*e;s&&(h+=Float64Array.BYTES_PER_ELEMENT*e),n&&(h+=Float64Array.BYTES_PER_ELEMENT*e),u.isMultipart()&&(h+=(r+1)*Int32Array.BYTES_PER_ELEMENT,h+=(r+1)*Int8Array.BYTES_PER_ELEMENT),i&&(h+=e*Int8Array.BYTES_PER_ELEMENT,h+=e*Int32Array.BYTES_PER_ELEMENT,h+=u.segmentParamCount*Float64Array.BYTES_PER_ELEMENT);const l=new ArrayBuffer(h);let c=0;return u.vertexXY=new Float64Array(l,c,2*e),c+=u.vertexXY.byteLength,s&&(u.vertexZ=new Float64Array(l,c,e),c+=u.vertexZ.byteLength),n&&(u.vertexM=new Float64Array(l,c,e),c+=u.vertexM.byteLength),i&&(u.segmentParams=new Float64Array(l,c,u.segmentParamCount),c+=u.segmentParams.byteLength,u.segmentIndices=new Int32Array(l,c,e),u.segmentIndices.fill(Q),c+=u.segmentIndices.byteLength),u.isMultipart()&&(u.partOffsets=new Int32Array(l,c,r+1),c+=u.partOffsets.byteLength,u.partFlags=new Int8Array(l,c,r+1),c+=u.partFlags.byteLength,"polygon"===u.type&&u.partFlags.subarray(0,r).fill(1)),i&&(u.segmentFlags=new Int8Array(l,c,e),u.segmentFlags.fill(1),c+=u.segmentFlags.byteLength),u}function D(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const[o,[u,h],l,c,g,f,m]=e.a;let p=4;c||(p|=1),l||(p|=2);const x=S(t,e),[v,d]=F(x,.5);return n[a++]=p,n[a++]=f,n[a++]=m,n[a++]=g,n[a++]=u,n[a++]=h,n[a++]=x.u2-x.u1,n[a++]=x.u1,n[a++]=v,n[a++]=d,a}function q(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const o=O(t,e);return J(o,4,...m(o,.5),n,a)}function G(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;return J(p(t,e),0,...e.c[1],n,a)}function J(t,e,r,s,n,i){const{cx:a,cy:o,thetaStart:u,thetaEnd:h,radius:l}=t;u>h||(e|=1);return Math.abs(h-u)<=Math.PI||(e|=2),n[i++]=e,n[i++]=l,n[i++]=1,n[i++]=0,n[i++]=a,n[i++]=o,n[i++]=h-u,n[i++]=u,n[i++]=r,n[i++]=s,i}function H(t,{b:[e,[r,s],[n,i]]},{segmentFlags:a,segmentIndices:o,segmentParams:u},h,l){return a[h]=2,o[h]=l,u[l++]=r,u[l++]=s,u[l++]=n,u[l++]=i,l}const K=1.61803,Q=-1;export{_ as FlatGeometry,U as allocateFlatGeometry,X as convertFlatToGeometryJSON,L as convertFlatToOptimizedGeometry,I as convertGeometryToFlat,N as convertGeometryxToFlat,B as convertOptimizedGeometryToFlat,w as getBoundingBox,b as getBoundingRect,Y as getExtentJSON,H as writeBezierCurveSegment,G as writeCircularArcSegment,q as writeEllipticArc4Segment,D as writeEllipticArc7Segment};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{equals as n,sliceEquals as r}from"../../../core/arrayUtils.js";function t(n){return"curveRings"in n&&!!n.curveRings?.length||"curvePaths"in n&&!!n.curvePaths?.length}function u(n){return"curveRings"in n?n.curveRings:n.curvePaths}function e(n){return"b"in n}function c(n){return"c"in n}function i(n){return Array.isArray(n)}function o(n){return"a"in n}function s(n){return"a"in n&&4===n.a.length}function a(n){return"a"in n&&7===n.a.length}function f(n){return!(!n||!t(n))&&u(n).some(n=>n.some(n=>c(n)))}function g(n,r){return i(n)?i(r):e(n)?e(r):c(n)?c(r):s(n)?s(r):!!a(n)&&a(r)}function h(n){return i(n)?n:e(n)?n.b[0]:c(n)?n.c[0]:n.a[0]}function b(n){if(e(n)){const[r,t,u]=n.b;return{b:[[...r],[...t],[...u]]}}if(c(n)){const[r,t]=n.c;return{c:[[...r],[...t]]}}if(i(n))return[...n];if(s(n)){const[r,t,u,e]=n.a;return{a:[[...r],[...t],u,e]}}if(a(n)){const[r,t,u,e,c,i,o]=n.a;return{a:[[...r],[...t],u,e,c,i,o]}}return n}function l(n){return t(n)?"curveRings"in n?n.curveRings:n.curvePaths:"rings"in n?n.rings:n.paths}function v(n){return n.some(n=>!i(n))}function R(n,r=0,t=1){let u=0;const e=n.length;let c=h(n[0]);for(let i=1;i<e;i++){const e=h(n[i]);u+=(e[r]-c[r])*(e[t]+c[t]),c=e}if(m(n)){const e=h(n[0]);u+=(e[r]-c[r])*(e[t]+c[t])}return u>=0}function m(r){const t=r.length;return t>0&&!n(h(r[0]),h(r[t-1]))}function P(t,u){return i(t)&&i(u)?n(t,u):c(t)&&c(u)?n(t.c[0],u.c[0])&&n(t.c[1],u.c[1]):e(t)&&e(u)?n(t.b[0],u.b[0])&&n(t.b[1],u.b[1])&&n(t.b[2],u.b[2]):!(!o(t)||!o(u))&&(n(t.a[0],u.a[0])&&n(t.a[1],u.a[1])&&r(t.a,2,-1,u.a,2,-1))}export{b as cloneCurve,P as curveEquals,g as curvesAreSameType,u as getCurves,h as getEndpoint,l as getPaths,f as hasCircularArc,e as isBezierCurve,c as isCircularArc,R as isClockwise,i as isCoordinate,t as isCurvedGeometry,o as isEllipticArc,s as isEllipticArc4,a as isEllipticArc7,v as pathHasCurves};
2
+ import{equals as n,sliceEquals as r}from"../../../core/arrayUtils.js";function t(n){return"curveRings"in n&&!!n.curveRings?.length||"curvePaths"in n&&!!n.curvePaths?.length}function u(n){return"curveRings"in n?n.curveRings:n.curvePaths}function i(n){return"b"in n}function c(n){return"c"in n}function e(n){return Array.isArray(n)}function a(n){return"a"in n}function o(n){return"a"in n&&4===n.a.length}function s(n){return"a"in n&&7===n.a.length}function f(n,r){return u(n).flat().some(n=>b(n,r))}function b(n,r){return!e(n)&&(i(n)?!r.has("cubic-bezier"):c(n)?!r.has("circular-arc"):!(!o(n)&&!s(n))&&!r.has("elliptic-arc"))}function g(n){return!(!n||!t(n))&&u(n).some(n=>n.some(n=>c(n)))}function h(n,r){return e(n)?e(r):i(n)?i(r):c(n)?c(r):o(n)?o(r):!!s(n)&&s(r)}function v(n){return e(n)?n:i(n)?n.b[0]:c(n)?n.c[0]:n.a[0]}function l(n){if(i(n)){const[r,t,u]=n.b;return{b:[[...r],[...t],[...u]]}}if(c(n)){const[r,t]=n.c;return{c:[[...r],[...t]]}}if(e(n))return[...n];if(o(n)){const[r,t,u,i]=n.a;return{a:[[...r],[...t],u,i]}}if(s(n)){const[r,t,u,i,c,e,a]=n.a;return{a:[[...r],[...t],u,i,c,e,a]}}return n}function m(n){return t(n)?"curveRings"in n?n.curveRings:n.curvePaths:"rings"in n?n.rings:n.paths}function R(n){return n.some(n=>!e(n))}function p(t,u){return e(t)&&e(u)?n(t,u):c(t)&&c(u)?n(t.c[0],u.c[0])&&n(t.c[1],u.c[1]):i(t)&&i(u)?n(t.b[0],u.b[0])&&n(t.b[1],u.b[1])&&n(t.b[2],u.b[2]):!(!a(t)||!a(u))&&(n(t.a[0],u.a[0])&&n(t.a[1],u.a[1])&&r(t.a,2,-1,u.a,2,-1))}export{l as cloneCurve,p as curveEquals,h as curvesAreSameType,u as getCurves,v as getEndpoint,m as getPaths,g as hasCircularArc,f as hasUnsupportedCurve,i as isBezierCurve,c as isCircularArc,e as isCoordinate,t as isCurvedGeometry,a as isEllipticArc,o as isEllipticArc4,s as isEllipticArc7,R as pathHasCurves};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../core/Error.js";import{memoize as e}from"../../../core/memoize.js";import{fromJSON as s}from"../jsonUtils.js";import{interpolateCubicBezier as n}from"./bezierCurveUtils.js";import{deriveCircleFromCircularArc as i}from"./circularArcUtils.js";import{isCurvedGeometry as r,getCurves as a,getPaths as c,isClockwise as o,getEndpoint as h,isCoordinate as u,isBezierCurve as p,isCircularArc as l,isEllipticArc4 as m,isEllipticArc7 as f,cloneCurve as d}from"./curveUtils.js";import{deriveCircleFromEllipticArc4 as S}from"./ellipticArc4Utils.js";import{deriveEllipse as v,interpolateEllipse as E}from"./ellipticArc7Utils.js";import{interpolateSegment as g,pointToSegmentDistance2 as x,distance2 as M}from"./mathUtils.js";const P={maxSegmentLength:0,maxDeviation:0,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1},k=100,C=1e-6,_=[0,0],y=new Set;function w(t){return{maxSegmentLength:t.maxSegmentLength??P.maxSegmentLength,maxDeviation:t.maxDeviation??P.maxDeviation,maxSegmentsPerCurve:t.maxSegmentsPerCurve??P.maxSegmentsPerCurve,minSegmentsPerCurve:Math.max(t.minSegmentsPerCurve??P.minSegmentsPerCurve,1)}}class R{constructor(t,e){this.curveStart=t,this.curveEnd=e,this.tStart=0,this.tEnd=0,this.tEndStack=[],this.arcEndStack=[]}get stackSize(){return this.tEndStack.length}initialize(t,e){this.tStart=0,this.arcStart=t,this.tEndStack.push(1),this.arcEndStack.push(e)}splitAt(t){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(t),this.arcEndStack.push(this.interpolate(t))}splitInHalf(){return this.splitAt((this.tStart+this.tEnd)/2)}pop(){this.tEnd=this.tEndStack.pop(),this.arcEnd=this.arcEndStack.pop()}next(){this.tStart=this.tEnd,this.arcStart=this.arcEnd}densify(t,{maxDeviation:e,maxSegmentLength:s,maxSegmentsPerCurve:n,minSegmentsPerCurve:i}){const r=s*s,a=e*e,c=1/n,o=this.interpolate(0),h=this.interpolate(1);M(this.curveStart,o)>C&&t.push(o),this.initialize(o,h);const u=1/i;for(let p=i-1;p>0;p--){const t=p*u;this.pop(),this.splitAt(t)}for(;this.stackSize>0;)this.pop(),this.tStart===this.tEnd||this.tEnd-this.tStart<c||(0===r||!isFinite(r)||M(this.arcStart,this.arcEnd)<r)&&(0===a||!isFinite(a)||this.getDeviation2()<a)?(t.push(this.arcEnd),this.next()):this.splitInHalf();return M(this.curveEnd,h)>C&&t.push([...this.curveEnd]),t}}class b extends R{constructor(t,e){const[s,n,i]=e.b;super(t,s),this._controlPointsStack=[],this._curveControlPoints=[n,i],this._arcControlPoints=[n,i],this._controlPointsStack.push(this._arcControlPoints)}splitAt(t){const{arcStart:e,arcEnd:s,tStart:n,tEnd:i}=this,[r,a]=this._arcControlPoints,c=(t-n)/(i-n),o=g([],e,r,c),h=g(_,r,a,c),u=g([],a,s,c),p=g([],o,h,c),l=g([],h,u,c),m=g([],p,l,c);this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this._controlPointsStack.push([l,u]),this.tEndStack.push(t),this.arcEndStack.push(m),this._arcControlPoints[0]=o,this._arcControlPoints[1]=p,this._controlPointsStack.push(this._arcControlPoints)}pop(){super.pop(),this._arcControlPoints=this._controlPointsStack.pop()}interpolate(t){const{curveStart:e,curveEnd:s}=this,[i,r]=this._curveControlPoints;return n(e,i,r,s,t)}getDeviation2(){const{arcStart:t,arcEnd:e}=this,[s,n]=this._arcControlPoints;return Math.max(x(s,t,e),x(n,t,e))}}class j extends R{constructor(t,e){const[s]=e.a;super(t,s),this._derivedEllipse=v(t,e)}pop(){super.pop(),this._tMid=(this.tStart+this.tEnd)/2,this._arcMid=this.interpolate(this._tMid)}splitInHalf(){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(this._tMid),this.arcEndStack.push(this._arcMid)}interpolate(t){return E(this._derivedEllipse,t)}getDeviation2(){return x(this._arcMid,this.arcStart,this.arcEnd)}}function Z(t,e,s,{cx:n,cy:i,radius:r,thetaStart:a,thetaEnd:c,isInvalid:o},{maxDeviation:h,maxSegmentLength:u,maxSegmentsPerCurve:p,minSegmentsPerCurve:l}){if(o)return t.push([...s]),t;const m=2*r,f=[n+r*Math.cos(a),i+r*Math.sin(a)],d=[n+r*Math.cos(c),i+r*Math.sin(c)];M(e,f)>C&&t.push(f);const S=Math.abs(c-a),v=u>0&&u<m?2*Math.asin(u/m):S,E=h>0&&h<=r?2*Math.acos(1-h/r):S,g=Math.min(v,E),x=Math.min(p,Math.max(l,Math.ceil(Math.abs(S/g)))),P=1/x;for(let M=1;M<x;M++){const e=M*P,s=a*(1-e)+c*e;t.push([n+r*Math.cos(s),i+r*Math.sin(s)])}return t.push(d),M(s,d)>C&&t.push([...s]),t}function D(t,e,s,n){return new b(e,s).densify(t,n)}function z(t,e,s,n){const r=i(e,s),[a]=s.c;return Z(t,e,a,r,n)}function A(t,e,s,n){const i=S(e,s),[r]=s.a;return Z(t,e,r,i,n)}function L(t,e,s,n){const[i,r,a,c,o,h,u]=s.a;return 0===h||0===u?(t.push([...i]),t):new j(e,s).densify(t,n)}function U(t,e,s,n){return u(s)?(t.push([...s]),t):p(s)?D(t,e,s,n):l(s)?z(t,e,s,n):m(s)?A(t,e,s,n):L(t,e,s,n)}function T(t,e={}){if(!r(t))return t;const s=w(e),n=a(t),i=[];for(const r of n){const t=[];for(let e=0;e<r.length-1;e++){const n=e+1,i=[...h(r[e])];0===e&&t.push(i);U(t,i,r[n],s)}i.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},paths:i,spatialReference:t.spatialReference}:{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},rings:i,spatialReference:t.spatialReference}}const I=e(t=>({maxDeviation:0,maxSegmentLength:t*k,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1}));function J(t,e,s){if(!r(t))return t;const n=new Set(e),i=w(s),c=a(t),o=[];let S=!1;for(const r of c){const t=[];for(let e=0;e<r.length-1;e++){const s=e+1,a=[...h(r[e])];0===e&&t.push(a);const c=r[s];u(c)?t.push([...c]):p(c)&&!n.has("cubic-bezier")?D(t,a,c,i):l(c)&&!n.has("circular-arc")?z(t,a,c,i):m(c)&&!n.has("elliptic-arc")?A(t,a,c,i):f(c)&&!n.has("elliptic-arc")?L(t,a,c,i):(t.push(d(c)),S=!0)}o.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},spatialReference:t.spatialReference,...S?{curvePaths:o}:{paths:o}}:{hasZ:t.hasZ,hasM:t.hasM,spatialReference:t.spatialReference,...S?{curveRings:o}:{rings:o}}}async function N(t,e,n,i){const a=new Set(e);return await O(t,a,n,i),t.map(t=>{if(!t||!r(t))return t;const e=t.spatialReference.xyTolerance;if(null==e)return t;const i=I(e),c=!n&&H(t)?y:a;return s(J(t,c,i))})}async function O(e,s,n,i){let c=null;for(const o of e){if(!o||!r(o)||null!=o.spatialReference.xyTolerance)continue;const e=!n&&H(o)?y:s;if(a(o).flat().some(t=>F(t,e))){const e=o.spatialReference;if(!e)throw new t("geometry:missing-spatial-reference","Geometry contains an unsupported curve type, but it cannot be densified because it has no spatial reference.");const s=G(e);if(i.has(s))o.spatialReference=i.get(s);else{c||(c=await import("../../operators/support/apiConverter.js"));const n=c.fromSpatialReference(e),r=n?.getTolerance();if(null==r)throw new t("geometry:missing-tolerance","Geometry contains an unsupported curve type, but it cannot be densified because the tolerance of its spatial reference is unknown. Set the `xyTolerance` property of the spatial reference.");const a=o.spatialReference.clone();a.read({xyTolerance:r}),o.spatialReference=a,i.set(s,a)}}}}function H(t){if(!r(t))return!1;const e=c(t);if(e.length<2)return!1;const s=o(e[0])?o:t=>!o(t);for(let n=1;n<e.length;n++)if(s(e[n]))return!0;return!1}function F(t,e){return!u(t)&&(p(t)?!e.has("cubic-bezier"):l(t)?!e.has("circular-arc"):!(!m(t)&&!f(t))&&!e.has("elliptic-arc"))}function G(t){if(null!=t.wkid)return`${t.wkid}`;if(null!=t.wkt)return t.wkt;const e="toJSON"in t&&"function"==typeof t.toJSON?t.toJSON():t;return JSON.stringify(e)}export{T as densifyCurvedGeometry,N as densifyUnsupportedCurves,I as getAutoDensifyOptions,G as getCacheKey,J as selectiveDensifyCurvedGeometryJSON};
2
+ import t from"../../../core/Error.js";import{memoize as e}from"../../../core/memoize.js";import{fromJSON as s}from"../jsonUtils.js";import{interpolateCubicBezier as n}from"./bezierCurveUtils.js";import{deriveCircleFromCircularArc as i}from"./circularArcUtils.js";import{isCurvedGeometry as r,hasUnsupportedCurve as a,getCurves as o,getEndpoint as c,isCoordinate as h,isBezierCurve as u,isCircularArc as p,isEllipticArc4 as l,isEllipticArc7 as m,cloneCurve as d}from"./curveUtils.js";import{deriveCircleFromEllipticArc4 as f}from"./ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as v}from"./ellipticArc7Utils.js";import{interpolateSegment as E,pointToSegmentDistance2 as g,distance2 as x}from"./mathUtils.js";const M={maxSegmentLength:0,maxDeviation:0,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1},P=100,k=1e-6,C=[0,0];function _(t){return{maxSegmentLength:t.maxSegmentLength??M.maxSegmentLength,maxDeviation:t.maxDeviation??M.maxDeviation,maxSegmentsPerCurve:t.maxSegmentsPerCurve??M.maxSegmentsPerCurve,minSegmentsPerCurve:Math.max(t.minSegmentsPerCurve??M.minSegmentsPerCurve,1)}}class y{constructor(t,e){this.curveStart=t,this.curveEnd=e,this.tStart=0,this.tEnd=0,this.tEndStack=[],this.arcEndStack=[]}get stackSize(){return this.tEndStack.length}initialize(t,e){this.tStart=0,this.arcStart=t,this.tEndStack.push(1),this.arcEndStack.push(e)}splitAt(t){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(t),this.arcEndStack.push(this.interpolate(t))}splitInHalf(){return this.splitAt((this.tStart+this.tEnd)/2)}pop(){this.tEnd=this.tEndStack.pop(),this.arcEnd=this.arcEndStack.pop()}next(){this.tStart=this.tEnd,this.arcStart=this.arcEnd}densify(t,{maxDeviation:e,maxSegmentLength:s,maxSegmentsPerCurve:n,minSegmentsPerCurve:i}){const r=s*s,a=e*e,o=1/n,c=this.interpolate(0),h=this.interpolate(1);x(this.curveStart,c)>k&&t.push(c),this.initialize(c,h);const u=1/i;for(let p=i-1;p>0;p--){const t=p*u;this.pop(),this.splitAt(t)}for(;this.stackSize>0;)this.pop(),this.tStart===this.tEnd||this.tEnd-this.tStart<o||(0===r||!isFinite(r)||x(this.arcStart,this.arcEnd)<r)&&(0===a||!isFinite(a)||this.getDeviation2()<a)?(t.push(this.arcEnd),this.next()):this.splitInHalf();return x(this.curveEnd,h)>k&&t.push([...this.curveEnd]),t}}class R extends y{constructor(t,e){const[s,n,i]=e.b;super(t,s),this._controlPointsStack=[],this._curveControlPoints=[n,i],this._arcControlPoints=[n,i],this._controlPointsStack.push(this._arcControlPoints)}splitAt(t){const{arcStart:e,arcEnd:s,tStart:n,tEnd:i}=this,[r,a]=this._arcControlPoints,o=(t-n)/(i-n),c=E([],e,r,o),h=E(C,r,a,o),u=E([],a,s,o),p=E([],c,h,o),l=E([],h,u,o),m=E([],p,l,o);this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this._controlPointsStack.push([l,u]),this.tEndStack.push(t),this.arcEndStack.push(m),this._arcControlPoints[0]=c,this._arcControlPoints[1]=p,this._controlPointsStack.push(this._arcControlPoints)}pop(){super.pop(),this._arcControlPoints=this._controlPointsStack.pop()}interpolate(t){const{curveStart:e,curveEnd:s}=this,[i,r]=this._curveControlPoints;return n(e,i,r,s,t)}getDeviation2(){const{arcStart:t,arcEnd:e}=this,[s,n]=this._arcControlPoints;return Math.max(g(s,t,e),g(n,t,e))}}class w extends y{constructor(t,e){const[s]=e.a;super(t,s),this._derivedEllipse=S(t,e)}pop(){super.pop(),this._tMid=(this.tStart+this.tEnd)/2,this._arcMid=this.interpolate(this._tMid)}splitInHalf(){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(this._tMid),this.arcEndStack.push(this._arcMid)}interpolate(t){return v(this._derivedEllipse,t)}getDeviation2(){return g(this._arcMid,this.arcStart,this.arcEnd)}}function b(t,e,s,{cx:n,cy:i,radius:r,thetaStart:a,thetaEnd:o,isInvalid:c},{maxDeviation:h,maxSegmentLength:u,maxSegmentsPerCurve:p,minSegmentsPerCurve:l}){if(c)return t.push([...s]),t;const m=2*r,d=[n+r*Math.cos(a),i+r*Math.sin(a)],f=[n+r*Math.cos(o),i+r*Math.sin(o)];x(e,d)>k&&t.push(d);const S=Math.abs(o-a),v=u>0&&u<m?2*Math.asin(u/m):S,E=h>0&&h<=r?2*Math.acos(1-h/r):S,g=Math.min(v,E),M=Math.min(p,Math.max(l,Math.ceil(Math.abs(S/g)))),P=1/M;for(let x=1;x<M;x++){const e=x*P,s=a*(1-e)+o*e;t.push([n+r*Math.cos(s),i+r*Math.sin(s)])}return t.push(f),x(s,f)>k&&t.push([...s]),t}function j(t,e,s,n){return new R(e,s).densify(t,n)}function Z(t,e,s,n){const r=i(e,s),[a]=s.c;return b(t,e,a,r,n)}function D(t,e,s,n){const i=f(e,s),[r]=s.a;return b(t,e,r,i,n)}function z(t,e,s,n){const[i,r,a,o,c,h,u]=s.a;return 0===h||0===u?(t.push([...i]),t):new w(e,s).densify(t,n)}function A(t,e,s,n){return h(s)?(t.push([...s]),t):u(s)?j(t,e,s,n):p(s)?Z(t,e,s,n):l(s)?D(t,e,s,n):z(t,e,s,n)}function L(t,e={}){if(!r(t))return t;const s=_(e),n=o(t),i=[];for(const r of n){const t=[];for(let e=0;e<r.length-1;e++){const n=e+1,i=[...c(r[e])];0===e&&t.push(i);A(t,i,r[n],s)}i.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},paths:i,spatialReference:t.spatialReference}:{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},rings:i,spatialReference:t.spatialReference}}const U=e(t=>({maxDeviation:0,maxSegmentLength:t*P,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1}));function T(t,e,s){if(!r(t))return t;const n=new Set(e),i=_(s),a=o(t),f=[];let S=!1;for(const r of a){const t=[];for(let e=0;e<r.length-1;e++){const s=e+1,a=[...c(r[e])];0===e&&t.push(a);const o=r[s];h(o)?t.push([...o]):u(o)&&!n.has("cubic-bezier")?j(t,a,o,i):p(o)&&!n.has("circular-arc")?Z(t,a,o,i):l(o)&&!n.has("elliptic-arc")?D(t,a,o,i):m(o)&&!n.has("elliptic-arc")?z(t,a,o,i):(t.push(d(o)),S=!0)}f.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},spatialReference:t.spatialReference,...S?{curvePaths:f}:{paths:f}}:{hasZ:t.hasZ,hasM:t.hasM,spatialReference:t.spatialReference,...S?{curveRings:f}:{rings:f}}}async function I(t,e,n){const i=new Set(e);return await J(t,i,n),t.map(t=>{if(!t||!r(t))return t;const n=t.spatialReference.xyTolerance;if(null==n)return t;const i=U(n);return s(T(t,e,i))})}async function J(e,s,n){let i=null;for(const o of e)if(o&&r(o)&&null==o.spatialReference.xyTolerance&&a(o,s)){const e=o.spatialReference;if(!e)throw new t("geometry:missing-spatial-reference","Geometry contains an unsupported curve type, but it cannot be densified because it has no spatial reference.");const s=N(e);if(n.has(s))o.spatialReference=n.get(s);else{i||(i=await import("../../operators/support/apiConverter.js"));const r=i.fromSpatialReference(e),a=r?.getTolerance();if(null==a)throw new t("geometry:missing-tolerance","Geometry contains an unsupported curve type, but it cannot be densified because the tolerance of its spatial reference is unknown. Set the `xyTolerance` property of the spatial reference.");const c=o.spatialReference.clone();c.read({xyTolerance:a}),o.spatialReference=c,n.set(s,c)}}}function N(t){if(null!=t.wkid)return`${t.wkid}`;if(null!=t.wkt)return t.wkt;const e="toJSON"in t&&"function"==typeof t.toJSON?t.toJSON():t;return JSON.stringify(e)}export{L as densifyCurvedGeometry,I as densifyUnsupportedCurves,U as getAutoDensifyOptions,N as getCacheKey,T as selectiveDensifyCurvedGeometryJSON};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{isSubtypeGroupLayer as r}from"../layers/support/layerUtils.js";function e(r){return r&&"layer"in r?r.layer:void 0}function o(o){let t=e(o.origin);return r(t)&&(t=t.findSublayerForFeature(o)),t??o.sourceLayer??o.layer}export{o as getGraphicLayer,e as getGraphicOriginLayer};
2
+ import{isSubtypeGroupLayer as r,isLinkChartLayer as e,isKnowledgeGraphLayer as o,isKnowledgeGraphSublayer as a}from"../layers/support/layerUtils.js";function t(r){return r&&"layer"in r?r.layer:void 0}function u(u){let i=t(u.origin);return r(i)?i=i.findSublayerForFeature(u):(e(i)||o(i))&&a(u.sourceLayer)&&(i=u.sourceLayer),i??u.sourceLayer??u.layer}export{u as getGraphicLayer,t as getGraphicOriginLayer};
package/kernel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.1";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.1.0-next.20",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
2
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.1";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.1.0-next.22",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
@@ -1372,15 +1372,13 @@ export abstract class __FeatureLayerSansType extends FeatureLayerSuperclass {
1372
1372
  * >
1373
1373
  * > **Notes**
1374
1374
  * >
1375
- * > FeatureLayers are not optimized for high-frequency, dynamic data, or real-time streaming use cases. As a result, they may not perform efficiently with rapidly updating data streams.
1376
- * > For real-time or dynamic data updates, use [StreamLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/StreamLayer/), which are designed for efficient handling of high-frequency streaming data and dynamic features.
1377
- * >
1378
- * > When calling the applyEdits method on a service that does not have [vertical coordinate system](https://pro.arcgis.com/en/pro-app/help/mapping/properties/vertical-coordinate-systems.htm) information,
1379
- * > the z-values of the geometries in the `edits` object will automatically be converted to match the spatial reference of the layer.
1380
- * > Example: The service has a horizontal spatial reference with `feet` units, and `applyEdits()` is called with z-values based on `meter` units,
1381
- * > then the method will automatically convert the z values from `meter` to `feet` units.
1382
- * >
1383
- * > As of version 4.17, using applyEdits to add geometries with z-values to a FeatureLayer with `hasZ: false` no longer silently drops the z-value and now throws an error.
1375
+ * > - FeatureLayers are not optimized for high-frequency, dynamic data, or real-time streaming use cases. As a result, they may not perform efficiently with rapidly updating data streams.
1376
+ * > For real-time or dynamic data updates, use [StreamLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/StreamLayer/), which are designed for efficient handling of high-frequency streaming data and dynamic features.
1377
+ * > - When calling the applyEdits method on a service that does not have [vertical coordinate system](https://pro.arcgis.com/en/pro-app/help/mapping/properties/vertical-coordinate-systems.htm) information,
1378
+ * > the z-values of the geometries in the `edits` object will automatically be converted to match the spatial reference of the layer.
1379
+ * > Example: The service has a horizontal spatial reference with `feet` units, and `applyEdits()` is called with z-values based on `meter` units,
1380
+ * > then the method will automatically convert the z values from `meter` to `feet` units.
1381
+ * > - As of version 4.17, using applyEdits to add geometries with z-values to a FeatureLayer with `hasZ: false` no longer silently drops the z-value and now throws an error.
1384
1382
  *
1385
1383
  * @param edits - Object containing features and attachments to be added, updated or deleted.
1386
1384
  * @param options - Additional edit options to specify when editing features or attachments.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../request.js";import r from"../core/Error.js";import has from"../core/has.js";import i from"../core/Logger.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{on as n,sync as a}from"../core/reactiveUtils.js";import{property as l,subclass as p}from"../core/accessorSupport/decorators.js";import{persistable as m}from"../core/accessorSupport/decorators/persistable.js";import c from"../geometry/Extent.js";import d from"../geometry/SpatialReference.js";import h from"./Layer.js";import{APIKeyMixin as u}from"./mixins/APIKeyMixin.js";import{ArcGISService as f}from"./mixins/ArcGISService.js";import{CustomParametersMixin as y}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as S}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as _}from"./mixins/ScaleRangeLayer.js";import{elevationInfo as v,url as j}from"./support/commonProperties.js";import T from"./support/SceneModifications.js";import{default3DTilesSpatialReference as w,default3DTilesFullExtent as L,initFullExtent as b}from"./support/tiles3DUtils.js";import x from"../portal/Portal.js";import{logInvalidElevationInfoWarning as P,elevationModeRequiredMessage as I,featureExpressionUnsupportedMessage as k}from"../support/elevationInfoUtils.js";import{f as R}from"../chunks/persistableUrlUtils.js";import{isBasemap as D}from"../support/userTypeGuards/isBasemap.js";import{initialize as E,switchMeshModificationPolygonVCSSync as U}from"../views/3d/layers/Lyr3DWorker.js";import{toWasmModification as O,fromWasmModification as A}from"../views/3d/layers/SceneLayerWorkerHandle.js";import{reader as M}from"../core/accessorSupport/decorators/reader.js";let q=class extends(f(g(S(_(o(y(u(h)))))))){readModifications(e,t,r){this._modificationsSource={url:R(e,r),context:r}}initialize(){this.addHandles(n(()=>this.modifications,"after-changes",()=>this.modifications=this.modifications,a))}constructor(e){super(e),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.modifications=null,this._modificationsSource=null,this.spatialReference=w,this.fullExtent=L,this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0,this._rootTilesetJSON=null,this._rootTileset=null,this._key=null,this._session=null,this._rootRequestPromise=null,this.queryElevationCallback=null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}async load(e){return this.addResolvingPromise(this._doLoad(e)),this}get rootTilesetJSON(){return this._rootTilesetJSON}get rootTileset(){return this._rootTileset}get key(){return this._key}get session(){return this._session}_findSessionParameter(e){const t=[e];for(;t?.length>0;){const e=t.pop();if(!e)return;for(const[i,o]of Object.entries(e)){if("uri"===i)try{const e=new URL("https://tmp"+o).searchParams.get("session");if(e)return e}catch(r){}"object"==typeof o&&null!==o&&t.push(o)}}return null}async requestRootAndSession(e){const o=(e,t)=>new r("3dtiles-init:"+e,t);return this._rootRequestPromise||(this._rootRequestPromise=new Promise((r,n)=>{this.url||n(o("url-missing","Layer url missing")),this._key=this.customParameters?this.customParameters.key:null;new Promise((e,r)=>{if(this.replacesTerrain&&!this._key){const i=this.portalItem?.portal||this.parent?.portalItem?.portal||x.getDefault();i.signIn().then(()=>{i.g3dTilesEnabled?t(i.restUrl+"/portals/self/modules/g3dtiles",{responseType:"json",query:{f:"json"}}).then(t=>{this._key=t.data.keyString,e()},()=>r(o("g3dtiles-key-error","Error fetching Google 3D Tiles key from portal"))):r(o("g3dTilesEnabled-false","Google 3D Tiles are not enabled on Portal "+i.url))},()=>r(o("sign-in-failed","Error signing in to Portal")))}else e()}).then(()=>{t(this.url,{query:this._key?{key:this._key,token:this.apiKey}:{token:this.apiKey},responseType:"array-buffer",signal:e}).then(e=>{try{this._rootTilesetJSON=JSON.parse((new TextDecoder).decode(e.data))}catch(t){return void n(o("root-parse-failed","Error parsing root tile, details: "+t))}this._rootTilesetJSON?(this._session=this._findSessionParameter(this._rootTilesetJSON),this._rootTileset=e.data,this.fullExtent=b(this._rootTilesetJSON),r(),this._rootRequestPromise=null):n(o("root-is-null","Root tile is null."))},e=>{s(e),n(o("root-load-failed","Error loading root tile")),this._rootRequestPromise=null,i.getLogger("IntegratedMesh3DTilesLayer").error("Layer loading failed",e)})},e=>n(e))})),this._rootRequestPromise}async _doLoad(e){const t=null!=e?e.signal:null;if(this.isUsedAsGroundLayer&&!has("enable-feature:basemap-groundlayers"))throw new r("3dtiles-init:not-supported-in-groundlayers","Layer is not supported in basemap.");try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:e=>{if(e.typeKeywords?.includes("IntegratedMesh"))return!0;throw new r("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},e)}catch(o){s(o)}if(null!=this._modificationsSource){const t=await T.fromUrl(this._modificationsSource.url,this.spatialReference,e);if(t&&t.length>0){await E();try{const e=O(null,t.toArray(),this.spatialReference),r=U({modifications:e,inVCS:115700});r.success&&r.modifications&&A(r.modifications,t)}catch(n){i.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",n)}null!=this._modificationsSource&&this.setAtOrigin("modifications",t,this._modificationsSource.context.origin),this._modificationsSource=null}}await this.requestRootAndSession(t)}async beforeSave(){if(null==this._modificationsSource){const{modifications:t}=this;if(t&&t.length>0){await E();try{const e=O(null,t.toArray(),this.spatialReference),r=U({modifications:e,inVCS:5773});r.success&&r.modifications&&A(r.modifications,t)}catch(e){i.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",e)}}return}await this.load().then(()=>{},()=>{})}get hasAttributionData(){return!1}_validateElevationInfo(e){const t="Integrated mesh 3d tiles layers";P(i.getLogger(this),I(t,"absolute-height",e)),P(i.getLogger(this),k(t,e))}get replacesTerrain(){return!!has("enable-feature:basemap-groundlayers")&&this.hasGoogleUrl&&this.isUsedAsGroundLayer}get isUsedAsGroundLayer(){return D(this.parent)}get hasGoogleUrl(){return!!this.url?.match(/.+\.googleapis.com/)}};e([l({type:["IntegratedMesh3DTilesLayer"]})],q.prototype,"operationalLayerType",void 0),e([l({type:T,clonable:e=>e.clone()}),m({origins:["web-scene","portal-item"],type:"resource",prefix:"modifications"})],q.prototype,"modifications",void 0),e([M(["web-scene","portal-item"],"modifications")],q.prototype,"readModifications",null),e([l({type:d})],q.prototype,"spatialReference",void 0),e([l({type:c})],q.prototype,"fullExtent",void 0),e([l(v)],q.prototype,"elevationInfo",null),e([l({type:["show","hide"]})],q.prototype,"listMode",void 0),e([l(j)],q.prototype,"url",void 0),e([l({readOnly:!0})],q.prototype,"type",void 0),e([l({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],q.prototype,"path",void 0),e([l({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],q.prototype,"minScale",void 0),e([l({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],q.prototype,"maxScale",void 0),e([l({readOnly:!0})],q.prototype,"hasAttributionData",null),e([l()],q.prototype,"replacesTerrain",null),e([l()],q.prototype,"isUsedAsGroundLayer",null),e([l()],q.prototype,"hasGoogleUrl",null),q=e([p("esri.layers.IntegratedMesh3DTilesLayer")],q);const G=q;export{G as default};
2
+ import{__decorate as e}from"tslib";import t from"../request.js";import o from"../core/Error.js";import has from"../core/has.js";import r from"../core/Logger.js";import{MultiOriginJSONSupportMixin as i}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{on as a,sync as n}from"../core/reactiveUtils.js";import{property as l,subclass as p}from"../core/accessorSupport/decorators.js";import{persistable as m}from"../core/accessorSupport/decorators/persistable.js";import c from"../geometry/Extent.js";import d from"../geometry/SpatialReference.js";import u from"./Layer.js";import{APIKeyMixin as h}from"./mixins/APIKeyMixin.js";import{ArcGISService as f}from"./mixins/ArcGISService.js";import{CustomParametersMixin as y}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as S}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as _}from"./mixins/ScaleRangeLayer.js";import{elevationInfo as v,url as j}from"./support/commonProperties.js";import T from"./support/SceneModifications.js";import{default3DTilesSpatialReference as w,default3DTilesFullExtent as L,initFullExtent as b}from"./support/tiles3DUtils.js";import x from"../portal/Portal.js";import{logInvalidElevationInfoWarning as P,elevationModeRequiredMessage as I,featureExpressionUnsupportedMessage as k}from"../support/elevationInfoUtils.js";import{f as R}from"../chunks/persistableUrlUtils.js";import{isBasemap as D}from"../support/userTypeGuards/isBasemap.js";import{initialize as U,switchMeshModificationPolygonVCSSync as E}from"../views/3d/layers/Lyr3DWorker.js";import{toWasmModification as O,fromWasmModificationInLoad as M}from"../views/3d/layers/SceneLayerWorkerHandle.js";import{reader as q}from"../core/accessorSupport/decorators/reader.js";let A=class extends(f(g(S(_(i(y(h(u)))))))){readModifications(e,t,o){this._modificationsSource={url:R(e,o),context:o}}initialize(){this.addHandles(a(()=>this.modifications,"after-changes",()=>this.modifications=this.modifications,n))}constructor(e){super(e),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.modifications=null,this._modificationsSource=null,this.spatialReference=w,this.fullExtent=L,this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0,this._rootTilesetJSON=null,this._rootTileset=null,this._key=null,this._session=null,this._rootRequestPromise=null,this.queryElevationCallback=null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}async load(e){return this.addResolvingPromise(this._doLoad(e)),this}get rootTilesetJSON(){return this._rootTilesetJSON}get rootTileset(){return this._rootTileset}get key(){return this._key}get session(){return this._session}_findSessionParameter(e){const t=[e];for(;t?.length>0;){const e=t.pop();if(!e)return;for(const[r,i]of Object.entries(e)){if("uri"===r)try{const e=new URL("https://tmp"+i).searchParams.get("session");if(e)return e}catch(o){}"object"==typeof i&&null!==i&&t.push(i)}}return null}async requestRootAndSession(e){const i=(e,t)=>new o("3dtiles-init:"+e,t);return this._rootRequestPromise||(this._rootRequestPromise=new Promise((o,a)=>{this.url||a(i("url-missing","Layer url missing")),this._key=this.customParameters?this.customParameters.key:null;new Promise((e,o)=>{if(this.replacesTerrain&&!this._key){const r=this.portalItem?.portal||this.parent?.portalItem?.portal||x.getDefault();r.signIn().then(()=>{r.g3dTilesEnabled?t(r.restUrl+"/portals/self/modules/g3dtiles",{responseType:"json",query:{f:"json"}}).then(t=>{this._key=t.data.keyString,e()},()=>o(i("g3dtiles-key-error","Error fetching Google 3D Tiles key from portal"))):o(i("g3dTilesEnabled-false","Google 3D Tiles are not enabled on Portal "+r.url))},()=>o(i("sign-in-failed","Error signing in to Portal")))}else e()}).then(()=>{t(this.url,{query:this._key?{key:this._key,token:this.apiKey}:{token:this.apiKey},responseType:"array-buffer",signal:e}).then(e=>{try{this._rootTilesetJSON=JSON.parse((new TextDecoder).decode(e.data))}catch(t){return void a(i("root-parse-failed","Error parsing root tile, details: "+t))}this._rootTilesetJSON?(this._session=this._findSessionParameter(this._rootTilesetJSON),this._rootTileset=e.data,this.fullExtent=b(this._rootTilesetJSON),o(),this._rootRequestPromise=null):a(i("root-is-null","Root tile is null."))},e=>{s(e),a(i("root-load-failed","Error loading root tile")),this._rootRequestPromise=null,r.getLogger("IntegratedMesh3DTilesLayer").error("Layer loading failed",e)})},e=>a(e))})),this._rootRequestPromise}async _doLoad(e){const t=null!=e?e.signal:null;if(this.isUsedAsGroundLayer&&!has("enable-feature:basemap-groundlayers"))throw new o("3dtiles-init:not-supported-in-groundlayers","Layer is not supported in basemap.");try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:e=>{if(e.typeKeywords?.includes("IntegratedMesh"))return!0;throw new o("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},e)}catch(i){s(i)}if(null!=this._modificationsSource){const t=await T.fromUrl(this._modificationsSource.url,this.spatialReference,e);if(t&&t.length>0){await U();try{const e=O(null,t.toArray(),this.spatialReference),o=E({modifications:e,inVCS:115700});o.success&&o.modifications&&M(o.modifications,t)}catch(a){r.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",a)}null!=this._modificationsSource&&this.setAtOrigin("modifications",t,this._modificationsSource.context.origin),this._modificationsSource=null}}await this.requestRootAndSession(t)}async beforeSave(){if(null==this._modificationsSource){const{modifications:e}=this;return void(e&&e.length>0&&await U())}await this.load().then(()=>{},()=>{})}get hasAttributionData(){return!1}_validateElevationInfo(e){const t="Integrated mesh 3d tiles layers";P(r.getLogger(this),I(t,"absolute-height",e)),P(r.getLogger(this),k(t,e))}get replacesTerrain(){return!!has("enable-feature:basemap-groundlayers")&&this.hasGoogleUrl&&this.isUsedAsGroundLayer}get isUsedAsGroundLayer(){return D(this.parent)}get hasGoogleUrl(){return!!this.url?.match(/.+\.googleapis.com/)}};e([l({type:["IntegratedMesh3DTilesLayer"]})],A.prototype,"operationalLayerType",void 0),e([l({type:T,clonable:e=>e.clone()}),m({origins:["web-scene","portal-item"],type:"resource",prefix:"modifications"})],A.prototype,"modifications",void 0),e([q(["web-scene","portal-item"],"modifications")],A.prototype,"readModifications",null),e([l({type:d})],A.prototype,"spatialReference",void 0),e([l({type:c})],A.prototype,"fullExtent",void 0),e([l(v)],A.prototype,"elevationInfo",null),e([l({type:["show","hide"]})],A.prototype,"listMode",void 0),e([l(j)],A.prototype,"url",void 0),e([l({readOnly:!0})],A.prototype,"type",void 0),e([l({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],A.prototype,"path",void 0),e([l({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],A.prototype,"minScale",void 0),e([l({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],A.prototype,"maxScale",void 0),e([l({readOnly:!0})],A.prototype,"hasAttributionData",null),e([l()],A.prototype,"replacesTerrain",null),e([l()],A.prototype,"isUsedAsGroundLayer",null),e([l()],A.prototype,"hasGoogleUrl",null),A=e([p("esri.layers.IntegratedMesh3DTilesLayer")],A);const G=A;export{G as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import i from"../request.js";import t from"../core/Accessor.js";import s from"../core/Error.js";import r from"../core/Logger.js";import{createAbortError as a,isAborted as n,isAbortError as o}from"../core/promiseUtils.js";import{watch as l}from"../core/reactiveUtils.js";import{addFrameTask as d}from"../core/scheduling.js";import{property as h,subclass as _}from"../core/accessorSupport/decorators.js";import y from"../geometry/SpatialReference.js";import{isGeographic as c}from"../geometry/support/spatialReferenceUtils.js";import u from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as m,elevQueriesFull as g,elevQueriesGenericFail as w,invalidLayerView as p}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as b}from"./Lyr3DWorkerHandle.js";import{getVCSFromHeightModelInfo as f}from"./support/tiles3DUtils.js";import{loadLyr3DMainWASM as v}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as D}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as M}from"../views/3d/layers/support/makeScheduleFunction.js";const L=3857,k=32662,R=4326,S=5773,C=115700;let W=class extends t{constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._lyr3DBusyCount=0,this._lyr3DInternalMemoryBytes=0,this._isTerrainReady=!1,this._hasLayerThatReplacesTerrain=!1,this._elevationQueries=new Map,this._debugFlags=new Set,this._debugLevel=0,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._cameraElevationDirty=!0,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,i,t,s=!0){if(this._debugFlags.has(e)&&this._debugLevel>=i){const e=s?`[js] ${t}`:`${t}`;0===i||1===i?r.getLogger(this).error(e):2===i&&r.getLogger(this).warn(e),r.getLogger(this).info(e)}}get lyr3DInternalMemoryBytes(){return this._lyr3DInternalMemoryBytes}initialize(){this._debugLevel>2&&(r.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([l(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera()),l(()=>this.view.state?.contentCamera.relativeElevation,()=>{this._cameraElevationDirty=!0,this._markAllLayerViewsUpdating()})]),this._pulseTaskHandle=d({preRender:()=>this._pulseTask()})}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._layers.forEach(e=>{e.abortController.abort()}),this._elevationQueries.forEach((e,i)=>{this._lyr3DMain.cancel_elevation_query(i),e.rejectCallback(a())}),this._elevationQueries.clear(),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null);const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:m})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._doRemoveLayerView(e);const i=this._layers.size;return 0===i&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),i}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(i=>{i.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){this._lyr3DMain.set_enabled(e.wasmLayerId,i),t.needMemoryUsageUpdate=!0;const s=this._isUpdating(t);t.needFrame=!0,s||t.layerView.updatingFlagChanged()}}setLayerOffset(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,i)}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,i,t)}setMeshModifications(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){const s=this._lyr3DMain._malloc(8*i.length),r=new Float64Array(this._lyr3DMain.HEAPF64.buffer,s,i.length);for(let e=0;e<i.length;++e)r[e]=i[e];this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,s,i.length),this._lyr3DMain._free(s);const a=this._isUpdating(t);t.needFrame=!0,a||t.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const i=this._layers.get(e);return!!i&&(i.outstandingJobCount>0||i.outstandingRenderableCount>0||i.needFrame||this._lyr3DBusyCount>0)}initializeWasm(e,i){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=v().then(t=>{this._lyr3DMain=t,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"v"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"v"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"viii"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"viiii"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii"),l=this._lyr3DMain.addFunction(this._onElevQueryComplete.bind(this),"vi");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();const d="global"===this.view.viewingMode?5:3;if(5===d)this._viewSR.wkid=this._viewSR.latestWkid=R,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(this.view.renderSpatialReference?.isWebMercator)this._viewSR.wkid=this._viewSR.latestWkid=L,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(this.view.renderSpatialReference?.wkid===k)this._viewSR.wkid=this._viewSR.latestWkid=R,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(!this._viewSR.latestVcsWkid&&!this._viewSR.vcsWkid){const e=f(this.view.heightModelInfo);if(e)this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=e;else{const e=this.view.heightModelInfo?.heightModel,i=!e||"gravity-related-height"===e;this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=i?S:C}}return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,l,e,i,d,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0))?(this._workerHandle=new b(M(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}get isTerrainReady(){return this._isTerrainReady}setLodPixelThreshold(e,i){this._lyr3DMain?.set_lod_pixel_threshold(i);const t=this._layers.get(e.wasmLayerId);t&&(t.needFrame=!0)}setMaximumGaussianSplatCount(e){this._lyr3DMain.set_maximum_splat_count(e),this._layers.forEach(e=>{"gaussian-splat-3d"===e.layerView.type&&(e.needFrame=!0)})}queryElevation(e,i,t){if(!this._lyr3DMain)return Promise.reject(this._wasmNotLoaded);if(0===i.coordinates.length)return Promise.reject("no coordinates for elevation query");const s="global"===this.view.viewingMode?y.WGS84:this._viewSR.wkid===L?y.WebMercator:y.PlateCarree,r=i.projectSync(s);r&&(i=r);const a=2*i.coordinates.length,n=this._lyr3DMain._malloc(8*a),o=new Float64Array(this._lyr3DMain.HEAPF64.buffer,n,a);for(let y=0;y<i.coordinates.length;++y){const e=i.coordinates[y];o[2*y]=e.x,o[2*y+1]=e.y}const l=t?.maxGeometricError??0,d=this._lyr3DMain.create_elevation_query(e.wasmLayerId,l,n,a);if(this._lyr3DMain._free(n),d===g)return Promise.reject("max mesh elevation query limit exceeded");if(d===w)return Promise.reject("elevation query failed");const h={descriptor:i,signal:t?.signal,resolveCallback:null,rejectCallback:null},_=new Promise((e,i)=>{h.resolveCallback=e,h.rejectCallback=i});return this._elevationQueries.set(d,h),_}_checkForAbortedElevationQueries(){const e=[];this._elevationQueries.forEach((i,t)=>{n(i.signal)&&(this._lyr3DMain.cancel_elevation_query(t),i.rejectCallback(a()),e.push(t))});for(let i=0;i<e.length;++i)this._elevationQueries.delete(e[i])}_pulseTask(){if(this._lyr3DMain){if(this._cameraElevationDirty){const e=this.view.state?.contentCamera.relativeElevation;this._lyr3DMain.set_camera_elevation(e)}this._checkForAbortedElevationQueries();let e=0,i=0;this._layers.forEach(t=>{e+=t.layerView.usedMemory,i+=t.layerView.cachedMemory}),e/=1048576,i/=1048576;const t=this.view.resourceController.memoryController,s=t.usedMemory*t.maxMemory-e;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(t.memoryFactor,e,i,s,t.maxMemory),this._lyr3DInternalMemoryBytes=this._lyr3DMain.get_index_memory_bytes(),this._layers.forEach(e=>{this._cameraElevationDirty||(e.needFrame=!1),e.layerView.updatingFlagChanged()}),this._hasLayerThatReplacesTerrain&&!this._isTerrainReady&&(this._isTerrainReady=this._lyr3DMain.is_terrain_ready(),this._isTerrainReady&&this.notifyChange("isTerrainReady")),this._cameraElevationDirty=!1}}_isUpdating(e){return e.outstandingJobCount>0||e.outstandingRenderableCount>0||e.needFrame||this._lyr3DBusyCount>0}_incrementJobCount(e,i){if(i.isForElevationQuery)return;const t=this._isUpdating(e);e.outstandingJobCount+=1,t||e.layerView.updatingFlagChanged()}_decrementJobCount(e,i){if(i.isForElevationQuery)return;const t=this._isUpdating(e);e.outstandingJobCount-=1;t!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_incrementRenderableCount(e){const i=this._isUpdating(e);e.outstandingRenderableCount+=1,i||e.layerView.updatingFlagChanged()}_decrementRenderableCount(e){const i=this._isUpdating(e);e.outstandingRenderableCount-=1;i!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_onJobFailed(e,i,t){i.error.length&&this._debugLog(1,1,i.error,!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(t.jobId,t.desc),this._decrementJobCount(e,t)}_onJobSucceeded(e,i,t){if(this._lyr3DMain){if(e.layerView.destroyed)return void this._lyr3DMain.on_job_failed(t.jobId,t.desc);const s=i.data.byteLength,r=this._lyr3DMain._malloc(s);new Uint8Array(this._lyr3DMain.HEAPU8.buffer,r,s).set(i.data),this._lyr3DMain.on_job_completed(t.jobId,i.jobDescJson,r,s),this._lyr3DMain._free(r)}this._decrementJobCount(e,t)}_getRequestPromises(e,t,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.append("session",r.session)}a.push(i(e.toString(),t).then(e=>e.data))}return a}_getInitialPromise(e,i,t,s,r,a,n){const l=this._getRequestPromises(e.urls,i,t,s);return Promise.all(l).then(e=>(r.inputs=e,this._workerHandle.invoke(r,a))).then(e=>e).catch(i=>{let t=1;return o(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):n&&400===i.details?.httpStatus?(t=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${i}.`),{status:t,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(){const e=this._lyr3DMain.get_next_job(),i=this._layers.get(e.layerId);if(!i)return;this._incrementJobCount(i,e);const t=i.abortController.signal,s=i.layerView.layer,r="integrated-mesh-3dtiles"===s.type?s.key:null,a="integrated-mesh-3dtiles"===s.type?s.session:null,n={responseType:"array-buffer",signal:t,query:{...i.customParameters,token:i.apiKey,key:r}},l={id:e.jobId,inputs:[],jobDescJson:e.desc.slice(),isMissingResourceCase:!1},d=new URL(s.url),h=r=>{if(1===r.status)this._onJobFailed(i,r,e);else if(0===r.status)this._onJobSucceeded(i,r,e);else if(2===r.status){const a=this._getRequestPromises(r.missingInputUrls,n,d,s);Promise.all(a).then(e=>{l.jobDescJson=r.jobDescJson,r.originalInputs?l.inputs=r.originalInputs:l.inputs=[],l.isMissingResourceCase=!0;for(const i of e)l.inputs.push(i);return this._workerHandle.invoke(l,t)}).then(t=>{1===t.status?this._onJobFailed(i,t,e):0===t.status&&this._onJobSucceeded(i,t,e)}).catch(t=>{this._decrementJobCount(i,e),o(t)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):this._debugLog(1,1,`job ${e.jobId} failed with error ${t}.`),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)})}};try{const i=await this._getInitialPromise(e,n,d,s,l,t,a);if(3===i.status&&"integrated-mesh-3dtiles"===s.type){a===s.session&&null!==s.session&&await s.requestRootAndSession(t);h(await this._getInitialPromise(e,n,d,s,l,t,s.session))}else h(i)}catch(_){_&&this._debugLog(1,1,_.toString(),!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc),this._decrementJobCount(i,e)}}_onNewRenderable(){const e=this._lyr3DMain.get_next_renderable(),{meshData:i}=e;i.data&&i.data.byteLength>0&&(i.data=i.data.slice());const t=this._layers.get(e.layerId);t&&(this._incrementRenderableCount(t),t.layerView.createRenderable(e).then(i=>{const s=i.numGaussians??0;this._lyr3DMain?.on_renderable_created(!0,e.layerId,e.handle,i.memUsageBytes,s),this._decrementRenderableCount(t)}).catch(i=>{o(i)||this._debugLog(2,1,`createRenderable failed with error ${i}.`),this._lyr3DMain?.on_renderable_created(!1,e.layerId,e.handle,0,0),this._decrementRenderableCount(t)}))}_freeRenderables(e,i,t){if(t<1)return;const s=this._layers.get(e);if(!s)return;const r=s.layerView,a=[],n=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,t);for(let o=0;o<t;++o)a.push(n[o]);for(let o=0;o<t;++o)r.freeRenderable(a[o])}_setRenderableVisibility(e,i,t,s){if(s<1)return;const r=this._layers.get(e);if(!r)return;const a=r.layerView,n=[],o=[],l=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,s),d=new Uint8Array(this._lyr3DMain.HEAPU8.buffer,t,s);for(let h=0;h<s;++h)n.push(l[h]),o.push(!!(1&d[h]));a.setRenderableVisibility(n,o,s)}_onWasmError(e,i,t,s){this._lyr3DMain&&this._debugLog(t,s,this._lyr3DMain.UTF8ToString(e,i),!1)}_onElevQueryComplete(e){const i=this._elevationQueries.get(e),t=this._lyr3DMain.get_elevation_query_result(e);if(i)if(t.succeeded&&t.zs){const s=t.zs.slice(),r=i.descriptor.clone();for(let e=0;e<s.length;++e)r.coordinates[e].z=s[e];this._debugLog(2,3,`Success EQ ${e}, number points ${s.length}.`),i.resolveCallback(r),this._elevationQueries.delete(e)}else i.rejectCallback(new s("elevation-query:error",t?.error??"Elevation query failed")),this._elevationQueries.delete(e);else this._debugLog(2,1,`_onElevQueryComplete called for unknown queryId ${e}.`)}_doRemoveLayerView(e){const i=this._layers.get(e.wasmLayerId);return!!i&&(i.abortController.abort(),this._lyr3DMain.remove_layer(e.wasmLayerId),this._is3DTilesIMLayerView(e)&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!1,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")),this._layers.delete(e.wasmLayerId),!0)}_is3DTilesIMLayerView(e){return"integrated-mesh-3dtiles"===e.layer.type}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const i=e.layer;if(!i.url||!i.rootTilesetJSON)return{wasmLayerId:p};const t="integrated-mesh-3dtiles"===i.type?0:2,s=this._lyr3DMain.validate_root_tileset(JSON.stringify(i.rootTilesetJSON),t);if(0!==s.errorCode)return{wasmLayerId:p,check:s};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:i.customParameters,apiKey:i.apiKey,needFrame:!0});const o=D(i.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),d=e=>r.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let h=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(i)){let t=i.spatialReference;if(e.useEsriCrs&&i.esriCrsSpatialReference){t=i.esriCrsSpatialReference;const s=c(t);let r=1,a=1;!s&&t.wkid&&-1!==t.wkid&&(r=u.values[u[t.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(t)),s,r,a).catch(d),t.vcsWkid&&this._viewSR.vcsWkid&&this._viewSR.vcsWkid!==t.vcsWkid&&this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),!1,1,1).catch(d)}h=this._lyr3DMain.add_gaussian_splat_layer(l,i.url,a,o)}else this._is3DTilesIMLayerView(e)&&(h=this._lyr3DMain.add_3dtiles_layer(l,i.url,a,o,e.layer.replacesTerrain),h&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!0,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")));return h?(this._updateWasmCamera(),e.updatingFlagChanged(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:p})}_updateWasmCamera(){const e=this.view.state?.contentCamera;if(!e||!this._lyr3DMain)return;const{eye:i,center:t,up:s,near:r,far:a,fovY:n}=e,o=[e.viewport[2],e.viewport[3]],l=e.width/e.height;this._lyr3DMain.set_camera_parameters({eye:i,center:t,up:s,near:r,far:a,fov:n,aspectRatio:l,viewport:o}),this._markAllLayerViewsUpdating()}_markAllLayerViewsUpdating(){this._layers.forEach(e=>{const i=this._isUpdating(e);e.needFrame=!0,i||e.layerView.updatingFlagChanged()})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([h({constructOnly:!0})],W.prototype,"view",void 0),e([h({readOnly:!0})],W.prototype,"isTerrainReady",null),W=e([_("esri.layers.Lyr3DWasmPerSceneView")],W);const V=W;export{V as default};
2
+ import{__decorate as e}from"tslib";import i from"../request.js";import t from"../core/Accessor.js";import s from"../core/Error.js";import r from"../core/Logger.js";import{createAbortError as a,isAborted as n,isAbortError as o}from"../core/promiseUtils.js";import{watch as l}from"../core/reactiveUtils.js";import{addFrameTask as d}from"../core/scheduling.js";import{property as h,subclass as _}from"../core/accessorSupport/decorators.js";import y from"../geometry/SpatialReference.js";import{isGeographic as c}from"../geometry/support/spatialReferenceUtils.js";import u from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as m,elevQueriesFull as g,elevQueriesGenericFail as w,invalidLayerView as p}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as b}from"./Lyr3DWorkerHandle.js";import{getVCSFromHeightModelInfo as f}from"./support/tiles3DUtils.js";import{loadLyr3DMainWASM as v}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as D}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as M}from"../views/3d/layers/support/makeScheduleFunction.js";const L=3857,k=32662,R=4326,S=5773,C=115700;let W=class extends t{constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._lyr3DBusyCount=0,this._lyr3DInternalMemoryBytes=0,this._isTerrainReady=!1,this._hasLayerThatReplacesTerrain=!1,this._elevationQueries=new Map,this._debugFlags=new Set,this._debugLevel=0,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._cameraElevationDirty=!0,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,i,t,s=!0){if(this._debugFlags.has(e)&&this._debugLevel>=i){const e=s?`[js] ${t}`:`${t}`;0===i||1===i?r.getLogger(this).error(e):2===i&&r.getLogger(this).warn(e),r.getLogger(this).info(e)}}get lyr3DInternalMemoryBytes(){return this._lyr3DInternalMemoryBytes}initialize(){this._debugLevel>2&&(r.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([l(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera()),l(()=>this.view.state?.contentCamera.relativeElevation,()=>{this._cameraElevationDirty=!0,this._markAllLayerViewsUpdating()})]),this._pulseTaskHandle=d({preRender:()=>this._pulseTask()})}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._layers.forEach(e=>{e.abortController.abort()}),this._elevationQueries.forEach((e,i)=>{this._lyr3DMain.cancel_elevation_query(i),e.rejectCallback(a())}),this._elevationQueries.clear(),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null);const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:m})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._doRemoveLayerView(e);const i=this._layers.size;return 0===i&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),i}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(i=>{i.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){this._lyr3DMain.set_enabled(e.wasmLayerId,i),t.needMemoryUsageUpdate=!0;const s=this._isUpdating(t);t.needFrame=!0,s||t.layerView.updatingFlagChanged()}}setLayerOffset(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,i)}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,i,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,i,t)}setMeshModifications(e,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const t=this._layers.get(e.wasmLayerId);if(t){const s=this._lyr3DMain._malloc(8*i.length),r=new Float64Array(this._lyr3DMain.HEAPF64.buffer,s,i.length);for(let e=0;e<i.length;++e)r[e]=i[e];this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,s,i.length),this._lyr3DMain._free(s);const a=this._isUpdating(t);t.needFrame=!0,a||t.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const i=this._layers.get(e);return!!i&&(i.outstandingJobCount>0||i.outstandingRenderableCount>0||i.needFrame||this._lyr3DBusyCount>0)}initializeWasm(e,i){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=v().then(t=>{this._lyr3DMain=t,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"v"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"v"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"viii"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"viiii"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii"),l=this._lyr3DMain.addFunction(this._onElevQueryComplete.bind(this),"vi");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();const d="global"===this.view.viewingMode?5:3;if(5===d)this._viewSR.wkid=this._viewSR.latestWkid=R,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(this.view.renderSpatialReference?.isWebMercator)this._viewSR.wkid=this._viewSR.latestWkid=L,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(this.view.renderSpatialReference?.wkid===k)this._viewSR.wkid=this._viewSR.latestWkid=R,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=S;else if(!this._viewSR.latestVcsWkid&&!this._viewSR.vcsWkid){const e=f(this.view.heightModelInfo);if(e)this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=e;else{const e=this.view.heightModelInfo?.heightModel,i=!e||"gravity-related-height"===e;this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=i?S:C}}return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,l,e,i,d,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0))?(this._workerHandle=new b(M(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}get isTerrainReady(){return this._isTerrainReady}setLodPixelThreshold(e,i){this._lyr3DMain?.set_lod_pixel_threshold(i);const t=this._layers.get(e.wasmLayerId);t&&(t.needFrame=!0)}setMaximumGaussianSplatCount(e){this._lyr3DMain.set_maximum_splat_count(e),this._layers.forEach(e=>{"gaussian-splat-3d"===e.layerView.type&&(e.needFrame=!0)})}queryElevation(e,i,t){if(!this._lyr3DMain)return Promise.reject(this._wasmNotLoaded);if(0===i.coordinates.length)return Promise.reject("no coordinates for elevation query");const s="global"===this.view.viewingMode?y.WGS84:this._viewSR.wkid===L?y.WebMercator:y.PlateCarree,r=i.projectSync(s);r&&(i=r);const a=2*i.coordinates.length,n=this._lyr3DMain._malloc(8*a),o=new Float64Array(this._lyr3DMain.HEAPF64.buffer,n,a);for(let y=0;y<i.coordinates.length;++y){const e=i.coordinates[y];o[2*y]=e.x,o[2*y+1]=e.y}const l=t?.maxGeometricError??0,d=this._lyr3DMain.create_elevation_query(e.wasmLayerId,l,n,a);if(this._lyr3DMain._free(n),d===g)return Promise.reject("max mesh elevation query limit exceeded");if(d===w)return Promise.reject("elevation query failed");const h={descriptor:i,signal:t?.signal,resolveCallback:null,rejectCallback:null},_=new Promise((e,i)=>{h.resolveCallback=e,h.rejectCallback=i});return this._elevationQueries.set(d,h),_}_checkForAbortedElevationQueries(){const e=[];this._elevationQueries.forEach((i,t)=>{n(i.signal)&&(this._lyr3DMain.cancel_elevation_query(t),i.rejectCallback(a()),e.push(t))});for(let i=0;i<e.length;++i)this._elevationQueries.delete(e[i])}_pulseTask(){if(this._lyr3DMain){if(this._cameraElevationDirty){const e=this.view.state?.contentCamera.relativeElevation;this._lyr3DMain.set_camera_elevation(e)}this._checkForAbortedElevationQueries();let e=0,i=0;this._layers.forEach(t=>{e+=t.layerView.usedMemory,i+=t.layerView.cachedMemory}),e/=1048576,i/=1048576;const t=this.view.resourceController.memoryController,s=t.usedMemory*t.maxMemory-e-this._lyr3DInternalMemoryBytes/1048576;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(t.memoryFactor,e,i,s,t.maxMemory),this._lyr3DInternalMemoryBytes=this._lyr3DMain.get_index_memory_bytes(),this._layers.forEach(e=>{this._cameraElevationDirty||(e.needFrame=!1),e.layerView.updatingFlagChanged()}),this._hasLayerThatReplacesTerrain&&!this._isTerrainReady&&(this._isTerrainReady=this._lyr3DMain.is_terrain_ready(),this._isTerrainReady&&this.notifyChange("isTerrainReady")),this._cameraElevationDirty=!1}}_isUpdating(e){return e.outstandingJobCount>0||e.outstandingRenderableCount>0||e.needFrame||this._lyr3DBusyCount>0}_incrementJobCount(e,i){if(i.isForElevationQuery)return;const t=this._isUpdating(e);e.outstandingJobCount+=1,t||e.layerView.updatingFlagChanged()}_decrementJobCount(e,i){if(i.isForElevationQuery)return;const t=this._isUpdating(e);e.outstandingJobCount-=1;t!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_incrementRenderableCount(e){const i=this._isUpdating(e);e.outstandingRenderableCount+=1,i||e.layerView.updatingFlagChanged()}_decrementRenderableCount(e){const i=this._isUpdating(e);e.outstandingRenderableCount-=1;i!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_onJobFailed(e,i,t){i.error.length&&this._debugLog(1,1,i.error,!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(t.jobId,t.desc),this._decrementJobCount(e,t)}_onJobSucceeded(e,i,t){if(this._lyr3DMain){if(e.layerView.destroyed)return void this._lyr3DMain.on_job_failed(t.jobId,t.desc);const s=i.data.byteLength,r=this._lyr3DMain._malloc(s);new Uint8Array(this._lyr3DMain.HEAPU8.buffer,r,s).set(i.data),this._lyr3DMain.on_job_completed(t.jobId,i.jobDescJson,r,s),this._lyr3DMain._free(r)}this._decrementJobCount(e,t)}_getRequestPromises(e,t,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.append("session",r.session)}a.push(i(e.toString(),t).then(e=>e.data))}return a}_getInitialPromise(e,i,t,s,r,a,n){const l=this._getRequestPromises(e.urls,i,t,s);return Promise.all(l).then(e=>(r.inputs=e,this._workerHandle.invoke(r,a))).then(e=>e).catch(i=>{let t=1;return o(i)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):n&&400===i.details?.httpStatus?(t=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${i}.`),{status:t,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(){const e=this._lyr3DMain.get_next_job(),i=this._layers.get(e.layerId);if(!i)return;this._incrementJobCount(i,e);const t=i.abortController.signal,s=i.layerView.layer,r="integrated-mesh-3dtiles"===s.type?s.key:null,a="integrated-mesh-3dtiles"===s.type?s.session:null,n={responseType:"array-buffer",signal:t,query:{...i.customParameters,token:i.apiKey,key:r}},l={id:e.jobId,inputs:[],jobDescJson:e.desc.slice(),isMissingResourceCase:!1},d=new URL(s.url),h=r=>{if(1===r.status)this._onJobFailed(i,r,e);else if(0===r.status)this._onJobSucceeded(i,r,e);else if(2===r.status){const a=this._getRequestPromises(r.missingInputUrls,n,d,s);Promise.all(a).then(e=>{l.jobDescJson=r.jobDescJson,r.originalInputs?l.inputs=r.originalInputs:l.inputs=[],l.isMissingResourceCase=!0;for(const i of e)l.inputs.push(i);return this._workerHandle.invoke(l,t)}).then(t=>{1===t.status?this._onJobFailed(i,t,e):0===t.status&&this._onJobSucceeded(i,t,e)}).catch(t=>{this._decrementJobCount(i,e),o(t)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):this._debugLog(1,1,`job ${e.jobId} failed with error ${t}.`),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc)})}};try{const i=await this._getInitialPromise(e,n,d,s,l,t,a);if(3===i.status&&"integrated-mesh-3dtiles"===s.type){a===s.session&&null!==s.session&&await s.requestRootAndSession(t);h(await this._getInitialPromise(e,n,d,s,l,t,s.session))}else h(i)}catch(_){_&&this._debugLog(1,1,_.toString(),!1),this._lyr3DMain&&this._lyr3DMain.on_job_failed(e.jobId,e.desc),this._decrementJobCount(i,e)}}_onNewRenderable(){const e=this._lyr3DMain.get_next_renderable(),{meshData:i}=e;i.data&&i.data.byteLength>0&&(i.data=i.data.slice());const t=this._layers.get(e.layerId);t&&(this._incrementRenderableCount(t),t.layerView.createRenderable(e).then(i=>{const s=i.numGaussians??0;this._lyr3DMain?.on_renderable_created(!0,e.layerId,e.handle,i.memUsageBytes,s),this._decrementRenderableCount(t)}).catch(i=>{o(i)||this._debugLog(2,1,`createRenderable failed with error ${i}.`),this._lyr3DMain?.on_renderable_created(!1,e.layerId,e.handle,0,0),this._decrementRenderableCount(t)}))}_freeRenderables(e,i,t){if(t<1)return;const s=this._layers.get(e);if(!s)return;const r=s.layerView,a=[],n=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,t);for(let o=0;o<t;++o)a.push(n[o]);for(let o=0;o<t;++o)r.freeRenderable(a[o])}_setRenderableVisibility(e,i,t,s){if(s<1)return;const r=this._layers.get(e);if(!r)return;const a=r.layerView,n=[],o=[],l=new Uint32Array(this._lyr3DMain.HEAPU32.buffer,i,s),d=new Uint8Array(this._lyr3DMain.HEAPU8.buffer,t,s);for(let h=0;h<s;++h)n.push(l[h]),o.push(!!(1&d[h]));a.setRenderableVisibility(n,o,s)}_onWasmError(e,i,t,s){this._lyr3DMain&&this._debugLog(t,s,this._lyr3DMain.UTF8ToString(e,i),!1)}_onElevQueryComplete(e){const i=this._elevationQueries.get(e),t=this._lyr3DMain.get_elevation_query_result(e);if(i)if(t.succeeded&&t.zs){const s=t.zs.slice(),r=i.descriptor.clone();for(let e=0;e<s.length;++e)r.coordinates[e].z=s[e];this._debugLog(2,3,`Success EQ ${e}, number points ${s.length}.`),i.resolveCallback(r),this._elevationQueries.delete(e)}else i.rejectCallback(new s("elevation-query:error",t?.error??"Elevation query failed")),this._elevationQueries.delete(e);else this._debugLog(2,1,`_onElevQueryComplete called for unknown queryId ${e}.`)}_doRemoveLayerView(e){const i=this._layers.get(e.wasmLayerId);return!!i&&(i.abortController.abort(),this._lyr3DMain.remove_layer(e.wasmLayerId),this._is3DTilesIMLayerView(e)&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!1,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")),this._layers.delete(e.wasmLayerId),!0)}_is3DTilesIMLayerView(e){return"integrated-mesh-3dtiles"===e.layer.type}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const i=e.layer;if(!i.url||!i.rootTilesetJSON)return{wasmLayerId:p};const t="integrated-mesh-3dtiles"===i.type?0:2,s=this._lyr3DMain.validate_root_tileset(JSON.stringify(i.rootTilesetJSON),t);if(0!==s.errorCode)return{wasmLayerId:p,check:s};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:i.customParameters,apiKey:i.apiKey,needFrame:!0});const o=D(i.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),d=e=>r.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let h=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(i)){let t=i.spatialReference;if(e.useEsriCrs&&i.esriCrsSpatialReference){t=i.esriCrsSpatialReference;const s=c(t);let r=1,a=1;!s&&t.wkid&&-1!==t.wkid&&(r=u.values[u[t.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(t)),s,r,a).catch(d),t.vcsWkid&&this._viewSR.vcsWkid&&this._viewSR.vcsWkid!==t.vcsWkid&&this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),!1,1,1).catch(d)}h=this._lyr3DMain.add_gaussian_splat_layer(l,i.url,a,o)}else this._is3DTilesIMLayerView(e)&&(h=this._lyr3DMain.add_3dtiles_layer(l,i.url,a,o,e.layer.replacesTerrain),h&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!0,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")));return h?(this._updateWasmCamera(),e.updatingFlagChanged(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:p})}_updateWasmCamera(){const e=this.view.state?.contentCamera;if(!e||!this._lyr3DMain)return;const{eye:i,center:t,up:s,near:r,far:a,fovY:n}=e,o=[e.viewport[2],e.viewport[3]],l=e.width/e.height;this._lyr3DMain.set_camera_parameters({eye:i,center:t,up:s,near:r,far:a,fov:n,aspectRatio:l,viewport:o}),this._markAllLayerViewsUpdating()}_markAllLayerViewsUpdating(){this._layers.forEach(e=>{const i=this._isUpdating(e);e.needFrame=!0,i||e.layerView.updatingFlagChanged()})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([h({constructOnly:!0})],W.prototype,"view",void 0),e([h({readOnly:!0})],W.prototype,"isTerrainReady",null),W=e([_("esri.layers.Lyr3DWasmPerSceneView")],W);const V=W;export{V as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../request.js";import{isSome as r}from"../core/arrayUtils.js";import i from"../core/Collection.js";import s from"../core/Error.js";import{clone as a}from"../core/lang.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{getDeepValue as l}from"../core/object.js";import{throwIfAbortError as n}from"../core/promiseUtils.js";import{watch as m,sync as p,on as c}from"../core/reactiveUtils.js";import{urlToObject as u,objectToQuery as y}from"../core/urlUtils.js";import{property as d,subclass as h}from"../core/accessorSupport/decorators.js";import f from"../geometry/Extent.js";import v from"./Layer.js";import g from"./WebTileLayer.js";import{BlendLayer as w}from"./mixins/BlendLayer.js";import{OperationalLayer as I}from"./mixins/OperationalLayer.js";import{PortalLayer as L}from"./mixins/PortalLayer.js";import{RefreshableLayer as S}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as M}from"./mixins/ScaleRangeLayer.js";import{createTileBitmap as T}from"./support/imageBitmapUtils.js";import P from"./support/TileInfo.js";import b from"./support/TileInfoTilemapCache.js";import{WMTSLayerInfo as j}from"./support/WMTSLayerInfo.js";import x from"./support/WMTSSublayer.js";import{getTileUrlFromResourceUrls as E,getTileUrlTemplateFromResourceUrls as C,parseResourceInfo as _,parseText as U,validateCapabilities as R,parseCapabilities as O}from"./support/wmtsUtils.js";import{reader as A}from"../core/accessorSupport/decorators/reader.js";import{writer as W}from"../core/accessorSupport/decorators/writer.js";var F;const V={"image/png":".png","image/png8":".png","image/png24":".png","image/png32":".png","image/jpg":".jpg","image/jpeg":".jpeg","image/gif":".gif","image/bmp":".bmp","image/tiff":".tif","image/jpgpng":"","image/jpegpng":"","image/unknown":""},B=new Set(["version","service","request","layer","style","format","tilematrixset","tilematrix","tilerow","tilecol"]);let $=F=class extends(w(S(M(I(L(o(v))))))){constructor(...e){super(...e),this.activeLayer=null,this.copyright="",this.customParameters=null,this.customLayerParameters=null,this.fullExtent=null,this.operationalLayerType="WebTiledLayer",this.resourceInfo=null,this.serviceMode="RESTful",this.sublayers=null,this.type="wmts",this.version="1.0.0",this.addHandles([m(()=>this.activeLayer,(e,t)=>{t&&!this.sublayers?.includes(t)&&(t.layer=null,t.parent=null),e&&(e.layer=this,e.parent=this)},p),c(()=>this.sublayers,"after-add",({item:e})=>{e.layer=this,e.parent=this},p),c(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=null,e.parent=null},p),m(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=null,r.parent=null;if(e)for(const r of e)r.layer=this,r.parent=this},p)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMTS"]},e).catch(n).then(()=>this._fetchService(e)).catch(e=>{throw n(e),new s("wmtslayer:unsupported-service-data","Invalid response from the WMTS service.",{error:e})})),Promise.resolve(this)}readActiveLayerFromService(e,t,r){this.activeLayer||(this.activeLayer=new x);let i=t.layers.find(e=>e.id===this.activeLayer.id);return i||(i=t.layers[0]),this.activeLayer.read(i,r),this.activeLayer}readActiveLayerFromItemOrWebDoc(e,t){const{templateUrl:r,wmtsInfo:i}=t,s=r?this._getLowerCasedUrlParams(r):null,a=i?.layerIdentifier;let o=null;const l=i?.tileMatrixSet;l&&(Array.isArray(l)?l.length&&(o=l[0]):o=l);const n=s?.format,m=s?.style;return new x({id:a,imageFormat:n,styleId:m,tileMatrixSetId:o})}writeActiveLayer(e,t,r,i){const s=this.activeLayer;t.templateUrl=this.getUrlTemplate(s.id,s.tileMatrixSetId,s.imageFormat,s.styleId);const a=l("tileMatrixSet.tileInfo",s);t.tileInfo=a?a.toJSON(i):null,t.wmtsInfo={...t.wmtsInfo,layerIdentifier:s.id,tileMatrixSet:s.tileMatrixSetId}}readCustomParameters(e,t){const r=t.wmtsInfo;return r?this._mergeParams(r.customParameters,r.url):null}get fullExtents(){return this.activeLayer.fullExtents}readServiceMode(e,t){return t.templateUrl.includes("?")?"KVP":"RESTful"}readSublayersFromService(e,t,r){return K(t.layers,r)}get supportedSpatialReferences(){return this.activeLayer.tileMatrixSets?.map(e=>e.tileInfo?.spatialReference).toArray().filter(r)??[]}get tilemapCache(){const e=this.activeLayer?.tileMatrixSet?.tileInfo;return e?new b(e):void 0}get title(){return this.activeLayer?.title??"Layer"}set title(e){this._overrideIfSome("title",e)}get url(){return this._get("url")}set url(e){e&&e.endsWith("/")?this._set("url",e.slice(0,-1)):this._set("url",e)}createWebTileLayer(e){const t=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId),r=this._getTileMatrixSetById(e.tileMatrixSetId),i=r?.tileInfo,s=e.fullExtent,a=new j({layerIdentifier:e.id,tileMatrixSet:e.tileMatrixSetId,url:this.url});return this.customLayerParameters&&(a.customLayerParameters=this.customLayerParameters),this.customParameters&&(a.customParameters=this.customParameters),new g({fullExtent:s,urlTemplate:t,tileInfo:i,wmtsInfo:a})}async fetchTile(e,r,i,s={}){const{signal:a}=s,o=this.getTileUrl(e,r,i),{data:l}=await t(o,{responseType:"image",signal:a});return l}async fetchImageBitmapTile(e,r,i,s={}){const{signal:a}=s;if(this.fetchTile!==F.prototype.fetchTile){const t=await this.fetchTile(e,r,i,s);return T(t,e,r,i,a)}const o=this.getTileUrl(e,r,i),{data:l}=await t(o,{responseType:"blob",signal:a});return T(l,e,r,i,a)}findSublayerById(e){return this.sublayers?.find(t=>t.id===e)}getTileUrl(e,t,r){const i=this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId),s=i?.tileInfo?.lods[e],a=s?s.levelValue||`${s.level}`:`${e}`;let o=this.resourceInfo?"":E({dimensionMap:this.dimensionMap,layerMap:this.layerMap},this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId,a,t,r);if(!o){o=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId).replaceAll(/\{level\}/gi,a).replaceAll(/\{row\}/gi,`${t}`).replaceAll(/\{col\}/gi,`${r}`)}return o=this._appendCustomLayerParameters(o),o}getUrlTemplate(e,t,r,i){if(!this.resourceInfo){const r=C({dimensionMap:this.dimensionMap,layerMap:this.layerMap},e,t,i);if(r)return r}if("KVP"===this.serviceMode)return this.url+"?SERVICE=WMTS&VERSION="+this.version+"&REQUEST=GetTile&LAYER="+e+"&STYLE="+i+"&FORMAT="+r+"&TILEMATRIXSET="+t+"&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";if("RESTful"===this.serviceMode){let s="";return V[r.toLowerCase()]&&(s=V[r.toLowerCase()]),this.url+e+"/"+i+"/"+t+"/{level}/{row}/{col}"+s}return""}async _fetchService(e){if(this.resourceInfo)return"KVP"!==this.resourceInfo.serviceMode||this.url.includes("?")||(this.url+="?"),_(this.resourceInfo),void this.read(this.resourceInfo,{origin:"service"});let t=null;try{const{data:r}=await this._getCapabilities(this.serviceMode,e);t=U(r),R(t)}catch{const r="KVP"===this.serviceMode?"RESTful":"KVP";try{const{data:i}=await this._getCapabilities(r,e);t=U(i),R(t),this.serviceMode=r}catch(o){throw new s("wmtslayer:unsupported-service-data","Services does not support RESTful or KVP service modes.",{error:o})}}const{serviceMode:r,url:i}=this,a=O(t,{serviceMode:r,url:i});this.read(a,{origin:"service"})}async _getCapabilities(e,r){const i=this._getCapabilitiesUrl(e);return await t(i,{...r,responseType:"text"})}_getTileMatrixSetById(e){const t=this.findSublayerById(this.activeLayer.id);return t?.tileMatrixSets?.find(({id:t})=>t===e)}_appendCustomParameters(e){return this._appendParameters(e,this.customParameters)}_appendCustomLayerParameters(e){return this._appendParameters(e,{...a(this.customParameters),...this.customLayerParameters})}_appendParameters(e,t){const r=u(e),i={...r.query,...t},s=y(i);return""===s?r.path:`${r.path}?${s}`}_getCapabilitiesUrl(e){this.url=u(this.url).path;let t=this.url;switch(e){case"KVP":t+=`?request=GetCapabilities&service=WMTS&version=${this.version}`;break;case"RESTful":{const e=`/${this.version}/WMTSCapabilities.xml`,r=new RegExp(e,"i");t=t.replace(r,""),t+=e;break}}return this._appendCustomParameters(t)}_getLowerCasedUrlParams(e){if(!e)return null;const t=u(e).query;if(!t)return null;const r={};return Object.keys(t).forEach(e=>{r[e.toLowerCase()]=t[e]}),r}_mergeParams(e,t){const r=this._getLowerCasedUrlParams(t);if(r){const t=Object.keys(r);t.length&&(e=e?a(e):{},t.forEach(t=>{e.hasOwnProperty(t)||B.has(t)||(e[t]=r[t])}))}return e}};function K(e,t){return e.map(e=>{const r=new x;return r.read(e,t),r})}e([d()],$.prototype,"dimensionMap",void 0),e([d()],$.prototype,"layerMap",void 0),e([d({type:x,json:{origins:{"web-document":{write:{ignoreOrigin:!0}}}}})],$.prototype,"activeLayer",void 0),e([A("service","activeLayer",["layers"])],$.prototype,"readActiveLayerFromService",null),e([A(["web-document","portal-item"],"activeLayer",["wmtsInfo"])],$.prototype,"readActiveLayerFromItemOrWebDoc",null),e([W(["web-document","portal-item"],"activeLayer",{templateUrl:{type:String},tileInfo:{type:P},"wmtsInfo.layerIdentifier":{type:String},"wmtsInfo.tileMatrixSet":{type:String}})],$.prototype,"writeActiveLayer",null),e([d({type:String,value:"",json:{write:!0}})],$.prototype,"copyright",void 0),e([d({type:["show","hide"]})],$.prototype,"listMode",void 0),e([d({json:{read:!0,write:!0}})],$.prototype,"blendMode",void 0),e([d({json:{origins:{"web-document":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}},"portal-item":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}}}}})],$.prototype,"customParameters",void 0),e([A(["portal-item","web-document"],"customParameters")],$.prototype,"readCustomParameters",null),e([d({json:{origins:{"web-document":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}},"portal-item":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}}}}})],$.prototype,"customLayerParameters",void 0),e([d({type:f,json:{write:{ignoreOrigin:!0},origins:{"web-document":{read:{source:"fullExtent"}},"portal-item":{read:{source:"fullExtent"}}}}})],$.prototype,"fullExtent",void 0),e([d({readOnly:!0})],$.prototype,"fullExtents",null),e([d({type:["WebTiledLayer"]})],$.prototype,"operationalLayerType",void 0),e([d()],$.prototype,"resourceInfo",void 0),e([d()],$.prototype,"serviceMode",void 0),e([A(["portal-item","web-document"],"serviceMode",["templateUrl"])],$.prototype,"readServiceMode",null),e([d({type:i.ofType(x)})],$.prototype,"sublayers",void 0),e([A("service","sublayers",["layers"])],$.prototype,"readSublayersFromService",null),e([d({readOnly:!0})],$.prototype,"supportedSpatialReferences",null),e([d({readOnly:!0})],$.prototype,"tilemapCache",null),e([d({json:{read:{source:"title"}}})],$.prototype,"title",null),e([d({json:{read:!1},readOnly:!0,value:"wmts"})],$.prototype,"type",void 0),e([d({json:{origins:{service:{read:{source:"tileUrl"}},"web-document":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}},"portal-item":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}}}}})],$.prototype,"url",null),e([d()],$.prototype,"version",void 0),$=F=e([h("esri.layers.WMTSLayer")],$);const k=$;export{k as default};
2
+ import{__decorate as e}from"tslib";import t from"../request.js";import{isSome as r}from"../core/arrayUtils.js";import i from"../core/Collection.js";import s from"../core/Error.js";import{clone as a}from"../core/lang.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as l}from"../core/promiseUtils.js";import{watch as n,sync as m,on as p}from"../core/reactiveUtils.js";import{urlToObject as c,objectToQuery as u}from"../core/urlUtils.js";import{property as y,subclass as d}from"../core/accessorSupport/decorators.js";import h from"../geometry/Extent.js";import f from"./Layer.js";import v from"./WebTileLayer.js";import{BlendLayer as g}from"./mixins/BlendLayer.js";import{OperationalLayer as w}from"./mixins/OperationalLayer.js";import{PortalLayer as I}from"./mixins/PortalLayer.js";import{RefreshableLayer as L}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{createTileBitmap as M}from"./support/imageBitmapUtils.js";import T from"./support/TileInfo.js";import P from"./support/TileInfoTilemapCache.js";import{WMTSLayerInfo as b}from"./support/WMTSLayerInfo.js";import j from"./support/WMTSSublayer.js";import{getTileUrlFromResourceUrls as x,getTileUrlTemplateFromResourceUrls as E,parseResourceInfo as _,parseText as C,validateCapabilities as U,parseCapabilities as R}from"./support/wmtsUtils.js";import{reader as O}from"../core/accessorSupport/decorators/reader.js";import{writer as A}from"../core/accessorSupport/decorators/writer.js";var W;const F={"image/png":".png","image/png8":".png","image/png24":".png","image/png32":".png","image/jpg":".jpg","image/jpeg":".jpeg","image/gif":".gif","image/bmp":".bmp","image/tiff":".tif","image/jpgpng":"","image/jpegpng":"","image/unknown":""},V=new Set(["version","service","request","layer","style","format","tilematrixset","tilematrix","tilerow","tilecol"]);let B=W=class extends(g(L(S(w(I(o(f))))))){constructor(...e){super(...e),this.activeLayer=null,this.copyright="",this.customParameters=null,this.customLayerParameters=null,this.fullExtent=null,this.operationalLayerType="WebTiledLayer",this.resourceInfo=null,this.serviceMode="RESTful",this.sublayers=null,this.type="wmts",this.version="1.0.0",this.addHandles([n(()=>this.activeLayer,(e,t)=>{t&&!this.sublayers?.includes(t)&&(t.layer=null,t.parent=null),e&&(e.layer=this,e.parent=this)},m),p(()=>this.sublayers,"after-add",({item:e})=>{e.layer=this,e.parent=this},m),p(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=null,e.parent=null},m),n(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=null,r.parent=null;if(e)for(const r of e)r.layer=this,r.parent=this},m)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMTS"]},e).catch(l).then(()=>this._fetchService(e)).catch(e=>{throw l(e),new s("wmtslayer:unsupported-service-data","Invalid response from the WMTS service.",{error:e})})),Promise.resolve(this)}readActiveLayerFromService(e,t,r){this.activeLayer||(this.activeLayer=new j);let i=t.layers.find(e=>e.id===this.activeLayer.id);return i||(i=t.layers[0]),this.activeLayer.read(i,r),this.activeLayer}readActiveLayerFromItemOrWebDoc(e,t){const{templateUrl:r,wmtsInfo:i}=t,s=r?this._getLowerCasedUrlParams(r):null,a=i?.layerIdentifier;let o=null;const l=i?.tileMatrixSet;l&&(Array.isArray(l)?l.length&&(o=l[0]):o=l);const n=s?.format,m=s?.style;return new j({id:a,imageFormat:n,styleId:m,tileMatrixSetId:o})}writeActiveLayer(e,t,r,i){const{activeLayer:s,loaded:a}=this,{id:o,tileMatrixSet:l,tileMatrixSetId:n,imageFormat:m,styleId:p}=s;t.templateUrl=a?this.getUrlTemplate(o,n,m,p):void 0,t.tileInfo=a?l?.tileInfo?.toJSON(i)??null:void 0,t.wmtsInfo={...t.wmtsInfo,layerIdentifier:o,tileMatrixSet:n}}readCustomParameters(e,t){const r=t.wmtsInfo;return r?this._mergeParams(r.customParameters,r.url):null}get fullExtents(){return this.activeLayer.fullExtents}readServiceMode(e,t){return t.templateUrl.includes("?")?"KVP":"RESTful"}readSublayersFromService(e,t,r){return $(t.layers,r)}get supportedSpatialReferences(){return this.activeLayer.tileMatrixSets?.map(e=>e.tileInfo?.spatialReference).toArray().filter(r)??[]}get tilemapCache(){const e=this.activeLayer?.tileMatrixSet?.tileInfo;return e?new P(e):void 0}get title(){return this.activeLayer?.title??"Layer"}set title(e){this._overrideIfSome("title",e)}get url(){return this._get("url")}set url(e){e&&e.endsWith("/")?this._set("url",e.slice(0,-1)):this._set("url",e)}createWebTileLayer(e){const t=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId),r=this._getTileMatrixSetById(e.tileMatrixSetId),i=r?.tileInfo,s=e.fullExtent,a=new b({layerIdentifier:e.id,tileMatrixSet:e.tileMatrixSetId,url:this.url});return this.customLayerParameters&&(a.customLayerParameters=this.customLayerParameters),this.customParameters&&(a.customParameters=this.customParameters),new v({fullExtent:s,urlTemplate:t,tileInfo:i,wmtsInfo:a})}async fetchTile(e,r,i,s={}){const{signal:a}=s,o=this.getTileUrl(e,r,i),{data:l}=await t(o,{responseType:"image",signal:a});return l}async fetchImageBitmapTile(e,r,i,s={}){const{signal:a}=s;if(this.fetchTile!==W.prototype.fetchTile){const t=await this.fetchTile(e,r,i,s);return M(t,e,r,i,a)}const o=this.getTileUrl(e,r,i),{data:l}=await t(o,{responseType:"blob",signal:a});return M(l,e,r,i,a)}findSublayerById(e){return this.sublayers?.find(t=>t.id===e)}getTileUrl(e,t,r){const i=this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId),s=i?.tileInfo?.lods[e],a=s?s.levelValue||`${s.level}`:`${e}`;let o=this.resourceInfo?"":x({dimensionMap:this.dimensionMap,layerMap:this.layerMap},this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId,a,t,r);if(!o){o=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId).replaceAll(/\{level\}/gi,a).replaceAll(/\{row\}/gi,`${t}`).replaceAll(/\{col\}/gi,`${r}`)}return o=this._appendCustomLayerParameters(o),o}getUrlTemplate(e,t,r,i){if(!this.resourceInfo){const r=E({dimensionMap:this.dimensionMap,layerMap:this.layerMap},e,t,i);if(r)return r}if("KVP"===this.serviceMode)return this.url+"?SERVICE=WMTS&VERSION="+this.version+"&REQUEST=GetTile&LAYER="+e+"&STYLE="+i+"&FORMAT="+r+"&TILEMATRIXSET="+t+"&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";if("RESTful"===this.serviceMode){let s="";const a=r.toLowerCase();return F[a]&&(s=F[a]),this.url+e+"/"+i+"/"+t+"/{level}/{row}/{col}"+s}return""}async _fetchService(e){if(this.resourceInfo)return"KVP"!==this.resourceInfo.serviceMode||this.url.includes("?")||(this.url+="?"),_(this.resourceInfo),void this.read(this.resourceInfo,{origin:"service"});let t=null;try{const{data:r}=await this._getCapabilities(this.serviceMode,e);t=C(r),U(t)}catch{const r="KVP"===this.serviceMode?"RESTful":"KVP";try{const{data:i}=await this._getCapabilities(r,e);t=C(i),U(t),this.serviceMode=r}catch(o){throw new s("wmtslayer:unsupported-service-data","Services does not support RESTful or KVP service modes.",{error:o})}}const{serviceMode:r,url:i}=this,a=R(t,{serviceMode:r,url:i});this.read(a,{origin:"service"})}async _getCapabilities(e,r){const i=this._getCapabilitiesUrl(e);return await t(i,{...r,responseType:"text"})}_getTileMatrixSetById(e){const t=this.findSublayerById(this.activeLayer.id);return t?.tileMatrixSets?.find(({id:t})=>t===e)}_appendCustomParameters(e){return this._appendParameters(e,this.customParameters)}_appendCustomLayerParameters(e){return this._appendParameters(e,{...a(this.customParameters),...this.customLayerParameters})}_appendParameters(e,t){const r=c(e),i={...r.query,...t},s=u(i);return""===s?r.path:`${r.path}?${s}`}_getCapabilitiesUrl(e){this.url=c(this.url).path;let t=this.url;switch(e){case"KVP":t+=`?request=GetCapabilities&service=WMTS&version=${this.version}`;break;case"RESTful":{const e=`/${this.version}/WMTSCapabilities.xml`,r=new RegExp(e,"i");t=t.replace(r,""),t+=e;break}}return this._appendCustomParameters(t)}_getLowerCasedUrlParams(e){if(!e)return null;const t=c(e).query;if(!t)return null;const r={};return Object.keys(t).forEach(e=>{r[e.toLowerCase()]=t[e]}),r}_mergeParams(e,t){const r=this._getLowerCasedUrlParams(t);if(r){const t=Object.keys(r);t.length&&(e=e?a(e):{},t.forEach(t=>{e.hasOwnProperty(t)||V.has(t)||(e[t]=r[t])}))}return e}};function $(e,t){return e.map(e=>{const r=new j;return r.read(e,t),r})}e([y()],B.prototype,"dimensionMap",void 0),e([y()],B.prototype,"layerMap",void 0),e([y({type:j,json:{origins:{"web-document":{write:{ignoreOrigin:!0}}}}})],B.prototype,"activeLayer",void 0),e([O("service","activeLayer",["layers"])],B.prototype,"readActiveLayerFromService",null),e([O(["web-document","portal-item"],"activeLayer",["wmtsInfo"])],B.prototype,"readActiveLayerFromItemOrWebDoc",null),e([A(["web-document","portal-item"],"activeLayer",{templateUrl:{type:String},tileInfo:{type:T},"wmtsInfo.layerIdentifier":{type:String},"wmtsInfo.tileMatrixSet":{type:String}})],B.prototype,"writeActiveLayer",null),e([y({type:String,value:"",json:{write:!0}})],B.prototype,"copyright",void 0),e([y({type:["show","hide"]})],B.prototype,"listMode",void 0),e([y({json:{read:!0,write:!0}})],B.prototype,"blendMode",void 0),e([y({json:{origins:{"web-document":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}},"portal-item":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}}}}})],B.prototype,"customParameters",void 0),e([O(["portal-item","web-document"],"customParameters")],B.prototype,"readCustomParameters",null),e([y({json:{origins:{"web-document":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}},"portal-item":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}}}}})],B.prototype,"customLayerParameters",void 0),e([y({type:h,json:{write:{ignoreOrigin:!0},origins:{"web-document":{read:{source:"fullExtent"}},"portal-item":{read:{source:"fullExtent"}}}}})],B.prototype,"fullExtent",void 0),e([y({readOnly:!0})],B.prototype,"fullExtents",null),e([y({type:["WebTiledLayer"]})],B.prototype,"operationalLayerType",void 0),e([y()],B.prototype,"resourceInfo",void 0),e([y()],B.prototype,"serviceMode",void 0),e([O(["portal-item","web-document"],"serviceMode",["templateUrl"])],B.prototype,"readServiceMode",null),e([y({type:i.ofType(j)})],B.prototype,"sublayers",void 0),e([O("service","sublayers",["layers"])],B.prototype,"readSublayersFromService",null),e([y({readOnly:!0})],B.prototype,"supportedSpatialReferences",null),e([y({readOnly:!0})],B.prototype,"tilemapCache",null),e([y({json:{read:{source:"title"}}})],B.prototype,"title",null),e([y({json:{read:!1},readOnly:!0,value:"wmts"})],B.prototype,"type",void 0),e([y({json:{origins:{service:{read:{source:"tileUrl"}},"web-document":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}},"portal-item":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}}}}})],B.prototype,"url",null),e([y()],B.prototype,"version",void 0),B=W=e([d("esri.layers.WMTSLayer")],B);const K=B;export{K as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as l}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as u,isCoordinate as c,cloneCurve as m}from"../../../geometry/support/curves/curveUtils.js";import d from"./AttributesBuilder.js";import{cleanFromGeometryEngine as p,getGeometry as f,transformCentroid as h}from"./geometryUtils.js";import{project as y}from"./projectionSupport.js";import{getDateInNumber as g}from"./queryUtils.js";import{SnappingCandidateEdge as x,SnappingCandidateVertex as T}from"./SnappingCandidate.js";import{isDateField as F,isDateOnlyField as I,isTimestampOffsetField as _,isStringField as v,isTimeOnlyField as V}from"../../support/fieldUtils.js";import S from"../../../rest/support/AutoIntervalBinParameters.js";import b from"../../../rest/support/DateBinParameters.js";import{unitsDict as z}from"../../../rest/support/DateBinUtils.js";import R from"../../../rest/support/FixedBoundariesBinParameters.js";import B from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as M,calculateStringStatistics as A,calculateStatistics as w,processSummaryStatisticsResult as N,calculateUniqueValuesCount as D,createUVResult as P,calculateClassBreaks as q,resolveCBResult as j,calculateHistogram as C,getAttributeComparator as O,calculatePercentile as Z,binIndex as G,getBinParams as E}from"../../../statistics/utils.js";import{utc as H}from"../../../time/constants.js";import{DateTime as U}from"luxon";const k="bin";class J{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 d(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 n=new Map,r=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!r.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,this.items,n);s.push(t)}r.set(a,this._calculateUniqueValues(s,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:i,items:a}=u[t],n=i.join(",");s&&!e.validateItems(a,s)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=p({spatialReference:this.query.outSR,...y(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=p({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,s){const i=this.featureAdapter,a=Y(this.hasZ,this.hasM),{point:n}=e,r="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y;function d(e,t){const s=(e-n.x)/r,i=(t-n.y)/o;return s*s+i*i}const p={candidates:[]},f="esriGeometryPolygon"===this.geometryType,h="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,y=this._getPointCreator(t,this.spatialReference,s),g=new X(null,0),F=new X(null,0),I={x:0,y:0,z:0};for(const l of this.items){const e=i.getObjectId(l),t=i.getGeometryWithCurves?.(l);if(null!=t){v(t,e);continue}const s=i.getGeometry(l);null==s||_(s,e)}return p.candidates.sort((e,t)=>e.distance-t.distance),p;function _(t,s){const{coords:i}=t,r=t.isPoint?L:t.lengths;if(g.coords=i,F.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],o=e;for(let t=0;t<i;t++,e+=a){if(!f&&t===i-1)continue;if(g.coordsIndex=e,F.coordsIndex=t===i-1?o:e+a,!Q(I,n,g,F))continue;const r=d(I.x,I.y);r<=1&&p.candidates.push(new x(s,y(I),Math.sqrt(r),y(g),y(F)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],n=e,o=F;o.coordsIndex=n;for(let t=0;t<i;t++,e+=a){if(g.coordsIndex=e,f&&t===i-1&&g.x===o.x&&g.y===o.y)continue;const a=d(g.x,g.y);a<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(a)))}}}else if(h&&"ends"===e.vertexMode){let e=0;const t=[];for(let s=0;s<r.length;s++){t.push(e);const i=r[s];e+=i*a,i>1&&t.push(e-a)}for(const i of t){g.coordsIndex=i;const e=d(g.x,g.y);e<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(e)))}}}function v(t,s){const{candidates:i}=p,a={x:0,y:0,z:0};if(e.returnEdge){const e=[n.x,n.y],r=new X(e,0),o=new X(e,0);for(const{segments:n}of t.parts)for(const{start:t,curve:p}of n){const{curvePoint:n}=l(t,p,e),f=d(...n);if(f>1)continue;[a.x,a.y]=n,r.coords=t,o.coords=u(p);const h=c(p)?null:m(p);i.push(new x(s,y(a),Math.sqrt(f),y(r),y(o),!1,h))}}function r(e){a.x=t.vertexXY[2*e],a.y=t.vertexXY[2*e+1];const n=d(a.x,a.y);n>1||(a.z=t.vertexZ?.[e]??0,i.push(new T(s,y(a),Math.sqrt(n))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)r(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":r(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const s=t.partOffsets[e],i=t.partOffsets[e+1]-1;r(s),i!==s&&r(i)}}}}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>y(e,t,s),{hasZ:a}=this,n=0;return a&&e?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:n})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=F(m)||I(m)||_(m),p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),f=M({normalizationType:a,normalizationField:i,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},y=v(m)?A({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):w({values:p,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return N(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:n,timeZone:r},this.items,!1),l=D(o);return P(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),f=q(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return j(f,r)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return C(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.slice().reverse()){const t=i.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=O(n?.type,r,"case-sensitive");e.sort((e,t)=>{const i=s(e,a,n),r=s(t,a,n);return o(i,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:s,hasM:i,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:f,returnM:h}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:s,hasM:i&&h,hasZ:a&&f,objectIdFieldName:r,spatialReference:p(u||o),transform:c&&n(c)||null}}_createFeatures(e,t){const s=new d(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=i&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,i)=>s.getFieldValue(e,t,i)),this.geometryType&&(l||u)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const i of _){const a=this.featureAdapter.getGeometry(i),n=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),geometry:f(this.geometryType,a,c,e,x,T)});t&&a&&!n.geometry&&(n.centroid=h(this,this.featureAdapter.getCentroid(i,this),e)),F[I++]=n}else if(!l&&u)for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:h(this,this.featureAdapter.getCentroid(i,this),e)});else for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:h(this,this.featureAdapter.getCentroid(i,this),e),geometry:f(this.geometryType,this.featureAdapter.getGeometry(i),c,e,x,T)})}else for(const n of _){const e=s.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const v=m||0;if(null!=p){const e=v+p;F=F.slice(v,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const s=this.featureAdapter.getMetadata?.(e);return void 0!==s&&(t.metadata=s),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,s=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,i=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>s)e=!0;else{const t=Y(this.hasZ,this.hasM),s=this.featureAdapter;e=this.items.reduce((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)},0)/t>i}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,s={attributes:{}}){const i=[],a=new Map,n=new Map,r=new Map,o=new Map,l=new d(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:p,resultRecordCount:f}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const d of u??[]){const{outStatisticFieldName:e,statisticType:u}=d,p=d,f="exceedslimit"!==u?d.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,F="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,I=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!r.has(f)){const e=[];for(const s of c){const i=this._getAttributeValues(l,s,t,a);e.push(i)}r.set(f,this._calculateUniqueValues(e,t,!F&&l.returnDistinctValues))}const s=r.get(f);if(!s)continue;const i=Object.keys(s);for(const n of i){const{count:i,data:r,items:u,itemPositions:d}=s[n],h=r.join(",");if(!m||l.validateItems(u,m)){const s=o.get(h)||{attributes:{}};if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(p,u);s.aggregateGeometries[t]=e}else{let n=null;if(I)n=i;else{const e=this._getAttributeValues(l,f,t,a),s=d.map(t=>e[t]);n=T&&"statisticParameters"in p?this._getPercentileValue(p,s):this._getStatisticValue(p,s,null,l.returnDistinctValues)}s.attributes[e]=n}let n=0;c.forEach((e,t)=>s.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,s)}}}else if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(p,t);s.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,f,t,a);s.attributes[e]=T&&"statisticParameters"in p?this._getPercentileValue(p,i):this._getStatisticValue(p,i,n,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!v(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;i.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const T=y?Array.from(o.values()):[s];return this._sortFeatures(T,p,(e,t)=>e.attributes[t]),f&&(T.length=Math.min(f,T.length)),{fields:i,features:T}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return F(t)||I(t)||_(t)||V(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,p=n.map(e=>f(d,c.getGeometry(e))),h=r(m,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?i(h):a(o(m,p));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):s(a(o(m,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:n}=e;let r=null;r=s?.has(a)?s.get(a):v(this.fieldsIndex.get(a))||this._isAnyDateField(a)?A({values:t,returnDistinct:i}):w({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:n,orderBy:r}=i,o=this.fieldsIndex.get(s);return Z(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s,i){if(i.has(t))return i.get(t);const a=this.fieldsIndex.get(t),n=s.map(s=>e.getFieldValue(s,t,a));return i.set(t,n),n}_calculateUniqueValues(e,t,s){const i={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==i[o]?i[o]={count:1,data:r,items:[a],itemPositions:[n]}:(s||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(n))}return i}async _getDataValues(t,s,i=!0){const a=new d(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(s,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(s,e(t),i)}_calculateHistogramBins(e,t,s){if(null==t.min&&null==t.max)return[];const i=t.intervals,a=t.min??0,n=t.max??0,r=i.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=s[o];if(null!=t&&t>=a&&t<=n){const e=G(i,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:s,outAlias:i,valueType:a}=t,n=[],r=[{name:i??s,alias:i??s,type:a??"esriFieldTypeString"},{name:k,alias:k,type:"esriFieldTypeInteger"}],o=new d(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[s],(e,t,s)=>o.getFieldValue(e,t,s));const c=this._getAttributeValues(o,s,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[i??s]:d}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const s=e.bin;switch(t=t??this.items,s.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(S.fromJSON(s),e,t);case"dateBin":return this._createDateBinsResponse(b.fromJSON(s),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(R.fromJSON(s),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(B.fromJSON(s),e,t)}}async _createAutoIntervalBinsResponse(e,t,s){const{field:i,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),m=E(c,{field:i,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:g(r?e.normalizationMinValue:l,!1),maxValue:g(r?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,s);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,s){const{field:i,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),p=V(this.fieldsIndex.get(i)),f=z.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=n?g(n,p):h[0],x=null!=r?g(r,p):h[h.length-1],T=[];if(null!=y&&null!=x){const e={zone:t.outTimeReference?.ianaTimeZone??H},s=u?.unit?z.toJSON(u.unit):"milliseconds",i={[s]:u?.value||0},n=U.fromMillis(y,e).minus(i),r=U.fromMillis(x,e).minus(i),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const s=(e.weekday-t+7)%7;return e.minus({days:s}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(r,m):r;for(;e>n;){const t=e.minus({[f]:a.value});if(t<n){T.unshift([l?t.plus(i).toMillis():n.plus(i).toMillis(),e.plus(i).toMillis()]);break}T.unshift([t.plus(i).toMillis(),e.plus(i).toMillis()]),e=t}}else{let e="first"===o?n:"week"===f?d(n,m):n.startOf(f);for(;e<=r;){const t=e.plus({[f]:a.value});if(t>r){T.push([e.plus(i).toMillis(),l?t.plus(i).toMillis():r.plus(i).toMillis()]);break}T.push([e.plus(i).toMillis(),t.plus(i).toMillis()]),e=t}}}const F=this._calculateHistogramBins(d,{intervals:T,min:y,max:x},s);return this._createFeaturesFromHistogramBins(F,t)}async _createFixedBoundariesBinsResponse(e,t,s){const{field:i}=e,a=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),n=V(this.fieldsIndex.get(i)),r=e.boundaries.map(e=>g(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,s);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,s){const{field:i,interval:a,normalizationType:n,start:r,end:o}=e,l=await this._getDataValues({field:i||e.expression,normalizationField:e.normalizationField,normalizationType:n,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),u=V(this.fieldsIndex.get(i)),c=E(l,{field:i,classificationMethod:"defined-interval",definedInterval:a,minValue:g(n?e.normalizationMinValue:r,u),maxValue:g(n?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,s);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:s,lowerBoundaryAlias:i}=t,a=i||"lowerBoundary",n=s||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:k,alias:k,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:s,items:i}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?U.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[n]=m&&d&&null!=s?U.fromMillis(s,{zone:d}).toISO():s),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},i),f.attributes[k]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...s})=>({...s,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(f))):(t.bin?.splitBy&&(f.attributes[k]=++c),h=await this._createStatisticsQueryResponse(t,i,f),r.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function Q(e,t,s,i){const a=i.x-s.x,n=i.y-s.y,r=t.x-s.x,o=t.y-s.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=s.x+a*c,e.y=s.y+n*c,!0}function Y(e,t){return e?t?4:3:t?3:2}class X{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]}}const L=[1];export{J as QueryEngineResult};
2
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as l}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as u,isCoordinate as c,cloneCurve as m}from"../../../geometry/support/curves/curveUtils.js";import d from"./AttributesBuilder.js";import{cleanFromGeometryEngine as p,getGeometry as f,transformCentroid as h}from"./geometryUtils.js";import{project as y}from"./projectionSupport.js";import{getDateInNumber as g}from"./queryUtils.js";import{SnappingCandidateEdge as x,SnappingCandidateVertex as T}from"./SnappingCandidate.js";import{isDateField as F,isDateOnlyField as I,isTimestampOffsetField as _,isStringField as v,isTimeOnlyField as V}from"../../support/fieldUtils.js";import S from"../../../rest/support/AutoIntervalBinParameters.js";import b from"../../../rest/support/DateBinParameters.js";import{unitsDict as z}from"../../../rest/support/DateBinUtils.js";import R from"../../../rest/support/FixedBoundariesBinParameters.js";import B from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as M,calculateStringStatistics as A,calculateStatistics as w,processSummaryStatisticsResult as N,calculateUniqueValuesCount as D,createUVResult as P,calculateClassBreaks as q,resolveCBResult as j,calculateHistogram as C,getAttributeComparator as O,calculatePercentile as Z,binIndex as G,getBinParams as E}from"../../../statistics/utils.js";import{utc as H}from"../../../time/constants.js";import{DateTime as U}from"luxon";const k="bin";class J{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 d(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 n=new Map,r=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!r.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,this.items,n);s.push(t)}r.set(a,this._calculateUniqueValues(s,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:i,items:a}=u[t],n=i.join(",");s&&!e.validateItems(a,s)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=p({spatialReference:this.query.outSR,...y(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=p({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,s){const i=this.featureAdapter,a=Y(this.hasZ,this.hasM),{point:n}=e,r="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y;function d(e,t){const s=(e-n.x)/r,i=(t-n.y)/o;return s*s+i*i}const p={candidates:[]},f="esriGeometryPolygon"===this.geometryType,h="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,y=this._getPointCreator(t,this.spatialReference,s),g=new X(null,0),F=new X(null,0),I={x:0,y:0,z:0};for(const l of this.items){const e=i.getObjectId(l),t=i.getGeometryWithCurves?.(l);if(null!=t){v(t,e);continue}const s=i.getGeometry(l);null==s||_(s,e)}return p.candidates.sort((e,t)=>e.distance-t.distance),p;function _(t,s){const{coords:i}=t,r=t.isPoint?L:t.lengths;if(g.coords=i,F.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],o=e;for(let t=0;t<i;t++,e+=a){if(!f&&t===i-1)continue;if(g.coordsIndex=e,F.coordsIndex=t===i-1?o:e+a,!Q(I,n,g,F))continue;const r=d(I.x,I.y);r<=1&&p.candidates.push(new x(s,y(I),Math.sqrt(r),y(g),y(F)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],n=e,o=F;o.coordsIndex=n;for(let t=0;t<i;t++,e+=a){if(g.coordsIndex=e,f&&t===i-1&&g.x===o.x&&g.y===o.y)continue;const a=d(g.x,g.y);a<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(a)))}}}else if(h&&"ends"===e.vertexMode){let e=0;const t=[];for(let s=0;s<r.length;s++){t.push(e);const i=r[s];e+=i*a,i>1&&t.push(e-a)}for(const i of t){g.coordsIndex=i;const e=d(g.x,g.y);e<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(e)))}}}function v(t,s){const{candidates:i}=p,a={x:0,y:0,z:0};if(e.returnEdge){const e=[n.x,n.y],r=new X(e,0),o=new X(e,0);for(const{segments:n}of t.parts)for(const{start:t,curve:p}of n){const{curvePoint:n}=l(t,p,e),f=d(...n);if(f>1)continue;[a.x,a.y]=n,r.coords=t,o.coords=u(p);const h=c(p)?null:m(p);i.push(new x(s,y(a),Math.sqrt(f),y(r),y(o),!1,h))}}function r(e){a.x=t.vertexXY[2*e],a.y=t.vertexXY[2*e+1];const n=d(a.x,a.y);n>1||(a.z=t.vertexZ?.[e]??0,i.push(new T(s,y(a),Math.sqrt(n))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)r(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":r(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const s=t.partOffsets[e],i=t.partOffsets[e+1]-1;r(s),i!==s&&r(i)}}}}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>y(e,t,s),{hasZ:a}=this,n=0;return a&&e?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:n})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=F(m)||I(m)||_(m),p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),f=M({normalizationType:a,normalizationField:i,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},y=v(m)?A({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):w({values:p,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return N(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:n,timeZone:r},this.items,!1),l=D(o);return P(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),f=q(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return j(f,r)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return C(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.slice().reverse()){const t=i.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=O(n?.type,r,"case-insensitive");e.sort((e,t)=>{const i=s(e,a,n),r=s(t,a,n);return o(i,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:s,hasM:i,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:f,returnM:h}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:s,hasM:i&&h,hasZ:a&&f,objectIdFieldName:r,spatialReference:p(u||o),transform:c&&n(c)||null}}_createFeatures(e,t){const s=new d(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=i&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,i)=>s.getFieldValue(e,t,i)),this.geometryType&&(l||u)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const i of _){const a=this.featureAdapter.getGeometry(i),n=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),geometry:f(this.geometryType,a,c,e,x,T)});t&&a&&!n.geometry&&(n.centroid=h(this,this.featureAdapter.getCentroid(i,this),e)),F[I++]=n}else if(!l&&u)for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:h(this,this.featureAdapter.getCentroid(i,this),e)});else for(const i of _)F[I++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:h(this,this.featureAdapter.getCentroid(i,this),e),geometry:f(this.geometryType,this.featureAdapter.getGeometry(i),c,e,x,T)})}else for(const n of _){const e=s.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const v=m||0;if(null!=p){const e=v+p;F=F.slice(v,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const s=this.featureAdapter.getMetadata?.(e);return void 0!==s&&(t.metadata=s),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,s=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,i=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>s)e=!0;else{const t=Y(this.hasZ,this.hasM),s=this.featureAdapter;e=this.items.reduce((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)},0)/t>i}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,s={attributes:{}}){const i=[],a=new Map,n=new Map,r=new Map,o=new Map,l=new d(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:p,resultRecordCount:f}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const d of u??[]){const{outStatisticFieldName:e,statisticType:u}=d,p=d,f="exceedslimit"!==u?d.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,F="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,I=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!r.has(f)){const e=[];for(const s of c){const i=this._getAttributeValues(l,s,t,a);e.push(i)}r.set(f,this._calculateUniqueValues(e,t,!F&&l.returnDistinctValues))}const s=r.get(f);if(!s)continue;const i=Object.keys(s);for(const n of i){const{count:i,data:r,items:u,itemPositions:d}=s[n],h=r.join(",");if(!m||l.validateItems(u,m)){const s=o.get(h)||{attributes:{}};if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(p,u);s.aggregateGeometries[t]=e}else{let n=null;if(I)n=i;else{const e=this._getAttributeValues(l,f,t,a),s=d.map(t=>e[t]);n=T&&"statisticParameters"in p?this._getPercentileValue(p,s):this._getStatisticValue(p,s,null,l.returnDistinctValues)}s.attributes[e]=n}let n=0;c.forEach((e,t)=>s.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,s)}}}else if(F){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(p,t);s.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,f,t,a);s.attributes[e]=T&&"statisticParameters"in p?this._getPercentileValue(p,i):this._getStatisticValue(p,i,n,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!v(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;i.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const T=y?Array.from(o.values()):[s];return this._sortFeatures(T,p,(e,t)=>e.attributes[t]),f&&(T.length=Math.min(f,T.length)),{fields:i,features:T}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return F(t)||I(t)||_(t)||V(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,p=n.map(e=>f(d,c.getGeometry(e))),h=r(m,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?i(h):a(o(m,p));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):s(a(o(m,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:n}=e;let r=null;r=s?.has(a)?s.get(a):v(this.fieldsIndex.get(a))||this._isAnyDateField(a)?A({values:t,returnDistinct:i}):w({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:n,orderBy:r}=i,o=this.fieldsIndex.get(s);return Z(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s,i){if(i.has(t))return i.get(t);const a=this.fieldsIndex.get(t),n=s.map(s=>e.getFieldValue(s,t,a));return i.set(t,n),n}_calculateUniqueValues(e,t,s){const i={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==i[o]?i[o]={count:1,data:r,items:[a],itemPositions:[n]}:(s||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(n))}return i}async _getDataValues(t,s,i=!0){const a=new d(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(s,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(s,e(t),i)}_calculateHistogramBins(e,t,s){if(null==t.min&&null==t.max)return[];const i=t.intervals,a=t.min??0,n=t.max??0,r=i.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=s[o];if(null!=t&&t>=a&&t<=n){const e=G(i,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:s,outAlias:i,valueType:a}=t,n=[],r=[{name:i??s,alias:i??s,type:a??"esriFieldTypeString"},{name:k,alias:k,type:"esriFieldTypeInteger"}],o=new d(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[s],(e,t,s)=>o.getFieldValue(e,t,s));const c=this._getAttributeValues(o,s,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[i??s]:d}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const s=e.bin;switch(t=t??this.items,s.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(S.fromJSON(s),e,t);case"dateBin":return this._createDateBinsResponse(b.fromJSON(s),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(R.fromJSON(s),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(B.fromJSON(s),e,t)}}async _createAutoIntervalBinsResponse(e,t,s){const{field:i,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),m=E(c,{field:i,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:g(r?e.normalizationMinValue:l,!1),maxValue:g(r?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,s);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,s){const{field:i,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),p=V(this.fieldsIndex.get(i)),f=z.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=n?g(n,p):h[0],x=null!=r?g(r,p):h[h.length-1],T=[];if(null!=y&&null!=x){const e={zone:t.outTimeReference?.ianaTimeZone??H},s=u?.unit?z.toJSON(u.unit):"milliseconds",i={[s]:u?.value||0},n=U.fromMillis(y,e).minus(i),r=U.fromMillis(x,e).minus(i),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const s=(e.weekday-t+7)%7;return e.minus({days:s}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(r,m):r;for(;e>n;){const t=e.minus({[f]:a.value});if(t<n){T.unshift([l?t.plus(i).toMillis():n.plus(i).toMillis(),e.plus(i).toMillis()]);break}T.unshift([t.plus(i).toMillis(),e.plus(i).toMillis()]),e=t}}else{let e="first"===o?n:"week"===f?d(n,m):n.startOf(f);for(;e<=r;){const t=e.plus({[f]:a.value});if(t>r){T.push([e.plus(i).toMillis(),l?t.plus(i).toMillis():r.plus(i).toMillis()]);break}T.push([e.plus(i).toMillis(),t.plus(i).toMillis()]),e=t}}}const F=this._calculateHistogramBins(d,{intervals:T,min:y,max:x},s);return this._createFeaturesFromHistogramBins(F,t)}async _createFixedBoundariesBinsResponse(e,t,s){const{field:i}=e,a=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),n=V(this.fieldsIndex.get(i)),r=e.boundaries.map(e=>g(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,s);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,s){const{field:i,interval:a,normalizationType:n,start:r,end:o}=e,l=await this._getDataValues({field:i||e.expression,normalizationField:e.normalizationField,normalizationType:n,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),u=V(this.fieldsIndex.get(i)),c=E(l,{field:i,classificationMethod:"defined-interval",definedInterval:a,minValue:g(n?e.normalizationMinValue:r,u),maxValue:g(n?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,s);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:s,lowerBoundaryAlias:i}=t,a=i||"lowerBoundary",n=s||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:k,alias:k,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:s,items:i}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?U.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[n]=m&&d&&null!=s?U.fromMillis(s,{zone:d}).toISO():s),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},i),f.attributes[k]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...s})=>({...s,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(f))):(t.bin?.splitBy&&(f.attributes[k]=++c),h=await this._createStatisticsQueryResponse(t,i,f),r.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function Q(e,t,s,i){const a=i.x-s.x,n=i.y-s.y,r=t.x-s.x,o=t.y-s.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=s.x+a*c,e.y=s.y+n*c,!0}function Y(e,t){return e?t?4:3:t?3:2}class X{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]}}const L=[1];export{J as QueryEngineResult};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- 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{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{createResolver as o}from"../../core/promiseUtils.js";import{dataComponents as n}from"../../core/urlUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{normalizeCentralMeridian as l}from"../../geometry/support/normalizeUtils.js";import{isGeographic as u,equals as p,isWGS84 as c,isWebMercator as m}from"../../geometry/support/spatialReferenceUtils.js";import{densifyUnsupportedCurves as h}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{isEditBusLayer as f,emitApplyEditsEvent as y}from"../mixins/EditBusLayer.js";import{isHostedAgolService as g}from"../support/arcgisLayerUrl.js";import{isValidFieldValue as b}from"../support/fieldUtils.js";import{isGlbSupportedEditFormat as w}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as F,getEffectiveLayerCapabilities as A}from"../support/layerUtils.js";function v(e){return null!=e?.applyEdits}const I=()=>s.getLogger("esri.layers.graphics.editingSupport"),$=new WeakMap;async function E(e,t,a,s={}){let i;const n="gdbVersion"in e?e.gdbVersion:null,d=s.gdbVersion??n;if(f(e)&&e.url)i=y(e.url,e.layerId,d,"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 S(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(l){throw i.reject(l),l}}async function S(e,t,r,s){if(await e.load(),!v(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!F(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:i,options:o}=await R(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,o)}:{edits:i,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function R(e,t,r){const s=A(e),o=t&&(t.addFeatures||t.updateFeatures||t.deleteFeatures),n=t&&(t.addAttachments||t.updateAttachments||t.deleteAttachments),d=null!=e.infoFor3D;if(V(t,s,r,!!o,!!n,`${e.type}-layer`),!s.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(!s.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||s.editing.supportsRollbackOnFailure||(l.rollbackOnFailureEnabled=!0),l.rollbackOnFailureEnabled||"original-and-current-features"!==l.returnServiceEditsOption||(!1===l.rollbackOnFailureEnabled&&I().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 overwritten and set to true."),l.rollbackOnFailureEnabled=!0),!s.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=D(t,s,`${e.type}-layer`),p=r?.globalIdUsed||d,c=e.fields.filter(e=>"big-integer"===e.type||"oid"===e.type&&(e.length||0)>=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=>B(e,t))}u.addFeatures.forEach(t=>U(t,e,p,c)),u.updateFeatures.forEach(t=>L(t,e,p,c)),u.deleteFeatures.forEach(t=>k(t,e,p,c)),u.addAttachments.forEach(t=>T(t,e)),u.updateAttachments.forEach(t=>T(t,e)),d&&await z(u,e);const m=i($,e,()=>new Map),h=!g(e.url);return{edits:await M(u,s.data.supportedCurveTypes??[],h,m),options:l}}function O(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&&!b(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 j(e,t){if("geometry"in e&&"mesh"===e.geometry?.type&&null!=t.infoFor3D&&null!=t.spatialReference){const{geometry:r}=e,{spatialReference:s,vertexSpace:i}=r,o=t.spatialReference,n="local"===i.type,d=u(o),l=p(o,s),h=l||c(o)&&(c(s)||m(s));if(!(n&&d&&h||!n&&!d&&l))throw new a(`${t.type}-layer:mesh-unsupported`,`Uploading a mesh with a ${i.type} vertex space and a spatial reference wkid:${s.wkid} to a layer with a spatial reference wkid:${o.wkid} is not supported.`)}}function U(e,t,a,r){O(e,t,a,r),j(e,t)}function k(e,t,a,r){O(e,t,a,r)}function L(e,t,r,s){O(e,t,r,s),j(e,t);const i=A(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 T(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 B(e,t){const{attributes:a}=e;null==a[t]&&(a[t]=d())}async function M(e,t,a,r){const s=e.addFeatures??[],i=e.updateFeatures??[],o=s.concat(i).map(e=>e.geometry),n=await h(o,t,a,r),d=await l(n),u=s.length,p=i.length;return d.slice(0,u).forEach((e,t)=>s[t].geometry=e),d.slice(u,u+p).forEach((e,t)=>i[t].geometry=e),e}function G(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 D(e,t,r){const s=G(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(x),s.updateFeatures=s.updateFeatures.map(x),s.addAssetFeatures=[],s}function V(e,t,r,s,i,o){if(!(e&&(s||i)||r?.usingTelecomOperations))throw new a(`${o}:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!t.editing.supportsGlobalId&&r?.globalIdUsed&&!r.usingFeatureServiceEndpoint)throw new a(`${o}:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!t.editing.supportsGlobalId&&i)throw new a(`${o}: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(`${o}:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true")}function x(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function z(e,t){const{infoFor3D:r}=t;if(null==r)return;if(!w(r))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:s}=e;for(const a of e.addFeatures??[])C(a)&&s.push(a);for(const a of e.updateFeatures??[])C(a)&&s.push(a)}function C(e){return"mesh"===e?.geometry?.type}function W(e,t,r,s){if(!v(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{E as applyEdits,V as checkEditingCapabilities,G as normalizeCollections,D as normalizeEdits,M as processGeometries,x as shallowCloneFeature,W as uploadAssets};
2
+ 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{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{createResolver as o}from"../../core/promiseUtils.js";import{dataComponents as n}from"../../core/urlUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{normalizeCentralMeridian as l}from"../../geometry/support/normalizeUtils.js";import{isGeographic as u,equals as p,isWGS84 as c,isWebMercator as m}from"../../geometry/support/spatialReferenceUtils.js";import{densifyUnsupportedCurves as h}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{isEditBusLayer as f,emitApplyEditsEvent as y}from"../mixins/EditBusLayer.js";import{isValidFieldValue as g}from"../support/fieldUtils.js";import{isGlbSupportedEditFormat as b}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as w,getEffectiveLayerCapabilities as F}from"../support/layerUtils.js";function A(e){return null!=e?.applyEdits}const v=()=>s.getLogger("esri.layers.graphics.editingSupport"),I=new WeakMap;async function $(e,t,a,s={}){let i;const n="gdbVersion"in e?e.gdbVersion:null,d=s.gdbVersion??n;if(f(e)&&e.url)i=y(e.url,e.layerId,d,"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 E(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(l){throw i.reject(l),l}}async function E(e,t,r,s){if(await e.load(),!A(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!w(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:i,options:o}=await S(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,o)}:{edits:i,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function S(e,t,r){const s=F(e),o=t&&(t.addFeatures||t.updateFeatures||t.deleteFeatures),n=t&&(t.addAttachments||t.updateAttachments||t.deleteAttachments),d=null!=e.infoFor3D;if(D(t,s,r,!!o,!!n,`${e.type}-layer`),!s.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(!s.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||s.editing.supportsRollbackOnFailure||(l.rollbackOnFailureEnabled=!0),l.rollbackOnFailureEnabled||"original-and-current-features"!==l.returnServiceEditsOption||(!1===l.rollbackOnFailureEnabled&&v().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 overwritten and set to true."),l.rollbackOnFailureEnabled=!0),!s.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=G(t,s,`${e.type}-layer`),p=r?.globalIdUsed||d,c=e.fields.filter(e=>"big-integer"===e.type||"oid"===e.type&&(e.length||0)>=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=>T(e,t))}u.addFeatures.forEach(t=>j(t,e,p,c)),u.updateFeatures.forEach(t=>k(t,e,p,c)),u.deleteFeatures.forEach(t=>U(t,e,p,c)),u.addAttachments.forEach(t=>L(t,e)),u.updateAttachments.forEach(t=>L(t,e)),d&&await x(u,e);const m=i(I,e,()=>new Map);return{edits:await B(u,s.data.supportedCurveTypes??[],m),options:l}}function R(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&&!g(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 O(e,t){if("geometry"in e&&"mesh"===e.geometry?.type&&null!=t.infoFor3D&&null!=t.spatialReference){const{geometry:r}=e,{spatialReference:s,vertexSpace:i}=r,o=t.spatialReference,n="local"===i.type,d=u(o),l=p(o,s),h=l||c(o)&&(c(s)||m(s));if(!(n&&d&&h||!n&&!d&&l))throw new a(`${t.type}-layer:mesh-unsupported`,`Uploading a mesh with a ${i.type} vertex space and a spatial reference wkid:${s.wkid} to a layer with a spatial reference wkid:${o.wkid} is not supported.`)}}function j(e,t,a,r){R(e,t,a,r),O(e,t)}function U(e,t,a,r){R(e,t,a,r)}function k(e,t,r,s){R(e,t,r,s),O(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 L(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 T(e,t){const{attributes:a}=e;null==a[t]&&(a[t]=d())}async function B(e,t,a){const r=e.addFeatures??[],s=e.updateFeatures??[],i=r.concat(s).map(e=>e.geometry),o=await h(i,t,a),n=await l(o),d=r.length,u=s.length;return n.slice(0,d).forEach((e,t)=>r[t].geometry=e),n.slice(d,d+u).forEach((e,t)=>s[t].geometry=e),e}function M(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 G(e,t,r){const s=M(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(V),s.updateFeatures=s.updateFeatures.map(V),s.addAssetFeatures=[],s}function D(e,t,r,s,i,o){if(!(e&&(s||i)||r?.usingTelecomOperations))throw new a(`${o}:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");if(!t.editing.supportsGlobalId&&r?.globalIdUsed&&!r.usingFeatureServiceEndpoint)throw new a(`${o}:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!t.editing.supportsGlobalId&&i)throw new a(`${o}: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(`${o}:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true")}function V(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function x(e,t){const{infoFor3D:r}=t;if(null==r)return;if(!b(r))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:s}=e;for(const a of e.addFeatures??[])z(a)&&s.push(a);for(const a of e.updateFeatures??[])z(a)&&s.push(a)}function z(e){return"mesh"===e?.geometry?.type}function C(e,t,r,s){if(!A(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{$ as applyEdits,D as checkEditingCapabilities,M as normalizeCollections,G as normalizeEdits,B as processGeometries,V as shallowCloneFeature,C as uploadAssets};