@arcgis/core 5.0.0-next.35 → 5.0.0-next.37
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.
- package/WebLinkChart.js +1 -1
- package/analysis/ShadowCast/types.d.ts +2 -0
- package/applications/Components/analysisUtils.d.ts +1 -0
- package/applications/Components/analysisUtils.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/actions/AttributeFilter.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerOGC.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/FeatureSetIterator.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/014dbe6fa93a277b08f7.js +1 -0
- package/assets/esri/core/workers/chunks/06462b267ff8d5984882.js +1 -0
- package/assets/esri/core/workers/chunks/{b48bb38e5d60fc7a9097.js → 08ef90e3fcfd4eda4301.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa01d1813fa78034526e.js → 0a5427127634738aa239.js} +1 -1
- package/assets/esri/core/workers/chunks/0a58b57e1777a8b0ea23.js +1 -0
- package/assets/esri/core/workers/chunks/{7115c52e22b7becff8de.js → 103153951ba312dc5e9e.js} +1 -1
- package/assets/esri/core/workers/chunks/{c7c721de93bc8688e13c.js → 1d4ea8db272655c0608c.js} +1 -1
- package/assets/esri/core/workers/chunks/1d566539ff6fb6ac798c.js +1 -0
- package/assets/esri/core/workers/chunks/1de216d9850c39c1735d.js +1 -0
- package/assets/esri/core/workers/chunks/20e4243ea563d05a5256.js +1 -0
- package/assets/esri/core/workers/chunks/262232437d37a7460b11.js +1 -0
- package/assets/esri/core/workers/chunks/{fafbacf2467e6883b6c9.js → 28db329528def851efd7.js} +1 -1
- package/assets/esri/core/workers/chunks/{2367bd1cb34799a3f08a.js → 30184e39129d9c66ea54.js} +1 -1
- package/assets/esri/core/workers/chunks/{f55328aabf84770c8e6a.js → 328106e181e5957ceaa5.js} +1 -1
- package/assets/esri/core/workers/chunks/48e2737182c75005fb8f.js +1 -0
- package/assets/esri/core/workers/chunks/{d3db7244fac7398cc700.js → 4b6a44c6265c8959abd8.js} +1 -1
- package/assets/esri/core/workers/chunks/{a372d9af43ade7c6314c.js → 52c8687b473c9953c2f2.js} +1 -1
- package/assets/esri/core/workers/chunks/{63933cbcb5c12df09715.js → 59ce992d3a5e7c32b9fb.js} +1 -1
- package/assets/esri/core/workers/chunks/{c9c2e00fed979c21e2f0.js → 5e30acfda04f7fc2b676.js} +1 -1
- package/assets/esri/core/workers/chunks/6330d8767ba1d5329daa.js +1 -0
- package/assets/esri/core/workers/chunks/640085b5ade5c7f16228.js +1 -0
- package/assets/esri/core/workers/chunks/690a40d2eef52bfc149f.js +1 -0
- package/assets/esri/core/workers/chunks/727804cf901094b1d620.js +1 -0
- package/assets/esri/core/workers/chunks/{dd34d56caafa38d4b8e4.js → 7aa730e5ac7b268e3c98.js} +1 -1
- package/assets/esri/core/workers/chunks/8c271e9272e4eaf1325a.js +1 -0
- package/assets/esri/core/workers/chunks/{2a0fe1aede5c68374ccf.js → 8ec238b5b59ef18a1713.js} +1 -1
- package/assets/esri/core/workers/chunks/{f1dfb1323d50247e80f9.js → 9110287f272141f60c35.js} +1 -1
- package/assets/esri/core/workers/chunks/951a3442d4342539f2ea.js +1 -0
- package/assets/esri/core/workers/chunks/9664d9e679abc41f6c42.js +1 -0
- package/assets/esri/core/workers/chunks/{2921f05a40fda12f9f81.js → a00bba1c7cbf8cd7892c.js} +1 -1
- package/assets/esri/core/workers/chunks/a716b8fdeda4e16f03ab.js +1 -0
- package/assets/esri/core/workers/chunks/aead7c9830fa310e5b53.js +1 -0
- package/assets/esri/core/workers/chunks/{1fa55d4c4b092a98bdd7.js → b56c07c0b43cb1999070.js} +1 -1
- package/assets/esri/core/workers/chunks/b59be95949445ff5afab.js +1 -0
- package/assets/esri/core/workers/chunks/b6dec5dfdeca54bae88d.js +1 -0
- package/assets/esri/core/workers/chunks/{6afd59412bfc134bdf75.js → c052fb8c952cda0b5d13.js} +1 -1
- package/assets/esri/core/workers/chunks/c5967133f3ba34a883f8.js +1 -0
- package/assets/esri/core/workers/chunks/{4356274cfa477eb6d749.js → cda5c95fd49b8901f7d4.js} +1 -1
- package/assets/esri/core/workers/chunks/{82cc758bddd9f8397b9f.js → ce8fc1ca229d53a4b68d.js} +8 -8
- package/assets/esri/core/workers/chunks/{f2ebd6471e1259a6eac0.js → ce99abfdcd71ff9e4e36.js} +1 -1
- package/assets/esri/core/workers/chunks/{726a797f5df7eeee0b3d.js → d786b17cc9062b1450ac.js} +1 -1
- package/assets/esri/core/workers/chunks/dd105d6e0fcedee32644.js +1 -0
- package/assets/esri/core/workers/chunks/{2e76fbd3c874300fc4a7.js → de3da4d31a7529761565.js} +1 -1
- package/assets/esri/core/workers/chunks/e1148067ceae7d9eaaf8.js +1 -0
- package/assets/esri/core/workers/chunks/{b536fdb655ad293d9024.js → e501d68a1464805c4b4e.js} +1 -1
- package/assets/esri/core/workers/chunks/{33431e8131f6017de2f9.js → e7f4d135ef9665de1468.js} +1 -1
- package/assets/esri/core/workers/chunks/{97650ee3d0eecb69ccbb.js → e9bc3c6482ba778c9349.js} +39 -39
- package/assets/esri/core/workers/chunks/{7804be2f5b3d86188a24.js → edc3d98f33d7bf959154.js} +1 -1
- package/assets/esri/core/workers/chunks/{0446562aee0639c61485.js → ee67c8a7c1f8b482cd99.js} +1 -1
- package/assets/esri/core/workers/chunks/eefad79be500667af96e.js +1 -0
- package/assets/esri/core/workers/chunks/{2b7f9a57a2cfbc108673.js → f1b99529e2055873b65a.js} +1 -1
- package/assets/esri/core/workers/chunks/{abb05a903440d97a6a74.js → f441fc74451330384fb0.js} +1 -1
- package/assets/esri/core/workers/chunks/f609b256df9eb3803464.js +1 -0
- package/assets/esri/core/workers/chunks/f693a4d97b2762d0e6ff.js +1 -0
- package/assets/esri/core/workers/chunks/f8caceeaa14d99c35526.js +1 -0
- package/assets/esri/core/workers/chunks/f97a7cb367634353177d.js +1 -0
- package/assets/esri/core/workers/chunks/febce0d80f019dc2a427.js +1 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
- package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Attribution.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/CloudsComposition.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +2 -2
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/GaussianSplat.glsl.js +2 -2
- package/chunks/Laserlines.glsl.js +1 -1
- package/chunks/Magnifier.glsl.js +1 -1
- package/chunks/Path.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +34 -36
- package/chunks/WaterSurface.glsl.js +1 -1
- package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
- package/chunks/arcgis-knowledge-client-core.js +1 -1
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/vec32.js +1 -1
- package/chunks/vec42.js +1 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/core/iteratorUtils.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/math/vec4.js +1 -1
- package/geometry/support/aaBoundingRect.js +1 -1
- package/geometry/support/buffer/BufferView.js +1 -1
- package/geometry/support/buffer/internals/Vec4.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +143 -5
- package/kernel.js +1 -1
- package/layers/GaussianSplatLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/support/csvUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/package.json +5 -5
- package/rest/knowledgeGraph/DataModel.js +1 -1
- package/rest/knowledgeGraph/GraphDataModelSingletonOperationResult.d.ts +4 -0
- package/rest/knowledgeGraph/GraphDataModelSingletonOperationResult.js +5 -0
- package/rest/knowledgeGraph/GraphProperty.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToDataModelFactories.js +1 -1
- package/rest/knowledgeGraphService.d.ts +3 -0
- package/rest/knowledgeGraphService.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
- package/views/2d/interactive/SegmentLabels2D.js +1 -1
- package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineVisualization3D.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization3D.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/CloudsParameters.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/interactive/SegmentLabels3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImagerySubView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/graphicUtils.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/ScaleRangeQueries.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TextureFader.js +1 -1
- package/views/3d/terrain/TextureReference.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +4 -7
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +19 -15
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +5 -5
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js +14 -14
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +16 -37
- package/views/3d/webgl-engine/core/shaderLibrary/util/CameraSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Normals.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +9 -10
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/ensureColor4.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +5 -5
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileVisualizationUtils.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
- package/views/layers/LayerView.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/GroundElevationSampler.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geodesicLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/webmap/utils.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/assets/esri/core/workers/chunks/032444974011118127d7.js +0 -1
- package/assets/esri/core/workers/chunks/05e55118dc0023d500fc.js +0 -1
- package/assets/esri/core/workers/chunks/089221bac1f019692f48.js +0 -1
- package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +0 -1
- package/assets/esri/core/workers/chunks/15c1a48e8cd2a8882d85.js +0 -1
- package/assets/esri/core/workers/chunks/1b9e7d416c9f00e020bb.js +0 -1
- package/assets/esri/core/workers/chunks/1bfe0b2bf38d4dee7fd6.js +0 -1
- package/assets/esri/core/workers/chunks/27bd88e1101873d4ce12.js +0 -1
- package/assets/esri/core/workers/chunks/483dc4ee5d73cdfe6229.js +0 -1
- package/assets/esri/core/workers/chunks/53d95ba86d010231fc4e.js +0 -1
- package/assets/esri/core/workers/chunks/7d3e665613927904ba4f.js +0 -1
- package/assets/esri/core/workers/chunks/a5f2da24497349239648.js +0 -1
- package/assets/esri/core/workers/chunks/a7b1b42bdb9cb9ecac45.js +0 -1
- package/assets/esri/core/workers/chunks/acaaefd4997316d319b8.js +0 -1
- package/assets/esri/core/workers/chunks/ad138b989c2c7a1168ac.js +0 -1
- package/assets/esri/core/workers/chunks/cc7c37f9ed3f831fd25c.js +0 -1
- package/assets/esri/core/workers/chunks/d14bd320f72d8e8a0ad8.js +0 -1
- package/assets/esri/core/workers/chunks/d86e59da76eea888ba86.js +0 -1
- package/assets/esri/core/workers/chunks/d8975dd7b85b5d065ee4.js +0 -1
- package/assets/esri/core/workers/chunks/de99c4fd1582a8e610cf.js +0 -1
- package/assets/esri/core/workers/chunks/ded3ef385d5a3a2ec8ca.js +0 -1
- package/assets/esri/core/workers/chunks/e3a994587f9b2e88db85.js +0 -1
- package/assets/esri/core/workers/chunks/eab0938d4ad7d7cc7309.js +0 -1
- package/assets/esri/core/workers/chunks/ed1dabed10ff9f4e0369.js +0 -1
- package/assets/esri/core/workers/chunks/ef5b13ee3362763c1096.js +0 -1
- package/assets/esri/core/workers/chunks/effbc4d240752e8ba0ab.js +0 -1
- package/assets/esri/core/workers/chunks/f403d8e414766fab2936.js +0 -1
- package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +0 -1
package/WebLinkChart.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import
|
|
5
|
+
import{__decorate as t}from"tslib";import a from"./Basemap.js";import r from"./WebDocument2D.js";import i from"./core/Error.js";import{property as e,subclass as n}from"./core/accessorSupport/decorators.js";import o from"./layers/LinkChartLayer.js";import{getInclusionDefinitionFromCypherResults as h,getInclusionDefinitionFromIdTypePairs as s}from"./layers/knowledgeGraph/layerUtils.js";import{getDefaultChronologicalOverlayLayerId as l,getChronologicalOverlay as y}from"./layers/knowledgeGraph/supportUtils.js";import c from"./linkChart/LayoutSettings.js";import k from"./linkChart/LinkChartProperties.js";import p from"./linkChart/NonspatialDataDisplay.js";import L from"./webmap/InitialViewProperties.js";import{currentVersion as C}from"./webmap/utils.js";import{Version as d}from"./webmap/Version.js";var u;const w={currentVersion:C,createInitialViewProperties:()=>new L,parseVersion:d.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let f=u=class extends r{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new k}get activeLinkChartLayer(){return this.layers.find(({type:t})=>"link-chart"===t)}get context(){return w}async applyLayout(t="organic-standard",r){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");"geographic-organic-standard"!==t||this.basemap?.baseLayers?.length||(this.basemap=a.fromId("topo-vector"),await(this.basemap?.load())),this.linkChartProperties.layoutType=t;const e=r?.layoutSettings??this.linkChartProperties.layoutSettings??new c;this.linkChartProperties.layoutSettings=e;const n={...r,layoutSettings:e};return this.activeLinkChartLayer.applyNewLinkChartLayout(t,n)}changeNonspatialDataDisplay(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new p),this.linkChartProperties.nonspatialDataDisplay.mode=t}async addRecords(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.addRecords(t,a)}async createSublayerForNamedType(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.createSublayerForNamedType(t)}async removeRecords(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.removeRecords(t)}async expand(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.expand(t,a);return r?.records??[]}async refreshLinkChartData(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.refreshLinkChartCache(t)}async connectBetweenEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectBetweenEntities(t,a);return r?.records??[]}async connectFromEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const r=await this.activeLinkChartLayer.connectFromEntities(t,a);return r?.records??[]}getMemberIdsByType(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return Array.from(this.activeLinkChartLayer?.dataManager.sublayerCaches.get(t)?.keys()??[])}get diagramNodesExtent(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.linkChartExtent}get entityCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.entityLinkChartDiagramLookup.size}get relationshipCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.relationshipLinkChartDiagramLookup.size}get knowledgeGraph(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer?.knowledgeGraph}add(t,a){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new i("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t,a),"type"in t&&"link-chart"===t.type){const a=t.initializationLinkChartConfig?.layoutMode;a&&(this.linkChartProperties.layoutType=a);const r=t.initializationLinkChartConfig?.layoutSettings;r&&(this.linkChartProperties.layoutSettings=r)}}static fromJSON(t){if(t)return new u({resourceInfo:t});throw new i("linkchart:empty-resource","Expected a JSON resource but got nothing")}handleChronologicalOverlay(){if(!this.activeLinkChartLayer)return;const t=this.activeLinkChartLayer,a=this.findLayerById(l());if(a&&this.remove(a),"chronological-mono-timeline"===this.linkChartProperties.layoutType||"chronological-multi-timeline"===this.linkChartProperties.layoutType){const a=y(t);this.add(a,0)}}static async fromCypherQuery(t,a,r,i){const e=await h(t,a,i),n=new u,s=new o({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return s.load({signal:i?.signal}),n.add(s),n}static fromIdTypePairs(t,a,r,i){const e=s(t,a),n=new u,h=new o({url:t.url,initializationInclusionModeDefinition:e,initializationLinkChartConfig:r});return h.load({signal:i?.signal}),n.add(h),n}};t([e({readOnly:!0})],f.prototype,"activeLinkChartLayer",null),t([e({json:{write:{ignoreOrigin:!0}}})],f.prototype,"mapType",void 0),t([e({type:k,nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],f.prototype,"linkChartProperties",void 0),t([e({readOnly:!0})],f.prototype,"diagramNodesExtent",null),t([e({readOnly:!0})],f.prototype,"entityCount",null),t([e({readOnly:!0})],f.prototype,"relationshipCount",null),t([e({readOnly:!0})],f.prototype,"knowledgeGraph",null),f=u=t([n("esri.WebLinkChart")],f);const m=f;export{m as default};
|
|
@@ -4,3 +4,4 @@ export const createChart: __esri.analysisUtils["createChart"];
|
|
|
4
4
|
export const forceInteractive: __esri.analysisUtils["forceInteractive"];
|
|
5
5
|
export const hasValidAreaResult: __esri.analysisUtils["hasValidAreaResult"];
|
|
6
6
|
export const isAboveGeodesicDistanceThreshold: __esri.analysisUtils["isAboveGeodesicDistanceThreshold"];
|
|
7
|
+
export const setElevationProfileTestConfig: __esri.analysisUtils["setElevationProfileTestConfig"];
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{throwIfAborted as
|
|
5
|
+
import{throwIfAborted as n}from"../../core/promiseUtils.js";import{toUnit as e}from"../../core/quantity.js";import{setTestConfig as i}from"../../views/analysis/ElevationProfile/constants.js";import{geodesicDistanceThreshold as o}from"../../views/support/geodesicMeasurementUtils.js";function r(n){return n.forceInteractive()}function t(n){return e(n,"meters").value>o}function s(n){return 0===n.viewData.intersectingSegments.size}function a(){return i()}async function c(e){const{ElevationProfileChart:i}=await import("../../views/analysis/ElevationProfile/ElevationProfileChart.js");return n(e.signal),new i({analysisView:e.analysisView,container:e.container,messages:e.messages,onCursorPositionChange:e.onCursorPositionChange,onRangeChange:e.onRangeChange,uniformScaling:e.uniformScaling??!1,view:e.view})}export{c as createChart,r as forceInteractive,s as hasValidAreaResult,t as isAboveGeodesicDistanceThreshold,a as setElevationProfileTestConfig};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as a}from"./compilerUtils.js";import{getNestedOptionalValue as i,geometryMember as s,getGeometryKeys as c}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as u,ensureArcadeExecutionError as f}from"./executionError.js";import{Feature as p}from"./Feature.js";import{NativeFunction as w,ScopeMarshalledFunction as d,ArcadeFunction as h,wrapModuleScopedResponse as m}from"./FunctionWrapper.js";import{R as g,I as y,q as b,i as v,z as x,A as S,B as F,v as k,x as I,s as j,u as O,w as M,y as R,r as A,j as N,k as C,m as E,h as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as G}from"./treeAnalysis.js";import{A as U}from"../chunks/aiServices.js";import{A as K}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as _}from"./functions/feature.js";import{registerFunctions as D}from"./functions/geomasync.js";import{registerFunctions as Z}from"./functions/geometry.js";import{registerFunctions as z}from"./functions/maths.js";import{registerFunctions as q}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import{registerFunctions as W}from"./functions/track.js";import"../core/has.js";import V from"../core/Logger.js";import T from"../geometry/Geometry.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as $,isBoolean as H,isString as J,isArray as Q,isNumber as X}from"../support/guards.js";const ee=()=>V.getLogger("esri.arcade.arcadeAsyncRuntime"),te=Symbol("uninitialized");function ne(e){if(e===te)throw new u(null,"InvalidIdentifier",null)}function re(e){return ne(e),e}function oe(t,n){const r=e(n);if(null!==t.localScope){const e=t.localScope[r];if(void 0!==e)return{scope:t.localScope,id:r,var:e}}const o=t.globalScope[r];if(void 0!==o)return{scope:t.globalScope,id:r,var:o};throw new u(t,"InvalidIdentifier",n)}function ae(t,n,r="InvalidIdentifier"){const o=e(n);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return ne(e),e.value}const a=t.globalScope[o];if(void 0!==a)return ne(a),a.value;throw new u(t,r,n)}const ie=function(){};async function se(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await we(e,t.arguments[r]));return n}async function ce(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await se(e,t))}ie.prototype=Object.freeze(Object.create(null));class le extends h{constructor(e,t,n,r){super(),this.definition=e,this.context=t,this._params=n,this._locals=r}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,services:this.context.services,abortSignal:this.context.abortSignal,localScope:new ie,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(n.depthCounter.depth>64)throw new u(e,"MaximumCallDepth",null);return ue(n,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return pe(e,t,(n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:new ie,abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},track:e.track};if(a.depthCounter.depth>64)throw new u(e,"MaximumCallDepth",t);return ue(a,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,n,r){return r(e,t,async(o,a,i)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:new ie,track:e.track};return i=i.map(t=>!v(t)||t instanceof d?t:m(t,e,r)),m(await ue(s,this.definition.body,this._params,this._locals,i,t),n,r)})}}async function ue(e,t,n,r,o,a){if(n.length!==o.length)throw new u(e,"WrongNumberOfParameters",a);if(null!=e.localScope){for(let t=0;t<n.length;t++)e.localScope[n[t]]={value:o[t]};for(const t of r)e.localScope[t]=te}const i=await de(e,t);if(i instanceof g)return i.value;if(i===x)throw new u(e,"UnexpectedToken",a);if(i===S)throw new u(e,"UnexpectedToken",a);return i instanceof y?i.value:i}class fe extends n{constructor(e){super(),this.moduleGlobalContext=e}global(t){const n=e(t),r=this.moduleGlobalContext.globalScope[n];if(ne(r),v(r.value)&&!(r.value instanceof d)){const e=new d;return e.fn=r.value,e.parameterEvaluator=ce,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[n]={value:e},e}return r.value}setGlobal(t,n){if(v(n))throw new u(null,"AssignModuleFunction",null);const r=e(t);if(void 0===this.moduleGlobalContext.globalScope[r])throw new u(null,"ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[r]={value:n}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static async load(e,n){const{globals:a,exports:i}=o(n),s=new Xe;for(const t of a)t in s||(s[t]=te);const c=e.spatialReference??Y.WebMercator,l={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:c,track:null,depthCounter:{depth:1},libraryResolver:new r(e.libraryResolver._moduleSingletons,n.loadedModules),exports:i,localScope:null,globalScope:s};return await Ae(l,n),new fe(l)}}async function pe(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await se(e,t))}async function we(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await Ie(e,t);case"AssignmentExpression":return await Oe(e,t);case"TemplateLiteral":return await We(e,t);case"Identifier":return qe(e,t);case"MemberExpression":return await Le(e,t);case"Literal":return t.value;case"CallExpression":return await Pe(e,t);case"UnaryExpression":return await _e(e,t);case"BinaryExpression":return await Ze(e,t);case"LogicalExpression":return await ze(e,t);case"ArrayExpression":return await De(e,t);case"ObjectExpression":return await he(e,t);default:throw new u(e,"Unrecognized",t)}}catch(n){throw f(e,t,n)}}async function de(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await Be(e,t);case"ExportNamedDeclaration":return await Ge(e,t);case"VariableDeclaration":return await Ue(e,t);case"BlockStatement":return await Ae(e,t);case"FunctionDeclaration":return await Ee(e,t);case"ReturnStatement":return await Ce(e,t);case"IfStatement":return await Re(e,t);case"ExpressionStatement":return await Me(e,t);case"ForStatement":return await ge(e,t);case"WhileStatement":return await me(e,t);case"ForInStatement":return await Fe(e,t);case"ForOfStatement":return await ke(e,t);case"BreakStatement":return x;case"EmptyStatement":return k;case"ContinueStatement":return S;default:throw new u(e,"Unrecognized",t)}}catch(n){throw f(e,t,n)}}async function he(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await we(e,r.value),a="Identifier"===r.key.type?r.key.name:await we(e,r.key);n[i]={key:a,value:o}}const r=Object.create(null),o=new Map;for(let i=0;i<n.length;i++){const a=n[i];if(v(a.value))throw new u(e,"NoFunctionInDictionary",t);if(!1===J(a.key))throw new u(e,"KeyMustBeString",t);let s=a.key.toString();const c=s.toLowerCase();o.has(c)?s=o.get(c):o.set(c,s),a.value===k?r[s]=null:r[s]=a.value}const a=new l(r);return a.immutable=!1,a}async function me(e,t){let n=await we(e,t.test);if(!1===n)return k;if(!0!==n)throw new u(e,"BooleanConditionRequired",t);for(;!0===n;){const r=await de(e,t.body);if(r===x)break;if(r instanceof g)return r;if(n=await we(e,t.test),!0!==n&&!1!==n)throw new u(e,"BooleanConditionRequired",t)}return k}async function ge(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await de(e,t.init):await we(e,t.init));;){if(null!==t.test){const n=await we(e,t.test);if(!0===e.abortSignal?.aborted)throw new u(e,"Cancelled",t);if(!1===n)break;if(!0!==n)throw new u(e,"BooleanConditionRequired",t)}const n=await de(e,t.body);if(n===x)break;if(n instanceof g)return n;null!==t.update&&await we(e,t.update)}return k}catch(n){throw n}}async function ye(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new u(e,"OutOfBounds",t);r.scope[r.id]={value:n[i]}}else r.scope[r.id]={value:i};const a=await de(e,t.body);if(a===x)break;if(a instanceof g)return a}return k}async function be(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.scope[r.id]="k"===o?{value:n.get(i)}:{value:i};const a=await de(e,t.body);if(a===x)break;if(a instanceof g)return a}return k}async function ve(e,t,n,r){const o=n.iterator(e.abortSignal);let a;for(;null!=(a=await o.next());){const o=p.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone);o._underlyingGraphic=a,r.scope[r.id]={value:o};const i=await de(e,t.body);if(i===x)break;if(i instanceof g)return i}return k}async function xe(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.scope[r.id]={value:l.containerEntry(o,a)};const i=await de(e,t.body);if(i===x)break;if(i instanceof g)return i}return k}async function Se(e,t,n,r){for(const o of c(n)){const a=s(n,o,e,t,1);r.scope[r.id]={value:l.containerEntry(o,a)};const i=await de(e,t.body);if(i===x)break;if(i instanceof g)return i}return k}async function Fe(e,t){const n=await we(e,t.right);"VariableDeclaration"===t.left.type&&await de(e,t.left);const r=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return Q(n)||J(n)?await ye(e,t,n,r):N(n)?await be(e,t,n,r):n instanceof l||A(n)?await ye(e,t,n.keys(),r,"k"):E(n)?await ve(e,t,n,r):B(n)?await ye(e,t,c(n),r,"k"):k}async function ke(e,t){const n=await we(e,t.right);"VariableDeclaration"===t.left.type&&await de(e,t.left);const r=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return Q(n)||J(n)?await ye(e,t,n,r,"k"):N(n)?await be(e,t,n,r,"k"):n instanceof l||A(n)?await xe(e,t,n,r):E(n)?await ve(e,t,n,r):B(n)?await Se(e,t,n,r):k}async function Ie(e,t){const n=t.argument;if("CallExpression"===n.type)throw new u(e,"NeverReach",t);if("MemberExpression"===n.type){const r=await we(e,n.object);let o,a;if(!0===n.computed)o=await we(e,n.property);else{if("Identifier"!==n.property.type)throw new u(e,"Unrecognized",t);o=n.property.name}if(Q(r)){if(!X(o))throw new u(e,"ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>=r.length)throw new u(e,"OutOfBounds",t);a=j(r[o]),r[o]="++"===t.operator?a+1:a-1}else if(r instanceof l){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new u(e,"FieldNotFound",t,{key:o});a=j(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}else if(r instanceof fe){if(!1===J(o))throw new u(e,"ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new u(e,"ModuleExportNotFound",t);a=j(r.global(o)),r.setGlobal(o,"++"===t.operator?a+1:a-1)}else{if(!C(r))throw N(r)?new u(e,"Immutable",t):new u(e,"InvalidParameter",t);if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new u(e,"FieldNotFound",t,{key:o});a=j(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}return!1===t.prefix?a:"++"===t.operator?a+1:a-1}const r=oe(e,n),o=j(re(r.var).value),a="++"===t.operator?o+1:o-1;return r.scope[r.id]={value:a},!1===t.prefix?o:"++"===t.operator?o+1:o-1}function je(e,t,n,r,o){switch(t){case"=":return e===k?null:e;case"/=":return j(n)/j(e);case"*=":return j(n)*j(e);case"-=":return j(n)-j(e);case"+=":return J(n)||J(e)?O(n)+O(e):j(n)+j(e);case"%=":return j(n)%j(e);default:throw new u(o,"UnsupportedOperator",r)}}async function Oe(e,t){const n=t.left;if("MemberExpression"===n.type){const r=await we(e,n.object);let o;if(!0===n.computed)o=await we(e,n.property);else{if("Identifier"!==n.property.type)throw new u(e,"InvalidIdentifier",t);o=n.property.name}const a=await we(e,t.right);if(Q(r)){if(!X(o))throw new u(e,"ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>r.length)throw new u(e,"OutOfBounds",t);if(o===r.length){if("="!==t.operator)throw new u(e,"OutOfBounds",t);r[o]=je(a,t.operator,r[o],t,e)}else r[o]=je(a,t.operator,r[o],t,e)}else if(r instanceof l){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,je(a,t.operator,r.field(o),t,e));else{if("="!==t.operator)throw new u(e,"FieldNotFound",t,{key:o});r.setField(o,je(a,t.operator,null,t,e))}}else if(r instanceof fe){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new u(e,"ModuleExportNotFound",t);r.setGlobal(o,je(a,t.operator,r.global(o),t,e))}else{if(!C(r))throw N(r)?new u(e,"Immutable",t):new u(e,"InvalidParameter",t);if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,je(a,t.operator,r.field(o),t,e));else{if("="!==t.operator)throw new u(e,"FieldNotFound",t,{key:o});r.setField(o,je(a,t.operator,null,t,e))}}return k}const r=oe(e,n),o=await we(e,t.right);return r.scope[r.id]={value:je(o,t.operator,"="!==t.operator?re(r.var).value:null,t,e)},k}async function Me(e,t){const n=await we(e,t.expression);return n===k?k:new y(n)}async function Re(e,t){const n=await we(e,t.test);if(!0===n)return de(e,t.consequent);if(!1===n)return null!==t.alternate?de(e,t.alternate):k;throw new u(e,"BooleanConditionRequired",t)}async function Ae(e,t){return Ne(e,t,0)}async function Ne(e,t,n){if(n>=t.body.length)return k;const r=await de(e,t.body[n]);return r instanceof g||r===x||r===S||n===t.body.length-1?r:Ne(e,t,n+1)}async function Ce(e,t){if(null===t.argument)return new g(k);const n=await we(e,t.argument);return new g(n)}async function Ee(t,n){if(null!=t.localScope)throw ee().error("Function declarations are only valid in global scope."),new u(t,"NeverReach",n);const r=e(n.id);if(!(r in t.globalScope))throw ee().error(`Function "${r}" not declared.`),new u(t,"NeverReach",n);const o=a(n),i=n.params.map(t=>e(t)),s=Array.from(o).filter(e=>!i.includes(e));return t.globalScope[r]={value:new le(n,t,i,s)},k}async function Be(e,t){const n=oe(e,t.specifiers[0].local),r=e.libraryResolver;if(null==r)throw ee().error("Internal error: module loader not initialized"),new u(e,"NeverReach",t);const o=r.loadLibrary(n.id);let a;return r._moduleSingletons?.has(o.uri)?a=r._moduleSingletons.get(o.uri):(a=await fe.load(e,o.syntax),r._moduleSingletons?.set(o.uri,a)),n.scope[n.id]={value:a},k}async function Ge(e,t){return await de(e,t.declaration),k}async function Ue(e,t){for(const n of t.declarations)await Ke(e,n);return k}async function Ke(e,t){let n=null;n=null===t.init?null:await we(e,t.init),n===k&&(n=null);const r=oe(e,t.id);r.scope[r.id]={value:n}}async function Le(e,t){const n=await we(e,t.object);if(null===n)throw new u(e,"MemberOfNull",t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||A(n))return n.field(t.property.name);if(n instanceof T)return s(n,t.property.name,e,t);if(n instanceof fe){if(!n.hasGlobal(t.property.name))throw new u(e,"InvalidIdentifier",t);return n.global(t.property.name)}throw new u(e,"InvalidMemberAccessKey",t)}throw new u(e,"InvalidMemberAccessKey",t)}let r=await we(e,t.property);if(n instanceof l||A(n)){if(J(r))return n.field(r);throw new u(e,"InvalidMemberAccessKey",t)}if(n instanceof fe){if(J(r))return n.global(r);throw new u(e,"InvalidMemberAccessKey",t)}if(n instanceof T){if(J(r))return s(n,r,e,t);throw new u(e,"InvalidMemberAccessKey",t)}if(Q(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new u(e,"OutOfBounds",t);return n[r]}throw new u(e,"InvalidMemberAccessKey",t)}if(N(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new u(e,"OutOfBounds",t);return n.get(r)}throw new u(e,"InvalidMemberAccessKey",t)}if(J(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new u(e,"OutOfBounds",t);return n[r]}throw new u(e,"InvalidMemberAccessKey",t)}throw new u(e,"InvalidMemberAccessKey",t)}async function _e(e,t){const n=await we(e,t.argument);if(H(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*j(n);if("+"===t.operator)return 1*j(n);if("~"===t.operator)return~j(n);throw new u(e,"UnsupportUnaryOperator",t)}if("-"===t.operator)return-1*j(n);if("+"===t.operator)return 1*j(n);if("~"===t.operator)return~j(n);throw new u(e,"UnsupportUnaryOperator",t)}async function De(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await we(e,t.elements[r]));for(let r=0;r<n.length;r++){if(v(n[r]))throw new u(e,"NoFunctionInArray",t);n[r]===k&&(n[r]=null)}return n}async function Ze(e,t){const n=await we(e,t.left),r=await we(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return R(j(n),j(r),t.operator);case"==":return I(n,r);case"!=":return!I(n,r);case"<":case">":case"<=":case">=":return M(n,r,t.operator);case"+":return J(n)||J(r)?O(n)+O(r):j(n)+j(r);case"-":return j(n)-j(r);case"*":return j(n)*j(r);case"/":return j(n)/j(r);case"%":return j(n)%j(r);default:throw new u(e,"UnsupportedOperator",t)}}async function ze(e,t){const n=await we(e,t.left);if(!H(n))throw new u(e,"LogicalExpressionOnlyBoolean",t);switch(t.operator){case"||":{if(!0===n)return n;const r=await we(e,t.right);if(H(r))return r;throw new u(e,"LogicExpressionOrAnd",t)}case"&&":{if(!1===n)return n;const r=await we(e,t.right);if(H(r))return r;throw new u(e,"LogicExpressionOrAnd",t)}default:throw new u(e,"LogicExpressionOrAnd",t)}}function qe(e,t){return ae(e,t)}async function Pe(e,t){if("MemberExpression"===t.callee.type){const n=await we(e,t.callee.object);if(!(n instanceof fe))throw new u(e,"FunctionNotFound",t);const r=!1===t.callee.computed?t.callee.property.name:await we(e,t.callee.property);if(!n.hasGlobal(r))throw new u(e,"FunctionNotFound",t);const o=n.global(r);if(!v(o))throw new u(e,"CallNonFunction",t);return o.call(e,t)}if("Identifier"!==t.callee.type)throw new u(e,"FunctionNotFound",t);const n=ae(e,t.callee,"FunctionNotFound");if(v(n))return n.call(e,t);throw new u(e,"CallNonFunction",t)}async function We(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await we(e,t.expressions[r]);if(v(o))throw new u(e,"NoFunctionInTemplateLiteral",t);n+=O(o)}r++}return n}async function Ve(e,t){F(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await we(e,t.arguments[0]);if(!1===H(n))throw new u(e,"BooleanConditionRequired",t);return we(e,n?t.arguments[1]:t.arguments[2])}async function Te(e,t){F(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await we(e,t.arguments[0]);if(3===t.arguments.length){const r=await we(e,t.arguments[1]),o=i(n,r);return null!=o&&""!==o?o:we(e,t.arguments[2])}return null==n||""===n?we(e,t.arguments[1]):n}async function Ye(e,t){if(t.arguments.length<2)throw new u(e,"WrongNumberOfParameters",t);if(2===t.arguments.length)return we(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new u(e,"WrongNumberOfParameters",t);return $e(e,t,1,await we(e,t.arguments[0]))}async function $e(e,t,n,r){const o=await we(e,t.arguments[n]);if(I(o,r))return we(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?we(e,t.arguments[n]):2===a?null:3===a?we(e,t.arguments[n+2]):$e(e,t,n+2,r)}async function He(e,t){if(t.arguments.length<3)throw new u(e,"WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new u(e,"WrongNumberOfParameters",t);const n=await we(e,t.arguments[0]);if(!1===H(n))throw new u(e,"BooleanConditionRequired",t.arguments[0]);return Je(e,t,0,n)}async function Je(e,t,n,r){if(!0===r)return we(e,t.arguments[n+1]);if(3===t.arguments.length-n)return we(e,t.arguments[n+2]);const o=await we(e,t.arguments[n+2]);if(!1===H(o))throw new u(e,"ModuleExportNotFound",t.arguments[n+2]);return Je(e,t,n+2,o)}function Qe(){const e=Object.create(null);L(e,ce),P(e,ce),_(e,ce,qe),z(e,ce),Z(e,ce),q(e,ce),W(e,ce),D({functions:e,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:ce,standardFunctionAsync:pe}),e.iif=Ve,e.defaultvalue=Te,e.decode=Ye,e.when=He;const t=function(){this.textformatting={value:l.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[n,r]of Object.entries(e))t.prototype[n]=Object.freeze({value:new w(r)});return t}const Xe=Qe();function et(e){const t={mode:"async",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:ce,standardFunctionAsync:pe,evaluateIdentifier:qe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const[n,r]of Object.entries(t.functions))Xe.prototype[n]=Object.freeze({value:new w(r)});for(let n=0;n<t.signatures.length;n++)G(t.signatures[n],"async")}function tt(e){console.log(e)}function nt(n,a){const i=new Set(Object.keys(a?.vars||{}).map(t=>e(t))),s=new Set(Object.keys(a?.customfunctions||{}).map(t=>e(t))),{globals:c,exports:l}=o(n);return async e=>{const o=e.spatialReference??Y.WebMercator;let a=null;n.usesModules&&(a=new r(new Map,n.loadedModules));const f=new Xe;for(const t of s)null!=e.customfunctions&&t in e.customfunctions?f[t]={value:new w(e.customfunctions[t])}:f[t]=te;for(const t of i){if(null==e.vars||!(t in e.vars)){t in f||(f[t]=te);continue}const n=e.vars[t]??null;$(n)?f[t]={value:p.createFromGraphic(n,e.timeZone??null)}:f[t]={value:n}}for(const t of c)t in f||(f[t]=te);const d={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:a,exports:l,localScope:null,globalScope:f},h=await Ae(d,n);if(h instanceof g||h instanceof y){const e=h.value;if(b(e))return null;if(v(e))throw new u(d,"IllegalResult",null);return e}if(b(h))return null;if(h===x)throw new u(d,"IllegalResult",null);if(h===S)throw new u(d,"IllegalResult",null);throw new u(d,"NeverReach",null)}}function rt(e,t){return nt(e,t)(t)}et([K]),et([U]);export{rt as executeScript,et as extend,nt as prepareScript};
|
|
5
|
+
import{toSymbolId as e,neverAbortedSignal as t}from"./arcadeEnvironment.js";import{ArcadeModule as n}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as o,collectDeclaredLocalNames as a}from"./compilerUtils.js";import{getNestedOptionalValue as i,geometryMember as s,getGeometryKeys as c}from"./containerUtils.js";import l from"./Dictionary.js";import{ArcadeExecutionError as u,ensureArcadeExecutionError as f}from"./executionError.js";import{Feature as p}from"./Feature.js";import{NativeFunction as w,ScopeMarshalledFunction as d,ArcadeFunction as h,wrapModuleScopedResponse as m}from"./FunctionWrapper.js";import{R as g,I as y,q as b,i as v,z as S,A as x,B as F,v as k,x as I,s as j,u as O,w as M,y as R,r as A,j as N,k as C,m as E,h as B}from"../chunks/languageUtils.js";import{addFunctionDeclaration as G}from"./treeAnalysis.js";import{A as U}from"../chunks/aiServices.js";import{A as K}from"../chunks/array.js";import{registerFunctions as L}from"./functions/date.js";import{registerFunctions as D}from"./functions/feature.js";import{registerFunctions as _}from"./functions/geomasync.js";import{registerFunctions as Z}from"./functions/geometry.js";import{registerFunctions as z}from"./functions/maths.js";import{registerFunctions as q}from"./functions/stats.js";import{registerFunctions as P}from"./functions/string.js";import{registerFunctions as W}from"./functions/track.js";import"../core/has.js";import V from"../core/Logger.js";import T from"../geometry/Geometry.js";import Y from"../geometry/SpatialReference.js";import{isGraphic as $,isBoolean as H,isString as J,isArray as Q,isNumber as X}from"../support/guards.js";const ee=()=>V.getLogger("esri.arcade.arcadeAsyncRuntime"),te=Symbol("uninitialized");function ne(e){if(e===te)throw new u(null,"InvalidIdentifier",null)}function re(e){return ne(e),e}function oe(t,n){const r=e(n);if(null!==t.localScope){const e=t.localScope[r];if(void 0!==e)return{scope:t.localScope,id:r,var:e}}const o=t.globalScope[r];if(void 0!==o)return{scope:t.globalScope,id:r,var:o};throw new u(t,"InvalidIdentifier",n)}function ae(t,n,r="InvalidIdentifier"){const o=e(n);if(null!==t.localScope){const e=t.localScope[o];if(void 0!==e)return ne(e),e.value}const a=t.globalScope[o];if(void 0!==a)return ne(a),a.value;throw new u(t,r,n)}const ie=function(){};async function se(e,t){const n=[];for(let r=0;r<t.arguments.length;r++)n.push(await we(e,t.arguments[r]));return n}async function ce(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await se(e,t))}ie.prototype=Object.freeze(Object.create(null));class le extends h{constructor(e,t,n,r){super(),this.definition=e,this.context=t,this._params=n,this._locals=r}createFunction(e){return(...t)=>{const n={spatialReference:this.context.spatialReference,console:this.context.console,lrucache:this.context.lrucache,timeZone:this.context.timeZone??null,exports:this.context.exports,libraryResolver:this.context.libraryResolver,interceptor:this.context.interceptor,services:this.context.services,abortSignal:this.context.abortSignal,localScope:new ie,depthCounter:{depth:e.depthCounter.depth+1},globalScope:this.context.globalScope,track:this.context.track};if(n.depthCounter.depth>64)throw new u(e,"MaximumCallDepth",null);return ue(n,this.definition.body,this._params,this._locals,t,null)}}call(e,t){return pe(e,t,(n,r,o)=>{const a={spatialReference:e.spatialReference,services:e.services,console:e.console,libraryResolver:e.libraryResolver,exports:e.exports,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:new ie,abortSignal:e.abortSignal,globalScope:e.globalScope,depthCounter:{depth:e.depthCounter.depth+1},track:e.track};if(a.depthCounter.depth>64)throw new u(e,"MaximumCallDepth",t);return ue(a,this.definition.body,this._params,this._locals,o,t)})}marshalledCall(e,t,n,r){return r(e,t,async(o,a,i)=>{const s={spatialReference:e.spatialReference,services:e.services,globalScope:n.globalScope,depthCounter:{depth:e.depthCounter.depth+1},libraryResolver:e.libraryResolver,exports:e.exports,console:e.console,abortSignal:e.abortSignal,lrucache:e.lrucache,timeZone:e.timeZone??null,interceptor:e.interceptor,localScope:new ie,track:e.track};return i=i.map(t=>!v(t)||t instanceof d?t:m(t,e,r)),m(await ue(s,this.definition.body,this._params,this._locals,i,t),n,r)})}}async function ue(e,t,n,r,o,a){if(n.length!==o.length)throw new u(e,"WrongNumberOfParameters",a);if(null!=e.localScope){for(let t=0;t<n.length;t++)e.localScope[n[t]]={value:o[t]};for(const t of r)e.localScope[t]=te}const i=await de(e,t);if(i instanceof g)return i.value;if(i===S)throw new u(e,"UnexpectedToken",a);if(i===x)throw new u(e,"UnexpectedToken",a);return i instanceof y?i.value:i}class fe extends n{constructor(e){super(),this.moduleGlobalContext=e}global(t){const n=e(t),r=this.moduleGlobalContext.globalScope[n];if(ne(r),v(r.value)&&!(r.value instanceof d)){const e=new d;return e.fn=r.value,e.parameterEvaluator=ce,e.context=this.moduleGlobalContext,this.moduleGlobalContext.globalScope[n]={value:e},e}return r.value}setGlobal(t,n){if(v(n))throw new u(null,"AssignModuleFunction",null);const r=e(t);if(void 0===this.moduleGlobalContext.globalScope[r])throw new u(null,"ModuleExportNotFound",null);this.moduleGlobalContext.globalScope[r]={value:n}}hasGlobal(t){return this.moduleGlobalContext.exports.has(e(t))}static async load(e,n){const{globals:a,exports:i}=o(n),s=new Xe;for(const t of a)t in s||(s[t]=te);const c=e.spatialReference??Y.WebMercator,l={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:c,track:null,depthCounter:{depth:1},libraryResolver:new r(e.libraryResolver._moduleSingletons,n.loadedModules),exports:i,localScope:null,globalScope:s};return await Ae(l,n),new fe(l)}}async function pe(e,t,n){if(!0===t.preparsed)return n(e,null,t.arguments);return n(e,t,await se(e,t))}async function we(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"UpdateExpression":return await Ie(e,t);case"AssignmentExpression":return await Oe(e,t);case"TemplateLiteral":return await We(e,t);case"Identifier":return qe(e,t);case"MemberExpression":return await Le(e,t);case"Literal":return t.value;case"CallExpression":return await Pe(e,t);case"UnaryExpression":return await De(e,t);case"BinaryExpression":return await Ze(e,t);case"LogicalExpression":return await ze(e,t);case"ArrayExpression":return await _e(e,t);case"ObjectExpression":return await he(e,t);default:throw new u(e,"Unrecognized",t)}}catch(n){throw f(e,t,n)}}async function de(e,t){t.breakpoint&&await t.breakpoint();try{switch(t.type){case"ImportDeclaration":return await Be(e,t);case"ExportNamedDeclaration":return await Ge(e,t);case"VariableDeclaration":return await Ue(e,t);case"BlockStatement":return await Ae(e,t);case"FunctionDeclaration":return await Ee(e,t);case"ReturnStatement":return await Ce(e,t);case"IfStatement":return await Re(e,t);case"ExpressionStatement":return await Me(e,t);case"ForStatement":return await ge(e,t);case"WhileStatement":return await me(e,t);case"ForInStatement":return await Fe(e,t);case"ForOfStatement":return await ke(e,t);case"BreakStatement":return S;case"EmptyStatement":return k;case"ContinueStatement":return x;default:throw new u(e,"Unrecognized",t)}}catch(n){throw f(e,t,n)}}async function he(e,t){const n=[];for(let i=0;i<t.properties.length;i++){const r=t.properties[i],o=await we(e,r.value),a="Identifier"===r.key.type?r.key.name:await we(e,r.key);n[i]={key:a,value:o}}const r=Object.create(null),o=new Map;for(let i=0;i<n.length;i++){const a=n[i];if(v(a.value))throw new u(e,"NoFunctionInDictionary",t);if(!1===J(a.key))throw new u(e,"KeyMustBeString",t);let s=a.key.toString();const c=s.toLowerCase();o.has(c)?s=o.get(c):o.set(c,s),a.value===k?r[s]=null:r[s]=a.value}const a=new l(r);return a.immutable=!1,a}async function me(e,t){let n=await we(e,t.test);if(!1===n)return k;if(!0!==n)throw new u(e,"BooleanConditionRequired",t);for(;!0===n;){const r=await de(e,t.body);if(r===S)break;if(r instanceof g)return r;if(n=await we(e,t.test),!0!==n&&!1!==n)throw new u(e,"BooleanConditionRequired",t)}return k}async function ge(e,t){try{for(null!==t.init&&("VariableDeclaration"===t.init.type?await de(e,t.init):await we(e,t.init));;){if(null!==t.test){const n=await we(e,t.test);if(!0===e.abortSignal?.aborted)throw new u(e,"Cancelled",t);if(!1===n)break;if(!0!==n)throw new u(e,"BooleanConditionRequired",t)}const n=await de(e,t.body);if(n===S)break;if(n instanceof g)return n;null!==t.update&&await we(e,t.update)}return k}catch(n){throw n}}async function ye(e,t,n,r,o="i"){const a=n.length;for(let i=0;i<a;i++){if("k"===o){if(i>=n.length)throw new u(e,"OutOfBounds",t);r.scope[r.id]={value:n[i]}}else r.scope[r.id]={value:i};const a=await de(e,t.body);if(a===S)break;if(a instanceof g)return a}return k}async function be(e,t,n,r,o="i"){const a=n.length();for(let i=0;i<a;i++){r.scope[r.id]="k"===o?{value:n.get(i)}:{value:i};const a=await de(e,t.body);if(a===S)break;if(a instanceof g)return a}return k}async function ve(e,t,n,r){e:for await(const o of await n.queryAll(e.abortSignal))for(const a of o){r.scope[r.id]={value:p.createFromGraphicLikeObject(a.geometry,a.attributes,n,e.timeZone)};const o=await de(e,t.body);if(o===S)break e;if(o instanceof g)return o}return k}async function Se(e,t,n,r){for(const o of n.keys()){const a=n.field(o);r.scope[r.id]={value:l.containerEntry(o,a)};const i=await de(e,t.body);if(i===S)break;if(i instanceof g)return i}return k}async function xe(e,t,n,r){for(const o of c(n)){const a=s(n,o,e,t,1);r.scope[r.id]={value:l.containerEntry(o,a)};const i=await de(e,t.body);if(i===S)break;if(i instanceof g)return i}return k}async function Fe(e,t){const n=await we(e,t.right);"VariableDeclaration"===t.left.type&&await de(e,t.left);const r=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return Q(n)||J(n)?await ye(e,t,n,r):N(n)?await be(e,t,n,r):n instanceof l||A(n)?await ye(e,t,n.keys(),r,"k"):E(n)?await ve(e,t,n,r):B(n)?await ye(e,t,c(n),r,"k"):k}async function ke(e,t){const n=await we(e,t.right);"VariableDeclaration"===t.left.type&&await de(e,t.left);const r=oe(e,"VariableDeclaration"===t.left.type?t.left.declarations[0].id:t.left);return Q(n)||J(n)?await ye(e,t,n,r,"k"):N(n)?await be(e,t,n,r,"k"):n instanceof l||A(n)?await Se(e,t,n,r):E(n)?await ve(e,t,n,r):B(n)?await xe(e,t,n,r):k}async function Ie(e,t){const n=t.argument;if("CallExpression"===n.type)throw new u(e,"NeverReach",t);if("MemberExpression"===n.type){const r=await we(e,n.object);let o,a;if(!0===n.computed)o=await we(e,n.property);else{if("Identifier"!==n.property.type)throw new u(e,"Unrecognized",t);o=n.property.name}if(Q(r)){if(!X(o))throw new u(e,"ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>=r.length)throw new u(e,"OutOfBounds",t);a=j(r[o]),r[o]="++"===t.operator?a+1:a-1}else if(r instanceof l){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new u(e,"FieldNotFound",t,{key:o});a=j(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}else if(r instanceof fe){if(!1===J(o))throw new u(e,"ModuleAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new u(e,"ModuleExportNotFound",t);a=j(r.global(o)),r.setGlobal(o,"++"===t.operator?a+1:a-1)}else{if(!C(r))throw N(r)?new u(e,"Immutable",t):new u(e,"InvalidParameter",t);if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasField(o))throw new u(e,"FieldNotFound",t,{key:o});a=j(r.field(o)),r.setField(o,"++"===t.operator?a+1:a-1)}return!1===t.prefix?a:"++"===t.operator?a+1:a-1}const r=oe(e,n),o=j(re(r.var).value),a="++"===t.operator?o+1:o-1;return r.scope[r.id]={value:a},!1===t.prefix?o:"++"===t.operator?o+1:o-1}function je(e,t,n,r,o){switch(t){case"=":return e===k?null:e;case"/=":return j(n)/j(e);case"*=":return j(n)*j(e);case"-=":return j(n)-j(e);case"+=":return J(n)||J(e)?O(n)+O(e):j(n)+j(e);case"%=":return j(n)%j(e);default:throw new u(o,"UnsupportedOperator",r)}}async function Oe(e,t){const n=t.left;if("MemberExpression"===n.type){const r=await we(e,n.object);let o;if(!0===n.computed)o=await we(e,n.property);else{if("Identifier"!==n.property.type)throw new u(e,"InvalidIdentifier",t);o=n.property.name}const a=await we(e,t.right);if(Q(r)){if(!X(o))throw new u(e,"ArrayAccessMustBeNumber",t);if(o<0&&(o=r.length+o),o<0||o>r.length)throw new u(e,"OutOfBounds",t);if(o===r.length){if("="!==t.operator)throw new u(e,"OutOfBounds",t);r[o]=je(a,t.operator,r[o],t,e)}else r[o]=je(a,t.operator,r[o],t,e)}else if(r instanceof l){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,je(a,t.operator,r.field(o),t,e));else{if("="!==t.operator)throw new u(e,"FieldNotFound",t,{key:o});r.setField(o,je(a,t.operator,null,t,e))}}else if(r instanceof fe){if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0!==r.hasGlobal(o))throw new u(e,"ModuleExportNotFound",t);r.setGlobal(o,je(a,t.operator,r.global(o),t,e))}else{if(!C(r))throw N(r)?new u(e,"Immutable",t):new u(e,"InvalidParameter",t);if(!1===J(o))throw new u(e,"KeyAccessorMustBeString",t);if(!0===r.hasField(o))r.setField(o,je(a,t.operator,r.field(o),t,e));else{if("="!==t.operator)throw new u(e,"FieldNotFound",t,{key:o});r.setField(o,je(a,t.operator,null,t,e))}}return k}const r=oe(e,n),o=await we(e,t.right);return r.scope[r.id]={value:je(o,t.operator,"="!==t.operator?re(r.var).value:null,t,e)},k}async function Me(e,t){const n=await we(e,t.expression);return n===k?k:new y(n)}async function Re(e,t){const n=await we(e,t.test);if(!0===n)return de(e,t.consequent);if(!1===n)return null!==t.alternate?de(e,t.alternate):k;throw new u(e,"BooleanConditionRequired",t)}async function Ae(e,t){return Ne(e,t,0)}async function Ne(e,t,n){if(n>=t.body.length)return k;const r=await de(e,t.body[n]);return r instanceof g||r===S||r===x||n===t.body.length-1?r:Ne(e,t,n+1)}async function Ce(e,t){if(null===t.argument)return new g(k);const n=await we(e,t.argument);return new g(n)}async function Ee(t,n){if(null!=t.localScope)throw ee().error("Function declarations are only valid in global scope."),new u(t,"NeverReach",n);const r=e(n.id);if(!(r in t.globalScope))throw ee().error(`Function "${r}" not declared.`),new u(t,"NeverReach",n);const o=a(n),i=n.params.map(t=>e(t)),s=Array.from(o).filter(e=>!i.includes(e));return t.globalScope[r]={value:new le(n,t,i,s)},k}async function Be(e,t){const n=oe(e,t.specifiers[0].local),r=e.libraryResolver;if(null==r)throw ee().error("Internal error: module loader not initialized"),new u(e,"NeverReach",t);const o=r.loadLibrary(n.id);let a;return r._moduleSingletons?.has(o.uri)?a=r._moduleSingletons.get(o.uri):(a=await fe.load(e,o.syntax),r._moduleSingletons?.set(o.uri,a)),n.scope[n.id]={value:a},k}async function Ge(e,t){return await de(e,t.declaration),k}async function Ue(e,t){for(const n of t.declarations)await Ke(e,n);return k}async function Ke(e,t){let n=null;n=null===t.init?null:await we(e,t.init),n===k&&(n=null);const r=oe(e,t.id);r.scope[r.id]={value:n}}async function Le(e,t){const n=await we(e,t.object);if(null===n)throw new u(e,"MemberOfNull",t);if(!1===t.computed){if("Identifier"===t.property.type){if(n instanceof l||A(n))return n.field(t.property.name);if(n instanceof T)return s(n,t.property.name,e,t);if(n instanceof fe){if(!n.hasGlobal(t.property.name))throw new u(e,"InvalidIdentifier",t);return n.global(t.property.name)}throw new u(e,"InvalidMemberAccessKey",t)}throw new u(e,"InvalidMemberAccessKey",t)}let r=await we(e,t.property);if(n instanceof l||A(n)){if(J(r))return n.field(r);throw new u(e,"InvalidMemberAccessKey",t)}if(n instanceof fe){if(J(r))return n.global(r);throw new u(e,"InvalidMemberAccessKey",t)}if(n instanceof T){if(J(r))return s(n,r,e,t);throw new u(e,"InvalidMemberAccessKey",t)}if(Q(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new u(e,"OutOfBounds",t);return n[r]}throw new u(e,"InvalidMemberAccessKey",t)}if(N(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length()+r),r>=n.length()||r<0)throw new u(e,"OutOfBounds",t);return n.get(r)}throw new u(e,"InvalidMemberAccessKey",t)}if(J(n)){if(X(r)&&isFinite(r)&&Math.floor(r)===r){if(r<0&&(r=n.length+r),r>=n.length||r<0)throw new u(e,"OutOfBounds",t);return n[r]}throw new u(e,"InvalidMemberAccessKey",t)}throw new u(e,"InvalidMemberAccessKey",t)}async function De(e,t){const n=await we(e,t.argument);if(H(n)){if("!"===t.operator)return!n;if("-"===t.operator)return-1*j(n);if("+"===t.operator)return 1*j(n);if("~"===t.operator)return~j(n);throw new u(e,"UnsupportUnaryOperator",t)}if("-"===t.operator)return-1*j(n);if("+"===t.operator)return 1*j(n);if("~"===t.operator)return~j(n);throw new u(e,"UnsupportUnaryOperator",t)}async function _e(e,t){const n=[];for(let r=0;r<t.elements.length;r++)n.push(await we(e,t.elements[r]));for(let r=0;r<n.length;r++){if(v(n[r]))throw new u(e,"NoFunctionInArray",t);n[r]===k&&(n[r]=null)}return n}async function Ze(e,t){const n=await we(e,t.left),r=await we(e,t.right);switch(t.operator){case"|":case"<<":case">>":case">>>":case"^":case"&":return R(j(n),j(r),t.operator);case"==":return I(n,r);case"!=":return!I(n,r);case"<":case">":case"<=":case">=":return M(n,r,t.operator);case"+":return J(n)||J(r)?O(n)+O(r):j(n)+j(r);case"-":return j(n)-j(r);case"*":return j(n)*j(r);case"/":return j(n)/j(r);case"%":return j(n)%j(r);default:throw new u(e,"UnsupportedOperator",t)}}async function ze(e,t){const n=await we(e,t.left);if(!H(n))throw new u(e,"LogicalExpressionOnlyBoolean",t);switch(t.operator){case"||":{if(!0===n)return n;const r=await we(e,t.right);if(H(r))return r;throw new u(e,"LogicExpressionOrAnd",t)}case"&&":{if(!1===n)return n;const r=await we(e,t.right);if(H(r))return r;throw new u(e,"LogicExpressionOrAnd",t)}default:throw new u(e,"LogicExpressionOrAnd",t)}}function qe(e,t){return ae(e,t)}async function Pe(e,t){if("MemberExpression"===t.callee.type){const n=await we(e,t.callee.object);if(!(n instanceof fe))throw new u(e,"FunctionNotFound",t);const r=!1===t.callee.computed?t.callee.property.name:await we(e,t.callee.property);if(!n.hasGlobal(r))throw new u(e,"FunctionNotFound",t);const o=n.global(r);if(!v(o))throw new u(e,"CallNonFunction",t);return o.call(e,t)}if("Identifier"!==t.callee.type)throw new u(e,"FunctionNotFound",t);const n=ae(e,t.callee,"FunctionNotFound");if(v(n))return n.call(e,t);throw new u(e,"CallNonFunction",t)}async function We(e,t){let n="",r=0;for(const o of t.quasis)if(n+=o.value?o.value.cooked:"",!1===o.tail){if(t.expressions[r]){const o=await we(e,t.expressions[r]);if(v(o))throw new u(e,"NoFunctionInTemplateLiteral",t);n+=O(o)}r++}return n}async function Ve(e,t){F(null===t.arguments?[]:t.arguments,3,3,e,t);const n=await we(e,t.arguments[0]);if(!1===H(n))throw new u(e,"BooleanConditionRequired",t);return we(e,n?t.arguments[1]:t.arguments[2])}async function Te(e,t){F(null===t.arguments?[]:t.arguments,2,3,e,t);const n=await we(e,t.arguments[0]);if(3===t.arguments.length){const r=await we(e,t.arguments[1]),o=i(n,r);return null!=o&&""!==o?o:we(e,t.arguments[2])}return null==n||""===n?we(e,t.arguments[1]):n}async function Ye(e,t){if(t.arguments.length<2)throw new u(e,"WrongNumberOfParameters",t);if(2===t.arguments.length)return we(e,t.arguments[1]);if((t.arguments.length-1)%2==0)throw new u(e,"WrongNumberOfParameters",t);return $e(e,t,1,await we(e,t.arguments[0]))}async function $e(e,t,n,r){const o=await we(e,t.arguments[n]);if(I(o,r))return we(e,t.arguments[n+1]);const a=t.arguments.length-n;return 1===a?we(e,t.arguments[n]):2===a?null:3===a?we(e,t.arguments[n+2]):$e(e,t,n+2,r)}async function He(e,t){if(t.arguments.length<3)throw new u(e,"WrongNumberOfParameters",t);if(t.arguments.length%2==0)throw new u(e,"WrongNumberOfParameters",t);const n=await we(e,t.arguments[0]);if(!1===H(n))throw new u(e,"BooleanConditionRequired",t.arguments[0]);return Je(e,t,0,n)}async function Je(e,t,n,r){if(!0===r)return we(e,t.arguments[n+1]);if(3===t.arguments.length-n)return we(e,t.arguments[n+2]);const o=await we(e,t.arguments[n+2]);if(!1===H(o))throw new u(e,"ModuleExportNotFound",t.arguments[n+2]);return Je(e,t,n+2,o)}function Qe(){const e=Object.create(null);L(e,ce),P(e,ce),D(e,ce,qe),z(e,ce),Z(e,ce),q(e,ce),W(e,ce),_({functions:e,compiled:!1,signatures:null,evaluateIdentifier:null,mode:"async",standardFunction:ce,standardFunctionAsync:pe}),e.iif=Ve,e.defaultvalue=Te,e.decode=Ye,e.when=He;const t=function(){this.textformatting={value:l.textFormatting()}};t.prototype=Object.create(null),t.prototype.infinity=Object.freeze({value:Number.POSITIVE_INFINITY}),t.prototype.pi=Object.freeze({value:Math.PI});for(const[n,r]of Object.entries(e))t.prototype[n]=Object.freeze({value:new w(r)});return t}const Xe=Qe();function et(e){const t={mode:"async",compiled:!1,functions:Object.create(null),signatures:[],standardFunction:ce,standardFunctionAsync:pe,evaluateIdentifier:qe};for(let n=0;n<e.length;n++)e[n].registerFunctions(t);for(const[n,r]of Object.entries(t.functions))Xe.prototype[n]=Object.freeze({value:new w(r)});for(let n=0;n<t.signatures.length;n++)G(t.signatures[n],"async")}function tt(e){console.log(e)}function nt(n,a){const i=new Set(Object.keys(a?.vars||{}).map(t=>e(t))),s=new Set(Object.keys(a?.customfunctions||{}).map(t=>e(t))),{globals:c,exports:l}=o(n);return async e=>{const o=e.spatialReference??Y.WebMercator;let a=null;n.usesModules&&(a=new r(new Map,n.loadedModules));const f=new Xe;for(const t of s)null!=e.customfunctions&&t in e.customfunctions?f[t]={value:new w(e.customfunctions[t])}:f[t]=te;for(const t of i){if(null==e.vars||!(t in e.vars)){t in f||(f[t]=te);continue}const n=e.vars[t]??null;$(n)?f[t]={value:p.createFromGraphic(n,e.timeZone??null)}:f[t]={value:n}}for(const t of c)t in f||(f[t]=te);const d={lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??tt,abortSignal:e.abortSignal??t,timeZone:e.timeZone??null,spatialReference:o,track:e.track,depthCounter:{depth:1},libraryResolver:a,exports:l,localScope:null,globalScope:f},h=await Ae(d,n);if(h instanceof g||h instanceof y){const e=h.value;if(b(e))return null;if(v(e))throw new u(d,"IllegalResult",null);return e}if(b(h))return null;if(h===S)throw new u(d,"IllegalResult",null);if(h===x)throw new u(d,"IllegalResult",null);throw new u(d,"NeverReach",null)}}function rt(e,t){return nt(e,t)(t)}et([K]),et([U]);export{rt as executeScript,et as extend,nt as prepareScript};
|
package/arcade/arcadeCompiler.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toSymbolId as e,neverAbortedSignal as n}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as l,collectDeclaredLocalNames as o}from"./compilerUtils.js";import{getNestedOptionalValue as a,geometryMember as s,getGeometryKeys as i}from"./containerUtils.js";import u from"./Dictionary.js";import{ArcadeExecutionError as c,ArcadeCompilationError as m,ArcadeUncompilableError as f}from"./executionError.js";import{Feature as p}from"./Feature.js";import{NativeFunction as d,ArcadeFunction as g,ScopeMarshalledFunction as h,wrapModuleScopedResponse as y}from"./FunctionWrapper.js";import{p as w,q as b,i as v,r as $,j as S,k as x,s as F,u as M,v as O,w as I,x as C,y as j,h as A,n as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as N}from"./treeAnalysis.js";import{A as E}from"../chunks/aiServices.js";import{A as B}from"../chunks/array.js";import{registerFunctions as _}from"./functions/date.js";import{registerFunctions as V}from"./functions/feature.js";import{registerFunctions as L}from"./functions/geometry.js";import{registerFunctions as R}from"./functions/geomsync.js";import{registerFunctions as T}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{registerFunctions as G}from"./functions/track.js";import{neverReached as K}from"../core/compilerUtils.js";import q from"../core/Logger.js";import{isPromiseLike as P}from"../core/promiseUtils.js";import{addMany as z}from"../core/SetUtils.js";import W from"../geometry/Geometry.js";import Z from"../geometry/SpatialReference.js";import{isGraphic as J,isString as Y,isArray as H,isNumber as Q,isBoolean as X}from"../support/guards.js";const ee=()=>q.getLogger("esri.arcade.arcadeCompiler");class ne{constructor(){this._symbolCounter=0}nextVarId(){return this._symbolCounter+=1,`_T${this._symbolCounter}`}nextTempVarId(){return this._symbolCounter+=1,`_Tvar${this._symbolCounter}`}nextLocalsSymbolMapId(){return this._symbolCounter+=1,`_Locals${this._symbolCounter}`}}function te(e,n){const t=e.localScope?.get(n);if(null!=t)return{scope:"local",name:n,var:t};const r=e.globalScope.get(n);return null!=r?{scope:"global",name:n,var:r}:e.standardGlobals.has(n)?{scope:"global",name:n,var:n}:null}function re(n,t,r="InvalidIdentifier"){const l=te(n,e(t));if(null!=l)return l;throw new m(null,r,t)}function le(n,t,r){const l=te(n,e(t));if(null==l)throw ee().error(`Internal error: Symbol "${t.name}" not declared.`),new m(null,"NeverReach",t);if(null!=r&&l.scope!==r)throw ee().error(`Internal error: Expected to resolve "${t.name}" in the ${r} scope but is in the ${l.scope} scope.`),new m(null,"NeverReach",t);return l}function oe(n,t){const r=e(t),l=n.symbolMetadata;if(n.localStack.length>0){const e=n.localStack[n.localStack.length-1],t=l.locals.get(e._SymbolsMapId);if(null==t)return void ee().error(`Internal error: no reflection metadata for ${e._SymbolsMapId}`);const o=t.get(r);if(null!=o)return Qe.requireInitialized(e[o])}const o=l.globals.get(r);if(null!=o)return Qe.requireInitialized(n.globalScope[o]);if(l.standardGlobals.has(r))return Qe.requireInitialized(n.globalScope[r]);throw new c(null,"InvalidIdentifier",null)}class ae extends g{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new c(e,"WrongNumberOfParameters",null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,r){return r(e,n,(n,l,o)=>{o=o.map(n=>!v(n)||n instanceof h?n:y(n,e,r));const a=this.call(t,{arguments:o});return P(a)?a.then(e=>y(e,t,r)):a})}}function se(e,n,t){try{return t(e,null,n.arguments)}catch(r){throw r}}function ie(e,n,t,r,o,a){const{globals:s,exports:i}=l(e);z(s,t);const u=new ne,c=[],m=new Map;for(const l of s)if(t.has(l)||n.has(l))m.set(l,l);else{const e=u.nextVarId();m.set(l,e),c.push(`gscope[${JSON.stringify(e)}] = ${Ye};`)}const f=new Map,p=Object.create(null),d={isAsync:r,symbols:u,standardGlobals:n,globalScope:m,exports:i,localScope:null,allLocalSymbolMetadata:f,moduleFactory:a,moduleFactoryMap:p,libraryResolver:o};return{body:[...c,"var lastStatement = lc.voidOperation;",Fe(d,e),"return lastStatement;"].join("\n"),symbolMetadata:{standardGlobals:n,exports:i,globals:m,locals:f},moduleFactoryMap:p}}function ue(e,n){switch(n.type){case"AssignmentExpression":return ve(e,n);case"UpdateExpression":return we(e,n);case"TemplateLiteral":return Be(e,n);case"Identifier":return Le(e,n);case"MemberExpression":return ke(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Re(e,n);case"UnaryExpression":return Ne(e,n);case"BinaryExpression":return _e(e,n);case"LogicalExpression":return Ve(e,n);case"ArrayExpression":return Ee(e,n);case"ObjectExpression":return me(e,n);default:throw new m(null,"Unrecognized",n)}}function ce(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return je(e,n);case"BlockStatement":return Fe(e,n);case"FunctionDeclaration":return Ce(e,n);case"ImportDeclaration":return Oe(e,n);case"ExportNamedDeclaration":return ce(e,n.declaration);case"ReturnStatement":return Me(e,n);case"IfStatement":return xe(e,n);case"ExpressionStatement":return $e(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return ye(e,n);case"ForInStatement":return ge(e,n);case"ForOfStatement":return he(e,n);case"WhileStatement":return be(e,n);default:throw new m(null,"Unrecognized",n)}}function me(e,n){let t="lang.dictionary([";for(let r=0;r<n.properties.length;r++){const l=n.properties[r];let o;o="Identifier"===l.key.type?"'"+l.key.name+"'":ue(e,l.key);r>0&&(t+=","),t+="lang.strCheck("+o+",'ObjectExpression'),lang.aCheck("+ue(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function fe(e,n,t,r,l=(e,n)=>`${e} = ${n}`){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId();return[`var ${o} = ${t};`,`for (var ${a} = 0; ${a} < ${o}; ${a}++) {`,` ${l(n,a)}`,` ${ce(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function pe(e,n,t,r,l=e=>e){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId();return[`var ${o} = ${t};`,`for (var ${a} of ${o}) {`,` ${n} = ${l(a)};`,` ${ce(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function de(e,n,t,r){const l=e.symbols.nextTempVarId();return[`var ${l} = ${t}.iterator(runtimeCtx.abortSignal);`,`while ((${n} = lang.graphicToFeature(yield ${l}.next(), ${t}, runtimeCtx)) != null) {`,` ${ce(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function ge(e,n){const t=e.symbols.nextTempVarId();let r,l,o="var "+t+" = "+ue(e,n.right)+";\n";switch("VariableDeclaration"===n.left.type?(r=le(e,n.left.declarations[0].id),o+=ce(e,n.left)):r=re(e,n.left),r.scope){case"local":l=`lscope['${r.var}']`;break;case"global":l=`gscope['${r.var}']`;break;default:throw K(r.scope),new m(null,"NeverReach",n.left)}return o+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",o+="else if (lc.isArray("+t+") || lc.isString("+t+")) {\n",o+=fe(e,l,`${t}.length`,n.body),o+="}\n",o+="else if (lc.isImmutableArray("+t+")) {\n",o+=fe(e,l,`${t}.length()`,n.body),o+="}\n",o+="else if (( "+t+" instanceof lang.Dictionary) || lc.isDictionaryLike("+t+")) {\n",o+=pe(e,l,`${t}.keys()`,n.body),o+="}\n",e.isAsync&&(o+="else if (lc.isFeatureSet("+t+")) {\n",o+=de(e,l,t,n.body),o+="}\n"),o+=`else if (lc.isGeometry(${t})) {\n`,o+=pe(e,l,`lang.getGeometryKeys(${t})`,n.body),o+="}\n",o+="else { lastStatement = lc.voidOperation; } \n",o}function he(e,n){const t=e.symbols.nextTempVarId();let r,l,o="var "+t+" = "+ue(e,n.right)+";\n";switch("VariableDeclaration"===n.left.type?(r=le(e,n.left.declarations[0].id),o+=ce(e,n.left)):r=re(e,n.left),r.scope){case"local":l=`lscope['${r.var}']`;break;case"global":l=`gscope['${r.var}']`;break;default:throw K(r.scope),new m(null,"NeverReach",n.left)}return o+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",o+="else if (lc.isArray("+t+") || lc.isString("+t+")) {\n",o+=fe(e,l,`${t}.length`,n.body,(e,n)=>[`if (${n} >= ${t}.length) {`," lang.error('OutOfBounds');","}",`${e} = ${t}[${n}];`].join("\n")),o+="}\n",o+="else if (lc.isImmutableArray("+t+")) {\n",o+=fe(e,l,`${t}.length()`,n.body,(e,n)=>`${e} = ${t}.get(${n});`),o+="}\n",o+="else if (( "+t+" instanceof lang.Dictionary) || lc.isDictionaryLike("+t+")) {\n",o+=pe(e,l,`${t}.keys()`,n.body,e=>`lang.entry(${e}, ${t}.field(${e}))`),o+="}\n",e.isAsync&&(o+="else if (lc.isFeatureSet("+t+")) {\n",o+=de(e,l,t,n.body),o+="}\n"),o+=`else if (lc.isGeometry(${t})) {\n`,o+=pe(e,l,`lang.getGeometryKeys(${t})`,n.body,e=>`lang.entry(${e}, lang.geometryMember(${t}, ${e}, runtimeCtx, null, 1))`),o+="}\n",o+="else { lastStatement = lc.voidOperation; } \n",o}function ye(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=ce(e,n.init):t+=ue(e,n.init)+"; ");const r=e.symbols.nextTempVarId(),l=e.symbols.nextTempVarId();return t+="var "+r+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+r+"===false) {\n "+ue(e,n.update)+" \n}\n "+r+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+ue(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('BooleanConditionRequired'); }\n"),t+=ce(e,n.body),null!==n.update&&(t+="\n "+ue(e,n.update)),t+="\n"+r+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function we(e,n){if("CallExpression"===n.argument.type)throw new m(null,"NeverReach",n);let t;if("MemberExpression"===n.argument.type){const r=ue(e,n.argument.object);return t=!0===n.argument.computed?ue(e,n.argument.property):"'"+n.argument.property.name+"'","lang.memberupdate("+r+","+t+",'"+n.operator+"',"+n.prefix+")"}const r=re(e,n.argument);switch(Ie(r),r.scope){case"local":return`lang.update(lscope, '${r.var}', '${n.operator}', ${n.prefix})`;case"global":return`lang.update(gscope, '${r.var}', '${n.operator}', ${n.prefix})`;default:throw K(r.scope),new m(null,"NeverReach",n.argument)}}function be(e,n){let t="lastStatement = lc.voidOperation; \n";const r=e.symbols.nextTempVarId();return t+=`\n var ${r} = true;\n do {\n ${r} = ${ue(e,n.test)};\n if (${r}==false) {\n break;\n }\n if (${r}!==true) {\n lang.error('BooleanConditionRequired');\n }\n ${ce(e,n.body)}\n }\n while (${r} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ve(e,n){const t=ue(e,n.right);if("MemberExpression"===n.left.type){let r;const l=ue(e,n.left.object);return r=!0===n.left.computed?ue(e,n.left.property):"'"+n.left.property.name+"'","lang.assignmember("+l+","+r+",'"+n.operator+"',"+t+")"}const r=re(e,n.left);switch(Ie(r),r.scope){case"local":return`lscope['${r.var}']=lang.assign(${t},'${n.operator}', ${"="===n.operator?"null":He(`lscope['${r.var}']`)})`;case"global":return`gscope['${r.var}']=lang.assign(${t},'${n.operator}', ${"="===n.operator?"null":He(`gscope['${r.var}']`)})`;default:throw K(r.scope),new m(null,"NeverReach",n.left)}}function $e(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+ue(e,n.expression)+"; \n ":"lastStatement = "+ue(e,n.expression)+"; "}function Se(e,n){return"BlockStatement"===n.type?ce(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?ce(e,n)+"; ":"ExpressionStatement"===n.type?ce(e,n):ce(e,n)+"; "}function xe(e,n){return`if (lang.mustBoolean(${ue(e,n.test)}, runtimeCtx) === true) {\n ${Se(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+xe(e,n.alternate):` else {\n ${Se(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function Fe(e,n){let t="";for(let r=0;r<n.body.length;r++)"EmptyStatement"!==n.body[r].type&&("ReturnStatement"===n.body[r].type||"BreakStatement"===n.body[r].type||"ContinueStatement"===n.body[r].type?t+=ce(e,n.body[r])+"; \n":t+=ce(e,n.body[r])+" \n");return t}function Me(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+ue(e,n.argument)}function Oe(e,n){const t=le(e,n.specifiers[0].local,"global"),r=e.libraryResolver?.loadLibrary(t.name),l=e.symbols.nextVarId();void 0===e.moduleFactory[r.uri]&&(e.moduleFactory[r.uri]=rn(r.syntax,e.moduleFactory,e.isAsync)),e.moduleFactoryMap[l]=r.uri;let o="";return o=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",Ie(t),`gscope['${t.var}']=${o}`}function Ie(e){if("global"===e.scope)switch(e.name){case"iif":case"when":case"defaultvalue":case"decode":throw new f}}function Ce(n,t){const r=new Set(t.params.map(n=>e(n))),l=o(t);z(l,r);const a=n.symbols,s=new Map;for(const e of l)s.set(e,a.nextVarId());const i=a.nextLocalsSymbolMapId();n.allLocalSymbolMetadata.set(i,s);const u={...n,localScope:s},c=[`lscope._SymbolsMapId = ${JSON.stringify(i)};`];for(let e=0;e<t.params.length;e++){const n=le(u,t.params[e],"local");Ie(n),c.push(`lscope['${n.var}'] = arguments[${e}];`)}for(const[e,o]of s)r.has(e)||c.push(`lscope['${o}'] = ${Ye};`);const m=Fe(u,t.body),f=!0===n.isAsync?["return lang.__awaiter(this, void 0, void 0, function* () {",` ${m}`," return lastStatement;","});"]:[m,"return lastStatement;"],p=["new lang.UserDefinedCompiledFunction("," lang.functionDepthchecker("," function() {"," var lastStatement = lc.voidOperation;"," var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];",...c,...f," },"," runtimeCtx,"," ),",` ${t.params.length},`,")"].join("\n"),d=le(n,t.id,"global");return Ie(d),`gscope['${d.var}']=${p}; lastStatement = lc.voidOperation;`}function je(e,n){const t=[];for(let r=0;r<n.declarations.length;r++)t.push(Ae(e,n.declarations[r]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function Ae(e,n){const t=null===n.init?"null":ue(e,n.init),r=le(e,n.id);switch(Ie(r),r.scope){case"local":return`lscope['${r.var}']=${t};`;case"global":return`gscope['${r.var}']=${t};`;default:throw K(r.scope),new m(null,"NeverReach",n.id)}}function ke(e,n){try{let t;return t=!0===n.computed?ue(e,n.property):"'"+n.property.name+"'","lang.member("+ue(e,n.object)+","+t+")"}catch(t){throw t}}function Ne(e,n){try{return"lang.unary("+ue(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function Ee(e,n){try{const t=[];for(let r=0;r<n.elements.length;r++)"Literal"===n.elements[r].type?t.push(ue(e,n.elements[r])):t.push("lang.aCheck("+ue(e,n.elements[r])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function Be(e,n){try{const t=[];let r=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[r]?"lang.castString(lang.aCheck("+ue(e,n.expressions[r])+", 'TemplateLiteral'))":""),r++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function _e(e,n){try{return"lang.binary("+ue(e,n.left)+","+ue(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function Ve(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new m(null,"LogicalExpressionOnlyBoolean",n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new m(null,"LogicalExpressionOnlyBoolean",n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+ue(e,n.left)+") "+n.operator+" lang.logicalCheck("+ue(e,n.right)+"))";throw new m(null,"LogicExpressionOrAnd",null)}catch(t){throw t}}function Le(e,n){const t=re(e,n);switch(Ie(t),t.scope){case"local":return He(`lscope['${t.var}']`);case"global":return He(`gscope['${t.var}']`);default:throw K(t.scope),new m(null,"NeverReach",n)}}function Re(e,n){try{if("MemberExpression"===n.callee.type){let t;t=!0===n.callee.computed?ue(e,n.callee.property):"'"+n.callee.property.name+"'";let r="[";for(let l=0;l<n.arguments.length;l++)l>0&&(r+=", "),r+=ue(e,n.arguments[l]);return r+="]",e.isAsync?"(yield lang.callModuleFunction("+ue(e,n.callee.object)+","+r+","+t+",runtimeCtx))":"lang.callModuleFunction("+ue(e,n.callee.object)+","+r+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new m(null,"FunctionNotFound",n);const t=re(e,n.callee,"FunctionNotFound");if("global"===t.scope)switch(t.name){case"iif":return Te(e,n);case"when":return Ue(e,n);case"defaultvalue":return De(e,n);case"decode":return Ge(e,n)}let r;switch(t.scope){case"local":r=He(`lscope['${t.var}']`);break;case"global":r=He(`gscope['${t.var}']`);break;default:throw K(t.scope),new m(null,"NeverReach",n.callee)}let l="[";for(let o=0;o<n.arguments.length;o++)o>0&&(l+=", "),l+=ue(e,n.arguments[o]);return l+="]",e.isAsync?"(yield lang.callfunc("+r+","+l+",runtimeCtx) )":"lang.callfunc("+r+","+l+",runtimeCtx)"}catch(t){throw t}}function Te(e,n){try{if(3!==n.arguments.length)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${ue(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${ue(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function De(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId(),r=e.symbols.nextTempVarId();return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n var ${r} = ${ue(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${r});\n return ${t} != null && ${t} !== "" ? ${t} : ${ue(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n if (${t} === null) {\n return ${ue(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${ue(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${ue(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ue(e,n){try{if(n.arguments.length<3)throw new m(null,"WrongNumberOfParameters",n);if(n.arguments.length%2==0)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();let r="var ";for(let l=0;l<n.arguments.length-1;l+=2)r+=`${t} = lang.mustBoolean(${ue(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${ue(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${r}\n return ${ue(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ge(e,n){try{if(n.arguments.length<2)throw new m(null,"WrongNumberOfParameters",n);if(2===n.arguments.length)return`(${ue(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();let r;if(n.arguments.every((e,n)=>n%2==0||"Literal"===e.type)){r=`switch (${t}) {`;for(let t=1;t<n.arguments.length-1;t+=2){const l=n.arguments[t],o=n.arguments[t+1];null==l.value?r+="\n case null:\n case lc.voidOperation:\n ":r+=`\n case ${JSON.stringify(l.value)}:\n `,r+=`return ${ue(e,o)}`}r+="}"}else{const l=e.symbols.nextTempVarId();r="var ";for(let o=1;o<n.arguments.length-1;o+=2){const a=n.arguments[o],s=n.arguments[o+1];r+=`${l} = ${ue(e,a)};\n if (lang.binary(${l}, ${t}, "==") === true ) {\n return ${ue(e,s)}\n }\n `}}return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n ${r}\n return ${ue(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ke(e,n){try{return se(e,n,(e,n)=>{throw new c(e,"Unrecognized",n)})}catch(t){throw t}}function qe(e){const n=function(){this.textformatting=u.textFormatting()};n.prototype=Object.create(null),n.provided=new Set(["textformatting","infinity","pi"]),n.prototype.infinity=Number.POSITIVE_INFINITY,n.prototype.pi=Math.PI;for(const[t,r]of Object.entries(e))n.prototype[t]=new d(r),n.provided.add(t);return n}function Pe(){const e=Object.create(null);_(e,se),U(e,se),V(e,se,oe),T(e,se),L(e,se),D(e,se),G(e,se),e.iif=Ke,e.decode=Ke,e.when=Ke,e.defaultvalue=Ke;const n=qe(e);R(e,se);return{ScopeSync:qe(e),ScopeAsync:n}}const{ScopeSync:ze,ScopeAsync:We}=Pe();function Ze(e,n){const t={mode:n,compiled:!0,functions:Object.create(null),signatures:[],standardFunction:se,standardFunctionAsync:se,evaluateIdentifier:oe};for(const r of e)r.registerFunctions(t);if("sync"===n)for(const[r,l]of Object.entries(t.functions))ze.prototype[r]=new d(l),ze.provided.add(r);else for(const[r,l]of Object.entries(t.functions))We.prototype[r]=new d(l),We.provided.add(r);for(const r of t.signatures)N(r,n)}Ze([B],"sync"),Ze([B],"async"),Ze([E],"async");const Je=Symbol("uninitialized"),Ye="lang.uninitialized";function He(e){return`lang.requireInitialized(${e})`}const Qe={uninitialized:Je,requireInitialized(e){if(e===Je)throw new c(null,"InvalidIdentifier",null);return e},isNumber:e=>Q(e),isArray:e=>H(e),isImmutableArray:e=>S(e),isDictionaryLike:e=>$(e),isString:e=>Y(e),isDictionary:e=>k(e),isGeometry:e=>A(e),getGeometryKeys:e=>i(e),geometryMember:(e,n,t,r,l=1)=>s(e,n,t,r,l),error(e){throw new c(null,e,null)},__awaiter(e,n,t,r){const l=r.apply(e,n||[]);let o=l.next();for(;!o.done&&!P(o.value);)o=l.next(o.value);return o.done?o.value:new Promise((e,n)=>{function t(r){for(;!r.done;){if(P(r.value))return void Promise.resolve(r.value).then(e=>{try{t(l.next(e))}catch(r){n(r)}},e=>{try{t(l.throw(e))}catch(r){n(r)}});try{r=l.next(r.value)}catch(o){return void n(o)}}e(r.value)}t(o)})},functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new c(null,"MaximumCallDepth",null);const t=e.apply(this,arguments);return P(t)?t.then(e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e)):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new c(n,"BooleanConditionRequired",null)},castString:e=>M(e),aCheck(e,n){if(v(e)){if("ArrayExpression"===n)throw new c(null,"NoFunctionInArray",null);if("ObjectExpression"===n)throw new c(null,"NoFunctionInDictionary",null);throw new c(null,"NoFunctionInTemplateLiteral",null)}return e===O?null:e},Dictionary:u,Feature:p,UserDefinedCompiledFunction:ae,dictionary(e){const n=Object.create(null),t=new Map;for(let l=0;l<e.length;l+=2){if(v(e[l+1]))throw new c(null,"NoFunctionInDictionary",null);if(!1===Y(e[l]))throw new c(null,"KeyMustBeString",null);let r=e[l].toString();const o=r.toLowerCase();t.has(o)?r=t.get(o):t.set(o,r),e[l+1]===O?n[r]=null:n[r]=e[l+1]}const r=new u(n);return r.immutable=!1,r},entry:(e,n)=>u.containerEntry(e,n),strCheck(e){if(!1===Y(e))throw new c(null,"KeyMustBeString",null);return e},unary(e,n){if(X(e)){if("!"===n)return!e;if("-"===n)return-1*F(e);if("+"===n)return 1*F(e);if("~"===n)return~F(e);throw new c(null,"UnsupportUnaryOperator",null)}if("-"===n)return-1*F(e);if("+"===n)return 1*F(e);if("~"===n)return~F(e);throw new c(null,"UnsupportUnaryOperator",null)},logicalCheck(e){if(!1===X(e))throw new c(null,"LogicExpressionOrAnd",null);return e},logical(e,n,t){if(X(e)&&X(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new c(null,"LogicExpressionOrAnd",null)}throw new c(null,"LogicExpressionOrAnd",null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return j(F(e),F(n),t);case"==":case"=":return C(e,n);case"!=":return!C(e,n);case"<":case">":case"<=":case">=":return I(e,n,t);case"+":return Y(e)||Y(n)?M(e)+M(n):F(e)+F(n);case"-":return F(e)-F(n);case"*":return F(e)*F(n);case"/":return F(e)/F(n);case"%":return F(e)%F(n);default:throw new c(null,"UnsupportedOperator",null)}},assign(e,n,t){switch(n){case"=":return e===O?null:e;case"/=":return F(t)/F(e);case"*=":return F(t)*F(e);case"-=":return F(t)-F(e);case"+=":return Y(t)||Y(e)?M(t)+M(e):F(t)+F(e);case"%=":return F(t)%F(e);default:throw new c(null,"UnsupportedOperator",null)}},update(e,n,t,r){const l=F(this.requireInitialized(e[n]));return e[n]="++"===t?l+1:l-1,!1===r?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:p.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,r){let l;if(H(e)){if(!Q(n))throw new c(null,"ArrayAccessMustBeNumber",null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new c(null,"OutOfBounds",null);l=F(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof u){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0!==e.hasField(n))throw new c(null,"FieldNotFound",null,{key:n});l=F(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if(x(e)){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0!==e.hasField(n))throw new c(null,"FieldNotFound",null);l=F(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(S(e))throw new c(null,"Immutable",null);if(!(e instanceof tn))throw new c(null,"InvalidIdentifier",null);if(!1===Y(n))throw new c(null,"ModuleAccessorMustBeString",null);if(!0!==e.hasGlobal(n))throw new c(null,"ModuleExportNotFound",null);l=F(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===r?l:"++"===t?l+1:l-1},assignmember(e,n,t,r){if(H(e)){if(!Q(n))throw new c(null,"ArrayAccessMustBeNumber",null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new c(null,"OutOfBounds",null);if(n===e.length){if("="!==t)throw new c(null,"OutOfBounds",null);e[n]=this.assign(r,t,e[n])}else e[n]=this.assign(r,t,e[n])}else if(e instanceof u){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0===e.hasField(n))e.setField(n,this.assign(r,t,e.field(n)));else{if("="!==t)throw new c(null,"FieldNotFound",null);e.setField(n,this.assign(r,t,null))}}else if(x(e)){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0===e.hasField(n))e.setField(n,this.assign(r,t,e.field(n)));else{if("="!==t)throw new c(null,"FieldNotFound",null);e.setField(n,this.assign(r,t,null))}}else{if(S(e))throw new c(null,"Immutable",null);if(!(e instanceof tn))throw new c(null,"InvalidIdentifier",null);if(!1===Y(n))throw new c(null,"ModuleAccessorMustBeString",null);if(!e.hasGlobal(n))throw new c(null,"ModuleExportNotFound",null);e.setGlobal(n,this.assign(r,t,e.global(n)))}},member(e,n){if(null===e)throw new c(null,"MemberOfNull",null);if(e instanceof u||$(e)){if(Y(n))return e.field(n);throw new c(null,"InvalidMemberAccessKey",null)}if(e instanceof W){if(Y(n))return s(e,n,null,null);throw new c(null,"InvalidMemberAccessKey",null)}if(H(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new c(null,"OutOfBounds",null);return e[n]}throw new c(null,"InvalidMemberAccessKey",null)}if(Y(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new c(null,"OutOfBounds",null);return e[n]}throw new c(null,"InvalidMemberAccessKey",null)}if(S(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new c(null,"OutOfBounds",null);return e.get(n)}throw new c(null,"InvalidMemberAccessKey",null)}if(e instanceof tn){if(Y(n))return e.global(n);throw new c(null,"InvalidMemberAccessKey",null)}throw new c(null,"InvalidMemberAccessKey",null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const r=n.moduleFactory[t]({moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,console:n.console,abortSignal:n.abortSignal,timeZone:n.timeZone??null,spatialReference:n.spatialReference});return n.moduleSingletons[t]=r,r},callModuleFunction(e,n,t,r){if(!(e instanceof tn))throw new c(null,"FunctionNotFound",null);const l=e.global(t);if(!1===v(l))throw new c(null,"CallNonFunction",null);return l.call(r,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>a(e,n)};function Xe(e){console.log(e)}function en(t,l,o=!1){let a=null;t.usesModules&&(a=new r(null,t.loadedModules));const s=Object.create(null),i=new Set(Object.keys(l?.vars||{}).map(n=>e(n))),u=new Set(Object.keys(l?.customfunctions||{}).map(n=>e(n))),m=ie(t,o?We.provided:ze.provided,new Set([...i,...u]),o,a,s);let f;f=o?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${m.body}`," });"," }"," return this.postProcess(yield mainBody());","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${m.body}`,"}","return this.postProcess(mainBody());"].join("\n");const{symbolMetadata:d,moduleFactoryMap:g}=m,h={lc:w,lang:Qe,postProcess(e){if(b(e))return null;if(v(e))throw new c(null,"IllegalResult",null);return e},prepare(e,t){const r=e.spatialReference??Z.WebMercator,l=t?new We:new ze;for(const n of u)null!=e.customfunctions&&n in e.customfunctions?l[n]=e.customfunctions[n]??null:l[n]=Je;for(const n of i){if(null==e.vars||!(n in e.vars)){n in l||(l[n]=Je);continue}const t=e.vars[n]??null;J(t)?l[n]=p.createFromGraphic(t,e.timeZone??null):l[n]=t}return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??Xe,abortSignal:e.abortSignal??n,timeZone:e.timeZone??null,spatialReference:r,track:e.track,globalScope:l,localStack:[],depthCounter:{depth:1},symbolMetadata:d,moduleFactory:s,moduleFactoryMap:g,moduleSingletons:Object.create(null)}}};return new Function("context",f).bind(h)}async function nn(){return Ze([await import("./functions/geomasync.js")],"async"),!0}class tn extends t{constructor(e){super(),this.moduleContext=e}hasGlobal(n){const t=this.moduleContext.symbolMetadata.exports;return t.has(n)||t.has(e(n))}setGlobal(n,t){if(v(t))throw new c(null,"AssignModuleFunction",null);const r=this.moduleContext.symbolMetadata.globals.get(e(n));if(null==r)throw new c(null,"ModuleExportNotFound",null);this.moduleContext.globalScope[r]=t}global(n){const t=this.moduleContext.symbolMetadata.globals.get(e(n));if(null==t)throw new c(null,"ModuleExportNotFound",null);const r=this.moduleContext.globalScope,l=Qe.requireInitialized(r[t]);if(v(l)&&!(l instanceof h)){const e=new h;return e.fn=l,e.parameterEvaluator=se,e.context=this.moduleContext,r[t]=e,e}return l}}function rn(e,t,l){const o=new r(null,e.loadedModules),a=ie(e,l?We.provided:ze.provided,new Set,l,o,t);let s;s=l?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${a.body}`," });"," }"," yield mainBody();"," return this.prepareModule(runtimeCtx);","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${a.body}`,"}","mainBody();","return this.prepareModule(runtimeCtx);"].join("\n");const{symbolMetadata:i,moduleFactoryMap:u}=a,c={lc:w,lang:Qe,prepareModule:e=>new tn(e),prepare(e,r){const l=e.spatialReference??Z.WebMercator,o=r?new We:new ze;return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??Xe,abortSignal:e.abortSignal??n,timeZone:e.timeZone??null,spatialReference:l,track:null,globalScope:o,localStack:[],depthCounter:e.depthCounter,symbolMetadata:i,moduleFactory:t,moduleFactoryMap:u,moduleSingletons:e.moduleSingletons}}};return new Function("context",s).bind(c)}export{ae as UserDefinedCompiledFunction,en as compileScript,nn as enableAsyncSupport,Ze as extend};
|
|
5
|
+
import{toSymbolId as e,neverAbortedSignal as n}from"./arcadeEnvironment.js";import{ArcadeModule as t}from"./ArcadeModule.js";import{ArcadeModuleLoader as r}from"./ArcadeModuleLoader.js";import{collectDeclaredGlobalNames as l,collectDeclaredLocalNames as o}from"./compilerUtils.js";import{getNestedOptionalValue as a,geometryMember as s,getGeometryKeys as i}from"./containerUtils.js";import u from"./Dictionary.js";import{ArcadeExecutionError as c,ArcadeCompilationError as m,ArcadeUncompilableError as f}from"./executionError.js";import{Feature as p}from"./Feature.js";import{NativeFunction as d,ArcadeFunction as g,ScopeMarshalledFunction as h,wrapModuleScopedResponse as y}from"./FunctionWrapper.js";import{p as w,q as b,i as v,r as $,j as S,k as x,s as F,u as I,v as M,w as O,x as C,y as j,h as A,n as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as N}from"./treeAnalysis.js";import{A as E}from"../chunks/aiServices.js";import{A as B}from"../chunks/array.js";import{registerFunctions as _}from"./functions/date.js";import{registerFunctions as V}from"./functions/feature.js";import{registerFunctions as L}from"./functions/geometry.js";import{registerFunctions as R}from"./functions/geomsync.js";import{registerFunctions as T}from"./functions/maths.js";import{registerFunctions as D}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{registerFunctions as G}from"./functions/track.js";import{neverReached as K}from"../core/compilerUtils.js";import q from"../core/Logger.js";import{isPromiseLike as P}from"../core/promiseUtils.js";import{addMany as z}from"../core/SetUtils.js";import W from"../geometry/Geometry.js";import Z from"../geometry/SpatialReference.js";import{isGraphic as J,isString as Y,isArray as H,isNumber as Q,isBoolean as X}from"../support/guards.js";const ee=()=>q.getLogger("esri.arcade.arcadeCompiler");class ne{constructor(){this._symbolCounter=0}nextVarId(){return this._symbolCounter+=1,`_T${this._symbolCounter}`}nextTempVarId(){return this._symbolCounter+=1,`_Tvar${this._symbolCounter}`}nextLocalsSymbolMapId(){return this._symbolCounter+=1,`_Locals${this._symbolCounter}`}}function te(e,n){const t=e.localScope?.get(n);if(null!=t)return{scope:"local",name:n,var:t};const r=e.globalScope.get(n);return null!=r?{scope:"global",name:n,var:r}:e.standardGlobals.has(n)?{scope:"global",name:n,var:n}:null}function re(n,t,r="InvalidIdentifier"){const l=te(n,e(t));if(null!=l)return l;throw new m(null,r,t)}function le(n,t,r){const l=te(n,e(t));if(null==l)throw ee().error(`Internal error: Symbol "${t.name}" not declared.`),new m(null,"NeverReach",t);if(null!=r&&l.scope!==r)throw ee().error(`Internal error: Expected to resolve "${t.name}" in the ${r} scope but is in the ${l.scope} scope.`),new m(null,"NeverReach",t);return l}function oe(n,t){const r=e(t),l=n.symbolMetadata;if(n.localStack.length>0){const e=n.localStack[n.localStack.length-1],t=l.locals.get(e._SymbolsMapId);if(null==t)return void ee().error(`Internal error: no reflection metadata for ${e._SymbolsMapId}`);const o=t.get(r);if(null!=o)return Qe.requireInitialized(e[o])}const o=l.globals.get(r);if(null!=o)return Qe.requireInitialized(n.globalScope[o]);if(l.standardGlobals.has(r))return Qe.requireInitialized(n.globalScope[r]);throw new c(null,"InvalidIdentifier",null)}class ae extends g{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new c(e,"WrongNumberOfParameters",null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,r){return r(e,n,(n,l,o)=>{o=o.map(n=>!v(n)||n instanceof h?n:y(n,e,r));const a=this.call(t,{arguments:o});return P(a)?a.then(e=>y(e,t,r)):a})}}function se(e,n,t){try{return t(e,null,n.arguments)}catch(r){throw r}}function ie(e,n,t,r,o,a){const{globals:s,exports:i}=l(e);z(s,t);const u=new ne,c=[],m=new Map;for(const l of s)if(t.has(l)||n.has(l))m.set(l,l);else{const e=u.nextVarId();m.set(l,e),c.push(`gscope[${JSON.stringify(e)}] = ${Ye};`)}const f=new Map,p=Object.create(null),d={isAsync:r,symbols:u,standardGlobals:n,globalScope:m,exports:i,localScope:null,allLocalSymbolMetadata:f,moduleFactory:a,moduleFactoryMap:p,libraryResolver:o};return{body:[...c,"var lastStatement = lc.voidOperation;",Fe(d,e),"return lastStatement;"].join("\n"),symbolMetadata:{standardGlobals:n,exports:i,globals:m,locals:f},moduleFactoryMap:p}}function ue(e,n){switch(n.type){case"AssignmentExpression":return ve(e,n);case"UpdateExpression":return we(e,n);case"TemplateLiteral":return Be(e,n);case"Identifier":return Le(e,n);case"MemberExpression":return ke(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return Re(e,n);case"UnaryExpression":return Ne(e,n);case"BinaryExpression":return _e(e,n);case"LogicalExpression":return Ve(e,n);case"ArrayExpression":return Ee(e,n);case"ObjectExpression":return me(e,n);default:throw new m(null,"Unrecognized",n)}}function ce(e,n){switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclaration":return je(e,n);case"BlockStatement":return Fe(e,n);case"FunctionDeclaration":return Ce(e,n);case"ImportDeclaration":return Me(e,n);case"ExportNamedDeclaration":return ce(e,n.declaration);case"ReturnStatement":return Ie(e,n);case"IfStatement":return xe(e,n);case"ExpressionStatement":return $e(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"ForStatement":return ye(e,n);case"ForInStatement":return ge(e,n);case"ForOfStatement":return he(e,n);case"WhileStatement":return be(e,n);default:throw new m(null,"Unrecognized",n)}}function me(e,n){let t="lang.dictionary([";for(let r=0;r<n.properties.length;r++){const l=n.properties[r];let o;o="Identifier"===l.key.type?"'"+l.key.name+"'":ue(e,l.key);r>0&&(t+=","),t+="lang.strCheck("+o+",'ObjectExpression'),lang.aCheck("+ue(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function fe(e,n,t,r,l=(e,n)=>`${e} = ${n}`){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId();return[`var ${o} = ${t};`,`for (var ${a} = 0; ${a} < ${o}; ${a}++) {`,` ${l(n,a)}`,` ${ce(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function pe(e,n,t,r,l=e=>e){const o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId();return[`var ${o} = ${t};`,`for (var ${a} of ${o}) {`,` ${n} = ${l(a)};`,` ${ce(e,r)}`,"}","lastStatement = lc.voidOperation;"].join("\n")}function de(e,n,t,r){const l=e.symbols.nextTempVarId(),o=e.symbols.nextTempVarId(),a=e.symbols.nextTempVarId(),s=e.symbols.nextTempVarId();return[`var ${l} = yield ${t}.queryAll(runtimeCtx.abortSignal);`,`var ${o} = { done: false, value: [] };`,`for (var ${a} = 0; ${a} < ${o}.value.length || ((${a} = 0), !(${o} = yield ${l}.next()).done); ${a}++) {`,` if (${o}.value.length === 0) continue;`,` var ${s} = ${o}.value[${a}];`,` ${n} = lang.createFeature(${s}, ${t}, runtimeCtx);`,` ${ce(e,r)}`,"}"].join("\n")}function ge(e,n){const t=e.symbols.nextTempVarId();let r,l,o="var "+t+" = "+ue(e,n.right)+";\n";switch("VariableDeclaration"===n.left.type?(r=le(e,n.left.declarations[0].id),o+=ce(e,n.left)):r=re(e,n.left),r.scope){case"local":l=`lscope['${r.var}']`;break;case"global":l=`gscope['${r.var}']`;break;default:throw K(r.scope),new m(null,"NeverReach",n.left)}return o+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",o+="else if (lc.isArray("+t+") || lc.isString("+t+")) {\n",o+=fe(e,l,`${t}.length`,n.body),o+="}\n",o+="else if (lc.isImmutableArray("+t+")) {\n",o+=fe(e,l,`${t}.length()`,n.body),o+="}\n",o+="else if (( "+t+" instanceof lang.Dictionary) || lc.isDictionaryLike("+t+")) {\n",o+=pe(e,l,`${t}.keys()`,n.body),o+="}\n",e.isAsync&&(o+="else if (lc.isFeatureSet("+t+")) {\n",o+=de(e,l,t,n.body),o+="}\n"),o+=`else if (lc.isGeometry(${t})) {\n`,o+=pe(e,l,`lang.getGeometryKeys(${t})`,n.body),o+="}\n",o+="else { lastStatement = lc.voidOperation; } \n",o}function he(e,n){const t=e.symbols.nextTempVarId();let r,l,o="var "+t+" = "+ue(e,n.right)+";\n";switch("VariableDeclaration"===n.left.type?(r=le(e,n.left.declarations[0].id),o+=ce(e,n.left)):r=re(e,n.left),r.scope){case"local":l=`lscope['${r.var}']`;break;case"global":l=`gscope['${r.var}']`;break;default:throw K(r.scope),new m(null,"NeverReach",n.left)}return o+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",o+="else if (lc.isArray("+t+") || lc.isString("+t+")) {\n",o+=fe(e,l,`${t}.length`,n.body,(e,n)=>[`if (${n} >= ${t}.length) {`," lang.error('OutOfBounds');","}",`${e} = ${t}[${n}];`].join("\n")),o+="}\n",o+="else if (lc.isImmutableArray("+t+")) {\n",o+=fe(e,l,`${t}.length()`,n.body,(e,n)=>`${e} = ${t}.get(${n});`),o+="}\n",o+="else if (( "+t+" instanceof lang.Dictionary) || lc.isDictionaryLike("+t+")) {\n",o+=pe(e,l,`${t}.keys()`,n.body,e=>`lang.entry(${e}, ${t}.field(${e}))`),o+="}\n",e.isAsync&&(o+="else if (lc.isFeatureSet("+t+")) {\n",o+=de(e,l,t,n.body),o+="}\n"),o+=`else if (lc.isGeometry(${t})) {\n`,o+=pe(e,l,`lang.getGeometryKeys(${t})`,n.body,e=>`lang.entry(${e}, lang.geometryMember(${t}, ${e}, runtimeCtx, null, 1))`),o+="}\n",o+="else { lastStatement = lc.voidOperation; } \n",o}function ye(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&("VariableDeclaration"===n.init.type?t+=ce(e,n.init):t+=ue(e,n.init)+"; ");const r=e.symbols.nextTempVarId(),l=e.symbols.nextTempVarId();return t+="var "+r+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+r+"===false) {\n "+ue(e,n.update)+" \n}\n "+r+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+ue(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('BooleanConditionRequired'); }\n"),t+=ce(e,n.body),null!==n.update&&(t+="\n "+ue(e,n.update)),t+="\n"+r+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function we(e,n){if("CallExpression"===n.argument.type)throw new m(null,"NeverReach",n);let t;if("MemberExpression"===n.argument.type){const r=ue(e,n.argument.object);return t=!0===n.argument.computed?ue(e,n.argument.property):"'"+n.argument.property.name+"'","lang.memberupdate("+r+","+t+",'"+n.operator+"',"+n.prefix+")"}const r=re(e,n.argument);switch(Oe(r),r.scope){case"local":return`lang.update(lscope, '${r.var}', '${n.operator}', ${n.prefix})`;case"global":return`lang.update(gscope, '${r.var}', '${n.operator}', ${n.prefix})`;default:throw K(r.scope),new m(null,"NeverReach",n.argument)}}function be(e,n){let t="lastStatement = lc.voidOperation; \n";const r=e.symbols.nextTempVarId();return t+=`\n var ${r} = true;\n do {\n ${r} = ${ue(e,n.test)};\n if (${r}==false) {\n break;\n }\n if (${r}!==true) {\n lang.error('BooleanConditionRequired');\n }\n ${ce(e,n.body)}\n }\n while (${r} !== false);\n lastStatement = lc.voidOperation;\n `,t}function ve(e,n){const t=ue(e,n.right);if("MemberExpression"===n.left.type){let r;const l=ue(e,n.left.object);return r=!0===n.left.computed?ue(e,n.left.property):"'"+n.left.property.name+"'","lang.assignmember("+l+","+r+",'"+n.operator+"',"+t+")"}const r=re(e,n.left);switch(Oe(r),r.scope){case"local":return`lscope['${r.var}']=lang.assign(${t},'${n.operator}', ${"="===n.operator?"null":He(`lscope['${r.var}']`)})`;case"global":return`gscope['${r.var}']=lang.assign(${t},'${n.operator}', ${"="===n.operator?"null":He(`gscope['${r.var}']`)})`;default:throw K(r.scope),new m(null,"NeverReach",n.left)}}function $e(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+ue(e,n.expression)+"; \n ":"lastStatement = "+ue(e,n.expression)+"; "}function Se(e,n){return"BlockStatement"===n.type?ce(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?ce(e,n)+"; ":"ExpressionStatement"===n.type?ce(e,n):ce(e,n)+"; "}function xe(e,n){return`if (lang.mustBoolean(${ue(e,n.test)}, runtimeCtx) === true) {\n ${Se(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+xe(e,n.alternate):` else {\n ${Se(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function Fe(e,n){let t="";for(let r=0;r<n.body.length;r++)"EmptyStatement"!==n.body[r].type&&("ReturnStatement"===n.body[r].type||"BreakStatement"===n.body[r].type||"ContinueStatement"===n.body[r].type?t+=ce(e,n.body[r])+"; \n":t+=ce(e,n.body[r])+" \n");return t}function Ie(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+ue(e,n.argument)}function Me(e,n){const t=le(e,n.specifiers[0].local,"global"),r=e.libraryResolver?.loadLibrary(t.name),l=e.symbols.nextVarId();void 0===e.moduleFactory[r.uri]&&(e.moduleFactory[r.uri]=rn(r.syntax,e.moduleFactory,e.isAsync)),e.moduleFactoryMap[l]=r.uri;let o="";return o=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",Oe(t),`gscope['${t.var}']=${o}`}function Oe(e){if("global"===e.scope)switch(e.name){case"iif":case"when":case"defaultvalue":case"decode":throw new f}}function Ce(n,t){const r=new Set(t.params.map(n=>e(n))),l=o(t);z(l,r);const a=n.symbols,s=new Map;for(const e of l)s.set(e,a.nextVarId());const i=a.nextLocalsSymbolMapId();n.allLocalSymbolMetadata.set(i,s);const u={...n,localScope:s},c=[`lscope._SymbolsMapId = ${JSON.stringify(i)};`];for(let e=0;e<t.params.length;e++){const n=le(u,t.params[e],"local");Oe(n),c.push(`lscope['${n.var}'] = arguments[${e}];`)}for(const[e,o]of s)r.has(e)||c.push(`lscope['${o}'] = ${Ye};`);const m=Fe(u,t.body),f=!0===n.isAsync?["return lang.__awaiter(this, void 0, void 0, function* () {",` ${m}`," return lastStatement;","});"]:[m,"return lastStatement;"],p=["new lang.UserDefinedCompiledFunction("," lang.functionDepthchecker("," function() {"," var lastStatement = lc.voidOperation;"," var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];",...c,...f," },"," runtimeCtx,"," ),",` ${t.params.length},`,")"].join("\n"),d=le(n,t.id,"global");return Oe(d),`gscope['${d.var}']=${p}; lastStatement = lc.voidOperation;`}function je(e,n){const t=[];for(let r=0;r<n.declarations.length;r++)t.push(Ae(e,n.declarations[r]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function Ae(e,n){const t=null===n.init?"null":ue(e,n.init),r=le(e,n.id);switch(Oe(r),r.scope){case"local":return`lscope['${r.var}']=${t};`;case"global":return`gscope['${r.var}']=${t};`;default:throw K(r.scope),new m(null,"NeverReach",n.id)}}function ke(e,n){try{let t;return t=!0===n.computed?ue(e,n.property):"'"+n.property.name+"'","lang.member("+ue(e,n.object)+","+t+")"}catch(t){throw t}}function Ne(e,n){try{return"lang.unary("+ue(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function Ee(e,n){try{const t=[];for(let r=0;r<n.elements.length;r++)"Literal"===n.elements[r].type?t.push(ue(e,n.elements[r])):t.push("lang.aCheck("+ue(e,n.elements[r])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function Be(e,n){try{const t=[];let r=0;for(const l of n.quasis)t.push(l.value?JSON.stringify(l.value.cooked):JSON.stringify("")),!1===l.tail&&(t.push(n.expressions[r]?"lang.castString(lang.aCheck("+ue(e,n.expressions[r])+", 'TemplateLiteral'))":""),r++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function _e(e,n){try{return"lang.binary("+ue(e,n.left)+","+ue(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function Ve(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new m(null,"LogicalExpressionOnlyBoolean",n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new m(null,"LogicalExpressionOnlyBoolean",n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+ue(e,n.left)+") "+n.operator+" lang.logicalCheck("+ue(e,n.right)+"))";throw new m(null,"LogicExpressionOrAnd",null)}catch(t){throw t}}function Le(e,n){const t=re(e,n);switch(Oe(t),t.scope){case"local":return He(`lscope['${t.var}']`);case"global":return He(`gscope['${t.var}']`);default:throw K(t.scope),new m(null,"NeverReach",n)}}function Re(e,n){try{if("MemberExpression"===n.callee.type){let t;t=!0===n.callee.computed?ue(e,n.callee.property):"'"+n.callee.property.name+"'";let r="[";for(let l=0;l<n.arguments.length;l++)l>0&&(r+=", "),r+=ue(e,n.arguments[l]);return r+="]",e.isAsync?"(yield lang.callModuleFunction("+ue(e,n.callee.object)+","+r+","+t+",runtimeCtx))":"lang.callModuleFunction("+ue(e,n.callee.object)+","+r+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new m(null,"FunctionNotFound",n);const t=re(e,n.callee,"FunctionNotFound");if("global"===t.scope)switch(t.name){case"iif":return Te(e,n);case"when":return Ue(e,n);case"defaultvalue":return De(e,n);case"decode":return Ge(e,n)}let r;switch(t.scope){case"local":r=He(`lscope['${t.var}']`);break;case"global":r=He(`gscope['${t.var}']`);break;default:throw K(t.scope),new m(null,"NeverReach",n.callee)}let l="[";for(let o=0;o<n.arguments.length;o++)o>0&&(l+=", "),l+=ue(e,n.arguments[o]);return l+="]",e.isAsync?"(yield lang.callfunc("+r+","+l+",runtimeCtx) )":"lang.callfunc("+r+","+l+",runtimeCtx)"}catch(t){throw t}}function Te(e,n){try{if(3!==n.arguments.length)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${ue(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${ue(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function De(e,n){try{if(n.arguments.length<2||n.arguments.length>3)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId(),r=e.symbols.nextTempVarId();return 3===n.arguments.length?`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n var ${r} = ${ue(e,n.arguments[1])};\n ${t} = lang.getNestedOptionalValue(${t}, ${r});\n return ${t} != null && ${t} !== "" ? ${t} : ${ue(e,n.arguments[2])};\n ${e.isAsync?"})}()))":"}()"}`:`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n if (${t} === null) {\n return ${ue(e,n.arguments[1])};\n }\n if (${t} === "") {\n return ${ue(e,n.arguments[1])};\n }\n if (${t} === undefined) {\n return ${ue(e,n.arguments[1])};\n }\n return ${t};\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ue(e,n){try{if(n.arguments.length<3)throw new m(null,"WrongNumberOfParameters",n);if(n.arguments.length%2==0)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();let r="var ";for(let l=0;l<n.arguments.length-1;l+=2)r+=`${t} = lang.mustBoolean(${ue(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${ue(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${r}\n return ${ue(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ge(e,n){try{if(n.arguments.length<2)throw new m(null,"WrongNumberOfParameters",n);if(2===n.arguments.length)return`(${ue(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new m(null,"WrongNumberOfParameters",n);const t=e.symbols.nextTempVarId();let r;if(n.arguments.every((e,n)=>n%2==0||"Literal"===e.type)){r=`switch (${t}) {`;for(let t=1;t<n.arguments.length-1;t+=2){const l=n.arguments[t],o=n.arguments[t+1];null==l.value?r+="\n case null:\n case lc.voidOperation:\n ":r+=`\n case ${JSON.stringify(l.value)}:\n `,r+=`return ${ue(e,o)}`}r+="}"}else{const l=e.symbols.nextTempVarId();r="var ";for(let o=1;o<n.arguments.length-1;o+=2){const a=n.arguments[o],s=n.arguments[o+1];r+=`${l} = ${ue(e,a)};\n if (lang.binary(${l}, ${t}, "==") === true ) {\n return ${ue(e,s)}\n }\n `}}return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${ue(e,n.arguments[0])};\n ${r}\n return ${ue(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Ke(e,n){try{return se(e,n,(e,n)=>{throw new c(e,"Unrecognized",n)})}catch(t){throw t}}function qe(e){const n=function(){this.textformatting=u.textFormatting()};n.prototype=Object.create(null),n.provided=new Set(["textformatting","infinity","pi"]),n.prototype.infinity=Number.POSITIVE_INFINITY,n.prototype.pi=Math.PI;for(const[t,r]of Object.entries(e))n.prototype[t]=new d(r),n.provided.add(t);return n}function Pe(){const e=Object.create(null);_(e,se),U(e,se),V(e,se,oe),T(e,se),L(e,se),D(e,se),G(e,se),e.iif=Ke,e.decode=Ke,e.when=Ke,e.defaultvalue=Ke;const n=qe(e);R(e,se);return{ScopeSync:qe(e),ScopeAsync:n}}const{ScopeSync:ze,ScopeAsync:We}=Pe();function Ze(e,n){const t={mode:n,compiled:!0,functions:Object.create(null),signatures:[],standardFunction:se,standardFunctionAsync:se,evaluateIdentifier:oe};for(const r of e)r.registerFunctions(t);if("sync"===n)for(const[r,l]of Object.entries(t.functions))ze.prototype[r]=new d(l),ze.provided.add(r);else for(const[r,l]of Object.entries(t.functions))We.prototype[r]=new d(l),We.provided.add(r);for(const r of t.signatures)N(r,n)}Ze([B],"sync"),Ze([B],"async"),Ze([E],"async");const Je=Symbol("uninitialized"),Ye="lang.uninitialized";function He(e){return`lang.requireInitialized(${e})`}const Qe={uninitialized:Je,requireInitialized(e){if(e===Je)throw new c(null,"InvalidIdentifier",null);return e},isNumber:e=>Q(e),isArray:e=>H(e),isImmutableArray:e=>S(e),isDictionaryLike:e=>$(e),isString:e=>Y(e),isDictionary:e=>k(e),isGeometry:e=>A(e),getGeometryKeys:e=>i(e),geometryMember:(e,n,t,r,l=1)=>s(e,n,t,r,l),error(e){throw new c(null,e,null)},__awaiter(e,n,t,r){const l=r.apply(e,n||[]);let o=l.next();for(;!o.done&&!P(o.value);)o=l.next(o.value);return o.done?o.value:new Promise((e,n)=>{function t(r){for(;!r.done;){if(P(r.value))return void Promise.resolve(r.value).then(e=>{try{t(l.next(e))}catch(r){n(r)}},e=>{try{t(l.throw(e))}catch(r){n(r)}});try{r=l.next(r.value)}catch(o){return void n(o)}}e(r.value)}t(o)})},functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push({}),n.depthCounter.depth>64)throw new c(null,"MaximumCallDepth",null);const t=e.apply(this,arguments);return P(t)?t.then(e=>(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,e)):(n.depthCounter.depth--,n.localStack.length=n.localStack.length-1,t)},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new c(n,"BooleanConditionRequired",null)},castString:e=>I(e),aCheck(e,n){if(v(e)){if("ArrayExpression"===n)throw new c(null,"NoFunctionInArray",null);if("ObjectExpression"===n)throw new c(null,"NoFunctionInDictionary",null);throw new c(null,"NoFunctionInTemplateLiteral",null)}return e===M?null:e},Dictionary:u,Feature:p,UserDefinedCompiledFunction:ae,dictionary(e){const n=Object.create(null),t=new Map;for(let l=0;l<e.length;l+=2){if(v(e[l+1]))throw new c(null,"NoFunctionInDictionary",null);if(!1===Y(e[l]))throw new c(null,"KeyMustBeString",null);let r=e[l].toString();const o=r.toLowerCase();t.has(o)?r=t.get(o):t.set(o,r),e[l+1]===M?n[r]=null:n[r]=e[l+1]}const r=new u(n);return r.immutable=!1,r},entry:(e,n)=>u.containerEntry(e,n),strCheck(e){if(!1===Y(e))throw new c(null,"KeyMustBeString",null);return e},unary(e,n){if(X(e)){if("!"===n)return!e;if("-"===n)return-1*F(e);if("+"===n)return 1*F(e);if("~"===n)return~F(e);throw new c(null,"UnsupportUnaryOperator",null)}if("-"===n)return-1*F(e);if("+"===n)return 1*F(e);if("~"===n)return~F(e);throw new c(null,"UnsupportUnaryOperator",null)},logicalCheck(e){if(!1===X(e))throw new c(null,"LogicExpressionOrAnd",null);return e},logical(e,n,t){if(X(e)&&X(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new c(null,"LogicExpressionOrAnd",null)}throw new c(null,"LogicExpressionOrAnd",null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return j(F(e),F(n),t);case"==":case"=":return C(e,n);case"!=":return!C(e,n);case"<":case">":case"<=":case">=":return O(e,n,t);case"+":return Y(e)||Y(n)?I(e)+I(n):F(e)+F(n);case"-":return F(e)-F(n);case"*":return F(e)*F(n);case"/":return F(e)/F(n);case"%":return F(e)%F(n);default:throw new c(null,"UnsupportedOperator",null)}},assign(e,n,t){switch(n){case"=":return e===M?null:e;case"/=":return F(t)/F(e);case"*=":return F(t)*F(e);case"-=":return F(t)-F(e);case"+=":return Y(t)||Y(e)?I(t)+I(e):F(t)+F(e);case"%=":return F(t)%F(e);default:throw new c(null,"UnsupportedOperator",null)}},update(e,n,t,r){const l=F(this.requireInitialized(e[n]));return e[n]="++"===t?l+1:l-1,!1===r?l:"++"===t?l+1:l-1},createFeature:(e,n,t)=>p.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeZone),memberupdate(e,n,t,r){let l;if(H(e)){if(!Q(n))throw new c(null,"ArrayAccessMustBeNumber",null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new c(null,"OutOfBounds",null);l=F(e[n]),e[n]="++"===t?l+1:l-1}else if(e instanceof u){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0!==e.hasField(n))throw new c(null,"FieldNotFound",null,{key:n});l=F(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else if(x(e)){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0!==e.hasField(n))throw new c(null,"FieldNotFound",null);l=F(e.field(n)),e.setField(n,"++"===t?l+1:l-1)}else{if(S(e))throw new c(null,"Immutable",null);if(!(e instanceof tn))throw new c(null,"InvalidIdentifier",null);if(!1===Y(n))throw new c(null,"ModuleAccessorMustBeString",null);if(!0!==e.hasGlobal(n))throw new c(null,"ModuleExportNotFound",null);l=F(e.global(n)),e.setGlobal(n,"++"===t?l+1:l-1)}return!1===r?l:"++"===t?l+1:l-1},assignmember(e,n,t,r){if(H(e)){if(!Q(n))throw new c(null,"ArrayAccessMustBeNumber",null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new c(null,"OutOfBounds",null);if(n===e.length){if("="!==t)throw new c(null,"OutOfBounds",null);e[n]=this.assign(r,t,e[n])}else e[n]=this.assign(r,t,e[n])}else if(e instanceof u){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0===e.hasField(n))e.setField(n,this.assign(r,t,e.field(n)));else{if("="!==t)throw new c(null,"FieldNotFound",null);e.setField(n,this.assign(r,t,null))}}else if(x(e)){if(!1===Y(n))throw new c(null,"KeyAccessorMustBeString",null);if(!0===e.hasField(n))e.setField(n,this.assign(r,t,e.field(n)));else{if("="!==t)throw new c(null,"FieldNotFound",null);e.setField(n,this.assign(r,t,null))}}else{if(S(e))throw new c(null,"Immutable",null);if(!(e instanceof tn))throw new c(null,"InvalidIdentifier",null);if(!1===Y(n))throw new c(null,"ModuleAccessorMustBeString",null);if(!e.hasGlobal(n))throw new c(null,"ModuleExportNotFound",null);e.setGlobal(n,this.assign(r,t,e.global(n)))}},member(e,n){if(null===e)throw new c(null,"MemberOfNull",null);if(e instanceof u||$(e)){if(Y(n))return e.field(n);throw new c(null,"InvalidMemberAccessKey",null)}if(e instanceof W){if(Y(n))return s(e,n,null,null);throw new c(null,"InvalidMemberAccessKey",null)}if(H(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new c(null,"OutOfBounds",null);return e[n]}throw new c(null,"InvalidMemberAccessKey",null)}if(Y(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new c(null,"OutOfBounds",null);return e[n]}throw new c(null,"InvalidMemberAccessKey",null)}if(S(e)){if(Q(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new c(null,"OutOfBounds",null);return e.get(n)}throw new c(null,"InvalidMemberAccessKey",null)}if(e instanceof tn){if(Y(n))return e.global(n);throw new c(null,"InvalidMemberAccessKey",null)}throw new c(null,"InvalidMemberAccessKey",null)},callfunc:(e,n,t)=>e.call(t,{arguments:n,preparsed:!0}),loadModule(e,n){const t=n.moduleFactoryMap[e];if(n.moduleSingletons[t])return n.moduleSingletons[t];const r=n.moduleFactory[t]({moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,lrucache:n.lrucache,interceptor:n.interceptor,services:n.services,console:n.console,abortSignal:n.abortSignal,timeZone:n.timeZone??null,spatialReference:n.spatialReference});return n.moduleSingletons[t]=r,r},callModuleFunction(e,n,t,r){if(!(e instanceof tn))throw new c(null,"FunctionNotFound",null);const l=e.global(t);if(!1===v(l))throw new c(null,"CallNonFunction",null);return l.call(r,{preparsed:!0,arguments:n})},getNestedOptionalValue:(e,n)=>a(e,n)};function Xe(e){console.log(e)}function en(t,l,o=!1){let a=null;t.usesModules&&(a=new r(null,t.loadedModules));const s=Object.create(null),i=new Set(Object.keys(l?.vars||{}).map(n=>e(n))),u=new Set(Object.keys(l?.customfunctions||{}).map(n=>e(n))),m=ie(t,o?We.provided:ze.provided,new Set([...i,...u]),o,a,s);let f;f=o?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${m.body}`," });"," }"," return this.postProcess(yield mainBody());","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${m.body}`,"}","return this.postProcess(mainBody());"].join("\n");const{symbolMetadata:d,moduleFactoryMap:g}=m,h={lc:w,lang:Qe,postProcess(e){if(b(e))return null;if(v(e))throw new c(null,"IllegalResult",null);return e},prepare(e,t){const r=e.spatialReference??Z.WebMercator,l=t?new We:new ze;for(const n of u)null!=e.customfunctions&&n in e.customfunctions?l[n]=e.customfunctions[n]??null:l[n]=Je;for(const n of i){if(null==e.vars||!(n in e.vars)){n in l||(l[n]=Je);continue}const t=e.vars[n]??null;J(t)?l[n]=p.createFromGraphic(t,e.timeZone??null):l[n]=t}return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??Xe,abortSignal:e.abortSignal??n,timeZone:e.timeZone??null,spatialReference:r,track:e.track,globalScope:l,localStack:[],depthCounter:{depth:1},symbolMetadata:d,moduleFactory:s,moduleFactoryMap:g,moduleSingletons:Object.create(null)}}};return new Function("context",f).bind(h)}async function nn(){return Ze([await import("./functions/geomasync.js")],"async"),!0}class tn extends t{constructor(e){super(),this.moduleContext=e}hasGlobal(n){const t=this.moduleContext.symbolMetadata.exports;return t.has(n)||t.has(e(n))}setGlobal(n,t){if(v(t))throw new c(null,"AssignModuleFunction",null);const r=this.moduleContext.symbolMetadata.globals.get(e(n));if(null==r)throw new c(null,"ModuleExportNotFound",null);this.moduleContext.globalScope[r]=t}global(n){const t=this.moduleContext.symbolMetadata.globals.get(e(n));if(null==t)throw new c(null,"ModuleExportNotFound",null);const r=this.moduleContext.globalScope,l=Qe.requireInitialized(r[t]);if(v(l)&&!(l instanceof h)){const e=new h;return e.fn=l,e.parameterEvaluator=se,e.context=this.moduleContext,r[t]=e,e}return l}}function rn(e,t,l){const o=new r(null,e.loadedModules),a=ie(e,l?We.provided:ze.provided,new Set,l,o,t);let s;s=l?["var runtimeCtx = this.prepare(context, true);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","return lang.__awaiter(this, void 0, void 0, function* () {"," function mainBody() {"," return lang.__awaiter(this, void 0, void 0, function* () {",` ${a.body}`," });"," }"," yield mainBody();"," return this.prepareModule(runtimeCtx);","});"].join("\n"):["var runtimeCtx = this.prepare(context, false);","var lc = this.lc;","var lang = this.lang;","var gscope = runtimeCtx.globalScope;","function mainBody() {",` ${a.body}`,"}","mainBody();","return this.prepareModule(runtimeCtx);"].join("\n");const{symbolMetadata:i,moduleFactoryMap:u}=a,c={lc:w,lang:Qe,prepareModule:e=>new tn(e),prepare(e,r){const l=e.spatialReference??Z.WebMercator,o=r?new We:new ze;return{lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,console:e.console??Xe,abortSignal:e.abortSignal??n,timeZone:e.timeZone??null,spatialReference:l,track:null,globalScope:o,localStack:[],depthCounter:e.depthCounter,symbolMetadata:i,moduleFactory:t,moduleFactoryMap:u,moduleSingletons:e.moduleSingletons}}};return new Function("context",s).bind(c)}export{ae as UserDefinedCompiledFunction,en as compileScript,nn as enableAsyncSupport,Ze as extend};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a1 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerOGC.js";import o from"./featureset/sources/FeatureLayerRelated.js";import u from"./featureset/support/cache.js";import{FeatureSetError as c}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as d,isSupportedLayer as p,extractServiceUrl as f}from"./featureset/support/shared.js";import{isLoadable as y}from"../core/Loadable.js";import m from"../core/sql/WhereClause.js";import h from"../layers/FeatureLayer.js";import w from"../layers/Layer.js";import I from"../portal/PortalItem.js";function L(){null===u.applicationCache&&(u.applicationCache=new u)}async function S(e,t,a){if(u.applicationCache){const a=u.applicationCache.getLayerInfo(e);if(a){const r=await a;return new h({url:e,outFields:t,sourceJSON:r})}const n=new h({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(u.applicationCache){u.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw u.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new h({url:e,outFields:t,sourceJSON:a})}const l=new h({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new h({url:e,outFields:t})}async function _(e,t,a,r,n,l=null){return C(await S(e,["*"],n),t,a,r,n,l)}function C(e,t=null,a=null,r=!0,o=null,u=null){switch(e.type){case"catalog-footprint":return C(e.parent,t,a,r,o,u);case"subtype-sublayer":{const l=C(e.parent,t,a,r,o,u);return new n({parentfeatureset:l,whereclause:m.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u};return!e.url&&e.source?new s(n):new l(n)}case"ogc-feature":return new i({layer:e,spatialReference:t,outFields:a,includeGeometry:r});default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function k(t){if(null!==u.applicationCache){const e=u.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!==u.applicationCache){u.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw u.applicationCache.clearLayerInfo(t),r}}return a}async function F(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==u.applicationCache){const e=u.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?.[0])return e.layerDataElements[0]}throw new c("DataElementsNotFound")})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw u.applicationCache.clearLayerInfo(r),l}}return n}async function g(t,a){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(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!==u.applicationCache){u.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw u.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function N(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await g(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await F(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await k(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await _(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:m.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)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function T(e,t,a,r=null,n=null,l=!0,s=null,i=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await _(u,r,n,l,s,i);return new o({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=C(e,this._overrideSpatialReference,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,a=null){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class A extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=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=C(e,this._overrideSpatialReference,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 g(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new A(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new O(e,t,a,r)}function D(e,t,a=null,r=null){return new A(e,t,a,r)}function M(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof w&&d(e)){const a=e;switch(t){case"datasource":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return C(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function b(e,t,a,r,n,l,s,i=null){if(u.applicationCache){const o=u.applicationCache.getLayerInfo(e+":"+l.url);if(o)return j(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await j(await o,t,a,r,n,s,i)}const o=new I({id:e,portal:l}).load();u.applicationCache?u.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await j(await o,t,a,r,n,s,i)}catch(c){throw u.applicationCache&&u.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),c}}async function j(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await S(f(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=w.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await w.fromPortalItem(e)}return C(i,a,r,n,l,s)}export{N as constructAssociationMetaDataFeatureSetFromUrl,C as constructFeatureSet,b as constructFeatureSetFromPortalItem,T as constructFeatureSetFromRelationship,_ as constructFeatureSetFromUrl,M as convertToFeatureSet,E as createFeatureSetCollectionFromMap,D as createFeatureSetCollectionFromService,L as initialiseMetaDataCache};
|
|
5
|
+
import e from"../request.js";import t from"./featureSetCollection.js";import{m as a,a1 as r}from"../chunks/languageUtils.js";import n from"./featureset/actions/AttributeFilter.js";import l from"./featureset/sources/FeatureLayerDynamic.js";import s from"./featureset/sources/FeatureLayerMemory.js";import i from"./featureset/sources/FeatureLayerOGC.js";import o from"./featureset/sources/FeatureLayerRelated.js";import u from"./featureset/support/cache.js";import{FeatureSetError as c}from"./featureset/support/errorsupport.js";import{isSupportedSourceLayer as d,isSupportedLayer as p,extractServiceUrl as f}from"./featureset/support/shared.js";import{isLoadable as y}from"../core/Loadable.js";import m from"../core/sql/WhereClause.js";import h from"../layers/FeatureLayer.js";import w from"../layers/Layer.js";import I from"../portal/PortalItem.js";function L(){null===u.applicationCache&&(u.applicationCache=new u)}async function S(e,t,a){if(u.applicationCache){const a=u.applicationCache.getLayerInfo(e);if(a){const r=await a;return new h({url:e,outFields:t,sourceJSON:r})}const n=new h({url:e,outFields:t}),l=(async()=>(await n.load(),n.sourceJSON))();if(u.applicationCache){u.applicationCache.setLayerInfo(e,l);try{return await l,n}catch(r){throw u.applicationCache.clearLayerInfo(e),r}}return await l,n}if(null!=a){const r=a.getCachedLayerMetadata(e);if(r){const a=await r;return new h({url:e,outFields:t,sourceJSON:a})}const l=new h({url:e,outFields:t}),s=(async()=>(await l.load(),l.sourceJSON))();a.setCachedLayerMetadata(e,s);try{return await s,l}catch(n){throw a.removeCachedLayerMetadata(e,s),n}}return new h({url:e,outFields:t})}async function _(e,t,a,r,n,l=null){return C(await S(e,["*"],n),t,a,r,n,l)}function C(e,t=null,a=null,r=!0,o=null,u=null){switch(e.type){case"catalog-footprint":return C(e.parent,t,a,r,o,u);case"subtype-sublayer":{const l=C(e.parent,t,a,r,o,u);return new n({parentfeatureset:l,whereclause:m.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:l.dateFieldsTimeZoneDefaultUTC})})}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new s({layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{const n={layer:e,spatialReference:t,outFields:a,includeGeometry:r,lrucache:o,interceptor:u};return!e.url&&e.source?new s(n):new l(n)}case"ogc-feature":return new i({layer:e,spatialReference:t,outFields:a,includeGeometry:r});default:throw new Error(`Unsupported layer type: ${e.type}`)}}async function k(t){if(null!==u.applicationCache){const e=u.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!==u.applicationCache){u.applicationCache.setLayerInfo(t,a);try{return await a}catch(r){throw u.applicationCache.clearLayerInfo(t),r}}return a}async function F(t,a){const r="QUERYDATAELEMTS:"+a.toString()+":"+t;if(null!==u.applicationCache){const e=u.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?.[0])return e.layerDataElements[0]}throw new c("DataElementsNotFound")})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(r,n);try{return await n}catch(l){throw u.applicationCache.clearLayerInfo(r),l}}return n}async function g(t,a){if(null!==u.applicationCache){const e=u.applicationCache.getLayerInfo(t);if(null!==e)return e}if(null!=a){const e=a.getCachedServiceMetadata(t);if(null!=e)return e}const r=(async()=>{const a=await e(t,{responseType:"json",query:{f:"json"},authMode:"no-prompt"});if(a.data){const e=a.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==u.applicationCache){u.applicationCache.setLayerInfo(t,r);try{return await r}catch(n){throw u.applicationCache.clearLayerInfo(t),n}}if(null!=a){a.setCachedServiceMetadata(t,r);try{return await r}catch(l){throw a.removeCachedServiceMetadata(t,r),l}}return r}async function N(e,t,a){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},l=await g(e,null);if(r.metadata=l,void 0!==l.controllerDatasetLayers?.utilityNetworkLayerId&&null!==l.controllerDatasetLayers.utilityNetworkLayerId){if(l.layers)for(const e of l.layers)r.layerNameLkp[e.id]=e.name;if(l.tables)for(const e of l.tables)r.layerNameLkp[e.id]=e.name;const s=l.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;const i=await F(e,s);if(i){r.queryelem=i,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources??[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});const l=await k(e+"/"+s);if(void 0!==l.systemLayers?.associationsTableId&&null!==l.systemLayers.associationsTableId){let s=null;if(a&&r.unVersion<8){const a=[];r.unVersion>=4&&(a.push("STATUS"),a.push("PERCENTALONG")),s=await _(e+"/"+l.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...a],!1,null,null),await s.load(),r.unVersion>=4&&(s=new n({parentfeatureset:s,whereclause:m.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)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})}),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function T(e,t,a,r=null,n=null,l=!0,s=null,i=null){let u=e.serviceUrl();if(!u)return null;u=u.endsWith("/")?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString();const c=await _(u,r,n,l,s,i);return new o({layer:e,relatedLayer:c,relationship:t,objectId:a,spatialReference:r,outFields:n,includeGeometry:l,lrucache:s,interceptor:i})}class O extends t{constructor(e,t=null,a=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=a,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,a=null){const r=C(e,this._overrideSpatialReference,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,a=null){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.title===e);if(null!=n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){if(y(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,a);null===a&&(a=["*"]),a=(a=a.slice()).sort();const r=JSON.stringify(a);for(let l=0;l<this._instantLayers.length;l++){const a=this._instantLayers[l];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[l].featureset}const n=this._map.allLayers.find(t=>p(t)&&t.id===e);if(n)return this._makeAndAddFeatureSet(n,t,a);if(this._map.allTables){const r=this._map.allTables.find(t=>p(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,a)}return null}}class A extends t{constructor(e,t=null,a=null,r=null){super(),this._url=e,this._overrideSpatialReference=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=C(e,this._overrideSpatialReference,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 g(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new A(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,a=null){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])s.name===e&&(l=s);if(!l)for(const s of n.tables??[])s.name===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}async featureSetById(e,t=!0,a=["*"]){null===a&&(a=["*"]),a=(a=a.slice()).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 l=null;for(const s of n.layers??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(!l)for(const s of n.tables??[])null!==s.id&&void 0!==s.id&&s.id.toString()===e&&(l=s);if(l){const e=await S(this._url+"/"+l.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,a)}return null}}function E(e,t,a=null,r=null){return new O(e,t,a,r)}function M(e,t,a=null,r=null){return new A(e,t,a,r)}function D(e,t,n,l,s){if(null===e)return null;if(a(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof w&&d(e)){const a=e;switch(t){case"datasource":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(a,s,"outFields"in a?a.outFields:null,!0,n,l)}return null}if(r(e)){switch(t){case"datasource":return C(e.parent,s,e.parent.outFields,!0,n,l).getDataSourceFeatureSet();case"parent":case"root":return C(e,s,e.parent.outFields,!0,n,l)}return null}return null}async function b(e,t,a,r,n,l,s,i=null){if(u.applicationCache){const o=u.applicationCache.getLayerInfo(e+":"+l.url);if(o)return j(await o,t,a,r,n,s,i)}if(null!=s){const o=s.getCachedPortalItem(l.url,e);if(null!=o)return await j(await o,t,a,r,n,s,i)}const o=new I({id:e,portal:l}).load();u.applicationCache?u.applicationCache.setLayerInfo(e+":"+l.url,o):null!=s&&s.setCachedPortalItem(l.url,e,o);try{return await j(await o,t,a,r,n,s,i)}catch(c){throw u.applicationCache&&u.applicationCache.clearLayerInfo(e+":"+l.url),null!=s&&s.removeCachedPortalItem(l.url,e,o),c}}async function j(e,t,a,r,n,l,s){let i;if("Feature Service"===e.type||"Map Service"===e.type)i=await S(f(e.url??"")+"/"+t,["*"],l);else{if(t)throw new Error(`layerId=${t} provided for ${e.type} item`);if(null!=l){const t=l.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)i=await t;else{const t=w.fromPortalItem(e);l.setCachedPortalItemLayer(e.portal.url,e.id,t);try{i=await t}catch(o){throw l.removeCachedPortalItemLayer(e.portal.url,e.id,t),o}}}else i=await w.fromPortalItem(e)}return C(i,a,r,n,l,s)}export{N as constructAssociationMetaDataFeatureSetFromUrl,C as constructFeatureSet,b as constructFeatureSetFromPortalItem,T as constructFeatureSetFromRelationship,_ as constructFeatureSetFromUrl,D as convertToFeatureSet,E as createFeatureSetCollectionFromMap,M as createFeatureSetCollectionFromService,L 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{neverAbortedSignal as t}from"../../arcadeEnvironment.js";import{cloneGeometry as r}from"../../kernel.js";import{throwIfCancelled as s,FeatureSetError as a}from"../support/errorsupport.js";import{FeatureSet as i}from"../support/FeatureSet.js";import{isDate as l,isLuxonDate as o,isArcadeTime as n,isArcadeDate as u,isArcadeDateOnly as h,cloneField as c,defaultMaxRecords as d}from"../support/shared.js";import{reformulateWithoutField as p,toWhereClause as f,translateFunctionToDatabaseSpecific as N,convertColumnReferenceToSql as g,makeToday as S,makeSqlFromDateTimeParameter as m,makeTimeString as T,arcadeDateToSqlString as w,arcadeDateOnlyToSqlString as C,convertIntervalToSql as _,combine as v,scanForField as y}from"../support/sqlUtils.js";import{SqlError as W}from"../../../core/sql/errorSupport.js";import A from"../../../core/sql/WhereClause.js";class E{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class F extends E{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class x extends E{constructor(e,t,r){super(c(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:p(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class I extends E{constructor(e,t,r){super(e),this.codefield=t,this._stringToCode=r,this._codeToString={};for(const s in r)this._codeToString[r[s]]=s;this.sqlRewritable=!0}static{this.BADNESS="_!!!_BAD_LKP_!!!!"}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,0,this.field.name,this.codefield instanceof A?f(this.codefield,0):this.codefield,e.parameters);return r.includes(I.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:A.create(r,{fieldsIndex:t._parent.getFieldsIndex(),timeZone:t.dateFieldsTimeZoneDefaultUTC})}}evaluateNodeToWhereClause(e,t,r=null,s=null,a){switch(e.type){case"interval":return _(this.evaluateNodeToWhereClause(e.value,t,r,s,a),e.qualifier,e.op);case"case-expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,I.BADNESS,a));for(const i of e.clauses)s+=" WHEN "+this.evaluateNodeToWhereClause(i.operand,t,r,I.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(i.value,t,r,I.BADNESS,a);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,I.BADNESS,a)),s+=" END ",s}case"parameter":{const r=a[e.value.toLowerCase()];return"string"==typeof r?"'"+r.toString().replaceAll("'","''")+"'":l(r)||o(r)?m(r,t):n(r)?T(r,t):u(r)?w(r,t):h(r)?C(r,t):Array.isArray(r)?r.map(e=>"string"==typeof e?"'"+e.toString().replaceAll("'","''")+"'":l(e)||o(e)?m(e,t):n(e)?T(e,t):u(e)?w(e,t):h(e)?C(e,t):e.toString()):r.toString()}case"expression-list":{const i=[];for(const l of e.value)i.push(this.evaluateNodeToWhereClause(l,t,r,s,a));return i}case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,I.BADNESS,a)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,a)+") ";case"IS":if("null"!==e.right.type)throw new W("UnsupportedIsRhs");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new W("UnsupportedIsRhs");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IS NOT NULL )";case"IN":{if("expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this._stringToCode[t.value]){l=!1;break}i.push(this._stringToCode[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}const i=this.evaluateNodeToWhereClause(e.right,t,r,s,a);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) "}const i=this.evaluateNodeToWhereClause(e.right,t,r,s,a);return Array.isArray(i)?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" IN ("+i+")) "}case"NOT IN":{if("expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const i=[];let l=!0;for(const t of e.right.value){if("string"!==t.type){l=!1;break}if(void 0===this._stringToCode[t.value]){l=!1;break}i.push(this._stringToCode[t.value].toString())}if(l)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}const i=this.evaluateNodeToWhereClause(e.right,t,r,s,a);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) "}const i=this.evaluateNodeToWhereClause(e.right,t,r,s,a);return Array.isArray(i)?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,a)+" NOT IN ("+i+")) "}case"BETWEEN":{const s=this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" BETWEEN "+s[0]+" AND "+s[1]+" ) "}case"NOTBETWEEN":{const s=this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" NOT BETWEEN "+s[0]+" AND "+s[1]+" ) "}case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this._stringToCode[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this._stringToCode[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._stringToCode[e.left.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,I.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,I.BADNESS,a)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return S(e.mode,t);case"current-user":return"CURRENT_USER";case"column-reference":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":g(e);case"data-type":return e.value;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,I.BADNESS,a);return N(e.name,s,t)}}throw new W("UnsupportedSyntax",{node:e.type})}extractValue(e){if(this.codefield instanceof A){const t=this.codefield.calculateValueCompiled(e);return this._codeToString[A.convertValueToStorageFormat(t)]}return this._codeToString[e.attributes[this.codefield]]}}class B extends E{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:p(e,this.field.name,f(this._sql,0),t.getFieldsIndex())}}extractValue(e){return A.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class D extends i{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}constructor(e){super(),this.declaredClass="esri.arcade.featureset.actions.Adapted",this._maxProcessing=30,this._parent=e.parentfeatureset,this._adaptedFields=e.adaptedFields,this._extraFilter=e.extraFilter}_initialiseFeatureSet(){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=[];for(const e of this._adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _queryAll(){return await this._ensureLoaded(),this._extraFilter?(await this.query({abortSignal:t})).features:this._calculateFields(await this._parent.queryAll(t))}async query(e){let t=e.where??null;const r=this._reformulateWithoutAdaptions(t),a=r.cannot;t=r.where;let i=!1,l=e.orderBy;if(null!=l){i=!0;const e=[];for(const t of this._adaptedFields)if(!(t instanceof F)&&!0===l.scanForField(t.field.name)){if(!(t instanceof x)){l=null,i=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}l&&e.length>0&&(l=l.replaceFields(e))}null!=t?null!=this._extraFilter&&(t=v(this._extraFilter,t)):t=this._extraFilter,await this._ensureLoaded();const o=await this._parent.query({...e,where:t,orderBy:l});return s(e.abortSignal),a?{...o,filterApplied:!1,ordered:!!i&&o.ordered,features:this._calculateFields(o.features)}:{...o,ordered:!!i&&o.ordered,features:this._calculateFields(o.features)}}async*_calculateFields(t){for await(const s of t)yield s.map(t=>{const s={};for(const e of this._adaptedFields)s[e.field.name]=e.extractValue(t);return new e({attributes:s,geometry:r(t.geometry)})})}async queryStat(e){let t=!1,r=e.field,s=this._reformulateWithoutAdaptions(r);t=s.cannot,r=s.where;let a=e.where??null;if(s=this._reformulateWithoutAdaptions(a),t=t||s.cannot,a=s.where,null!=a?null!==this._extraFilter&&(a=v(this._extraFilter,a)):a=this._extraFilter,t)return null==a&&null==e.spatialFilter?this._manualStat(e.stat,r,e.limit??d,e.abortSignal):{calculated:!1};const i=await this._parent.queryStat({...e,field:r,where:a});return i.calculated?i:null==a&&null==e.spatialFilter?this._manualStat(e.stat,r,e.limit??d,e.abortSignal):{calculated:!1}}async canQueryAggregate(e){for(const a of e.groupBy)for(const e of this._adaptedFields)if(a.toLowerCase()===e.field.name.toLowerCase()&&!(e instanceof F))return!1;const t=[];for(const a of e.statistics)if(null!==a.workingexpr){const e=this._reformulateWithoutAdaptions(a.workingexpr);if(e.cannot)return!1;const r=a.clone();r.workingexpr=e.where,t.push(r)}else t.push(a);let r=e.where??null;const s=this._reformulateWithoutAdaptions(r);return!s.cannot&&(r=s.where,null!==r?null!==this._extraFilter&&(r=v(this._extraFilter,r)):r=this._extraFilter,this._parent.canQueryAggregate({...e,statistics:t,where:r}))}async queryAggregate(e){const t=[];for(const i of e.statistics)if(null!==i.workingexpr){const e=this._reformulateWithoutAdaptions(i.workingexpr);if(e.cannot)throw new a("NeverReach");const r=i.clone();r.workingexpr=e.where,t.push(r)}else t.push(i);let r=e.where??null;const s=this._reformulateWithoutAdaptions(r);if(s.cannot)throw new a("NeverReach");return r=s.where,null!==r?null!==this._extraFilter&&(r=v(this._extraFilter,r)):r=this._extraFilter,this._parent.queryAggregate({...e,statistics:t,where:r})}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this._adaptedFields)if(!0===y(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}}export{D as AdaptedFeatureSet,E as AdaptedField,x as FieldRename,F as OriginalField,B as SqlExpressionAdapted,I as StringToCodeAdapted};
|
|
5
|
+
import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{throwIfCancelled as t,FeatureSetError as r}from"../support/errorsupport.js";import{FeatureSet as s}from"../support/FeatureSet.js";import{isDate as a,isLuxonDate as i,isArcadeTime as l,isArcadeDate as o,isArcadeDateOnly as n,cloneField as u,defaultMaxRecords as h}from"../support/shared.js";import{reformulateWithoutField as c,toWhereClause as d,translateFunctionToDatabaseSpecific as f,convertColumnReferenceToSql as p,makeToday as N,makeSqlFromDateTimeParameter as g,makeTimeString as S,arcadeDateToSqlString as m,arcadeDateOnlyToSqlString as T,convertIntervalToSql as C,combine as w,scanForField as _}from"../support/sqlUtils.js";import{SqlError as v}from"../../../core/sql/errorSupport.js";import y from"../../../core/sql/WhereClause.js";class W{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class A extends W{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class E extends W{constructor(e,t,r){super(u(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:c(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class F extends W{constructor(e,t,r){super(e),this.codefield=t,this._stringToCode=r,this._codeToString={};for(const s in r)this._codeToString[r[s]]=s;this.sqlRewritable=!0}static{this.BADNESS="_!!!_BAD_LKP_!!!!"}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,0,this.field.name,this.codefield instanceof y?d(this.codefield,0):this.codefield,e.parameters);return r.includes(F.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:y.create(r,{fieldsIndex:t._parent.getFieldsIndex(),timeZone:t.dateFieldsTimeZoneDefaultUTC})}}evaluateNodeToWhereClause(e,t,r=null,s=null,u){switch(e.type){case"interval":return C(this.evaluateNodeToWhereClause(e.value,t,r,s,u),e.qualifier,e.op);case"case-expression":{let s=" CASE ";"simple"===e.format&&(s+=this.evaluateNodeToWhereClause(e.operand,t,r,F.BADNESS,u));for(const a of e.clauses)s+=" WHEN "+this.evaluateNodeToWhereClause(a.operand,t,r,F.BADNESS,u)+" THEN "+this.evaluateNodeToWhereClause(a.value,t,r,F.BADNESS,u);return null!==e.else&&(s+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,F.BADNESS,u)),s+=" END ",s}case"parameter":{const r=u[e.value.toLowerCase()];return"string"==typeof r?"'"+r.toString().replaceAll("'","''")+"'":a(r)||i(r)?g(r,t):l(r)?S(r,t):o(r)?m(r,t):n(r)?T(r,t):Array.isArray(r)?r.map(e=>"string"==typeof e?"'"+e.toString().replaceAll("'","''")+"'":a(e)||i(e)?g(e,t):l(e)?S(e,t):o(e)?m(e,t):n(e)?T(e,t):e.toString()):r.toString()}case"expression-list":{const a=[];for(const i of e.value)a.push(this.evaluateNodeToWhereClause(i,t,r,s,u));return a}case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,F.BADNESS,u)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,s,u)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,s,u)+") ";case"IS":if("null"!==e.right.type)throw new v("UnsupportedIsRhs");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new v("UnsupportedIsRhs");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IS NOT NULL )";case"IN":{if("expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const a=[];let i=!0;for(const t of e.right.value){if("string"!==t.type){i=!1;break}if(void 0===this._stringToCode[t.value]){i=!1;break}a.push(this._stringToCode[t.value].toString())}if(i)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IN ("+a.join(",")+")) "}const a=this.evaluateNodeToWhereClause(e.right,t,r,s,u);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IN ("+a.join(",")+")) "}const a=this.evaluateNodeToWhereClause(e.right,t,r,s,u);return Array.isArray(a)?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IN ("+a.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" IN ("+a+")) "}case"NOT IN":{if("expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const a=[];let i=!0;for(const t of e.right.value){if("string"!==t.type){i=!1;break}if(void 0===this._stringToCode[t.value]){i=!1;break}a.push(this._stringToCode[t.value].toString())}if(i)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" NOT IN ("+a.join(",")+")) "}const a=this.evaluateNodeToWhereClause(e.right,t,r,s,u);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" NOT IN ("+a.join(",")+")) "}const a=this.evaluateNodeToWhereClause(e.right,t,r,s,u);return Array.isArray(a)?" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" NOT IN ("+a.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,s,u)+" NOT IN ("+a+")) "}case"BETWEEN":{const s=this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" BETWEEN "+s[0]+" AND "+s[1]+" ) "}case"NOTBETWEEN":{const s=this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u);return" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" NOT BETWEEN "+s[0]+" AND "+s[1]+" ) "}case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this._stringToCode[e.right.value.toString()])return" ("+s+" "+e.operator+" "+this._stringToCode[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._stringToCode[e.left.value.toString()].toString()+" "+e.operator+" "+s+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,F.BADNESS,u)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,F.BADNESS,u)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return N(e.mode,t);case"current-user":return"CURRENT_USER";case"column-reference":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+s+")":p(e);case"data-type":return e.value;case"function":{const s=this.evaluateNodeToWhereClause(e.args,t,r,F.BADNESS,u);return f(e.name,s,t)}}throw new v("UnsupportedSyntax",{node:e.type})}extractValue(e){if(this.codefield instanceof y){const t=this.codefield.calculateValueCompiled(e);return this._codeToString[y.convertValueToStorageFormat(t)]}return this._codeToString[e.attributes[this.codefield]]}}class x extends W{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:c(e,this.field.name,d(this._sql,0),t.getFieldsIndex())}}extractValue(e){return y.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class I extends s{static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}constructor(e){super(),this.declaredClass="esri.arcade.featureset.actions.Adapted",this._maxProcessing=30,this._parent=e.parentfeatureset,this._adaptedFields=e.adaptedFields,this._extraFilter=e.extraFilter}_initialiseFeatureSet(){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=[];for(const e of this._adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}async _queryAll(){return await this._ensureLoaded(),this._extraFilter?(await this.query({abortSignal:e})).features:this._calculateFields(await this._parent.queryAll(e))}async query(e){let r=e.where??null;const s=this._reformulateWithoutAdaptions(r),a=s.cannot;r=s.where;let i=!1,l=e.orderBy;if(null!=l){i=!0;const e=[];for(const t of this._adaptedFields)if(!(t instanceof A)&&!0===l.scanForField(t.field.name)){if(!(t instanceof E)){l=null,i=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}l&&e.length>0&&(l=l.replaceFields(e))}null!=r?null!=this._extraFilter&&(r=w(this._extraFilter,r)):r=this._extraFilter,await this._ensureLoaded();const o=await this._parent.query({...e,where:r,orderBy:l});return t(e.abortSignal),a?{...o,filterApplied:!1,ordered:!!i&&o.ordered,features:this._calculateFields(o.features)}:{...o,ordered:!!i&&o.ordered,features:this._calculateFields(o.features)}}async*_calculateFields(e){for await(const t of e)yield t.map(e=>{const t={};for(const r of this._adaptedFields)t[r.field.name]=r.extractValue(e);return{attributes:t,geometry:e.geometry}})}async queryStat(e){let t=!1,r=e.field,s=this._reformulateWithoutAdaptions(r);t=s.cannot,r=s.where;let a=e.where??null;if(s=this._reformulateWithoutAdaptions(a),t=t||s.cannot,a=s.where,null!=a?null!==this._extraFilter&&(a=w(this._extraFilter,a)):a=this._extraFilter,t)return null==a&&null==e.spatialFilter?this._manualStat(e.stat,r,e.limit??h,e.abortSignal):{calculated:!1};const i=await this._parent.queryStat({...e,field:r,where:a});return i.calculated?i:null==a&&null==e.spatialFilter?this._manualStat(e.stat,r,e.limit??h,e.abortSignal):{calculated:!1}}async canQueryAggregate(e){for(const a of e.groupBy)for(const e of this._adaptedFields)if(a.toLowerCase()===e.field.name.toLowerCase()&&!(e instanceof A))return!1;const t=[];for(const a of e.statistics)if(null!==a.workingexpr){const e=this._reformulateWithoutAdaptions(a.workingexpr);if(e.cannot)return!1;const r=a.clone();r.workingexpr=e.where,t.push(r)}else t.push(a);let r=e.where??null;const s=this._reformulateWithoutAdaptions(r);return!s.cannot&&(r=s.where,null!==r?null!==this._extraFilter&&(r=w(this._extraFilter,r)):r=this._extraFilter,this._parent.canQueryAggregate({...e,statistics:t,where:r}))}async queryAggregate(e){const t=[];for(const i of e.statistics)if(null!==i.workingexpr){const e=this._reformulateWithoutAdaptions(i.workingexpr);if(e.cannot)throw new r("NeverReach");const s=i.clone();s.workingexpr=e.where,t.push(s)}else t.push(i);let s=e.where??null;const a=this._reformulateWithoutAdaptions(s);if(a.cannot)throw new r("NeverReach");return s=a.where,null!==s?null!==this._extraFilter&&(s=w(this._extraFilter,s)):s=this._extraFilter,this._parent.queryAggregate({...e,statistics:t,where:s})}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this._adaptedFields)if(!0===_(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}}export{I as AdaptedFeatureSet,W as AdaptedField,E as FieldRename,A as OriginalField,x as SqlExpressionAdapted,F 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{throwIfCancelled as t}from"../support/errorsupport.js";import{FeatureSet as s}from"../support/FeatureSet.js";import{defaultMaxRecords as r}from"../support/shared.js";import{combine as
|
|
5
|
+
import{neverAbortedSignal as e}from"../../arcadeEnvironment.js";import{throwIfCancelled as t}from"../support/errorsupport.js";import{FeatureSet as s}from"../support/FeatureSet.js";import{defaultMaxRecords as r}from"../support/shared.js";import{combine as l}from"../support/sqlUtils.js";import a from"../../../core/sql/WhereClause.js";class i extends s{constructor(e){super(),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof a?(this._whereClause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereClause=null)}_initialiseFeatureSet(){this.fields=this._parent.fields.slice(),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.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes}async _queryAll(){return(await this.query({abortSignal:e})).features}async query(e){let s=e.where;null!==this._whereClauseFunction||(null!=s?null!==this._whereClause&&(s=l(this._whereClause,s)):s=this._whereClause),await this._ensureLoaded();const r=await this._parent.query({...e,where:s});return t(e.abortSignal),r.filterApplied&&null==this._whereClauseFunction?r:{...r,features:this._applyFilter(r.features,e.abortSignal)}}async*_applyFilter(e,s){for await(const r of e)if(t(s),null!=this._whereClause){const e=r.filter(e=>this._whereClause.testFeature(e));e.length>0&&(yield e)}else if(null!=this._whereClauseFunction){const e=[];for(const t of r)await this._whereClauseFunction(t)&&e.push(t);e.length>0&&(yield e)}else yield r}async queryStat(e){if(null!==this._whereClauseFunction)return null==e.where&&null==e.spatialFilter?this._manualStat(e.stat,e.field,e.limit??r,e.abortSignal):{calculated:!1};let t=this._whereClause;null!=e.where&&null!==this._whereClause&&(t=l(this._whereClause,e.where));const s=await this._parent.queryStat({...e,where:t});return s.calculated?s:null==e.where&&null==e.spatialFilter?this._manualStat(e.stat,e.field,e.limit??r,e.abortSignal):{calculated:!1}}async canQueryAggregate(e){if(null!==this._whereClauseFunction)return!1;let t=e.where;return null!=t?null!==this._whereClause&&(t=l(this._whereClause,t)):t=this._whereClause,this._parent.canQueryAggregate({...e,where:t})}async queryAggregate(e){let t=e.where;return null!=t?null!==this._whereClause&&(t=l(this._whereClause,t)):t=this._whereClause,this._parent.queryAggregate({...e,where:t})}getFieldsIndex(){return this._parent.getFieldsIndex()}}export{i as default};
|