@arcgis/core 4.28.0-next.20230920 → 4.28.0-next.20230922

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 (413) hide show
  1. package/Graphic.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/ArcadeDate.js +1 -1
  4. package/arcade/Feature.js +1 -1
  5. package/arcade/featureSetUtils.js +1 -1
  6. package/arcade/featureset/actions/Adapted.js +1 -1
  7. package/arcade/featureset/actions/GroupBy.js +1 -1
  8. package/arcade/featureset/support/FeatureSet.js +1 -1
  9. package/arcade/featureset/support/FeatureSetIterator.js +1 -1
  10. package/arcade/featureset/support/StatsField.js +1 -1
  11. package/arcade/featureset/support/sqlUtils.js +1 -1
  12. package/arcade/functions/date.js +1 -1
  13. package/arcade/functions/featuresetbase.js +1 -1
  14. package/arcade/functions/featuresetstats.js +1 -1
  15. package/arcade.js +1 -1
  16. package/assets/esri/core/workers/RemoteClient.js +1 -1
  17. package/assets/esri/core/workers/chunks/{2cb36f9686693234991a.js → 07a2dab2f645dcd7d8d6.js} +1 -1
  18. package/assets/esri/core/workers/chunks/07f6175b52366b2c28bd.js +1 -0
  19. package/assets/esri/core/workers/chunks/098073c3b2849f56dad8.js +1 -0
  20. package/assets/esri/core/workers/chunks/{7c72d5368bb2d7484b9b.js → 21fc02f0d5716c4a7acd.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{072b4e041b8630c513a0.js → 243b1f9b2fba02946481.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{dff1c3c38dda2bd1a9d6.js → 246a954347fe9318190e.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{314c307e30f308a40a28.js → 25b09e9c0511c8e1cf8a.js} +1 -1
  24. package/assets/esri/core/workers/chunks/28a5ef2e2daa4207dd8b.js +1 -0
  25. package/assets/esri/core/workers/chunks/2b017e1aa1be71974c2e.js +1 -0
  26. package/assets/esri/core/workers/chunks/425b5733bb88e6efe242.js +1 -0
  27. package/assets/esri/core/workers/chunks/4339ce8aaf87fabb80cc.js +1 -0
  28. package/assets/esri/core/workers/chunks/43ba2bacd0f7d19915f7.js +1 -0
  29. package/assets/esri/core/workers/chunks/44b8e75593b7df1843e1.js +1 -0
  30. package/assets/esri/core/workers/chunks/{c9dfb145f0c1d93e0fbd.js → 4bcca5fffb1fcc2d4353.js} +1 -1
  31. package/assets/esri/core/workers/chunks/4bf1a7e82a68ccee0ee1.js +1 -0
  32. package/assets/esri/core/workers/chunks/4c110c7f4f940ec58010.js +1 -0
  33. package/assets/esri/core/workers/chunks/{bde89b2684b6185992ef.js → 4ed77097e69fa3096ce4.js} +1 -1
  34. package/assets/esri/core/workers/chunks/51324d042f469f3b8914.js +1 -0
  35. package/assets/esri/core/workers/chunks/53097659f31750c03a6d.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3f4e9b1663ec521bfe00.js → 542ce10e1872399790b4.js} +1 -1
  37. package/assets/esri/core/workers/chunks/54d2b7e2ac4ba883bee8.js +1 -0
  38. package/assets/esri/core/workers/chunks/54ecb6cae310818d1aa2.js +1 -0
  39. package/assets/esri/core/workers/chunks/57c932e289d89d97da4b.js +1 -0
  40. package/assets/esri/core/workers/chunks/{6403de6fc067cf8f7436.js → 592c1fb531f2be928e8a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/5edb99b58549cd66b394.js +1 -0
  42. package/assets/esri/core/workers/chunks/609a475ab395f2ce63e2.js +1 -0
  43. package/assets/esri/core/workers/chunks/6203ddf6caad3d356327.js +1 -0
  44. package/assets/esri/core/workers/chunks/{b428fcb53ecc82b49e66.js → 65186e168dd112ac6221.js} +1 -1
  45. package/assets/esri/core/workers/chunks/652749dc847fcb887234.js +1 -0
  46. package/assets/esri/core/workers/chunks/6b9248fb2d6aadbce7bb.js +1 -0
  47. package/assets/esri/core/workers/chunks/709465832d306e02df52.js +1 -0
  48. package/assets/esri/core/workers/chunks/74368a5213def6c200a2.js +1 -0
  49. package/assets/esri/core/workers/chunks/74d3ecb1a06d9f81e2c5.js +1 -0
  50. package/assets/esri/core/workers/chunks/78e7af899d9d50aa7e74.js +1 -0
  51. package/assets/esri/core/workers/chunks/7ea33aa455c5143affb1.js +1 -0
  52. package/assets/esri/core/workers/chunks/7fe641cf1467496e670a.js +1 -0
  53. package/assets/esri/core/workers/chunks/{df8f62beb36fb9d2ac81.js → 810c8d6ff19976fd1366.js} +1 -1
  54. package/assets/esri/core/workers/chunks/83a15aa4b1c5252c651b.js +1 -0
  55. package/assets/esri/core/workers/chunks/85e436decdd693f240ee.js +1 -0
  56. package/assets/esri/core/workers/chunks/{243a4eed107d363dfad8.js → 887652bbdb3b71d0a089.js} +1 -1
  57. package/assets/esri/core/workers/chunks/896bfda379cf620b63ec.js +1 -0
  58. package/assets/esri/core/workers/chunks/90771b0de3e520a1df9a.js +1 -0
  59. package/assets/esri/core/workers/chunks/{1f7e041140088f8ac489.js → 97073a60f0ea2a397165.js} +1 -1
  60. package/assets/esri/core/workers/chunks/a277c980ba8704939688.js +1 -0
  61. package/assets/esri/core/workers/chunks/{101f776316a85b708927.js → a99070ec4c06c435b744.js} +1 -1
  62. package/assets/esri/core/workers/chunks/b499b4fa771e8c422b43.js +1 -0
  63. package/assets/esri/core/workers/chunks/bc1dc6383e60e7e61d50.js +1 -0
  64. package/assets/esri/core/workers/chunks/bffad8aec92f982cc75a.js +1 -0
  65. package/assets/esri/core/workers/chunks/cec607d0138351a4952e.js +1 -0
  66. package/assets/esri/core/workers/chunks/d414dba3179bcf75bc6b.js +1 -0
  67. package/assets/esri/core/workers/chunks/{b449d6bd5851187d419f.js → d6e5408f9fa6b4bcd118.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{f147269d85adfb4588ed.js → d9061beaa43065316062.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b558a402e2ce2616cf37.js → e14da83329f7771135bc.js} +22 -22
  70. package/assets/esri/core/workers/chunks/{f508ccfde6425dabe9ac.js → ee0bf611d191103a7046.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{9c40e7ed387071544f8c.js → f793cd41fcd022baeea2.js} +1 -1
  72. package/assets/esri/core/workers/chunks/fb87fd64411b78afea23.js +1 -0
  73. package/assets/esri/images/portal/onlinemedialayer16.png +0 -0
  74. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +2 -0
  75. package/assets/esri/themes/dark/main.css +1 -1
  76. package/assets/esri/themes/light/main.css +1 -1
  77. package/assets/esri/themes/light/view.css +1 -1
  78. package/chunks/LaserlinePath.glsl.js +5 -1
  79. package/config.js +1 -1
  80. package/core/Accessor.js +1 -1
  81. package/core/has.js +1 -1
  82. package/core/sql/DateOnly.js +1 -1
  83. package/core/sql/WhereClause.js +1 -1
  84. package/core/sql.js +1 -1
  85. package/identity/IdentityForm.js +1 -1
  86. package/identity/IdentityModal.js +1 -1
  87. package/interfaces.d.ts +29 -216
  88. package/layers/OrientedImageryLayer.js +1 -1
  89. package/layers/graphics/applyEditsUtils.js +5 -0
  90. package/layers/graphics/editingSupport.js +1 -1
  91. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  92. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  93. package/layers/mixins/EditBusLayer.js +1 -1
  94. package/layers/mixins/SceneService.js +1 -1
  95. package/layers/orientedImagery/core/CameraOrientationLTP.js +1 -1
  96. package/layers/orientedImagery/core/ElevationSourceDefinitions.js +5 -0
  97. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  98. package/layers/orientedImagery/core/cameraOrientationFactory.js +1 -1
  99. package/layers/orientedImagery/core/utils.js +5 -0
  100. package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
  101. package/layers/save/utils.js +1 -1
  102. package/layers/support/editableLayers.js +1 -1
  103. package/layers/support/fieldProperties.js +1 -1
  104. package/networks/Network.js +1 -1
  105. package/package.json +1 -1
  106. package/portal/PortalItem.js +1 -1
  107. package/rest/featureService/FeatureService.js +1 -1
  108. package/rest/geometryService/cut.js +1 -1
  109. package/rest/query/operations/query.js +1 -1
  110. package/rest/versionManagement/deleteVersion.js +1 -1
  111. package/rest/versionManagement/gdbVersion/alterVersion.js +1 -1
  112. package/rest/versionManagement/gdbVersion/post.js +1 -1
  113. package/rest/versionManagement/gdbVersion/reconcile.js +1 -1
  114. package/rest/versionManagement/gdbVersion/serverVersionUtils.js +5 -0
  115. package/support/arcadeUtils.js +1 -1
  116. package/support/revision.js +1 -1
  117. package/symbols/support/svgUtils.js +1 -1
  118. package/versionManagement/VersionManagementService.js +1 -1
  119. package/versionManagement/support/EditMomentStack.js +5 -0
  120. package/versionManagement/support/versionManagementUtils.js +1 -1
  121. package/views/2d/engine/Container.js +1 -1
  122. package/views/2d/engine/DisplayObject.js +1 -1
  123. package/views/2d/engine/ManagedCanvas.js +5 -0
  124. package/views/2d/engine/Stage.js +1 -1
  125. package/views/2d/engine/webgl/GroupContainer.js +1 -1
  126. package/views/2d/engine/webgl/Painter.js +1 -1
  127. package/views/2d/engine/webgl/WGLContainer.js +1 -1
  128. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  129. package/views/2d/engine/webgl/effects/FeatureEffect.js +1 -1
  130. package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
  131. package/views/2d/engine/webgl/effects/HittestEffectVTL.js +1 -1
  132. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  133. package/views/2d/layers/MediaLayerView2D.js +1 -1
  134. package/views/2d/layers/TileLayerView2D.js +1 -1
  135. package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
  136. package/views/2d/layers/graphics/BaseGraphicContainer.js +1 -1
  137. package/views/2d/layers/graphics/GraphicContainer.js +1 -1
  138. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  139. package/views/2d/layers/graphics/HighlightGraphicContainer.js +1 -1
  140. package/views/2d/layers/support/DisplayGL.js +1 -1
  141. package/views/2d/webglDeps.js +1 -1
  142. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  143. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  144. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  145. package/views/3d/environment/LocalAtmosphere.js +1 -1
  146. package/views/3d/interactive/manipulatorUtils.js +1 -1
  147. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  148. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  152. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  153. package/views/3d/layers/MediaLayerView3D.js +1 -1
  154. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  155. package/views/3d/layers/SceneLayerView3D.js +1 -1
  156. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  157. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  158. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  159. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  160. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  161. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  162. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  164. package/views/3d/layers/graphics/Labeler.js +1 -1
  165. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  166. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  167. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  168. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  169. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  170. package/views/3d/layers/i3s/featureEditing.js +1 -1
  171. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  172. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  173. package/views/3d/layers/support/overlayImageUtils.js +1 -1
  174. package/views/3d/layers/support/patternUtils.js +1 -1
  175. package/views/3d/support/buffer/glUtil.js +1 -1
  176. package/views/3d/support/dito.js +1 -1
  177. package/views/3d/support/engineContent/line.js +1 -1
  178. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  179. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  180. package/views/3d/support/viewpointUtils.js +1 -1
  181. package/views/3d/terrain/TerrainRenderer.js +1 -1
  182. package/views/3d/webgl-engine/Stage.js +1 -1
  183. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  184. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  185. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +6 -6
  186. package/views/3d/webgl-engine/effects/RenderPluginInput.js +1 -1
  187. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  188. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  189. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  190. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  191. package/views/3d/webgl-engine/lib/Attribute.js +1 -1
  192. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  193. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  194. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  195. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  196. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  197. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  198. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  199. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  200. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  201. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  202. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  203. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  204. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  205. package/views/3d/webgl-engine/lib/VertexAttribute.js +1 -1
  206. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  207. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  208. package/views/3d/webgl-engine/lib/edgeRendering/edgeProcessing.js +1 -1
  209. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  210. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  211. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  212. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  213. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  214. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  215. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  216. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  217. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  218. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  219. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  220. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  221. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  222. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  223. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  224. package/views/View.js +1 -1
  225. package/views/draw/DrawGraphicTool.js +1 -1
  226. package/views/interactive/keybindings.js +1 -1
  227. package/views/interactive/tooltip/SketchTooltipInfo.js +1 -1
  228. package/views/interactive/tooltip/TooltipContentWithHelpMessage.js +1 -1
  229. package/views/interactive/tooltip/TooltipEditableField.js +1 -1
  230. package/views/interactive/tooltip/constraintUtils.js +1 -1
  231. package/views/interactive/tooltip/content/Fields.js +5 -0
  232. package/views/interactive/tooltip/content/TooltipContentDrawCircle.js +1 -1
  233. package/views/interactive/tooltip/content/TooltipContentDrawMesh.js +1 -1
  234. package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
  235. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  236. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  237. package/views/interactive/tooltip/content/TooltipContentDrawRectangle.js +1 -1
  238. package/views/interactive/tooltip/content/TooltipContentExtentRotate.js +1 -1
  239. package/views/interactive/tooltip/content/TooltipContentExtentScale.js +1 -1
  240. package/views/interactive/tooltip/content/TooltipContentReshapeEdgeOffset.js +1 -1
  241. package/views/interactive/tooltip/content/TooltipContentTransformAbsolute.js +1 -1
  242. package/views/interactive/tooltip/content/TooltipContentTransformRotate.js +1 -1
  243. package/views/interactive/tooltip/content/TooltipContentTransformScale.js +1 -1
  244. package/views/interactive/tooltip/content/TooltipContentTranslateGraphic.js +1 -1
  245. package/views/interactive/tooltip/content/TooltipContentTranslateGraphicXY.js +1 -1
  246. package/views/interactive/tooltip/content/TooltipContentTranslateGraphicZ.js +1 -1
  247. package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
  248. package/views/interactive/tooltip/content/TooltipContentTranslateVertexXY.js +1 -1
  249. package/views/interactive/tooltip/content/TooltipContentTranslateVertexZ.js +1 -1
  250. package/views/support/angularMeasurementUtils.js +1 -1
  251. package/views/webgl/Texture.js +1 -1
  252. package/views/webgl/contextUtils.js +1 -1
  253. package/webdoc/saveAPIKeyUtils.js +5 -0
  254. package/webdoc/webdocSaveUtils.js +1 -1
  255. package/widgets/AreaMeasurement2D.js +1 -1
  256. package/widgets/AreaMeasurement3D.js +1 -1
  257. package/widgets/Attachments.js +1 -1
  258. package/widgets/Attribution.js +1 -1
  259. package/widgets/BasemapGallery.js +1 -1
  260. package/widgets/BasemapLayerList.js +1 -1
  261. package/widgets/BasemapToggle.js +1 -1
  262. package/widgets/Bookmarks.js +1 -1
  263. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesNode.js +1 -1
  264. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
  265. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  266. package/widgets/BuildingExplorer/BuildingLevelPicker/Label.js +1 -1
  267. package/widgets/BuildingExplorer/BuildingLevelPicker/LevelItem.js +1 -1
  268. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  269. package/widgets/BuildingExplorer.js +1 -1
  270. package/widgets/Compass.js +1 -1
  271. package/widgets/CoordinateConversion.js +1 -1
  272. package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
  273. package/widgets/Daylight.js +1 -1
  274. package/widgets/DirectLineMeasurement3D.js +1 -1
  275. package/widgets/DirectionalPad.js +1 -1
  276. package/widgets/Directions/components/SaveLayer.js +1 -1
  277. package/widgets/Directions.js +1 -1
  278. package/widgets/DistanceMeasurement2D.js +1 -1
  279. package/widgets/Editor/components/FooterActions.js +1 -1
  280. package/widgets/Editor/components/Notices.js +1 -1
  281. package/widgets/Editor/components/PanelContent.js +1 -1
  282. package/widgets/Editor/components/PanelToolbar.js +1 -1
  283. package/widgets/Editor/components/Prompt.js +1 -1
  284. package/widgets/Editor/components/Settings.js +1 -1
  285. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  286. package/widgets/Editor/components/UploadDetails.js +1 -1
  287. package/widgets/Editor.js +1 -1
  288. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  289. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  290. package/widgets/ElevationProfile/components/Statistics.js +1 -1
  291. package/widgets/ElevationProfile.js +1 -1
  292. package/widgets/Expand.js +1 -1
  293. package/widgets/Feature/FeatureContent.js +1 -1
  294. package/widgets/Feature/FeatureExpression.js +1 -1
  295. package/widgets/Feature/FeatureFields.js +1 -1
  296. package/widgets/Feature/FeatureMedia.js +1 -1
  297. package/widgets/Feature/FeatureRelationship.js +1 -1
  298. package/widgets/Feature/support/FeatureContentMixin.js +1 -1
  299. package/widgets/Feature/support/FeatureElementInfo.js +1 -1
  300. package/widgets/Feature.js +1 -1
  301. package/widgets/FeatureForm.js +1 -1
  302. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  303. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  304. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  305. package/widgets/FeatureTable.js +1 -1
  306. package/widgets/FeatureTemplates/ItemList.js +1 -1
  307. package/widgets/FeatureTemplates.js +1 -1
  308. package/widgets/Features/FeaturesRelatedRecords.js +1 -1
  309. package/widgets/Features.js +1 -1
  310. package/widgets/FloorFilter.js +1 -1
  311. package/widgets/Fullscreen.js +1 -1
  312. package/widgets/Histogram.js +1 -1
  313. package/widgets/HistogramRangeSlider.js +1 -1
  314. package/widgets/Home.js +1 -1
  315. package/widgets/LayerList/ListItemPanel.js +1 -1
  316. package/widgets/LayerList.js +1 -1
  317. package/widgets/Legend/styles/Card.js +1 -1
  318. package/widgets/Legend/styles/Classic.js +1 -1
  319. package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
  320. package/widgets/Legend/styles/support/univariateUtils.js +1 -1
  321. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  322. package/widgets/LineOfSight.js +1 -1
  323. package/widgets/Locate.js +1 -1
  324. package/widgets/NavigationToggle.js +1 -1
  325. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  326. package/widgets/OrientedImageryViewer.js +1 -1
  327. package/widgets/Popup.js +1 -1
  328. package/widgets/Print.js +1 -1
  329. package/widgets/ScaleRangeSlider.js +1 -1
  330. package/widgets/Search/SearchResultRenderer.js +1 -1
  331. package/widgets/Search.js +1 -1
  332. package/widgets/ShadowCast/components/DiscreteConfigurator.js +1 -1
  333. package/widgets/ShadowCast/components/DurationConfigurator.js +1 -1
  334. package/widgets/ShadowCast/components/ShadowTooltipContent.js +1 -1
  335. package/widgets/ShadowCast/components/ThresholdConfigurator.js +1 -1
  336. package/widgets/ShadowCast.js +1 -1
  337. package/widgets/Sketch.js +1 -1
  338. package/widgets/Slice.js +1 -1
  339. package/widgets/Slider.js +1 -1
  340. package/widgets/Swipe.js +1 -1
  341. package/widgets/TableList.js +1 -1
  342. package/widgets/TimeSlider.js +1 -1
  343. package/widgets/Track.js +1 -1
  344. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js +1 -1
  345. package/widgets/UtilityNetworkAssociations.js +1 -1
  346. package/widgets/UtilityNetworkTrace.js +1 -1
  347. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  348. package/widgets/ValuePicker.js +1 -1
  349. package/widgets/VideoPlayer/components/PlayerControlsGroup.js +1 -1
  350. package/widgets/VideoPlayer/components/SettingsButton.js +1 -1
  351. package/widgets/VideoPlayer.js +1 -1
  352. package/widgets/Weather/LabeledSlider.js +1 -1
  353. package/widgets/Weather.js +1 -1
  354. package/widgets/Zoom/IconButton.js +1 -1
  355. package/widgets/smartMapping/BinaryColorSizeSlider.js +1 -1
  356. package/widgets/smartMapping/ClassedColorSlider.js +1 -1
  357. package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
  358. package/widgets/smartMapping/ColorSizeSlider.js +1 -1
  359. package/widgets/smartMapping/ColorSlider.js +1 -1
  360. package/widgets/smartMapping/HeatmapSlider.js +1 -1
  361. package/widgets/smartMapping/OpacitySlider.js +1 -1
  362. package/widgets/smartMapping/SizeSlider.js +1 -1
  363. package/widgets/smartMapping/SmartMappingSliderBase.js +1 -1
  364. package/widgets/support/ColorPicker.js +1 -1
  365. package/widgets/support/DatePicker.js +1 -1
  366. package/widgets/support/Heading.js +1 -1
  367. package/widgets/support/LabeledSwitch.js +1 -1
  368. package/widgets/support/MeasurementWidgetContent.js +1 -1
  369. package/widgets/support/Popover.js +1 -1
  370. package/widgets/support/SelectionToolbar.js +1 -1
  371. package/widgets/support/SketchTooltipControls.js +1 -1
  372. package/widgets/support/SnappingControls.js +1 -1
  373. package/widgets/support/TimePicker.js +1 -1
  374. package/widgets/support/TimezonePicker.js +1 -1
  375. package/widgets/support/UnitSelect.js +1 -1
  376. package/widgets/support/globalCss.js +1 -1
  377. package/assets/esri/core/workers/chunks/034accc7cab6c88a3b31.js +0 -1
  378. package/assets/esri/core/workers/chunks/084a85e2e31b4d5fa924.js +0 -1
  379. package/assets/esri/core/workers/chunks/092920c25cac89c038ee.js +0 -1
  380. package/assets/esri/core/workers/chunks/1a449168d30a688e6128.js +0 -1
  381. package/assets/esri/core/workers/chunks/1b3655f5bf5d90fa8730.js +0 -1
  382. package/assets/esri/core/workers/chunks/1cf7bb514e7eefc3e9c6.js +0 -1
  383. package/assets/esri/core/workers/chunks/21f0fafafcd754f5fb88.js +0 -1
  384. package/assets/esri/core/workers/chunks/273167b2dd46e58b8739.js +0 -1
  385. package/assets/esri/core/workers/chunks/2bf58296a6ea4eee960b.js +0 -1
  386. package/assets/esri/core/workers/chunks/2d0d03cbea83c868edba.js +0 -1
  387. package/assets/esri/core/workers/chunks/2e130cb2f1038055c07b.js +0 -1
  388. package/assets/esri/core/workers/chunks/3c2c64832fb498bbaa83.js +0 -1
  389. package/assets/esri/core/workers/chunks/4b3a5cc435435c81e6a5.js +0 -1
  390. package/assets/esri/core/workers/chunks/4f4a424d1747d04501df.js +0 -1
  391. package/assets/esri/core/workers/chunks/56afd89d08c874f620a1.js +0 -1
  392. package/assets/esri/core/workers/chunks/6108d72faf48a592c8ba.js +0 -1
  393. package/assets/esri/core/workers/chunks/650a317b6dc245a7060f.js +0 -1
  394. package/assets/esri/core/workers/chunks/74ddc14e4b576ddbb582.js +0 -1
  395. package/assets/esri/core/workers/chunks/7a358b1fd0c0cce59e9b.js +0 -1
  396. package/assets/esri/core/workers/chunks/7f680cf24dd97d61bcd2.js +0 -1
  397. package/assets/esri/core/workers/chunks/83d1a1b3d371c991cc4c.js +0 -1
  398. package/assets/esri/core/workers/chunks/9b54b5bdb6367c36f6e9.js +0 -1
  399. package/assets/esri/core/workers/chunks/a838dc6653ec29503053.js +0 -1
  400. package/assets/esri/core/workers/chunks/aa021bc97b4a18a749dd.js +0 -1
  401. package/assets/esri/core/workers/chunks/b10a91cae610aba62bf8.js +0 -1
  402. package/assets/esri/core/workers/chunks/b8eb842ea98a9734e161.js +0 -1
  403. package/assets/esri/core/workers/chunks/bbb63392485ed57703e0.js +0 -1
  404. package/assets/esri/core/workers/chunks/bdf13091bd0e1ab0db7e.js +0 -1
  405. package/assets/esri/core/workers/chunks/c60cf62f374e71e562fc.js +0 -1
  406. package/assets/esri/core/workers/chunks/c88869d2a647c22dc3e6.js +0 -1
  407. package/assets/esri/core/workers/chunks/c8f239c25fe864f0e47a.js +0 -1
  408. package/assets/esri/core/workers/chunks/e54ae2a4281dd58e0707.js +0 -1
  409. package/assets/esri/core/workers/chunks/e5fcfd41f0ec12dcb7f2.js +0 -1
  410. package/assets/esri/core/workers/chunks/f07a0ea10428adecea1a.js +0 -1
  411. package/assets/esri/core/workers/chunks/f38c54ada9e7012a2960.js +0 -1
  412. package/core/watchUtils.d.ts +0 -4
  413. package/core/watchUtils.js +0 -5
package/Graphic.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"./chunks/tslib.es6.js";import{geometryTypes as e}from"./geometry.js";import r from"./PopupTemplate.js";import{symbolTypes as o}from"./symbols.js";import{ClonableMixin as s}from"./core/Clonable.js";import{JSONSupport as i}from"./core/JSONSupport.js";import{generateUID as a}from"./core/uid.js";import{property as l}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import"./core/arrayUtils.js";import"./core/has.js";import{subclass as p}from"./core/accessorSupport/decorators/subclass.js";import{fromJSON as n}from"./geometry/support/jsonUtils.js";var u;function y(t){if(!t)return null;const e={};for(const r in t){const o=n(t[r]);o&&(e[r]=o)}return 0!==Object.keys(e).length?e:null}function m(t){if(null==t)return null;const e={};for(const r in t){const o=t[r];o&&(e[r]=o.toJSON())}return 0!==Object.keys(e).length?e:null}let g=u=class extends(s(i)){constructor(...t){super(...t),this.isAggregate=!1,this.layer=null,this.popupTemplate=null,this.sourceLayer=null,Object.defineProperty(this,"uid",{value:a(),configurable:!0})}normalizeCtorArgs(t,e,r,o){return t&&!t.declaredClass?t:{geometry:t,symbol:e,attributes:r,popupTemplate:o}}set aggregateGeometries(t){const e=this._get("aggregateGeometries");JSON.stringify(e)!==JSON.stringify(t)&&this._set("aggregateGeometries",t)}set attributes(t){const e=this._get("attributes");e!==t&&(this._set("attributes",t),this._notifyLayer("attributes",e,t))}set geometry(t){const e=this._get("geometry");e!==t&&(this._set("geometry",t),this._notifyLayer("geometry",e,t))}set symbol(t){const e=this._get("symbol");e!==t&&(this._set("symbol",t),this._notifyLayer("symbol",e,t))}set visible(t){const e=this._get("visible");e!==t&&(this._set("visible",t),this._notifyLayer("visible",e,t))}cloneShallow(){return new u({aggregateGeometries:this.aggregateGeometries,attributes:this.attributes,geometry:this.geometry,isAggregate:this.isAggregate,layer:this.layer,popupTemplate:this.popupTemplate,sourceLayer:this.sourceLayer,symbol:this.symbol,visible:this.visible})}getEffectivePopupTemplate(t=!1){if(this.popupTemplate)return this.popupTemplate;for(const e of[this.sourceLayer,this.layer])if(e){if("popupTemplate"in e&&e.popupTemplate)return e.popupTemplate;if(t&&"defaultPopupTemplate"in e&&null!=e.defaultPopupTemplate)return e.defaultPopupTemplate}return null}getAttribute(t){return this.attributes?.[t]}setAttribute(t,e){if(this.attributes){const r=this.getAttribute(t);this.attributes[t]=e,this._notifyLayer("attributes",r,e,t)}else this.attributes={[t]:e},this._notifyLayer("attributes",void 0,e,t)}getObjectId(){return this.sourceLayer&&"objectIdField"in this.sourceLayer&&this.sourceLayer.objectIdField?this.getAttribute(this.sourceLayer.objectIdField):null}toJSON(){return{aggregateGeometries:m(this.aggregateGeometries),geometry:null!=this.geometry?this.geometry.toJSON():null,symbol:null!=this.symbol?this.symbol.toJSON():null,attributes:{...this.attributes},popupTemplate:this.popupTemplate&&this.popupTemplate.toJSON()}}notifyGeometryChanged(){this._notifyLayer("geometry",this.geometry,this.geometry)}notifyMeshTransformChanged(t={}){const{geometry:e}=this;if("mesh"===e?.type){const r={origin:e.origin,transform:e.transform};this._notifyLayer("origin-transform",r,r,t.action)}}_notifyLayer(t,e,r,o){if(!this.layer||!("graphicChanged"in this.layer))return;const s={graphic:this,property:t,oldValue:e,newValue:r};"origin-transform"===t&&(s.action=o),"attributes"===t&&(s.attributeName=o),this.layer.graphicChanged(s)}};t([l({value:null,json:{read:y}})],g.prototype,"aggregateGeometries",null),t([l({value:null})],g.prototype,"attributes",null),t([l({value:null,types:e,json:{read:n}})],g.prototype,"geometry",null),t([l({type:Boolean})],g.prototype,"isAggregate",void 0),t([l({clonable:"reference"})],g.prototype,"layer",void 0),t([l({type:r})],g.prototype,"popupTemplate",void 0),t([l({clonable:"reference"})],g.prototype,"sourceLayer",void 0),t([l({value:null,types:o})],g.prototype,"symbol",null),t([l({type:Boolean,value:!0})],g.prototype,"visible",null),g=u=t([p("esri.Graphic")],g),function(t){t.generateUID=a}(g||(g={}));const h=g;export{h as default};
5
+ import{_ as t}from"./chunks/tslib.es6.js";import{geometryTypes as e}from"./geometry.js";import r from"./PopupTemplate.js";import{symbolTypes as s}from"./symbols.js";import{ClonableMixin as o}from"./core/Clonable.js";import{isSerializable as i,JSONSupport as a}from"./core/JSONSupport.js";import{generateUID as l}from"./core/uid.js";import{property as p}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import"./core/arrayUtils.js";import"./core/has.js";import{subclass as n}from"./core/accessorSupport/decorators/subclass.js";import{fromJSON as u}from"./geometry/support/jsonUtils.js";var y;function m(t){if(!t)return null;const e={};for(const r in t){const s=u(t[r]);s&&(e[r]=s)}return 0!==Object.keys(e).length?e:null}function g(t){if(null==t)return null;const e={};for(const r in t){const s=t[r];s&&(e[r]=s.toJSON())}return 0!==Object.keys(e).length?e:null}let h=y=class extends(o(a)){constructor(...t){super(...t),this.isAggregate=!1,this.layer=null,this.popupTemplate=null,this.sourceLayer=null,Object.defineProperty(this,"uid",{value:l(),configurable:!0})}normalizeCtorArgs(t,e,r,s){return t&&!t.declaredClass?t:{geometry:t,symbol:e,attributes:r,popupTemplate:s}}set aggregateGeometries(t){const e=this._get("aggregateGeometries");JSON.stringify(e)!==JSON.stringify(t)&&this._set("aggregateGeometries",t)}set attributes(t){const e=this._get("attributes");e!==t&&(this._set("attributes",t),this._notifyLayer("attributes",e,t))}set geometry(t){const e=this._get("geometry");e!==t&&(this._set("geometry",t),this._notifyLayer("geometry",e,t))}set symbol(t){const e=this._get("symbol");e!==t&&(this._set("symbol",t),this._notifyLayer("symbol",e,t))}set visible(t){const e=this._get("visible");e!==t&&(this._set("visible",t),this._notifyLayer("visible",e,t))}cloneShallow(){return new y({aggregateGeometries:this.aggregateGeometries,attributes:this.attributes,geometry:this.geometry,isAggregate:this.isAggregate,layer:this.layer,popupTemplate:this.popupTemplate,sourceLayer:this.sourceLayer,symbol:this.symbol,visible:this.visible})}getEffectivePopupTemplate(t=!1){if(this.popupTemplate)return this.popupTemplate;for(const e of[this.sourceLayer,this.layer])if(e){if("popupTemplate"in e&&e.popupTemplate)return e.popupTemplate;if(t&&"defaultPopupTemplate"in e&&null!=e.defaultPopupTemplate)return e.defaultPopupTemplate}return null}getAttribute(t){return this.attributes?.[t]}setAttribute(t,e){if(this.attributes){const r=this.getAttribute(t);this.attributes[t]=e,this._notifyLayer("attributes",r,e,t)}else this.attributes={[t]:e},this._notifyLayer("attributes",void 0,e,t)}getObjectId(){return this.sourceLayer&&"objectIdField"in this.sourceLayer&&this.sourceLayer.objectIdField?this.getAttribute(this.sourceLayer.objectIdField):null}toJSON(){return{aggregateGeometries:g(this.aggregateGeometries),geometry:null!=this.geometry?this.geometry.toJSON():null,symbol:null!=this.symbol?this.symbol.toJSON():null,attributes:i(this.attributes)?this.attributes.toJSON():{...this.attributes},popupTemplate:this.popupTemplate&&this.popupTemplate.toJSON()}}notifyGeometryChanged(){this._notifyLayer("geometry",this.geometry,this.geometry)}notifyMeshTransformChanged(t={}){const{geometry:e}=this;if("mesh"===e?.type){const r={origin:e.origin,transform:e.transform};this._notifyLayer("origin-transform",r,r,t.action)}}_notifyLayer(t,e,r,s){if(!this.layer||!("graphicChanged"in this.layer))return;const o={graphic:this,property:t,oldValue:e,newValue:r};"origin-transform"===t&&(o.action=s),"attributes"===t&&(o.attributeName=s),this.layer.graphicChanged(o)}};t([p({value:null,json:{read:m}})],h.prototype,"aggregateGeometries",null),t([p({value:null})],h.prototype,"attributes",null),t([p({value:null,types:e,json:{read:u}})],h.prototype,"geometry",null),t([p({type:Boolean})],h.prototype,"isAggregate",void 0),t([p({clonable:"reference"})],h.prototype,"layer",void 0),t([p({type:r})],h.prototype,"popupTemplate",void 0),t([p({clonable:"reference"})],h.prototype,"sourceLayer",void 0),t([p({value:null,types:s})],h.prototype,"symbol",null),t([p({type:Boolean,value:!0})],h.prototype,"visible",null),h=y=t([n("esri.Graphic")],h),function(t){t.generateUID=l}(h||(h={}));const c=h;export{c as default};
package/WebScene.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as u}from"./core/Promise.js";import{debounce as m}from"./core/promiseUtils.js";import{on as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as g}from"./core/urlUtils.js";import{property as f}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as v}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as O}from"./geometry/support/spatialReferenceUtils.js";import V from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{toggleTypeKeword as E,TypeKeyword as N}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import C from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as F,createCopyError as J}from"./support/webSceneUtils.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as x}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as W}from"./webdoc/interfaces.js";import{updateItemWithResources as B,saveResources as k}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as q}from"./webdoc/support/thumbnailUtils.js";import D from"./webscene/ApplicationProperties.js";import K from"./webscene/Environment.js";import H from"./webscene/InitialViewProperties.js";import z from"./webscene/Presentation.js";import Q from"./webscene/TransportationNetwork.js";import{Version as X}from"./webscene/Version.js";import{getLoader as Y}from"./webscene/support/schemaValidatorLoader.js";var Z;const ee=new X(1,32),te=()=>{const e=8,t=[],r=ee.major;for(let i=e;i<=ee.minor;i++)t.push(`${r}.${i}`);return t},re="Web Scene";let ie=class extends(n.LoadableMixin(u(d(r)))){constructor(e){super(e),this[Z]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new z,this.initialViewProperties=new H,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=m((async(e,t,r)=>{switch(e){case W.SAVE:return this._saveImpl(t);case W.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${ee.major}.${ee.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState?.environment&&(r.environment=K.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new H(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(W.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw p.getLogger(this).error("save(): requires the .portalItem property to be set"),await Promise.resolve(),new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(this.portalItem?.type!==re)throw await Promise.resolve(),new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${re}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl?w(this.portalItem.itemUrl):null,messages:[],portal:this.portalItem.portal??V.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await B(this.portalItem,i,this._resourceReferences,r,null),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(W.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw p.getLogger(this).error("saveAs(portalItem): requires a portal item parameter"),new s("webscene:portal-item-required","saveAs requires a portal item to save to");r.id&&(r=r.clone(),r.id=null);const i=r.portal||V.getDefault();await this._ensureLoadBeforeSave(),r.type=re,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:a}),await k(this._resourceReferences,o,null),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(o),n&&(this.thumbnailUrl=l?g(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!O(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages?.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)))??[];t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),r?.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=!!r?.strictSchemaValidationEnabled,l=Y();return o=n&&l?l().then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(e.length>0)throw F(e.concat(a));return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)throw new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e})}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(J()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=K.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=q(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||V.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r)}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:w(e.itemUrl),portal:e.portal||V.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!x(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!x(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=X.parse(e.version||"","webscene");return ee.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){E(e,N.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),E(e,N.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&T(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};Z=G,ie.version=`${ee.major}.${ee.minor}`,e([f({type:D,json:{write:!0}})],ie.prototype,"applicationProperties",void 0),e([f({type:I,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],ie.prototype,"clippingArea",void 0),e([S("clippingArea")],ie.prototype,"writeClippingArea",null),e([f({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],ie.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],ie.prototype,"readClippingEnabled",null),e([S("clippingEnabled")],ie.prototype,"writeClippingEnabled",null),e([f({type:C,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],ie.prototype,"floorInfo",void 0),e([f({type:j,json:{write:!0}})],ie.prototype,"heightModelInfo",void 0),e([f({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],ie.prototype,"layers",void 0),e([S("layers")],ie.prototype,"writeLayers",null),e([f({readOnly:!0,type:X,json:{type:te(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],ie.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],ie.prototype,"readSourceVersion",null),e([S("sourceVersion")],ie.prototype,"writeSourceVersion",null),e([f({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],ie.prototype,"tables",void 0),e([S("tables")],ie.prototype,"writeTables",null),e([f()],ie.prototype,"thumbnailUrl",null),e([f({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ie.prototype,"authoringApp",null),e([S("authoringApp")],ie.prototype,"writeAuthoringApp",null),e([f({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],ie.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],ie.prototype,"writeAuthoringAppVersion",null),e([f({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],ie.prototype,"ground",void 0),e([S("ground")],ie.prototype,"writeGround",null),e([f({type:o.ofType(Q),json:{write:!0}})],ie.prototype,"transportationNetworks",void 0),e([f({type:z,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],ie.prototype,"presentation",void 0),e([f({type:H,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new H({viewingMode:"global",spatialReference:R.WebMercator})}})],ie.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],ie.prototype,"readInitialViewProperties",null),e([f({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ie.prototype,"spatialReference",null),e([f({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],ie.prototype,"viewingMode",null),e([f({type:M})],ie.prototype,"portalItem",void 0),e([f()],ie.prototype,"resourceInfo",void 0),ie=e([v("esri.WebScene")],ie);const oe=ie;export{oe as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as u}from"./core/Promise.js";import{debounce as m}from"./core/promiseUtils.js";import{on as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as g}from"./core/urlUtils.js";import{property as f}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as v}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as O}from"./geometry/support/spatialReferenceUtils.js";import V from"./portal/Portal.js";import M from"./portal/PortalItem.js";import{toggleTypeKeword as E,TypeKeyword as N}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import C from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as F,createCopyError as J}from"./support/webSceneUtils.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as x}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as W}from"./webdoc/interfaces.js";import{validateSaveAPIKey as B}from"./webdoc/saveAPIKeyUtils.js";import{updateItemWithResources as k,saveResources as q}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as D}from"./webdoc/support/thumbnailUtils.js";import K from"./webscene/ApplicationProperties.js";import H from"./webscene/Environment.js";import z from"./webscene/InitialViewProperties.js";import Q from"./webscene/Presentation.js";import X from"./webscene/TransportationNetwork.js";import{Version as Y}from"./webscene/Version.js";import{getLoader as Z}from"./webscene/support/schemaValidatorLoader.js";var ee;const te=new Y(1,32),re=()=>{const e=8,t=[],r=te.major;for(let i=e;i<=te.minor;i++)t.push(`${r}.${i}`);return t},ie="Web Scene";let oe=class extends(n.LoadableMixin(u(d(r)))){constructor(e){super(e),this[ee]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new Q,this.initialViewProperties=new z,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=m((async(e,t,r)=>{switch(e){case W.SAVE:return this._saveImpl(t);case W.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new Y(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${te.major}.${te.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState?.environment&&(r.environment=H.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new z(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(W.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(B(this.portalItem),this.portalItem?.type!==ie)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${ie}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl?w(this.portalItem.itemUrl):null,messages:[],portal:this.portalItem.portal??V.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await k(this.portalItem,i,this._resourceReferences,r,null),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(W.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=M.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");B(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||V.getDefault();await this._ensureLoadBeforeSave(),r.type=ie,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:a}),await q(this._resourceReferences,o,null),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(o),n&&(this.thumbnailUrl=l?g(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!O(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages?.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)))??[];t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),r?.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=!!r?.strictSchemaValidationEnabled,l=Z();return o=n&&l?l().then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(e.length>0)throw F(e.concat(a));return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)throw new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e})}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(J()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=H.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=D(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||V.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r)}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:w(e.itemUrl),portal:e.portal||V.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!x(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!x(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=Y.parse(e.version||"","webscene");return te.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){E(e,N.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),E(e,N.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&T(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};ee=G,oe.version=`${te.major}.${te.minor}`,e([f({type:K,json:{write:!0}})],oe.prototype,"applicationProperties",void 0),e([f({type:I,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],oe.prototype,"clippingArea",void 0),e([S("clippingArea")],oe.prototype,"writeClippingArea",null),e([f({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],oe.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],oe.prototype,"readClippingEnabled",null),e([S("clippingEnabled")],oe.prototype,"writeClippingEnabled",null),e([f({type:C,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],oe.prototype,"floorInfo",void 0),e([f({type:j,json:{write:!0}})],oe.prototype,"heightModelInfo",void 0),e([f({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],oe.prototype,"layers",void 0),e([S("layers")],oe.prototype,"writeLayers",null),e([f({readOnly:!0,type:Y,json:{type:re(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],oe.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],oe.prototype,"readSourceVersion",null),e([S("sourceVersion")],oe.prototype,"writeSourceVersion",null),e([f({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],oe.prototype,"tables",void 0),e([S("tables")],oe.prototype,"writeTables",null),e([f()],oe.prototype,"thumbnailUrl",null),e([f({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],oe.prototype,"authoringApp",null),e([S("authoringApp")],oe.prototype,"writeAuthoringApp",null),e([f({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],oe.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],oe.prototype,"writeAuthoringAppVersion",null),e([f({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],oe.prototype,"ground",void 0),e([S("ground")],oe.prototype,"writeGround",null),e([f({type:o.ofType(X),json:{write:!0}})],oe.prototype,"transportationNetworks",void 0),e([f({type:Q,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],oe.prototype,"presentation",void 0),e([f({type:z,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new z({viewingMode:"global",spatialReference:R.WebMercator})}})],oe.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],oe.prototype,"readInitialViewProperties",null),e([f({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],oe.prototype,"spatialReference",null),e([f({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],oe.prototype,"viewingMode",null),e([f({type:M})],oe.prototype,"portalItem",void 0),e([f()],oe.prototype,"resourceInfo",void 0),oe=e([v("esri.WebScene")],oe);const se=oe;export{se as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{replace as e}from"../core/string.js";import{IANAZone as t,DateTime as n,Zone as r,FixedOffsetZone as s}from"luxon";class i{}var o;i.instance=new t("Etc/UTC"),function(e){e.TimeZoneNotRecognized="TimeZoneNotRecognized"}(o||(o={}));const a={[o.TimeZoneNotRecognized]:"Timezone identifier has not been recognized."};class d extends Error{constructor(t,n){super(e(a[t],n)),this.declaredRootClass="esri.arcade.arcadedate.dateerror",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function u(e,t,n){return e<t?e-t:e>n?e-n:0}function c(e,t,n){return e<t?t:e>n?n:e}class m{constructor(e){this._date=e,this.declaredRootClass="esri.arcade.arcadedate"}static fromParts(e=0,t=1,r=1,s=0,i=0,o=0,a=0,d){if(isNaN(e)||isNaN(t)||isNaN(r)||isNaN(s)||isNaN(i)||isNaN(o)||isNaN(a))return null;const l=n.local(e,t).daysInMonth;let f=n.fromObject({day:c(r,1,l),year:e,month:c(t,1,12),hour:c(s,0,23),minute:c(i,0,59),second:c(o,0,59),millisecond:c(a,0,999)},{zone:h(d)});return f=f.plus({months:u(t,1,12),days:u(r,1,l),hours:u(s,0,23),minutes:u(i,0,59),seconds:u(o,0,59),milliseconds:u(a,0,999)}),new m(f)}static get systemTimeZoneCanonicalName(){return Intl.DateTimeFormat().resolvedOptions().timeZone??"system"}static arcadeDateAndZoneToArcadeDate(e,t){const n=h(t);return e.isUnknownTimeZone||n===i.instance?m.fromParts(e.year,e.monthJS+1,e.day,e.hour,e.minute,e.second,e.millisecond,n):new m(e._date.setZone(n))}static dateJSToArcadeDate(e){return new m(n.fromJSDate(e,{zone:"system"}))}static dateJSAndZoneToArcadeDate(e,t="system"){return new m(n.fromJSDate(e,{zone:t}))}static unknownEpochToArcadeDate(e){return new m(n.fromMillis(e,{zone:i.instance}))}static unknownDateJSToArcadeDate(e){return new m(n.fromMillis(e.getTime(),{zone:i.instance}))}static epochToArcadeDate(e,t="system"){return new m(n.fromMillis(e,{zone:t}))}static dateTimeToArcadeDate(e){return new m(e)}clone(){return new m(this._date)}changeTimeZone(e){const t=h(e);return m.dateTimeToArcadeDate(this._date.setZone(t))}static dateTimeAndZoneToArcadeDate(e,t){const n=h(t);return e.zone===i.instance||n===i.instance?m.fromParts(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond,n):new m(e.setZone(n))}static nowToArcadeDate(e){return new m(n.fromJSDate(new Date,{zone:e}))}static nowUTCToArcadeDate(){return new m(n.utc())}get isSystem(){return"system"===this.timeZone||this.timeZone===m.systemTimeZoneCanonicalName}equals(e){return this.isSystem&&e.isSystem?this.toNumber()===e.toNumber():this.isUnknownTimeZone===e.isUnknownTimeZone&&this._date.equals(e._date)}get isUnknownTimeZone(){return this._date.zone===i.instance}get isValid(){return this._date.isValid}get hour(){return this._date.hour}get second(){return this._date.second}get day(){return this._date.day}get dayOfWeekISO(){return this._date.weekday}get dayOfWeekJS(){let e=this._date.weekday;return e>6&&(e=0),e}get millisecond(){return this._date.millisecond}get monthISO(){return this._date.month}get weekISO(){return this._date.weekNumber}get yearISO(){return this._date.weekYear}get monthJS(){return this._date.month-1}get year(){return this._date.year}get minute(){return this._date.minute}get zone(){return this._date.zone}get timeZoneOffset(){return this.isUnknownTimeZone?0:this._date.offset}get timeZone(){if(this.isUnknownTimeZone)return"unknown";if("system"===this._date.zone.type)return"system";const e=this.zone;return"fixed"===e.type?0===e.fixed?"UTC":e.formatOffset(0,"short"):e.name}stringify(){return JSON.stringify(this.toJSDate())}plus(e){return new m(this._date.plus(e))}diff(e,t="milliseconds"){return this._date.diff(e._date,t)[t]}toISOString(e){return e?this._date.toISO({suppressMilliseconds:!0,includeOffset:!this.isUnknownTimeZone}):this._date.toISO({includeOffset:!this.isUnknownTimeZone})}toFormat(e,t){return this.isUnknownTimeZone&&(e=e.replaceAll("Z","")),this._date.toFormat(e,t)}toJSDate(){return this._date.toJSDate()}toSQLValue(){return this._date.toFormat("yyyy-LL-dd HH:mm:ss")}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}toDateTime(){return this._date}toNumber(){return this._date.toMillis()}getTime(){return this._date.toMillis()}toUTC(){return new m(this._date.toUTC())}toLocal(){return new m(this._date.toLocal())}toString(){return this.toISOString(!0)}static fromReaderAsTimeStampOffset(e){if(!e)return null;const t=n.fromISO(e,{setZone:!0});return new m(t)}}function h(e,n=!0){if(e instanceof r)return e;if("system"===e.toLowerCase())return"system";if("utc"===e.toLowerCase())return"UTC";if("unknown"===e.toLowerCase())return i.instance;if(/^[\+\-]?[0-9]{1,2}([:][0-9]{2})?$/.test(e)){const t=s.parseSpecifier("UTC"+(e.startsWith("+")||e.startsWith("-")?"":"+")+e);if(t)return t}const a=t.create(e);if(!a.isValid){if(n)throw new d(o.TimeZoneNotRecognized);return null}return a}export{m as ArcadeDate,d as ArcadeDateError,o as ArcadeDateErrorCodes,a as ArcadeDateErrorMessages,i as UnknownTimeZone,h as createDateTimeZone};
5
+ import{replace as e}from"../core/string.js";import{IANAZone as t,DateTime as n,Zone as r,FixedOffsetZone as s}from"luxon";class i{}var o;i.instance=new t("Etc/UTC"),function(e){e.TimeZoneNotRecognized="TimeZoneNotRecognized"}(o||(o={}));const a={[o.TimeZoneNotRecognized]:"Timezone identifier has not been recognized."};class d extends Error{constructor(t,n){super(e(a[t],n)),this.declaredRootClass="esri.arcade.arcadedate.dateerror",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function c(e,t,n){return e<t?e-t:e>n?e-n:0}function u(e,t,n){return e<t?t:e>n?n:e}class m{constructor(e){this._date=e,this.declaredRootClass="esri.arcade.arcadedate"}static fromParts(e=0,t=1,r=1,s=0,i=0,o=0,a=0,d){if(isNaN(e)||isNaN(t)||isNaN(r)||isNaN(s)||isNaN(i)||isNaN(o)||isNaN(a))return null;const l=n.local(e,t).daysInMonth;let f=n.fromObject({day:u(r,1,l),year:e,month:u(t,1,12),hour:u(s,0,23),minute:u(i,0,59),second:u(o,0,59),millisecond:u(a,0,999)},{zone:h(d)});return f=f.plus({months:c(t,1,12),days:c(r,1,l),hours:c(s,0,23),minutes:c(i,0,59),seconds:c(o,0,59),milliseconds:c(a,0,999)}),new m(f)}static get systemTimeZoneCanonicalName(){return Intl.DateTimeFormat().resolvedOptions().timeZone??"system"}static arcadeDateAndZoneToArcadeDate(e,t){const n=h(t);return e.isUnknownTimeZone||n===i.instance?m.fromParts(e.year,e.monthJS+1,e.day,e.hour,e.minute,e.second,e.millisecond,n):new m(e._date.setZone(n))}static dateJSToArcadeDate(e){return new m(n.fromJSDate(e,{zone:"system"}))}static dateJSAndZoneToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromJSDate(e,{zone:r}))}static unknownEpochToArcadeDate(e){return new m(n.fromMillis(e,{zone:i.instance}))}static unknownDateJSToArcadeDate(e){return new m(n.fromMillis(e.getTime(),{zone:i.instance}))}static epochToArcadeDate(e,t="system"){const r=h(t);return new m(n.fromMillis(e,{zone:r}))}static dateTimeToArcadeDate(e){return new m(e)}clone(){return new m(this._date)}changeTimeZone(e){const t=h(e);return m.dateTimeToArcadeDate(this._date.setZone(t))}static dateTimeAndZoneToArcadeDate(e,t){const n=h(t);return e.zone===i.instance||n===i.instance?m.fromParts(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond,n):new m(e.setZone(n))}static nowToArcadeDate(e){const t=h(e);return new m(n.fromJSDate(new Date,{zone:t}))}static nowUTCToArcadeDate(){return new m(n.utc())}get isSystem(){return"system"===this.timeZone||this.timeZone===m.systemTimeZoneCanonicalName}equals(e){return this.isSystem&&e.isSystem?this.toNumber()===e.toNumber():this.isUnknownTimeZone===e.isUnknownTimeZone&&this._date.equals(e._date)}get isUnknownTimeZone(){return this._date.zone===i.instance}get isValid(){return this._date.isValid}get hour(){return this._date.hour}get second(){return this._date.second}get day(){return this._date.day}get dayOfWeekISO(){return this._date.weekday}get dayOfWeekJS(){let e=this._date.weekday;return e>6&&(e=0),e}get millisecond(){return this._date.millisecond}get monthISO(){return this._date.month}get weekISO(){return this._date.weekNumber}get yearISO(){return this._date.weekYear}get monthJS(){return this._date.month-1}get year(){return this._date.year}get minute(){return this._date.minute}get zone(){return this._date.zone}get timeZoneOffset(){return this.isUnknownTimeZone?0:this._date.offset}get timeZone(){if(this.isUnknownTimeZone)return"unknown";if("system"===this._date.zone.type)return"system";const e=this.zone;return"fixed"===e.type?0===e.fixed?"UTC":e.formatOffset(0,"short"):e.name}stringify(){return JSON.stringify(this.toJSDate())}plus(e){return new m(this._date.plus(e))}diff(e,t="milliseconds"){return this._date.diff(e._date,t)[t]}toISOString(e){return e?this._date.toISO({suppressMilliseconds:!0,includeOffset:!this.isUnknownTimeZone}):this._date.toISO({includeOffset:!this.isUnknownTimeZone})}toFormat(e,t){return this.isUnknownTimeZone&&(e=e.replaceAll("Z","")),this._date.toFormat(e,t)}toJSDate(){return this._date.toJSDate()}toSQLValue(){return this._date.toFormat("yyyy-LL-dd HH:mm:ss")}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}toDateTime(){return this._date}toNumber(){return this._date.toMillis()}getTime(){return this._date.toMillis()}toUTC(){return new m(this._date.toUTC())}toLocal(){return new m(this._date.toLocal())}toString(){return this.toISOString(!0)}static fromReaderAsTimeStampOffset(e){if(!e)return null;const t=n.fromISO(e,{setZone:!0});return new m(t)}}function h(e,n=!0){if(e instanceof r)return e;if("system"===e.toLowerCase())return"system";if("utc"===e.toLowerCase())return"UTC";if("unknown"===e.toLowerCase())return i.instance;if(/^[\+\-]?[0-9]{1,2}([:][0-9]{2})?$/.test(e)){const t=s.parseSpecifier("UTC"+(e.startsWith("+")||e.startsWith("-")?"":"+")+e);if(t)return t}const a=t.create(e);if(!a.isValid){if(n)throw new d(o.TimeZoneNotRecognized);return null}return a}export{m as ArcadeDate,d as ArcadeDateError,o as ArcadeDateErrorCodes,a as ArcadeDateErrorMessages,i as UnknownTimeZone,h as createDateTimeZone};
package/arcade/Feature.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"./ArcadeDate.js";import{DateTimeReferenceFieldIndex as t}from"./arcadeTimeUtils.js";import{configureDeepClone as i}from"./deepClone.js";import s from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as n}from"./executionError.js";import a from"./ImmutableArray.js";import{a as o,b as l,c as f,t as u,n as d,m as c,k as m,f as y,d as h}from"../chunks/languageUtils.js";import{DateOnly as p}from"../core/sql/DateOnly.js";import{TimeOnly as _}from"../core/sql/TimeOnly.js";import T from"../geometry/Geometry.js";import b from"../geometry/Point.js";import{fromJSON as g}from"../geometry/support/jsonUtils.js";import{convertToGeometry as F}from"../layers/graphics/featureConversionUtils.js";class x{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.dateTimeReferenceFieldIndex=null,this.contextTimeReference=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,i){const s=new x;return s.contextTimeReference=i??null,s._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?s.attributes={}:s.attributes=e.attributes,e._sourceLayer?(s._layer=e._sourceLayer,s._fieldTypesFixed=!1):e._layer?(s._layer=e._layer,s._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(s._layer=e.layer,s._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(s._layer=e.sourceLayer,s._fieldTypesFixed=!1),s._layer&&!s._fieldTypesFixed&&(void 0!==s._layer.dateTimeReferenceFieldIndex?s.dateTimeReferenceFieldIndex=s._layer.dateTimeReferenceFieldIndex:s.dateTimeReferenceFieldIndex=t.createFromLayer(s._layer)),s}static createFromArcadeFeature(e){if(e instanceof x){const t=new x;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.dateTimeReferenceFieldIndex=e.dateTimeReferenceFieldIndex,t.contextTimeReference=e.contextTimeReference,t}const t={};for(const i of e.keys())t[i]=e.field(i);return x.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeReference)}static createFromOptimisedFeature(e,t,i){const s=new x;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e){const t=new x;return t.attributes=e.field("attributes"),null!==t.attributes&&t.attributes instanceof s?(t.attributes=t.attributes.attributes,null===t.attributes&&(t.attributes={})):t.attributes={},t._geometry=e.field("geometry"),null!==t._geometry&&(t._geometry instanceof s?t._geometry=x.parseGeometryFromDictionary(t._geometry):t._geometry instanceof T||(t._geometry=null)),t}static createFromGraphicLikeObject(e,i,s=null,r){const n=new x;return n.contextTimeReference=r??null,null===i&&(i={}),n.attributes=i,n._geometry=null!=e?e:null,n._layer=s,n._layer&&(n._fieldTypesFixed=!1,void 0!==n._layer.dateTimeReferenceFieldIndex?n.dateTimeReferenceFieldIndex=n._layer.dateTimeReferenceFieldIndex:n.dateTimeReferenceFieldIndex=t.createFromLayer(n._layer)),n}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}get layerPreferredTimeZone(){return this.dateTimeReferenceFieldIndex?.layerPreferredTimeZone??""}fieldSourceTimeZone(e){return this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)??""}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":o(r)||l(r)||f(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof T?i+=JSON.stringify(s)+":"+u(r):r instanceof _||r instanceof p?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof a||r instanceof Array?i+=JSON.stringify(s)+":"+u(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":u(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeReference?.timeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let a=this.attributes[r];if(void 0===a){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(a=this.attributes[t],null!==a){if("time-only"===n){d(a)||(this.attributes[t]=_.fromReader(a.toString()));break}if("date-only"===n){c(a)||(this.attributes[t]=p.fromReader(a.toString()));break}if("timestamp-offset"===n){m(a)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(a.toString()));break}const s=this.isUnknownDateTimeField(t);a instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):m(a)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i))}break}}else if(null!==a){if("time-only"===n){d(a)?this.attributes[r]=a:this.attributes[r]=_.fromReader(a.toString());continue}if("date-only"===n){c(a)?this.attributes[r]=a:this.attributes[r]=p.fromReader(a.toString());continue}if("timestamp-offset"===n){m(a)?this.attributes[r]=a:this.attributes[r]=e.fromReaderAsTimeStampOffset(a.toString());continue}const t=this.isUnknownDateTimeField(r);m(a)?this.attributes[r]=a:a instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i)}}}geometry(){return null===this._geometry||this._geometry instanceof T||(this._optimizedGeomDefinition?(this._geometry=g(F(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=g(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new r(null,n.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new r(null,n.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===y(i))throw new r(null,n.TypeNotAllowedInFeature,null);const s=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===s)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e){const t=x._convertDictionaryToJson(e,!0);return void 0!==t.hasm&&(t.hasM=t.hasm,delete t.hasm),void 0!==t.hasz&&(t.hasZ=t.hasz,delete t.hasz),void 0!==t.spatialreference&&(t.spatialReference=t.spatialreference,delete t.spatialreference),void 0!==t.rings&&(t.rings=this._fixPathArrays(t.rings,!0===t.hasZ,!0===t.hasZ)),void 0!==t.paths&&(t.paths=this._fixPathArrays(t.paths,!0===t.hasZ,!0===t.hasM)),void 0!==t.points&&(t.points=this._fixPointArrays(t.points,!0===t.hasZ,!0===t.hasM)),g(t)}static _fixPathArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof a)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++){const n=e[r];n instanceof b?t&&i?s.push([n.x,n.y,n.z,n.m]):t?s.push([n.x,n.y,n.z]):i?s.push([n.x,n.y,n.m]):s.push([n.x,n.y]):n instanceof a?s.push(n.toArray()):s.push(n)}else if(e instanceof a)for(let r=0;r<e.length();r++){const n=e.get(r);n instanceof b?t&&i?s.push([n.x,n.y,n.z,n.m]):t?s.push([n.x,n.y,n.z]):i?s.push([n.x,n.y,n.m]):s.push([n.x,n.y]):n instanceof a?s.push(n.toArray()):s.push(n)}return s}static _convertDictionaryToJson(e,t=!1){const i={};for(const r in e.attributes){let n=e.attributes[r];n instanceof s&&(n=x._convertDictionaryToJson(n)),t?i[r.toLowerCase()]=n:i[r]=n}return i}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const s=e.attributes[i];if(!y(s))throw new r(null,n.InvalidParameter,null);t[i]=s}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=g(e.geometry));const s={};if(null!==e.attributes&&void 0!==e.attributes)for(const a in e.attributes){const t=e.attributes[a];if(null===t)s[a]=t;else{if(!(f(t)||l(t)||o(t)||m(t)||d(t)||c(t)))throw new r(null,n.InvalidParameter,null);s[a]=t}}return x.createFromGraphicLikeObject(i,s,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities&&this._layer.capabilities.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=h(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}i(x);export{x as default};
5
+ import{ArcadeDate as e}from"./ArcadeDate.js";import{DateTimeReferenceFieldIndex as t}from"./arcadeTimeUtils.js";import{configureDeepClone as i}from"./deepClone.js";import s from"./Dictionary.js";import{ArcadeExecutionError as r,ExecutionErrorCodes as n}from"./executionError.js";import a from"./ImmutableArray.js";import{a as o,b as l,c as f,t as u,n as d,m as c,k as m,f as y,d as h}from"../chunks/languageUtils.js";import{DateOnly as p}from"../core/sql/DateOnly.js";import{TimeOnly as _}from"../core/sql/TimeOnly.js";import T from"../geometry/Geometry.js";import b from"../geometry/Point.js";import{fromJSON as g}from"../geometry/support/jsonUtils.js";import{convertToGeometry as F}from"../layers/graphics/featureConversionUtils.js";class x{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._fieldTypesFixed=!0,this.dateTimeReferenceFieldIndex=null,this.contextTimeReference=null,this.immutable=!0,this._fieldsToFixDataTypes=null,this.immutable=!0}static createFromGraphic(e,i){const s=new x;return s.contextTimeReference=i??null,s._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?s.attributes={}:s.attributes=e.attributes,e._sourceLayer?(s._layer=e._sourceLayer,s._fieldTypesFixed=!1):e._layer?(s._layer=e._layer,s._fieldTypesFixed=!1):e.layer&&"fields"in e.layer?(s._layer=e.layer,s._fieldTypesFixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(s._layer=e.sourceLayer,s._fieldTypesFixed=!1),s._layer&&!s._fieldTypesFixed&&(void 0!==s._layer.dateTimeReferenceFieldIndex?s.dateTimeReferenceFieldIndex=s._layer.dateTimeReferenceFieldIndex:s.dateTimeReferenceFieldIndex=t.createFromLayer(s._layer)),s}static createFromArcadeFeature(e){if(e instanceof x){const t=new x;return t._fieldTypesFixed=e._fieldTypesFixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.dateTimeReferenceFieldIndex=e.dateTimeReferenceFieldIndex,t.contextTimeReference=e.contextTimeReference,t}const t={};for(const i of e.keys())t[i]=e.field(i);return x.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeReference)}static createFromOptimisedFeature(e,t,i){const s=new x;return s._geometry=e.geometry?{geometry:e.geometry}:null,s._optimizedGeomDefinition=i,s.attributes=e.attributes||{},s._layer=t,s._fieldTypesFixed=!1,s}static createFromArcadeDictionary(e){const t=new x;return t.attributes=e.field("attributes"),null!==t.attributes&&t.attributes instanceof s?(t.attributes=t.attributes.attributes,null===t.attributes&&(t.attributes={})):t.attributes={},t._geometry=e.field("geometry"),null!==t._geometry&&(t._geometry instanceof s?t._geometry=x.parseGeometryFromDictionary(t._geometry):t._geometry instanceof T||(t._geometry=null)),t}static createFromGraphicLikeObject(e,i,s=null,r){const n=new x;return n.contextTimeReference=r??null,null===i&&(i={}),n.attributes=i,n._geometry=null!=e?e:null,n._layer=s,n._layer&&(n._fieldTypesFixed=!1,void 0!==n._layer.dateTimeReferenceFieldIndex?n.dateTimeReferenceFieldIndex=n._layer.dateTimeReferenceFieldIndex:n.dateTimeReferenceFieldIndex=t.createFromLayer(n._layer)),n}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._fieldTypesFixed=!1:this._fieldTypesFixed=!0}get layerPreferredTimeZone(){return this.dateTimeReferenceFieldIndex?.layerPreferredTimeZone??""}fieldSourceTimeZone(e){return this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)??""}castToText(t=!1){let i="";!1===this._fieldTypesFixed&&this._fixFieldTypes();for(const s in this.attributes){""!==i&&(i+=",");const r=this.attributes[s];null==r?i+=JSON.stringify(s)+":null":o(r)||l(r)||f(r)?i+=JSON.stringify(s)+":"+JSON.stringify(r):r instanceof T?i+=JSON.stringify(s)+":"+u(r):r instanceof _||r instanceof p?i+=`${JSON.stringify(s)}:${JSON.stringify(r.toString())}`:r instanceof a||r instanceof Array?i+=JSON.stringify(s)+":"+u(r,null,t):r instanceof e?i+=t?JSON.stringify(s)+":"+JSON.stringify(r.getTime()):JSON.stringify(s)+":"+r.stringify():null!==r&&"object"==typeof r&&void 0!==r.castToText&&(i+=JSON.stringify(s)+":"+r.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":u(this.geometry()))+',"attributes":{'+i+"}}"}_fixFieldTypes(){if(this._fieldsToFixDataTypes&&this._fieldsToFixDataTypes?.length>0)return this._fixAllFields(this._fieldsToFixDataTypes),void(this._fieldTypesFixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const s=t[i],{name:r,type:n}=s;switch(n){case"date":case"esriFieldTypeDate":e.push({field:r,dataType:"date"});break;case"date-only":case"esriFieldTypeDateOnly":e.push({field:r,dataType:"date-only"});break;case"time-only":case"esriFieldTypeTimeOnly":e.push({field:r,dataType:"time-only"});break;case"timestamp-offset":case"esriFieldTypeTimestampOffset":e.push({field:r,dataType:"timestamp-offset"})}}this._fieldsToFixDataTypes=e,e.length>0&&this._fixAllFields(e),this._fieldTypesFixed=!0}isUnknownDateTimeField(e){return"unknown"===this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)?.toLowerCase()}_fixAllFields(t){this.attributes={...this.attributes};const i=this.contextTimeReference?.timeZone??"system";for(let s=0;s<t.length;s++){const r=t[s].field,n=t[s].dataType;let a=this.attributes[r];if(void 0===a){for(const t in this.attributes)if(t.toLowerCase()===r.toLowerCase()){if(a=this.attributes[t],null!==a){if("time-only"===n){d(a)||(this.attributes[t]=_.fromReader(a.toString()));break}if("date-only"===n){c(a)||(this.attributes[t]=p.fromReader(a.toString()));break}if("timestamp-offset"===n){m(a)||(this.attributes[t]=e.fromReaderAsTimeStampOffset(a.toString()));break}const s=this.isUnknownDateTimeField(t);a instanceof Date?this.attributes[t]=s?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):m(a)||(this.attributes[t]=s?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i))}break}}else if(null!==a){if("time-only"===n){d(a)?this.attributes[r]=a:this.attributes[r]=_.fromReader(a.toString());continue}if("date-only"===n){c(a)?this.attributes[r]=a:this.attributes[r]=p.fromReader(a.toString());continue}if("timestamp-offset"===n){m(a)?this.attributes[r]=a:this.attributes[r]=e.fromReaderAsTimeStampOffset(a.toString());continue}const t=this.isUnknownDateTimeField(r);m(a)?this.attributes[r]=a:a instanceof Date?this.attributes[r]=t?e.unknownDateJSToArcadeDate(a):e.dateJSAndZoneToArcadeDate(a,i):this.attributes[r]=t?e.unknownEpochToArcadeDate(a):e.epochToArcadeDate(a,i)}}}geometry(){return null===this._geometry||this._geometry instanceof T||(this._optimizedGeomDefinition?(this._geometry=g(F(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=g(this._geometry)),this._geometry}field(e){this._fieldTypesFixed||this._fixFieldTypes();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const s in this.attributes)if(s.toLowerCase()===i)return this.attributes[s];if(this._hasFieldDefinition(i))return null;throw new r(null,n.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new r(null,n.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===y(i))throw new r(null,n.TypeNotAllowedInFeature,null);const s=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===s)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const s=this._layer.fields[i];1!==t[s.name.toLowerCase()]&&e.push(s.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e){const t=x._convertDictionaryToJson(e,!0);return void 0!==t.hasm&&(t.hasM=t.hasm,delete t.hasm),void 0!==t.hasz&&(t.hasZ=t.hasz,delete t.hasz),void 0!==t.spatialreference&&(t.spatialReference=t.spatialreference,delete t.spatialreference),void 0!==t.rings&&(t.rings=this._fixPathArrays(t.rings,!0===t.hasZ,!0===t.hasZ)),void 0!==t.paths&&(t.paths=this._fixPathArrays(t.paths,!0===t.hasZ,!0===t.hasM)),void 0!==t.points&&(t.points=this._fixPointArrays(t.points,!0===t.hasZ,!0===t.hasM)),g(t)}static _fixPathArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++)s.push(this._fixPointArrays(e[r],t,i));else if(e instanceof a)for(let r=0;r<e.length();r++)s.push(this._fixPointArrays(e.get(r),t,i));return s}static _fixPointArrays(e,t,i){const s=[];if(e instanceof Array)for(let r=0;r<e.length;r++){const n=e[r];n instanceof b?t&&i?s.push([n.x,n.y,n.z,n.m]):t?s.push([n.x,n.y,n.z]):i?s.push([n.x,n.y,n.m]):s.push([n.x,n.y]):n instanceof a?s.push(n.toArray()):s.push(n)}else if(e instanceof a)for(let r=0;r<e.length();r++){const n=e.get(r);n instanceof b?t&&i?s.push([n.x,n.y,n.z,n.m]):t?s.push([n.x,n.y,n.z]):i?s.push([n.x,n.y,n.m]):s.push([n.x,n.y]):n instanceof a?s.push(n.toArray()):s.push(n)}return s}static _convertDictionaryToJson(e,t=!1){const i={};for(const r in e.attributes){let n=e.attributes[r];n instanceof s&&(n=x._convertDictionaryToJson(n)),t?i[r.toLowerCase()]=n:i[r]=n}return i}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const s=e.attributes[i];if(!y(s))throw new r(null,n.InvalidParameter,null);t[i]=s}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=g(e.geometry));const s={};if(null!==e.attributes&&void 0!==e.attributes)for(const a in e.attributes){const t=e.attributes[a];if(null===t)s[a]=t;else{if(!(f(t)||l(t)||o(t)||m(t)||d(t)||c(t)))throw new r(null,n.InvalidParameter,null);s[a]=t}}return x.createFromGraphicLikeObject(i,s,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities&&this._layer.capabilities.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const s=this.attributes[i];void 0!==s&&(t.attributes[i]=h(s,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}i(x);export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import t from"./featureSetCollection.js";import{$ as a,a0 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import i from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import l from"./featureset/actions/SpatialFilter.js";import o from"./featureset/actions/Top.js";import u from"./featureset/sources/FeatureLayerDynamic.js";import c from"./featureset/sources/FeatureLayerMemory.js";import d from"./featureset/sources/FeatureLayerRelated.js";import f from"./featureset/support/cache.js";import{FeatureSetError as p,FeatureSetErrorCodes as m}from"./featureset/support/errorsupport.js";import y from"./featureset/support/FeatureSet.js";import{extractServiceUrl as h}from"./featureset/support/shared.js";import{WhereClause as _}from"../core/sql/WhereClause.js";import w from"../layers/FeatureLayer.js";import L from"../portal/PortalItem.js";function S(){null===f.applicationCache&&(f.applicationCache=new f)}async function I(e,t){if(f.applicationCache){const r=f.applicationCache.getLayerInfo(e);if(r){const a=await r;return new w({url:e,outFields:t,sourceJSON:a})}const n=new w({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(f.applicationCache){f.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw f.applicationCache.clearLayerInfo(e),a}}return await i,n}return new w({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,r=null,n=!0,i=null,s=null){if(e instanceof w||a(e)){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:i,interceptor:s};return!0==!(e.url||!e.source)?new c(a):new u(a)}const l=g(e.parent,t,r,n,i,s);return l.filter(_.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex,{timeZone:l.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC}))}async function A(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function N(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new p(m.DataElementsNotFound)})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw f.applicationCache.clearLayerInfo(r),i}}return n}async function T(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function C(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await T(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await N(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await A(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(_.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",i.getFieldsIndex(),{timeZone:i.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC})),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await F(o,r,n,i,s,l);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}n.registerAction(),i.registerAction(),s.registerAction(),l.registerAction(),o.registerAction();class D extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.title===e)return!0}else if(a(t)){if(t.title===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e=a.outFields?a:{...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.title===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}async featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.id===e)return!0}else if(a(t)){if(t.id===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>t.id===e));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e={...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.id===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}}class b extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await T(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new b(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function O(e,t,a=null,r=null){return new D(e,t,a,r)}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function j(e,t,n,i,s){if(null===e)return null;if(e instanceof w){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(a(e)){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(r(e)){switch(t){case"datasource":return g(e.parent,s,e.parent.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.parent.outFields,!0,n,i)}return null}if(e instanceof y)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(f.applicationCache){const o=f.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new w({url:h(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();f.applicationCache&&f.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new w({url:h(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw f.applicationCache&&f.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{C as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,j as convertToFeatureSet,O as createFeatureSetCollectionFromMap,E as createFeatureSetCollectionFromService,S as initialiseMetaDataCache};
5
+ import e from"../request.js";import t from"./featureSetCollection.js";import{$ as a,a0 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import i from"./featureset/actions/GroupBy.js";import s from"./featureset/actions/OrderBy.js";import l from"./featureset/actions/SpatialFilter.js";import o from"./featureset/actions/Top.js";import u from"./featureset/sources/FeatureLayerDynamic.js";import c from"./featureset/sources/FeatureLayerMemory.js";import d from"./featureset/sources/FeatureLayerRelated.js";import f from"./featureset/support/cache.js";import{FeatureSetError as p,FeatureSetErrorCodes as m}from"./featureset/support/errorsupport.js";import y from"./featureset/support/FeatureSet.js";import{extractServiceUrl as h}from"./featureset/support/shared.js";import{WhereClause as _}from"../core/sql/WhereClause.js";import w from"../layers/FeatureLayer.js";import L from"../portal/PortalItem.js";function S(){null===f.applicationCache&&(f.applicationCache=new f)}async function I(e,t){if(f.applicationCache){const r=f.applicationCache.getLayerInfo(e);if(r){const a=await r;return new w({url:e,outFields:t,sourceJSON:a})}const n=new w({url:e,outFields:t}),i=(async()=>(await n.load(),n.sourceJSON))();if(f.applicationCache){f.applicationCache.setLayerInfo(e,i);try{return await i,n}catch(a){throw f.applicationCache.clearLayerInfo(e),a}}return await i,n}return new w({url:e,outFields:t})}async function F(e,t,a,r,n,i=null){return g(await I(e,["*"]),t,a,r,n,i)}function g(e,t=null,r=null,n=!0,i=null,s=null){if(e instanceof w||a(e)){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:n,lrucache:i,interceptor:s};return!0==!(e.url||!e.source)?new c(a):new u(a)}const l=g(e.parent,t,r,n,i,s);return l.filter(_.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),e.parent?.fieldsIndex,l.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC))}async function A(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});return a.data?a.data:null})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function N(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(r);if(null!==e)return e}const n=(async()=>{const r=await e(t+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([a.toString()]),f:"json"}});if(r.data){const e=r.data;if(e.layerDataElements&&e.layerDataElements[0])return e.layerDataElements[0]}throw new p(m.DataElementsNotFound)})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(r,n);try{return await n}catch(i){throw f.applicationCache.clearLayerInfo(r),i}}return n}async function T(t){if(null!==f.applicationCache){const e=f.applicationCache.getLayerInfo(t);if(null!==e)return e}const a=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"}});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==f.applicationCache){f.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw f.applicationCache.clearLayerInfo(t),r}}return a}async function C(e,t){const a={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null},r=await T(e);if(a.metadata=r,r.controllerDatasetLayers&&void 0!==r.controllerDatasetLayers.utilityNetworkLayerId&&null!==r.controllerDatasetLayers.utilityNetworkLayerId){if(r.layers)for(const e of r.layers)a.layerNameLkp[e.id]=e.name;if(r.tables)for(const e of r.tables)a.layerNameLkp[e.id]=e.name;const n=r.controllerDatasetLayers.utilityNetworkLayerId;a.networkId=n;const i=await N(e,n);if(i){a.queryelem=i,a.queryelem&&a.queryelem.dataElement&&void 0!==a.queryelem.dataElement.schemaGeneration&&(a.unVersion=a.queryelem.dataElement.schemaGeneration),a.lkp={},a.queryelem.dataElement.domainNetworks||(a.queryelem.dataElement.domainNetworks=[]);for(const e of a.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:a.layerNameLkp[t.layerId]??null};e.className&&(a.lkp[e.className]=e)}}if(a.queryelem.dataElement.terminalConfigurations)for(const e of a.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)a.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const r=await A(e+"/"+n);if(r.systemLayers&&void 0!==r.systemLayers.associationsTableId&&null!==r.systemLayers.associationsTableId){const n=[];a.unVersion>=4&&(n.push("STATUS"),n.push("PERCENTALONG"));let i=await F(e+"/"+r.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...n],!1,null,null);return await i.load(),a.unVersion>=4&&(i=i.filter(_.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",i.getFieldsIndex(),i.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC)),await i.load()),{lkp:a.lkp,associations:i,unVersion:a.unVersion,terminals:a.terminals}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}return{associations:null,unVersion:a.unVersion,lkp:null,terminals:[]}}async function k(e,t,a,r=null,n=null,i=!0,s=null,l=null){let o=e.serviceUrl();if(!o)return null;o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString();const u=await F(o,r,n,i,s,l);return new d({layer:e,relatedLayer:u,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:i,lrucache:s,interceptor:l})}n.registerAction(),i.registerAction(),s.registerAction(),l.registerAction(),o.registerAction();class D extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.title===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.title===e)return!0}else if(a(t)){if(t.title===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e=a.outFields?a:{...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.title===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}async featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return await this._map.load(),this.featureSetById(e,t,r);null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const n=JSON.stringify(r);for(let a=0;a<this._instantLayers.length;a++){const r=this._instantLayers[a];if(r.opitem.id===e&&r.includeGeometry===t&&r.outFields===n)return this._instantLayers[a].featureset}const i=[],s=this._map.allLayers.find((t=>{if(t instanceof w){if(t.id===e)return!0}else if(a(t)){if(t.id===e)return!0;i.push(t)}return!1}));if(s)return this._makeAndAddFeatureSet(s,t,r);if(this._map.tables){const a=this._map.tables.find((t=>t.id===e));if(a){if(a instanceof w)return this._makeAndAddFeatureSet(a,t,r);if(a._materializedTable);else{const e={...a,outFields:["*"]};a._materializedTable=new w(e)}return await a._materializedTable.load(),this._makeAndAddFeatureSet(a._materializedTable,t,r)}}for(const a of i){if("not-loaded"===a.loadStatus||"loading"===a.loadStatus)try{await a.load()}catch(l){}const n=a.sublayers.find((t=>t.id===e));if(n)return this._makeAndAddFeatureSet(n,t,r)}return null}}class b extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overridespref=t,this._lrucache=a,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,a=null){const r=g(e,this._overridespref,null===a?["*"]:a,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(a)}),r}async _loadMetaData(){const e=await T(this._url);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new b(this._url,this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])s.name===e&&(i=s);if(!i)for(const s of n.tables??[])s.name===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice(0)).sort();const r=JSON.stringify(a);e=null!=e?e.toString():"";for(let s=0;s<this._instantLayers.length;s++){const a=this._instantLayers[s];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[s].featureset}const n=await this._loadMetaData();let i=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(!i)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(i=s);if(i){const e=await I(this._url+"/"+i.id,["*"]);return this._makeAndAddFeatureSet(e,t,a)}return null}}function O(e,t,a=null,r=null){return new D(e,t,a,r)}function E(e,t,a=null,r=null){return new b(e,t,a,r)}function j(e,t,n,i,s){if(null===e)return null;if(e instanceof w){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(a(e)){switch(t){case"datasource":return g(e,s,e.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.outFields,!0,n,i)}return null}if(r(e)){switch(t){case"datasource":return g(e.parent,s,e.parent.outFields,!0,n,i).getDataSourceFeatureSet();case"parent":case"root":return g(e,s,e.parent.outFields,!0,n,i)}return null}if(e instanceof y)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}async function q(e,t,a,r,n,i,s,l=null){if(f.applicationCache){const o=f.applicationCache.getLayerInfo(e+":"+i.url);if(o){const e=await o;return g(new w({url:h(e.url)+"/"+t,outFields:["*"]}),a,r,n,s,l)}}const o=new L({id:e,portal:i}).load();f.applicationCache&&f.applicationCache.setLayerInfo(e+":"+i.url,o);try{const e=await o;return g(new w({url:h(e.url??"")+"/"+t,outFields:["*"]}),a,r,n,s,l)}catch(u){throw f.applicationCache&&f.applicationCache.clearLayerInfo(e+":"+i.url),u}}export{C as constructAssociationMetaDataFeatureSetFromUrl,g as constructFeatureSet,q as constructFeatureSetFromPortalItem,k as constructFeatureSetFromRelationship,F as constructFeatureSetFromUrl,j as convertToFeatureSet,O as createFeatureSetCollectionFromMap,E as createFeatureSetCollectionFromService,S as initialiseMetaDataCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{ArcadeDate as t}from"../../ArcadeDate.js";import{cloneGeometry as r}from"../../kernel.js";import{SqlError as s,SqlErrorCodes as a,FeatureSetError as i,FeatureSetErrorCodes as l}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{cloneField as h,FeatureServiceDatabaseType as u,layerGeometryEsriConstants as c}from"../support/shared.js";import{reformulateWithoutField as d,toWhereClause as p,translateFunctionToDatabaseSpecific as f,makeToday as g,makeDateString as N,arcadeDateToSqlString as _,convertIntervalToSql as S,combine as m,scanForField as w}from"../support/sqlUtils.js";import{assertIsSome as v}from"../../../core/maybe.js";import{WhereClause as C}from"../../../core/sql/WhereClause.js";import T from"../../../geometry/SpatialReference.js";class F{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class W extends F{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class A extends F{constructor(e,t,r){super(h(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:d(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class E extends F{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,u.Standardised,this.field.name,this.codefield instanceof C?p(this.codefield,u.Standardised):this.codefield,e.parameters);return r.includes(E.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:C.create(r,t._parent.getFieldsIndex(),{timeZone:t.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC})}}evaluateNodeToWhereClause(e,r,i=null,l=null,n){let o,h,u,c;switch(e.type){case"interval":return S(this.evaluateNodeToWhereClause(e.value,r,i,l,n),e.qualifier,e.op);case"case-expression":{let t=" CASE ";"simple"===e.format&&(t+=this.evaluateNodeToWhereClause(e.operand,r,i,E.BADNESS,n));for(let s=0;s<e.clauses.length;s++)t+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,r,i,E.BADNESS,n)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,r,i,E.BADNESS,n);return null!==e.else&&(t+=" ELSE "+this.evaluateNodeToWhereClause(e.else,r,i,E.BADNESS,n)),t+=" END ",t}case"parameter":{const s=n[e.value.toLowerCase()];if("string"==typeof s)return"'"+s.toString().replaceAll("'","''")+"'";if(s instanceof Date)return N(s,r,null);if(s instanceof t)return _(s,r,null);if(s instanceof Array){const e=[];for(let a=0;a<s.length;a++)"string"==typeof s[a]?e.push("'"+s[a].toString().replaceAll("'","''")+"'"):s[a]instanceof Date?e.push(N(s[a],r,null)):s[a]instanceof t?e.push(_(s[a],r,null)):e.push(s[a].toString());return e}return s.toString()}case"expression-list":h=[];for(const t of e.value)h.push(this.evaluateNodeToWhereClause(t,r,i,l,n));return h;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,r,i,E.BADNESS,n)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" AND "+this.evaluateNodeToWhereClause(e.right,r,i,l,n)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" OR "+this.evaluateNodeToWhereClause(e.right,r,i,l,n)+") ";case"IS":if("null"!==e.right.type)throw new s(a.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new s(a.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IS NOT NULL )";case"IN":if(o=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const t=[];let s=!0;for(const r of e.right.value){if("string"!==r.type){s=!1;break}if(void 0===this.lkp[r.value]){s=!1;break}t.push(this.lkp[r.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+t.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,r,i,l,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+o.join(",")+")) "}return c=this.evaluateNodeToWhereClause(e.right,r,i,l,n),c instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+c.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+c+")) ";case"NOT IN":if(o=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const t=[];let s=!0;for(const r of e.right.value){if("string"!==r.type){s=!1;break}if(void 0===this.lkp[r.value]){s=!1;break}t.push(this.lkp[r.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+t.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,r,i,l,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+o.join(",")+")) "}return c=this.evaluateNodeToWhereClause(e.right,r,i,l,n),c instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+c.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+c+")) ";case"BETWEEN":return u=this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" BETWEEN "+u[0]+" AND "+u[1]+" ) ";case"NOTBETWEEN":return u=this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT BETWEEN "+u[0]+" AND "+u[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+l+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+l+") ";return" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":case"date":return N(e.value,r,null);case"number":return e.value.toString();case"current-time":return g("date"===e.mode,r);case"column-reference":return i&&i.toLowerCase()===e.column.toLowerCase()?"("+l+")":e.column;case"data-type":return e.value;case"function":{const t=this.evaluateNodeToWhereClause(e.args,r,i,E.BADNESS,n);return f(e.name,t,r)}}throw new s(a.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof C?this.reverseLkp[C.convertValueToStorageFormat(this.codefield.calculateValueCompiled(e))]:this.reverseLkp[e.attributes[this.codefield]]}}E.BADNESS="_!!!_BAD_LKP_!!!!";class x extends F{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:d(e,this.field.name,p(this._sql,u.Standardised),t.getFieldsIndex())}}extractValue(e){return C.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class y extends n{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=[],this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new T({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=c.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await(this._parent?._getSet(e)),this._checkCancelled(e),v(t),this._wset=new o(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}async _getFeatures(t,s,a,i){const l=[];-1!==s&&void 0===this._featureCache[s]&&l.push(s);const n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(t,n))return await this._expandPagedSet(t,n,0,0,i),this._getFeatures(t,s,a,i);let h=0;for(let e=t._lastFetchedIndex;e<t._known.length&&(h++,h<=a&&(t._lastFetchedIndex+=1),!(void 0===this._featureCache[t._known[e]]&&(t._known[e]!==s&&l.push(t._known[e]),l.length>=n)));e++);if(0===l.length)return"success";t=new o([],l,t._ordered,null);const u=Math.min(l.length,a);await(this._parent?._getFeatures(t,-1,u,i)),this._checkCancelled(i);const c=[];for(let e=0;e<u;e++){const t=this._parent?._featureFromCache(l[e]);void 0!==t&&c.push({geometry:t.geometry,attributes:t.attributes,id:l[e]})}for(const o of c){const t=[];for(const e of this.adaptedFields)t[e.field.name]=e.extractValue(o);this._featureCache[o.id]=new e({attributes:t,geometry:r(o.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new i(l.NeverReach)}async _getFilteredSet(e,t,r,s,a){let i=!1;const l=this._reformulateWithoutAdaptions(r);i=l.cannot,r=l.where;let n=!1;if(null!==s){n=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof W)&&!0===s.scanForField(t.field.name)){if(!(t instanceof A)){s=null,n=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}s&&e.length>0&&(s=s.replaceFields(e))}null!==r?null!==this._extraFilter&&(r=m(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const h=await this._parent._getFilteredSet(e,t,r,s,a);let u;return this._checkCancelled(a),u=!0===i?new o(h._candidates.slice(0).concat(h._known.slice(0)),[],!0===n&&h._ordered,this._clonePageDefinition(h.pagesDefinition)):new o(h._candidates.slice(0),h._known.slice(0),!0===n&&h._ordered,this._clonePageDefinition(h.pagesDefinition)),u}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===w(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}async _stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);if(n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=m(this._extraFilter,a)):a=this._extraFilter,!0===n)return null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1};const h=await this._parent._stat(e,t,r,s,a,i,l);return!1===h.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:h}async _canDoAggregates(e,t,r,s,a){if(null===this._parent)return!1;for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof W))return!1;const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return!1;const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return!l.cannot&&(null!==(a=l.where)?null!==this._extraFilter&&(a=m(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}async _getAggregatePagesDataSourceDefinition(e,t,r,s,a,n,o){if(null===this._parent)throw new i(l.NeverReach);const h=[];for(let c=0;c<t.length;c++){const e=t[c];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)throw new i(l.NeverReach);const r=e.clone();r.workingexpr=t.where,h.push(r)}else h.push(e)}const u=this._reformulateWithoutAdaptions(a);if(u.cannot)throw new i(l.NeverReach);return null!==(a=u.where)?null!==this._extraFilter&&(a=m(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,a,n,o)}}export{y as AdaptedFeatureSet,F as AdaptedField,A as FieldRename,W as OriginalField,x as SqlExpressionAdapted,E as StringToCodeAdapted};
5
+ import e from"../../../Graphic.js";import{ArcadeDate as t}from"../../ArcadeDate.js";import{cloneGeometry as r}from"../../kernel.js";import{SqlError as s,SqlErrorCodes as a,FeatureSetError as i,FeatureSetErrorCodes as l}from"../support/errorsupport.js";import n from"../support/FeatureSet.js";import o from"../support/IdSet.js";import{cloneField as h,FeatureServiceDatabaseType as u,layerGeometryEsriConstants as c}from"../support/shared.js";import{reformulateWithoutField as d,toWhereClause as p,translateFunctionToDatabaseSpecific as f,makeToday as g,makeDateString as N,arcadeDateToSqlString as _,convertIntervalToSql as S,combine as w,scanForField as m}from"../support/sqlUtils.js";import{assertIsSome as v}from"../../../core/maybe.js";import{WhereClause as C}from"../../../core/sql/WhereClause.js";import T from"../../../geometry/SpatialReference.js";class F{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class W extends F{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class A extends F{constructor(e,t,r){super(h(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:d(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class E extends F{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const s in r)this.reverseLkp[r[s]]=s;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,u.Standardised,this.field.name,this.codefield instanceof C?p(this.codefield,u.Standardised):this.codefield,e.parameters);return r.includes(E.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:C.create(r,t._parent.getFieldsIndex(),t.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC)}}evaluateNodeToWhereClause(e,r,i=null,l=null,n){let o,h,u,c;switch(e.type){case"interval":return S(this.evaluateNodeToWhereClause(e.value,r,i,l,n),e.qualifier,e.op);case"case-expression":{let t=" CASE ";"simple"===e.format&&(t+=this.evaluateNodeToWhereClause(e.operand,r,i,E.BADNESS,n));for(let s=0;s<e.clauses.length;s++)t+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,r,i,E.BADNESS,n)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,r,i,E.BADNESS,n);return null!==e.else&&(t+=" ELSE "+this.evaluateNodeToWhereClause(e.else,r,i,E.BADNESS,n)),t+=" END ",t}case"parameter":{const s=n[e.value.toLowerCase()];if("string"==typeof s)return"'"+s.toString().replaceAll("'","''")+"'";if(s instanceof Date)return N(s,r,null);if(s instanceof t)return _(s,r,null);if(s instanceof Array){const e=[];for(let a=0;a<s.length;a++)"string"==typeof s[a]?e.push("'"+s[a].toString().replaceAll("'","''")+"'"):s[a]instanceof Date?e.push(N(s[a],r,null)):s[a]instanceof t?e.push(_(s[a],r,null)):e.push(s[a].toString());return e}return s.toString()}case"expression-list":h=[];for(const t of e.value)h.push(this.evaluateNodeToWhereClause(t,r,i,l,n));return h;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,r,i,E.BADNESS,n)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" AND "+this.evaluateNodeToWhereClause(e.right,r,i,l,n)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" OR "+this.evaluateNodeToWhereClause(e.right,r,i,l,n)+") ";case"IS":if("null"!==e.right.type)throw new s(a.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new s(a.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IS NOT NULL )";case"IN":if(o=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const t=[];let s=!0;for(const r of e.right.value){if("string"!==r.type){s=!1;break}if(void 0===this.lkp[r.value]){s=!1;break}t.push(this.lkp[r.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+t.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,r,i,l,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+o.join(",")+")) "}return c=this.evaluateNodeToWhereClause(e.right,r,i,l,n),c instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+c.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" IN ("+c+")) ";case"NOT IN":if(o=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const t=[];let s=!0;for(const r of e.right.value){if("string"!==r.type){s=!1;break}if(void 0===this.lkp[r.value]){s=!1;break}t.push(this.lkp[r.value].toString())}if(s)return" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+t.join(",")+")) "}return o=this.evaluateNodeToWhereClause(e.right,r,i,l,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+o.join(",")+")) "}return c=this.evaluateNodeToWhereClause(e.right,r,i,l,n),c instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+c.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,l,n)+" NOT IN ("+c+")) ";case"BETWEEN":return u=this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" BETWEEN "+u[0]+" AND "+u[1]+" ) ";case"NOTBETWEEN":return u=this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)," ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT BETWEEN "+u[0]+" AND "+u[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+l+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+l+") ";return" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,r,i,E.BADNESS,n)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,r,i,E.BADNESS,n)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":case"date":return N(e.value,r,null);case"number":return e.value.toString();case"current-time":return g("date"===e.mode,r);case"column-reference":return i&&i.toLowerCase()===e.column.toLowerCase()?"("+l+")":e.column;case"data-type":return e.value;case"function":{const t=this.evaluateNodeToWhereClause(e.args,r,i,E.BADNESS,n);return f(e.name,t,r)}}throw new s(a.UnsupportedSyntax,{node:e.type})}extractValue(e){return this.codefield instanceof C?this.reverseLkp[C.convertValueToStorageFormat(this.codefield.calculateValueCompiled(e))]:this.reverseLkp[e.attributes[this.codefield]]}}E.BADNESS="_!!!_BAD_LKP_!!!!";class x extends F{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:d(e,this.field.name,p(this._sql,u.Standardised),t.getFieldsIndex())}}extractValue(e){return C.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class y extends n{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=[],this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new T({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=c.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await(this._parent?._getSet(e)),this._checkCancelled(e),v(t),this._wset=new o(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}async _getFeatures(t,s,a,i){const l=[];-1!==s&&void 0===this._featureCache[s]&&l.push(s);const n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(t,n))return await this._expandPagedSet(t,n,0,0,i),this._getFeatures(t,s,a,i);let h=0;for(let e=t._lastFetchedIndex;e<t._known.length&&(h++,h<=a&&(t._lastFetchedIndex+=1),!(void 0===this._featureCache[t._known[e]]&&(t._known[e]!==s&&l.push(t._known[e]),l.length>=n)));e++);if(0===l.length)return"success";t=new o([],l,t._ordered,null);const u=Math.min(l.length,a);await(this._parent?._getFeatures(t,-1,u,i)),this._checkCancelled(i);const c=[];for(let e=0;e<u;e++){const t=this._parent?._featureFromCache(l[e]);void 0!==t&&c.push({geometry:t.geometry,attributes:t.attributes,id:l[e]})}for(const o of c){const t=[];for(const e of this.adaptedFields)t[e.field.name]=e.extractValue(o);this._featureCache[o.id]=new e({attributes:t,geometry:r(o.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new i(l.NeverReach)}async _getFilteredSet(e,t,r,s,a){let i=!1;const l=this._reformulateWithoutAdaptions(r);i=l.cannot,r=l.where;let n=!1;if(null!==s){n=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof W)&&!0===s.scanForField(t.field.name)){if(!(t instanceof A)){s=null,n=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}s&&e.length>0&&(s=s.replaceFields(e))}null!==r?null!==this._extraFilter&&(r=w(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const h=await this._parent._getFilteredSet(e,t,r,s,a);let u;return this._checkCancelled(a),u=!0===i?new o(h._candidates.slice(0).concat(h._known.slice(0)),[],!0===n&&h._ordered,this._clonePageDefinition(h.pagesDefinition)):new o(h._candidates.slice(0),h._known.slice(0),!0===n&&h._ordered,this._clonePageDefinition(h.pagesDefinition)),u}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===m(e,r.field.name)){const s=r.rewriteSql(e,this);if(!0!==s.rewritten){t.cannot=!0,t.where=null;break}t.where=s.where}return t}async _stat(e,t,r,s,a,i,l){let n=!1,o=this._reformulateWithoutAdaptions(t);if(n=o.cannot,t=o.where,o=this._reformulateWithoutAdaptions(a),n=n||o.cannot,null!==(a=o.where)?null!==this._extraFilter&&(a=w(this._extraFilter,a)):a=this._extraFilter,!0===n)return null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1};const h=await this._parent._stat(e,t,r,s,a,i,l);return!1===h.calculated?null===a&&""===r&&null===s?this._manualStat(e,t,i,l):{calculated:!1}:h}async _canDoAggregates(e,t,r,s,a){if(null===this._parent)return!1;for(let n=0;n<e.length;n++)for(const t of this.adaptedFields)if(e[n].toLowerCase()===t.field.name.toLowerCase()&&!(t instanceof W))return!1;const i=[];for(let n=0;n<t.length;n++){const e=t[n];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)return!1;const r=e.clone();r.workingexpr=t.where,i.push(r)}else i.push(e)}const l=this._reformulateWithoutAdaptions(a);return!l.cannot&&(null!==(a=l.where)?null!==this._extraFilter&&(a=w(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,i,r,s,a))}async _getAggregatePagesDataSourceDefinition(e,t,r,s,a,n,o){if(null===this._parent)throw new i(l.NeverReach);const h=[];for(let c=0;c<t.length;c++){const e=t[c];if(null!==e.workingexpr){const t=this._reformulateWithoutAdaptions(e.workingexpr);if(t.cannot)throw new i(l.NeverReach);const r=e.clone();r.workingexpr=t.where,h.push(r)}else h.push(e)}const u=this._reformulateWithoutAdaptions(a);if(u.cannot)throw new i(l.NeverReach);return null!==(a=u.where)?null!==this._extraFilter&&(a=w(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,h,r,s,a,n,o)}}export{y as AdaptedFeatureSet,F as AdaptedField,A as FieldRename,W as OriginalField,x as SqlExpressionAdapted,E as StringToCodeAdapted};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import{a1 as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import{FeatureSetError as l,FeatureSetErrorCodes as o}from"../support/errorsupport.js";import d from"../support/FeatureSet.js";import u from"../support/IdSet.js";import f from"../support/OrderbyClause.js";import{IdState as c,layerGeometryEsriConstants as p,FeatureServiceDatabaseType as h}from"../support/shared.js";import{isSingleField as g,toWhereClause as m,predictType as _,scanForField as y,reformulateWithoutField as b}from"../support/sqlUtils.js";import{calculateStat as w}from"../support/stats.js";import F from"../support/StatsField.js";import{createMD5Hash as I,outputTypes as S}from"../../../core/MD5.js";import{DateOnly as x}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as D}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as k}from"../../../core/sql/TimeOnly.js";import{WhereClause as j}from"../../../core/sql/WhereClause.js";import A from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/Field.js";import T from"../../../layers/support/FieldsIndex.js";function G(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class O extends d{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return c.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new T([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new F;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof j?i.expression:j.create(i.expression,r,{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC}),e.typeofstat=G(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof j?i.expression:j.create(i.expression,r,{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC}),sqlType:null};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=p.point,this.typeIdField="",this.types=null,this.spatialReference=new A({wkid:4326});this.fields=[];const a=new F;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=j.create(this._parent.objectIdField,this._parent.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC}),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new C;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,g(s.expression)){const e=this._parent.getField(m(s.expression,h.Standardised));if(!e)throw new l(o.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type,s.sqlType=e.type}else{t.type=this._convertToEsriFieldType(_(s.expression,this._parent.fields));const e=new C;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1,s.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new C;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&g(n.workingexpr)?m(n.workingexpr,h.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new l(o.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new l(o.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new l(o.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,l){if(""!==e)return new u([],[],!0,null);let o=null;const d={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===y(i,this._decodedStatsfield[n].tofieldname)){d.nowhereclause=!0,i=null;break}if(null!==s){d.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,d.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,d.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(l),o=!0===d.nowhereclause?new u(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new u(n._candidates.slice(0),n._known.slice(0),!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),o}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===d.nowhereclause)o=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}o=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return o}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=b(e,t.tofieldname,m(t.workingexpr,h.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=b(e,t.tofieldname,m(t.expression,h.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&(i instanceof x||i instanceof k?s.push(i.toNumber()):i instanceof D?s.push(i.toMilliseconds()):s.push(i))}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=w("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=w("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=w("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=w("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=w("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=w("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:j.convertValueToStorageFormat(e.expression.calculateValue(t.features[0]),e.sqlType);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return I(t,S.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d._featuresetFunctions.groupby=function(e,t){return new O({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{O as default};
5
+ import e from"../../../Graphic.js";import{a1 as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import{FeatureSetError as l,FeatureSetErrorCodes as o}from"../support/errorsupport.js";import d from"../support/FeatureSet.js";import u from"../support/IdSet.js";import f from"../support/OrderbyClause.js";import{IdState as c,layerGeometryEsriConstants as p,FeatureServiceDatabaseType as h}from"../support/shared.js";import{isSingleField as g,toWhereClause as _,predictType as m,scanForField as y,reformulateWithoutField as b}from"../support/sqlUtils.js";import{calculateStat as w}from"../support/stats.js";import F from"../support/StatsField.js";import{createMD5Hash as I,outputTypes as S}from"../../../core/MD5.js";import{DateOnly as x}from"../../../core/sql/DateOnly.js";import{SqlTimeStampOffset as D}from"../../../core/sql/SqlTimestampOffset.js";import{TimeOnly as k}from"../../../core/sql/TimeOnly.js";import{WhereClause as j}from"../../../core/sql/WhereClause.js";import A from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/Field.js";import T from"../../../layers/support/FieldsIndex.js";function G(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class O extends d{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return c.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new T([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new F;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof j?i.expression:j.create(i.expression,r,this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC),e.typeofstat=G(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof j?i.expression:j.create(i.expression,r,this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC),sqlType:null};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=p.point,this.typeIdField="",this.types=null,this.spatialReference=new A({wkid:4326});this.fields=[];const a=new F;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=j.create(this._parent.objectIdField,this._parent.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new C;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,g(s.expression)){const e=this._parent.getField(_(s.expression,h.Standardised));if(!e)throw new l(o.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type,s.sqlType=e.type}else{t.type=this._convertToEsriFieldType(m(s.expression,this._parent.fields));const e=new C;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1,s.sqlType=t.type}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new C;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&g(n.workingexpr)?_(n.workingexpr,h.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new l(o.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new l(o.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new l(o.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,l){if(""!==e)return new u([],[],!0,null);let o=null;const d={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===y(i,this._decodedStatsfield[n].tofieldname)){d.nowhereclause=!0,i=null;break}if(null!==s){d.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,d.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,d.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(l),o=!0===d.nowhereclause?new u(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new u(n._candidates.slice(0),n._known.slice(0),!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),o}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===d.nowhereclause)o=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}o=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return o}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=b(e,t.tofieldname,_(t.workingexpr,h.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=b(e,t.tofieldname,_(t.expression,h.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const l=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:l},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(l){a(l)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&(i instanceof x||i instanceof k?s.push(i.toNumber()):i instanceof D?s.push(i.toMilliseconds()):s.push(i))}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=w("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=w("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=w("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=w("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=w("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=w("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:j.convertValueToStorageFormat(e.expression.calculateValue(t.features[0]),e.sqlType);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return I(t,S.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d._featuresetFunctions.groupby=function(e,t){return new O({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{O as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{DateTimeReferenceFieldIndex as e}from"../../arcadeTimeUtils.js";import t from"./cache.js";import{FeatureSetError as i,FeatureSetErrorCodes as n}from"./errorsupport.js";import s from"./FeatureSetIterator.js";import a from"./IdSet.js";import{FeatureServiceDatabaseType as r,layerGeometryEsriConstants as l,IdState as u,convertSquareUnitsToCode as h,convertLinearUnitsToCode as o,esriFieldToJson as c,layerGeometryEsriRestConstants as d}from"./shared.js";import{max as _,min as f,sum as p,variance as m,stdev as g,mean as y,distinct as F,count as T}from"./stats.js";import{isPromiseLike as I}from"../../../core/promiseUtils.js";import{WhereClause as b}from"../../../core/sql/WhereClause.js";import{union as w,geodesicArea as S,planarArea as D,geodesicLength as x,planarLength as P}from"../../../geometry/geometryEngineAsync.js";import k from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/FieldsIndex.js";class R{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=r.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.typeIdField=null,this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this._dateFieldIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new k({wkid:4326}),this.geometryType=l.point)}getField(e,t){let i;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(i=t),!!i)))),i}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new C(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new i(n.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,i,n,s){return null!==this._parent&&this._parent._canDoAggregates(e,t,i,n,s)}async _getAggregatePagesDataSourceDefinition(e,t,s,a,r,l,u){if(null===this._parent)throw new i(n.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,t,s,a,r,l,u)}async _getAgregagtePhysicalPage(e,t,s){if(null===this._parent)throw new i(n.NeverReach);return this._parent._getAgregagtePhysicalPage(e,t,s)}async databaseType(){if(this._databaseType===r.NotEvaluated){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:r.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:r.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:r.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return r.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new i(n.NotImplemented)}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return u.Unknown}_getSet(e){throw new i(n.NotImplemented)}async _getFeature(e,t,s){if(this._checkCancelled(s),void 0!==this._featureFromCache(t))return this._featureFromCache(t);if(await this._getFeatures(e,t,this._maxProcessingRate(),s),this._checkCancelled(s),void 0!==this._featureFromCache(t))return this._featureFromCache(t);throw new i(n.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const i=new a([],e,!1,null),n=[];await this._getFeatures(i,-1,e.length,t),this._checkCancelled(t);for(const s of e)void 0!==this._featureFromCache(s)&&n.push(this._featureFromCache(s));return n}async _getFeatures(e,t,i,n){return"success"}_getFilteredSet(e,t,s,a,r){throw new i(n.NotImplemented)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const n=e._candidates.length;this._refineKnowns(e,t);let s=n-e._candidates.length;if(0===e._candidates.length)return e;if(s>=t)return e;if(await this._refineIfParentKnown(e,t-s,i),this._checkCancelled(i),this._refineKnowns(e,t-s),s=n-e._candidates.length,s<t&&e._candidates.length>0){const n=t-s,a=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(a,a.length>n?n:e._candidates.length,i),this._checkCancelled(i),this._refineKnowns(e,t-s),e}return e}_fetchAndRefineFeatures(e,t,i){return null}_prepareFetchAndRefineSet(e){const t=[];for(let i=0;i<e.length;i++)this._isPhysicalFeature(e[i])&&t.push(e[i]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let i=0,n=null;const s=[];t=this._maxQueryRate();for(let a=0;a<e._candidates.length&&"GETPAGES"!==e._candidates[a];a++){let r=!1;const l=this._candidateIdTransform(e._candidates[a]);l!==e._candidates[a]&&(r=!0);const h=this._isInFeatureSet(l);if(h===u.InFeatureSet)!0===r?e._known.includes(l)||(e._known.push(l),i+=1):(e._known.push(e._candidates[a]),i+=1),null===n?n={start:a,end:a}:n.end===a-1?n.end=a:(s.push(n),n={start:a,end:a});else if(h===u.NotInFeatureSet)null===n?n={start:a,end:a}:n.end===a-1?n.end=a:(s.push(n),n={start:a,end:a}),i+=1;else if(h===u.Unknown&&(i+=1,!0===e._ordered))break;if(i>=t)break}null!==n&&s.push(n);for(let a=s.length-1;a>=0;a--)e._candidates.splice(s[a].start,s[a].end-s[a].start+1)}_refineIfParentKnown(e,t,i){const n=new a([],[],e._ordered,null);return n._candidates=e._candidates.slice(0),this._parent._refineSetBlock(n,t,i)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let i=0;for(let n=e._lastFetchedIndex;n<e._known.length;n++){if("GETPAGES"===e._known[n])return!0;if(void 0===this._featureCache[e._known[n]]&&(i+=1,i>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let i=0;for(let n=0;n<e._candidates.length;n++){if("GETPAGES"===e._candidates[n])return!0;if(i+=1,i>=t)break}return!1}async _expandPagedSet(e,t,s,a,r){if(null===this._parent)throw new i(n.NotImplemented);return this._parent._expandPagedSet(e,t,s,a,r)}async _expandPagedSetFeatureSet(e,t,i,n,s){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(n=1),0===n&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(n=2),0===n)return"finished";const a=await this._getPage(e,n,s);return i+a<t?this._expandPagedSet(e,t,i+a,0,s):"success"}async _getPage(e,t,i){const n=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){n.length=n.length-1;let t=0;for(let s=0;s<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+s>=e.pagesDefinition.internal.set.length);s++)n[n.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+s],t++;e.pagesDefinition.resultOffset+=t;let i=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(i=!0),!1===i&&n.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,i),this._getPage(e,t,i)}_getPhysicalPage(e,t,i){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,i,n){await this._ensureLoaded();let s=await this._stat(e,t,"",null,null,i,n);return!1===s.calculated&&(s=await this._manualStat(e,t,i,n)),s.result}async _manualStat(e,t,i,n){let s=null;switch(e.toLowerCase()){case"count":return s=await T(this,n),{calculated:!0,result:s};case"distinct":return s=await F(this,t,i,n),{calculated:!0,result:s};case"avg":case"mean":return s=await y(this,t,n),{calculated:!0,result:s};case"stdev":return s=await g(this,t,n),{calculated:!0,result:s};case"variance":return s=await m(this,t,n),{calculated:!0,result:s};case"sum":return s=await p(this,t,n),{calculated:!0,result:s};case"min":return s=await f(this,t,n),{calculated:!0,result:s};case"max":return s=await _(this,t,n),{calculated:!0,result:s};default:return{calculated:!0,result:0}}}async _stat(e,t,i,n,s,a,r){const l=await this._parent._stat(e,t,i,n,s,a,r);return!1===l.calculated?null===s&&""===i&&null===n?this._manualStat(e,t,a,r):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),i=[];return new Promise(((e,n)=>{this._unionShapeInBatches(i,t,e,n)}))}_unionAllGeom(e){return new Promise(((t,i)=>{const n=this.iterator(this._defaultTracker(e)),s=[];this._unionShapeInBatches(s,n,t,i)}))}_unionShapeInBatches(e,t,i,n){t.next().then((s=>{try{null!==s&&null!==s.geometry&&e.push(s.geometry),e.length>30||null===s&&e.length>1?w(e).then((a=>{try{null===s?i(a):(e=[a],this._unionShapeInBatches(e,t,i,n))}catch(r){n(r)}}),n):null===s?1===e.length?i(e[0]):i(null):this._unionShapeInBatches(e,t,i,n)}catch(a){n(a)}}),n)}iterator(e){return new s(this,e)}intersection(e,t=!1){return R._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,i=!0){return R._featuresetFunctions.difference.bind(this)(e,t,i)}symmetricDifference(e,t=!1,i=!0){return R._featuresetFunctions.symmetricDifference.bind(this)(e,t,i)}morphShape(e,t,i="unknown",n=null){return R._featuresetFunctions.morphShape.bind(this)(e,t,i,n)}morphShapeAndAttributes(e,t,i="unknown"){return R._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,i)}union(e,t=!1){return R._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return R._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return R._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return R._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return R._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return R._featuresetFunctions.relate.bind(this)(e,t)}within(e){return R._featuresetFunctions.within.bind(this)(e)}touches(e){return R._featuresetFunctions.touches.bind(this)(e)}top(e){return R._featuresetFunctions.top.bind(this)(e)}crosses(e){return R._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,i,n=!0){return R._featuresetFunctions.buffer.bind(this)(e,t,i,n)}filter(e,t=null){return R._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return R._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return R._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return R._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,i){return new Promise(((n,s)=>{this._reduceImpl(this.iterator(this._defaultTracker(i)),e,t,0,n,s,0)}))}_reduceImpl(e,t,i,n,s,a,r){try{if(++r>1e3)return void setTimeout((()=>{r=0,this._reduceImpl(e,t,i,n,s,a,r)}));e.next().then((l=>{try{if(null===l)s(i);else{const u=t(i,l,n,this);I(u)?u.then((i=>{this._reduceImpl(e,t,i,n+1,s,a,r)}),a):this._reduceImpl(e,t,u,n+1,s,a,r)}}catch(u){a(u)}}),a)}catch(l){a(l)}}removeField(e){return R._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,i=null){return R._featuresetFunctions.addField.bind(this)(e,t,i)}sumArea(e,t=!1,i){const n=h(e);return this.reduce(((e,i)=>null===i.geometry?0:t?S(i.geometry,n).then((t=>e+t)):D(i.geometry,n).then((t=>e+t))),0,i)}sumLength(e,t=!1,i){const n=o(e);return this.reduce(((e,i)=>null===i.geometry?0:t?x(i.geometry,n).then((t=>e+t)):P(i.geometry,n).then((t=>e+t))),0,i)}_substituteVars(e,t){if(null!==t){const i={};for(const e in t)i[e.toLowerCase()]=t[e];e.parameters=i}}async distinct(e,t=1e3,i=null,n){await this.load();const s=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(s,i),this.calculateStatistic("distinct",s,t,this._defaultTracker(n))}async min(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("min",n,-1,this._defaultTracker(i))}async max(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("max",n,-1,this._defaultTracker(i))}async avg(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("avg",n,-1,this._defaultTracker(i))}async sum(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("sum",n,-1,this._defaultTracker(i))}async stdev(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("stdev",n,-1,this._defaultTracker(i))}async variance(e,t=null,i){await this.load();const n=b.create(e,this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC});return this._substituteVars(n,t),this.calculateStatistic("variance",n,-1,this._defaultTracker(i))}async count(e){return await this.load(),this.calculateStatistic("count",b.create("1",this.getFieldsIndex(),{timeZone:this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC}),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise(((i,n)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,i,n,0)}))}_forEachImpl(e,t,i,n,s,a){try{if(++a>1e3)return void setTimeout((()=>{a=0,this._forEachImpl(e,t,i,n,s,a)}),0);e.next().then((r=>{try{if(null===r)n(i);else{const l=t(r);null==l?this._forEachImpl(e,t,i,n,s,a):I(l)?l.then((()=>{try{this._forEachImpl(e,t,i,n,s,a)}catch(r){s(r)}}),s):this._forEachImpl(e,t,i,n,s,a)}}catch(l){s(l)}}),s)}catch(r){s(r)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let i=0;i<this.fields.length;i++)t.layerDefinition.fields.push(c(this.fields[i]));return this.reduce(((e,i)=>{const n={geometry:i.geometry&&i.geometry.toJSON(),attributes:{}};for(const t in i.attributes)n.attributes[t]=i.attributes[t];return t.featureSet.features.push(n),1}),0,e).then((()=>t))}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,i,n,s){return this._parent.queryAttachments(e,t,i,n,s)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(c(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===d[this.geometryType]?"esriGeometryNull":d[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,i)=>{const n={geometry:i.geometry?i.geometry.toJSON():null,attributes:i.attributes};return null!==n.geometry&&n.geometry.spatialReference&&delete n.geometry.spatialReference,e.push(n),1}),0,t);const i=this.schema();return i.features=e,i.spatialReference=this.spatialReference.toJSON(),JSON.stringify(i)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const i=[];await this.reduce(((e,n)=>{const s={geometry:n.geometry?!0===t?.keepGeometryType?n.geometry:n.geometry.toJSON():null,attributes:n.attributes};return null!==s.geometry&&s.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete s.geometry.spatialReference,i.push(s),1}),0,e);const n=this.schema();return n.features=i,n.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),n}get dateTimeReferenceFieldIndex(){return null===this._dateFieldIndex&&(this._dateFieldIndex=e.create(this.getFieldsIndex(),this)),this._dateFieldIndex}fieldTimeZone(e){return this.dateTimeReferenceFieldIndex.fieldTimeZone(e)}get preferredTimeReference(){return this._parent?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._parent?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}}R._featuresetFunctions={};export{R as default};
5
+ import{DateTimeReferenceFieldIndex as e}from"../../arcadeTimeUtils.js";import t from"./cache.js";import{FeatureSetError as i,FeatureSetErrorCodes as s}from"./errorsupport.js";import n from"./FeatureSetIterator.js";import a from"./IdSet.js";import{FeatureServiceDatabaseType as r,layerGeometryEsriConstants as l,IdState as u,convertSquareUnitsToCode as h,convertLinearUnitsToCode as c,esriFieldToJson as o,layerGeometryEsriRestConstants as d}from"./shared.js";import{max as _,min as f,sum as p,variance as m,stdev as g,mean as y,distinct as F,count as T}from"./stats.js";import{isPromiseLike as I}from"../../../core/promiseUtils.js";import{WhereClause as b}from"../../../core/sql/WhereClause.js";import{union as w,geodesicArea as S,planarArea as D,geodesicLength as x,planarLength as P}from"../../../geometry/geometryEngineAsync.js";import k from"../../../geometry/SpatialReference.js";import C from"../../../layers/support/FieldsIndex.js";class R{constructor(e){this.recentlyUsedQueries=null,this.featureSetQueryInterceptor=null,this._idstates=[],this._parent=null,this._wset=null,this._mainSetInUse=null,this._maxProcessing=200,this._maxQuery=500,this._totalCount=-1,this._databaseType=r.NotEvaluated,this._databaseTypeProbed=null,this.declaredRootClass="esri.arcade.featureset.support.FeatureSet",this._featureCache=[],this.typeIdField=null,this.types=null,this.fields=null,this.geometryType="",this.objectIdField="",this.globalIdField="",this.spatialReference=null,this.hasM=!1,this.hasZ=!1,this._transparent=!1,this.loaded=!1,this._loadPromise=null,this._fieldsIndex=null,this._dateFieldIndex=null,e&&e.lrucache&&(this.recentlyUsedQueries=e.lrucache),e&&e.interceptor&&(this.featureSetQueryInterceptor=e.interceptor)}optimisePagingFeatureQueries(e){this._parent&&this._parent.optimisePagingFeatureQueries(e)}_hasMemorySource(){return!0}prop(e,t){return void 0===t?this[e]:(void 0!==this[e]&&(this[e]=t),this)}end(){return null!==this._parent&&!0===this._parent._transparent?this._parent.end():this._parent}_ensureLoaded(){return this.load()}load(){return null===this._loadPromise&&(this._loadPromise=this.loadImpl()),this._loadPromise}async loadImpl(){return!0===this._parent?.loaded?(this._initialiseFeatureSet(),this):(await(this._parent?.load()),this._initialiseFeatureSet(),this)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new k({wkid:4326}),this.geometryType=l.point)}getField(e,t){let i;return(t=t||this.fields)&&(e=e.toLowerCase(),t.some((t=>(t&&t.name.toLowerCase()===e&&(i=t),!!i)))),i}getFieldsIndex(){return null===this._fieldsIndex&&(this._fieldsIndex=new C(this.fields)),this._fieldsIndex}_maxProcessingRate(){return null!==this._parent?Math.min(this._maxProcessing,this._parent._maxProcessingRate()):Math.min(this._maxProcessing,this._maxQueryRate())}_maxQueryRate(){return null!==this._parent?Math.max(this._maxQuery,this._parent._maxQueryRate()):this._maxQuery}_checkCancelled(e){if(null!=e&&e.aborted)throw new i(s.Cancelled)}nativeCapabilities(){return this._parent.nativeCapabilities()}async _canDoAggregates(e,t,i,s,n){return null!==this._parent&&this._parent._canDoAggregates(e,t,i,s,n)}async _getAggregatePagesDataSourceDefinition(e,t,n,a,r,l,u){if(null===this._parent)throw new i(s.NeverReach);return this._parent._getAggregatePagesDataSourceDefinition(e,t,n,a,r,l,u)}async _getAgregagtePhysicalPage(e,t,n){if(null===this._parent)throw new i(s.NeverReach);return this._parent._getAgregagtePhysicalPage(e,t,n)}async databaseType(){if(this._databaseType===r.NotEvaluated){if(null!==t.applicationCache){const e=t.applicationCache.getDatabaseType(this._cacheableFeatureSetSourceKey());if(null!==e)return e}if(null!==this._databaseTypeProbed)return this._databaseTypeProbed;try{this._databaseTypeProbed=this._getDatabaseTypeImpl(),null!==t.applicationCache&&t.applicationCache.setDatabaseType(this._cacheableFeatureSetSourceKey(),this._databaseTypeProbed)}catch(e){throw null!==t.applicationCache&&t.applicationCache.clearDatabaseType(this._cacheableFeatureSetSourceKey()),e}return this._databaseTypeProbed}return this._databaseType}async _getDatabaseTypeImpl(){const e=[{thetype:r.SqlServer,testwhere:"(CAST( '2015-01-01' as DATETIME) = CAST( '2015-01-01' as DATETIME)) AND OBJECTID<0"},{thetype:r.Oracle,testwhere:"(TO_DATE('2003-11-18','YYYY-MM-DD') = TO_DATE('2003-11-18','YYYY-MM-DD')) AND OBJECTID<0"},{thetype:r.StandardisedNoInterval,testwhere:"(date '2015-01-01 10:10:10' = date '2015-01-01 10:10:10') AND OBJECTID<0"}];for(const t of e){if(!0===await this._runDatabaseProbe(t.testwhere))return t.thetype}return r.StandardisedNoInterval}_cacheableFeatureSetSourceKey(){return"MUSTBESET"}async _runDatabaseProbe(e){if(null!==this._parent)return this._parent._runDatabaseProbe(e);throw new i(s.NotImplemented)}isTable(){return this._parent?.isTable()??!1}_featureFromCache(e){if(void 0!==this._featureCache[e])return this._featureCache[e]}_isInFeatureSet(e){return u.Unknown}_getSet(e){throw new i(s.NotImplemented)}async _getFeature(e,t,n){if(this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);if(await this._getFeatures(e,t,this._maxProcessingRate(),n),this._checkCancelled(n),void 0!==this._featureFromCache(t))return this._featureFromCache(t);throw new i(s.MissingFeatures)}async _getFeatureBatch(e,t){this._checkCancelled(t);const i=new a([],e,!1,null),s=[];await this._getFeatures(i,-1,e.length,t),this._checkCancelled(t);for(const n of e)void 0!==this._featureFromCache(n)&&s.push(this._featureFromCache(n));return s}async _getFeatures(e,t,i,s){return"success"}_getFilteredSet(e,t,n,a,r){throw new i(s.NotImplemented)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQueryRate()))return await this._expandPagedSet(e,this._maxQueryRate(),0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);let n=s-e._candidates.length;if(0===e._candidates.length)return e;if(n>=t)return e;if(await this._refineIfParentKnown(e,t-n,i),this._checkCancelled(i),this._refineKnowns(e,t-n),n=s-e._candidates.length,n<t&&e._candidates.length>0){const s=t-n,a=this._prepareFetchAndRefineSet(e._candidates);return await this._fetchAndRefineFeatures(a,a.length>s?s:e._candidates.length,i),this._checkCancelled(i),this._refineKnowns(e,t-n),e}return e}_fetchAndRefineFeatures(e,t,i){return null}_prepareFetchAndRefineSet(e){const t=[];for(let i=0;i<e.length;i++)this._isPhysicalFeature(e[i])&&t.push(e[i]);return t}_isPhysicalFeature(e){return null===this._parent||this._parent._isPhysicalFeature(e)}_refineKnowns(e,t){let i=0,s=null;const n=[];t=this._maxQueryRate();for(let a=0;a<e._candidates.length&&"GETPAGES"!==e._candidates[a];a++){let r=!1;const l=this._candidateIdTransform(e._candidates[a]);l!==e._candidates[a]&&(r=!0);const h=this._isInFeatureSet(l);if(h===u.InFeatureSet)!0===r?e._known.includes(l)||(e._known.push(l),i+=1):(e._known.push(e._candidates[a]),i+=1),null===s?s={start:a,end:a}:s.end===a-1?s.end=a:(n.push(s),s={start:a,end:a});else if(h===u.NotInFeatureSet)null===s?s={start:a,end:a}:s.end===a-1?s.end=a:(n.push(s),s={start:a,end:a}),i+=1;else if(h===u.Unknown&&(i+=1,!0===e._ordered))break;if(i>=t)break}null!==s&&n.push(s);for(let a=n.length-1;a>=0;a--)e._candidates.splice(n[a].start,n[a].end-n[a].start+1)}_refineIfParentKnown(e,t,i){const s=new a([],[],e._ordered,null);return s._candidates=e._candidates.slice(0),this._parent._refineSetBlock(s,t,i)}_candidateIdTransform(e){return this._parent._candidateIdTransform(e)}_checkIfNeedToExpandKnownPage(e,t){if(null===e.pagesDefinition)return!1;let i=0;for(let s=e._lastFetchedIndex;s<e._known.length;s++){if("GETPAGES"===e._known[s])return!0;if(void 0===this._featureCache[e._known[s]]&&(i+=1,i>=t))break}return!1}_checkIfNeedToExpandCandidatePage(e,t){if(null===e.pagesDefinition)return!1;let i=0;for(let s=0;s<e._candidates.length;s++){if("GETPAGES"===e._candidates[s])return!0;if(i+=1,i>=t)break}return!1}async _expandPagedSet(e,t,n,a,r){if(null===this._parent)throw new i(s.NotImplemented);return this._parent._expandPagedSet(e,t,n,a,r)}async _expandPagedSetFeatureSet(e,t,i,s,n){if(e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]&&(s=1),0===s&&e._candidates.length>0&&"GETPAGES"===e._candidates[e._candidates.length-1]&&(s=2),0===s)return"finished";const a=await this._getPage(e,s,n);return i+a<t?this._expandPagedSet(e,t,i+a,0,n):"success"}async _getPage(e,t,i){const s=1===t?e._known:e._candidates;if(e.pagesDefinition.internal.set.length>e.pagesDefinition.resultOffset||!0===e.pagesDefinition.internal.fullyResolved){s.length=s.length-1;let t=0;for(let n=0;n<e.pagesDefinition.resultRecordCount&&!(e.pagesDefinition.resultOffset+n>=e.pagesDefinition.internal.set.length);n++)s[s.length]=e.pagesDefinition.internal.set[e.pagesDefinition.resultOffset+n],t++;e.pagesDefinition.resultOffset+=t;let i=!1;return!0===e.pagesDefinition.internal.fullyResolved&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset&&(i=!0),!1===i&&s.push("GETPAGES"),t}return await this._getPhysicalPage(e,t,i),this._getPage(e,t,i)}_getPhysicalPage(e,t,i){return null}_clonePageDefinition(e){return null===this._parent?null:this._parent._clonePageDefinition(e)}_first(e){return this.iterator(e).next()}first(e){return this._first(e)}async calculateStatistic(e,t,i,s){await this._ensureLoaded();let n=await this._stat(e,t,"",null,null,i,s);return!1===n.calculated&&(n=await this._manualStat(e,t,i,s)),n.result}async _manualStat(e,t,i,s){let n=null;switch(e.toLowerCase()){case"count":return n=await T(this,s),{calculated:!0,result:n};case"distinct":return n=await F(this,t,i,s),{calculated:!0,result:n};case"avg":case"mean":return n=await y(this,t,s),{calculated:!0,result:n};case"stdev":return n=await g(this,t,s),{calculated:!0,result:n};case"variance":return n=await m(this,t,s),{calculated:!0,result:n};case"sum":return n=await p(this,t,s),{calculated:!0,result:n};case"min":return n=await f(this,t,s),{calculated:!0,result:n};case"max":return n=await _(this,t,s),{calculated:!0,result:n};default:return{calculated:!0,result:0}}}async _stat(e,t,i,s,n,a,r){const l=await this._parent._stat(e,t,i,s,n,a,r);return!1===l.calculated?null===n&&""===i&&null===s?this._manualStat(e,t,a,r):{calculated:!1}:l}_unionAllGeomSelf(e){const t=this.iterator(this._defaultTracker(e)),i=[];return new Promise(((e,s)=>{this._unionShapeInBatches(i,t,e,s)}))}_unionAllGeom(e){return new Promise(((t,i)=>{const s=this.iterator(this._defaultTracker(e)),n=[];this._unionShapeInBatches(n,s,t,i)}))}_unionShapeInBatches(e,t,i,s){t.next().then((n=>{try{null!==n&&null!==n.geometry&&e.push(n.geometry),e.length>30||null===n&&e.length>1?w(e).then((a=>{try{null===n?i(a):(e=[a],this._unionShapeInBatches(e,t,i,s))}catch(r){s(r)}}),s):null===n?1===e.length?i(e[0]):i(null):this._unionShapeInBatches(e,t,i,s)}catch(a){s(a)}}),s)}iterator(e){return new n(this,e)}intersection(e,t=!1){return R._featuresetFunctions.intersection.bind(this)(e,t)}difference(e,t=!1,i=!0){return R._featuresetFunctions.difference.bind(this)(e,t,i)}symmetricDifference(e,t=!1,i=!0){return R._featuresetFunctions.symmetricDifference.bind(this)(e,t,i)}morphShape(e,t,i="unknown",s=null){return R._featuresetFunctions.morphShape.bind(this)(e,t,i,s)}morphShapeAndAttributes(e,t,i="unknown"){return R._featuresetFunctions.morphShapeAndAttributes.bind(this)(e,t,i)}union(e,t=!1){return R._featuresetFunctions.union.bind(this)(e,t)}intersects(e){return R._featuresetFunctions.intersects.bind(this)(e)}envelopeIntersects(e){return R._featuresetFunctions.envelopeIntersects.bind(this)(e)}contains(e){return R._featuresetFunctions.contains.bind(this)(e)}overlaps(e){return R._featuresetFunctions.overlaps.bind(this)(e)}relate(e,t){return R._featuresetFunctions.relate.bind(this)(e,t)}within(e){return R._featuresetFunctions.within.bind(this)(e)}touches(e){return R._featuresetFunctions.touches.bind(this)(e)}top(e){return R._featuresetFunctions.top.bind(this)(e)}crosses(e){return R._featuresetFunctions.crosses.bind(this)(e)}buffer(e,t,i,s=!0){return R._featuresetFunctions.buffer.bind(this)(e,t,i,s)}filter(e,t=null){return R._featuresetFunctions.filter.bind(this)(e,t)}orderBy(e){return R._featuresetFunctions.orderBy.bind(this)(e)}dissolve(e,t){return R._featuresetFunctions.dissolve.bind(this)(e,t)}groupby(e,t){return R._featuresetFunctions.groupby.bind(this)(e,t)}reduce(e,t=null,i){return new Promise(((s,n)=>{this._reduceImpl(this.iterator(this._defaultTracker(i)),e,t,0,s,n,0)}))}_reduceImpl(e,t,i,s,n,a,r){try{if(++r>1e3)return void setTimeout((()=>{r=0,this._reduceImpl(e,t,i,s,n,a,r)}));e.next().then((l=>{try{if(null===l)n(i);else{const u=t(i,l,s,this);I(u)?u.then((i=>{this._reduceImpl(e,t,i,s+1,n,a,r)}),a):this._reduceImpl(e,t,u,s+1,n,a,r)}}catch(u){a(u)}}),a)}catch(l){a(l)}}removeField(e){return R._featuresetFunctions.removeField.bind(this)(e)}addField(e,t,i=null){return R._featuresetFunctions.addField.bind(this)(e,t,i)}sumArea(e,t=!1,i){const s=h(e);return this.reduce(((e,i)=>null===i.geometry?0:t?S(i.geometry,s).then((t=>e+t)):D(i.geometry,s).then((t=>e+t))),0,i)}sumLength(e,t=!1,i){const s=c(e);return this.reduce(((e,i)=>null===i.geometry?0:t?x(i.geometry,s).then((t=>e+t)):P(i.geometry,s).then((t=>e+t))),0,i)}_substituteVars(e,t){if(null!==t){const i={};for(const e in t)i[e.toLowerCase()]=t[e];e.parameters=i}}async distinct(e,t=1e3,i=null,s){await this.load();const n=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(n,i),this.calculateStatistic("distinct",n,t,this._defaultTracker(s))}async min(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("min",s,-1,this._defaultTracker(i))}async max(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("max",s,-1,this._defaultTracker(i))}async avg(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("avg",s,-1,this._defaultTracker(i))}async sum(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("sum",s,-1,this._defaultTracker(i))}async stdev(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("stdev",s,-1,this._defaultTracker(i))}async variance(e,t=null,i){await this.load();const s=b.create(e,this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC);return this._substituteVars(s,t),this.calculateStatistic("variance",s,-1,this._defaultTracker(i))}async count(e){return await this.load(),this.calculateStatistic("count",b.create("1",this.getFieldsIndex(),this.dateTimeReferenceFieldIndex.layerDateFieldsTimeZoneDefaultUTC),-1,this._defaultTracker(e))}_defaultTracker(e){return e??{aborted:!1}}forEach(e,t){return new Promise(((i,s)=>{this._forEachImpl(this.iterator(this._defaultTracker(t)),e,this,i,s,0)}))}_forEachImpl(e,t,i,s,n,a){try{if(++a>1e3)return void setTimeout((()=>{a=0,this._forEachImpl(e,t,i,s,n,a)}),0);e.next().then((r=>{try{if(null===r)s(i);else{const l=t(r);null==l?this._forEachImpl(e,t,i,s,n,a):I(l)?l.then((()=>{try{this._forEachImpl(e,t,i,s,n,a)}catch(r){n(r)}}),n):this._forEachImpl(e,t,i,s,n,a)}}catch(l){n(l)}}),n)}catch(r){n(r)}}convertToJSON(e){const t={layerDefinition:{geometryType:this.geometryType,fields:[]},featureSet:{features:[],geometryType:this.geometryType}};for(let i=0;i<this.fields.length;i++)t.layerDefinition.fields.push(o(this.fields[i]));return this.reduce(((e,i)=>{const s={geometry:i.geometry&&i.geometry.toJSON(),attributes:{}};for(const t in i.attributes)s.attributes[t]=i.attributes[t];return t.featureSet.features.push(s),1}),0,e).then((()=>t))}castToText(e=!1){return"object, FeatureSet"}queryAttachments(e,t,i,s,n){return this._parent.queryAttachments(e,t,i,s,n)}serviceUrl(){return this._parent.serviceUrl()}subtypes(){return this.typeIdField?{subtypeField:this.typeIdField,subtypes:this.types?this.types.map((e=>({name:e.name,code:e.id}))):[]}:null}relationshipMetaData(){return this._parent.relationshipMetaData()}get gdbVersion(){return this._parent?this._parent.gdbVersion:""}schema(){const e=[];for(const t of this.fields)e.push(o(t));return{objectIdField:this.objectIdField,globalIdField:this.globalIdField,geometryType:void 0===d[this.geometryType]?"esriGeometryNull":d[this.geometryType],fields:e}}async convertToText(e,t){if("schema"===e)return await this._ensureLoaded(),JSON.stringify(this.schema());if("featureset"===e){await this._ensureLoaded();const e=[];await this.reduce(((t,i)=>{const s={geometry:i.geometry?i.geometry.toJSON():null,attributes:i.attributes};return null!==s.geometry&&s.geometry.spatialReference&&delete s.geometry.spatialReference,e.push(s),1}),0,t);const i=this.schema();return i.features=e,i.spatialReference=this.spatialReference.toJSON(),JSON.stringify(i)}return this.castToText()}getFeatureByObjectId(e,t){return this._parent.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._parent.getOwningSystemUrl()}getIdentityUser(){return this._parent.getIdentityUser()}getRootFeatureSet(){return null!==this._parent?this._parent.getRootFeatureSet():this}getDataSourceFeatureSet(){return null!==this._parent?this._parent.getDataSourceFeatureSet():this}castAsJson(e=null){return"keeptype"===e?.featureset?this:"none"===e?.featureset?null:{type:"FeatureSet"}}async castAsJsonAsync(e=null,t=null){if("keeptype"===t?.featureset)return this;if("schema"===t?.featureset)return await this._ensureLoaded(),JSON.parse(JSON.stringify(this.schema()));if("none"===t?.featureset)return null;await this._ensureLoaded();const i=[];await this.reduce(((e,s)=>{const n={geometry:s.geometry?!0===t?.keepGeometryType?s.geometry:s.geometry.toJSON():null,attributes:s.attributes};return null!==n.geometry&&n.geometry.spatialReference&&!0!==t?.keepGeometryType&&delete n.geometry.spatialReference,i.push(n),1}),0,e);const s=this.schema();return s.features=i,s.spatialReference=!0===t?.keepGeometryType?this.spatialReference:this.spatialReference?.toJSON(),s}get dateTimeReferenceFieldIndex(){return null===this._dateFieldIndex&&(this._dateFieldIndex=e.create(this.getFieldsIndex(),this)),this._dateFieldIndex}fieldTimeZone(e){return this.dateTimeReferenceFieldIndex.fieldTimeZone(e)}get preferredTimeReference(){return this._parent?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._parent?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._parent.datesInUnknownTimezone}get editFieldsInfo(){return this._parent?.editFieldsInfo??null}get timeInfo(){return this._parent?.timeInfo??null}}R._featuresetFunctions={};export{R as default};