@arcgis/core 4.28.0-next.20230622 → 4.28.0-next.20230624
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/Basemap.js +1 -1
- package/Color.js +1 -1
- package/arcade/ArcadeModuleResolver.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeTimeUtils.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
- package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
- package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
- package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
- package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
- package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
- package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
- package/assets/esri/core/workers/chunks/{64008bde5d3ffd9f2499.js → 2306215cd5a16621e821.js} +1 -1
- package/assets/esri/core/workers/chunks/26dc66f0e00d533d9001.js +1 -0
- package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
- package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
- package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
- package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
- package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
- package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
- package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → 42560a448988f36a5b68.js} +1 -1
- package/assets/esri/core/workers/chunks/46bf80aa167771db5e8b.js +1 -0
- package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
- package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
- package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
- package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
- package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
- package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
- package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
- package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
- package/assets/esri/core/workers/chunks/7240b9dfcbb40eae04dd.js +1 -0
- package/assets/esri/core/workers/chunks/7a973d70e6bc42d804ee.js +1 -0
- package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
- package/assets/esri/core/workers/chunks/{a16458b4653b284b4b80.js → 89f7fd2ab92aa14fe0c0.js} +1 -1
- package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
- package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
- package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
- package/assets/esri/core/workers/chunks/ad3019e3542d81470dc1.js +1 -0
- package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
- package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
- package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
- package/assets/esri/core/workers/chunks/{2882a55a971af1f7858b.js → c3f4c5d530b586a3454d.js} +1 -1
- package/assets/esri/core/workers/chunks/c43d3c7e255f2c409c8f.js +1 -0
- package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
- package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
- package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
- package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
- package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
- package/assets/esri/core/workers/chunks/d18296f208339d52d8f3.js +1 -0
- package/assets/esri/core/workers/chunks/{05c0fdbfc82538f2f68d.js → e009e7f074a572894f48.js} +1 -1
- package/assets/esri/core/workers/chunks/e531b827b9f69d16ee7e.js +1 -0
- package/assets/esri/core/workers/chunks/{9c8ab6bd8c170cbc5fa5.js → e612f988f562f4c5d4b6.js} +1 -1
- package/assets/esri/core/workers/chunks/ea478f2f4a19463e13fd.js +1 -0
- package/assets/esri/core/workers/chunks/{57bb8516fa998a0fba78.js → eda278d51b145f37dd30.js} +1 -1
- package/assets/esri/core/workers/chunks/{dbd86e4b7983873cbe7c.js → eff6ebce38498a67d34e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
- package/assets/esri/core/workers/chunks/{002fe1ec63ea33e6972d.js → fff1d8917d6145eeba3a.js} +1 -1
- package/assets/esri/t9n/common.json +1 -1
- package/assets/esri/t9n/common_en.json +1 -1
- package/assets/esri/themes/base/_animation.scss +4 -4
- package/assets/esri/themes/base/widgets/_Attachments.scss +1 -1
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +1 -1
- package/assets/esri/themes/base/widgets/_Daylight.scss +1 -1
- package/assets/esri/themes/base/widgets/_Directions.scss +1 -1
- package/assets/esri/themes/base/widgets/_FeatureForm.scss +1 -1
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +3 -3
- package/assets/esri/themes/base/widgets/_IdentityModal.scss +6 -6
- package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
- package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +18 -9
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +2 -2
- package/assets/esri/themes/base/widgets/_Popup.scss +2 -2
- package/assets/esri/themes/base/widgets/_SaveLayer.scss +1 -1
- package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
- package/assets/esri/themes/base/widgets/_Slider.scss +1 -1
- package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +2 -2
- package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +1 -1
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +1 -1
- 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/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/chunks/HUDMaterial.glsl.js +39 -39
- package/chunks/HighlightBlur.glsl.js +2 -2
- package/chunks/ShadowHighlight.glsl.js +1 -1
- package/chunks/arcade.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/core/HandleOwner.js +1 -1
- package/core/JSONSupport.js +1 -1
- package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
- package/core/urlUtils.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/geometry/support/normalizeUtilsSync.js +1 -1
- package/interfaces.d.ts +1 -1
- package/kernel.js +1 -1
- package/layers/Layer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/mixins/PortalLayer.js +1 -1
- package/package.json +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
- package/views/2d/layers/features/sources/DataTileSource.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
- package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
- package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/LayerViewManager.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/layers/LayerView.js +1 -1
- package/views/overlay/ViewOverlay.js +1 -1
- package/views/webgl/checkWebGLError.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Slice.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/support/UnitSelect.js +1 -1
- package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
- package/assets/esri/core/workers/chunks/0fb1d3dce61bdd71bfff.js +0 -1
- package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
- package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
- package/assets/esri/core/workers/chunks/3620e9fa4b5dbc21ad87.js +0 -1
- package/assets/esri/core/workers/chunks/42be658be0019944d8d5.js +0 -1
- package/assets/esri/core/workers/chunks/42dfebbe964f2b44ffab.js +0 -1
- package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
- package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
- package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
- package/assets/esri/core/workers/chunks/5c69acab678f61d3f1a2.js +0 -1
- package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +0 -1
- package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
- package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
- package/assets/esri/core/workers/chunks/6aa42f510969014db3f4.js +0 -1
- package/assets/esri/core/workers/chunks/79cb672c85ea29e8484a.js +0 -1
- package/assets/esri/core/workers/chunks/80aa79040c0a7d039c3d.js +0 -1
- package/assets/esri/core/workers/chunks/88fdd288ef799a7ac48a.js +0 -1
- package/assets/esri/core/workers/chunks/91f957cd49a95a8a95f5.js +0 -1
- package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
- package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
- package/assets/esri/core/workers/chunks/a54f361506012be46fdb.js +0 -1
- package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
- package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
- package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
- package/assets/esri/core/workers/chunks/d0ff496834686dbfe29f.js +0 -1
- package/assets/esri/core/workers/chunks/d1c00e7d7884c3010e1c.js +0 -1
- package/assets/esri/core/workers/chunks/de3d57c9b5d7a1d33bf1.js +0 -1
- package/assets/esri/core/workers/chunks/dede2b4948f1f07a9859.js +0 -1
- package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
- package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
- package/assets/esri/core/workers/chunks/e3f7d464f6d74523fc13.js +0 -1
- package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
- package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
- package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.js +0 -1
- package/assets/esri/core/workers/chunks/f88a6a9c837b5f76bdd2.js +0 -1
package/Basemap.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import r from"./core/Collection.js";import{referenceSetter as t}from"./core/collectionUtils.js";import{deprecated as s}from"./core/deprecate.js";import{JSONSupportMixin as
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import r from"./core/Collection.js";import{referenceSetter as t}from"./core/collectionUtils.js";import{deprecated as s}from"./core/deprecate.js";import{JSONSupportMixin as a}from"./core/JSONSupport.js";import{isClonable as o,clone as i}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{throwIfAborted as c,eachAlways as m}from"./core/promiseUtils.js";import{isProtocolRelative as h,urlToObject as u}from"./core/urlUtils.js";import{property as y}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{subclass as d}from"./core/accessorSupport/decorators/subclass.js";import{writer as f}from"./core/accessorSupport/decorators/writer.js";import b from"./geometry/SpatialReference.js";import L from"./portal/Portal.js";import g from"./portal/PortalItem.js";import{getBasemapTitle as w,esriBasemapDefinitions as I}from"./support/basemapDefinitions.js";import{getLayerJSON as j}from"./webdoc/support/writeUtils.js";var S;let v=0;const _="esri.Basemap";let M=S=class extends(a(n)){constructor(e){super(e),this.id=null,this.portalItem=null,this.spatialReference=null,this.thumbnailUrl=null,this.title="Basemap",this.id=Date.now().toString(16)+"-basemap-"+v++,this.baseLayers=new r,this.referenceLayers=new r;const t=e=>{e.parent&&e.parent!==this&&"remove"in e.parent&&e.parent.remove(e),e.parent=this,"elevation"===e.type&&p.getLogger(this).error(`Layer '${e.title}, id:${e.id}' of type '${e.type}' is not supported as a basemap layer and will therefore be ignored.`)},s=e=>{e.parent=null};this.addHandles([this.baseLayers.on("after-add",(e=>t(e.item))),this.referenceLayers.on("after-add",(e=>t(e.item))),this.baseLayers.on("after-remove",(e=>s(e.item))),this.referenceLayers.on("after-remove",(e=>s(e.item)))])}initialize(){this.when().catch((e=>{p.getLogger(this).error("#load()",`Failed to load basemap (title: '${this.title}', id: '${this.id}')`,e)})),this.resourceInfo&&this.read(this.resourceInfo.data,this.resourceInfo.context)}destroy(){this.baseLayers.destroy(),this.referenceLayers.destroy(),this.portalItem=null}normalizeCtorArgs(e){return e&&"resourceInfo"in e&&(this._set("resourceInfo",e.resourceInfo),delete(e={...e}).resourceInfo),e}set baseLayers(e){this._set("baseLayers",t(e,this._get("baseLayers")))}_writeBaseLayers(e,r,t){const s=[];e?(t={...t,layerContainerType:"basemap"},this.baseLayers.forEach((e=>{const r=j(e,t.webmap?t.webmap.getLayerJSONFromResourceInfo(e):null,t);null!=r&&s.push(r)})),this.referenceLayers.forEach((e=>{const r=j(e,t.webmap?t.webmap.getLayerJSONFromResourceInfo(e):null,t);null!=r&&("scene"!==e.type&&(r.isReference=!0),s.push(r))})),r.baseMapLayers=s):r.baseMapLayers=s}set referenceLayers(e){this._set("referenceLayers",t(e,this._get("referenceLayers")))}writeTitle(e,r){r.title=e||"Basemap"}load(e){return this.addResolvingPromise(this._loadFromSource(e)),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.baseLayers,this.referenceLayers)}))}clone(){const e={id:this.id,title:this.title,portalItem:this.portalItem,baseLayers:this.baseLayers.map((e=>o(e)?e.clone():e)),referenceLayers:this.referenceLayers.map((e=>o(e)?e.clone():e))};return this.loaded&&(e.loadStatus="loaded"),new S({resourceInfo:this.resourceInfo}).set(e)}read(e,r){this.resourceInfo||this._set("resourceInfo",{data:e,context:r}),super.read(e,r)}write(e,r){return e=e||{},r&&r.origin||(r={origin:"web-map",...r}),super.write(e,r),!this.loaded&&this.resourceInfo&&this.resourceInfo.data.baseMapLayers&&(e.baseMapLayers=this.resourceInfo.data.baseMapLayers.map((e=>{const r=i(e);return r.url&&h(r.url)&&(r.url=`https:${r.url}`),r.templateUrl&&h(r.templateUrl)&&(r.templateUrl=`https:${r.templateUrl}`),r}))),e}async _loadFromSource(e){const{resourceInfo:r,portalItem:t}=this;c(e);const s=[];if(r){const t=r.context?r.context.url:null;if(s.push(this._loadLayersFromJSON(r.data,t,e)),r.data.id&&!r.data.title){const e=r.data.id;s.push(w(e).then((e=>{e&&this.read({title:e},r.context)})))}}else t&&s.push(this._loadFromItem(t,e));await Promise.all(s)}async _loadLayersFromJSON(e,r,t){const s=this.resourceInfo&&this.resourceInfo.context,a=this.portalItem&&this.portalItem.portal||s&&s.portal||null,o=x[s?.origin||""]??"web-map",{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),n=[];if(c(t),e.baseMapLayers&&Array.isArray(e.baseMapLayers)){const t={context:{origin:o,url:r,portal:a,layerContainerType:"basemap"},defaultLayerType:"DefaultTileLayer"},s=e=>"web-scene"===o&&"ArcGISSceneServiceLayer"===e.layerType||e.isReference,l=i(this.baseLayers,e.baseMapLayers.filter((e=>!s(e))),t);n.push(l);const p=i(this.referenceLayers,e.baseMapLayers.filter(s),t);n.push(p)}await m(n)}async _loadFromItem(e,r){const t=await e.load(r),s=await t.fetchData("json",r),a=u(e.itemUrl??"");return this._set("resourceInfo",{data:s.baseMap??{},context:{origin:U[e.type||""]??"web-map",portal:e.portal||L.getDefault(),url:a}}),this.read(this.resourceInfo.data,this.resourceInfo.context),this.read({spatialReference:s.spatialReference},this.resourceInfo.context),this.read({title:e.title,thumbnailUrl:e.thumbnailUrl},{origin:"portal-item",portal:e.portal||L.getDefault(),url:a}),this._loadLayersFromJSON(this.resourceInfo.data,a,r)}static fromId(e){const r=I[e];if(!r)return null;if(r.deprecated){let r=null;"dark-gray"===e?r="dark-gray-vector":"gray"===e?r="gray-vector":"streets"===e?r="streets-vector":"topo"===e&&(r="topo-vector"),s(p.getLogger(_),`The ${e} basemap has entered mature support and is no longer being updated.`,{replacement:r,see:"https://arcg.is/1iq8aD",warnOnce:!0})}return S.fromJSON(r)}};e([y({json:{write:{ignoreOrigin:!0,target:"baseMapLayers",writer(e,r,t,s){this._writeBaseLayers(e,r,s)}},origins:{"web-scene":{write:{ignoreOrigin:!0,target:{baseMapLayers:{type:r}},writer(e,r,t,s){this._writeBaseLayers(e,r,s)}}}}}})],M.prototype,"baseLayers",null),e([y({type:String,json:{origins:{"web-scene":{write:!0}}}})],M.prototype,"id",void 0),e([y({type:g})],M.prototype,"portalItem",void 0),e([y()],M.prototype,"referenceLayers",null),e([y({readOnly:!0})],M.prototype,"resourceInfo",void 0),e([y({type:b})],M.prototype,"spatialReference",void 0),e([y()],M.prototype,"thumbnailUrl",void 0),e([y({type:String,json:{origins:{"web-scene":{write:{isRequired:!0}}}}})],M.prototype,"title",void 0),e([f("title")],M.prototype,"writeTitle",null),M=S=e([d(_)],M);const U={"Web Scene":"web-scene","Web Map":"web-map","Link Chart":"link-chart"},x={"web-scene":"web-scene","web-map":"web-map","link-chart":"link-chart"},O=M;export{O as default};
|
package/Color.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as i}from"./core/mathUtils.js";import{ensureInteger as n}from"./core/accessorSupport/ensureType.js";function a(t){return i(n(t),0,255)}function e(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}class o{static blendColors(t,r,s,i=new o){return i.r=Math.round(t.r+(r.r-t.r)*s),i.g=Math.round(t.g+(r.g-t.g)*s),i.b=Math.round(t.b+(r.b-t.b)*s),i.a=t.a+(r.a-t.a)*s,i._sanitize()}static fromRgb(r,s){const i=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(i){const r=i[2].split(/\s*,\s*/),n=i[1];if("rgb"===n&&3===r.length||"rgba"===n&&4===r.length){const t=r[0];if("%"===t.charAt(t.length-1)){const t=r.map((t=>2.56*parseFloat(t)));return 4===r.length&&(t[3]=parseFloat(r[3])),o.fromArray(t,s)}return o.fromArray(r.map((t=>parseFloat(t))),s)}if("hsl"===n&&3===r.length||"hsla"===n&&4===r.length)return o.fromArray(t(parseFloat(r[0]),parseFloat(r[1])/100,parseFloat(r[2])/100,parseFloat(r[3])),s)}return null}static fromHex(t,r=new o){if(4!==t.length&&7!==t.length||"#"!==t[0])return null;const s=4===t.length?4:8,i=(1<<s)-1;let n=Number("0x"+t.substr(1));return isNaN(n)?null:(["b","g","r"].forEach((t=>{const a=n&i;n>>=s,r[t]=4===s?17*a:a})),r.a=1,r)}static fromArray(t,r=new o){return r._set(Number(t[0]),Number(t[1]),Number(t[2]),Number(t[3])),isNaN(r.a)&&(r.a=1),r._sanitize()}static fromString(t,i){const n=r(t)?s(t):null;return n&&o.fromArray(n,i)||o.fromRgb(t,i)||o.fromHex(t,i)}static fromJSON(t){return t
|
|
5
|
+
import{hsla2rgba as t,isNamedColor as r,getNamedColor as s}from"./colorUtils.js";import{clamp as i}from"./core/mathUtils.js";import{ensureInteger as n}from"./core/accessorSupport/ensureType.js";function a(t){return i(n(t),0,255)}function e(t,r,s){return t=Number(t),isNaN(t)?s:t<r?r:t>s?s:t}class o{static blendColors(t,r,s,i=new o){return i.r=Math.round(t.r+(r.r-t.r)*s),i.g=Math.round(t.g+(r.g-t.g)*s),i.b=Math.round(t.b+(r.b-t.b)*s),i.a=t.a+(r.a-t.a)*s,i._sanitize()}static fromRgb(r,s){const i=r.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(i){const r=i[2].split(/\s*,\s*/),n=i[1];if("rgb"===n&&3===r.length||"rgba"===n&&4===r.length){const t=r[0];if("%"===t.charAt(t.length-1)){const t=r.map((t=>2.56*parseFloat(t)));return 4===r.length&&(t[3]=parseFloat(r[3])),o.fromArray(t,s)}return o.fromArray(r.map((t=>parseFloat(t))),s)}if("hsl"===n&&3===r.length||"hsla"===n&&4===r.length)return o.fromArray(t(parseFloat(r[0]),parseFloat(r[1])/100,parseFloat(r[2])/100,parseFloat(r[3])),s)}return null}static fromHex(t,r=new o){if(4!==t.length&&7!==t.length||"#"!==t[0])return null;const s=4===t.length?4:8,i=(1<<s)-1;let n=Number("0x"+t.substr(1));return isNaN(n)?null:(["b","g","r"].forEach((t=>{const a=n&i;n>>=s,r[t]=4===s?17*a:a})),r.a=1,r)}static fromArray(t,r=new o){return r._set(Number(t[0]),Number(t[1]),Number(t[2]),Number(t[3])),isNaN(r.a)&&(r.a=1),r._sanitize()}static fromString(t,i){const n=r(t)?s(t):null;return n&&o.fromArray(n,i)||o.fromRgb(t,i)||o.fromHex(t,i)}static fromJSON(t){return null!=t?new o([t[0],t[1],t[2],(t[3]??255)/255]):void 0}static toUnitRGB(t){return null!=t?[t.r/255,t.g/255,t.b/255]:null}static toUnitRGBA(t){return null!=t?[t.r/255,t.g/255,t.b/255,null!=t.a?t.a:1]:null}constructor(t){this.r=255,this.g=255,this.b=255,this.a=1,t&&this.setColor(t)}get isBright(){return.299*this.r+.587*this.g+.114*this.b>=127}setColor(t){return"string"==typeof t?o.fromString(t,this):Array.isArray(t)?o.fromArray(t,this):(this._set(t.r??0,t.g??0,t.b??0,t.a??1),t instanceof o||this._sanitize()),this}toRgb(){return[this.r,this.g,this.b]}toRgba(){return[this.r,this.g,this.b,this.a]}toHex(){const t=this.r.toString(16),r=this.g.toString(16),s=this.b.toString(16);return`#${t.length<2?"0"+t:t}${r.length<2?"0"+r:r}${s.length<2?"0"+s:s}`}toCss(t=!1){const r=this.r+", "+this.g+", "+this.b;return t?`rgba(${r}, ${this.a})`:`rgb(${r})`}toString(){return this.toCss(!0)}toJSON(){return this.toArray()}toArray(t=o.AlphaMode.ALWAYS){const r=a(this.r),s=a(this.g),i=a(this.b);return t===o.AlphaMode.ALWAYS||1!==this.a?[r,s,i,a(255*this.a)]:[r,s,i]}clone(){return new o(this.toRgba())}hash(){return this.r<<24|this.g<<16|this.b<<8|255*this.a}equals(t){return null!=t&&t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a}_sanitize(){return this.r=Math.round(e(this.r,0,255)),this.g=Math.round(e(this.g,0,255)),this.b=Math.round(e(this.b,0,255)),this.a=e(this.a,0,1),this}_set(t,r,s,i){this.r=t,this.g=r,this.b=s,this.a=i}}o.prototype.declaredClass="esri.Color",function(t){var r;(r=t.AlphaMode||(t.AlphaMode={}))[r.ALWAYS=0]="ALWAYS",r[r.UNLESS_OPAQUE=1]="UNLESS_OPAQUE"}(o||(o={}));const h=o;export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../request.js";import t from"
|
|
5
|
+
import e from"../request.js";import{ModuleError as t,ModuleErrorCodes as r}from"./executionError.js";import{parseScript as o}from"./parser.js";import s from"./featureset/support/RecentlyUsedCache.js";import i from"../portal/Portal.js";class l{constructor(e){this.portalUri=e}normalizeModuleUri(e){const o=/^[a-z0-9A-Z]+(@[0-9]+\.[0-9]+\.[0-9]+)?([\?|\/].*)?$/gi,s=/(?<portalurl>.+)\/home\/item\.html\?id\=(?<itemid>.+)$/gi,c=/(?<portalurl>.+)\/sharing\/rest\/content\/users\/[a-zA-Z0-9]+\/items\/(?<itemid>.+)$/gi,u=/(?<portalurl>.+)\/sharing\/rest\/content\/items\/(?<itemid>.+)$/gi,n=/(?<itemid>.*)@(?<versionstring>[0-9]+\.[0-9]+\.[0-9]+)([\?|\/].*)?$/gi;if(e.startsWith("portal+")){let l=e.substring(7),a="",m=l,d=!1;for(const e of[s,u,c]){const t=e.exec(l);if(null!==t){const e=t.groups;m=e.itemid,a=e.portalurl,d=!0;break}}if(!1===d){if(!o.test(l))throw new t(r.UnsupportedUriProtocol,{uri:e});m=l,a=this.portalUri}m.includes("/")&&(m=m.split("/")[0]),m.includes("?")&&(m=m.split("?")[0]);let h="current";const p=n.exec(m);if(null!==p){const e=p.groups;m=e.itemid,h=e.versionstring}return l=new i({url:a}).restUrl+"/content/items/"+m+"/resources/"+h+".arc",{url:l,scheme:"portal",uri:"PO:"+l}}if(e.startsWith("mock")){if("mock"===e){return{url:"",scheme:"mock",data:'\n export var hello = 1;\n export function helloWorld() {\n return "Hello World " + hello;\n }\n ',uri:"mock"}}const t=e.replace("mock:","");if(void 0!==l.mocks[t])return{url:"",scheme:"mock",data:l.mocks[t],uri:e}}throw new t(r.UnrecognisedUri,{uri:e})}async fetchModule(e){const t=l.cachedModules.getFromCache(e.uri);if(t)return t;const r=this.fetchSource(e);l.cachedModules.addToCache(e.uri,r);let o=null;try{o=await r}catch(s){throw l.cachedModules.removeFromCache(e.uri),s}return o}async fetchSource(s){if("portal"===s.scheme){const t=await e(s.url,{responseType:"text",query:{}});if(t.data)return o(t.data,[])}if("mock"===s.scheme)return o(s.data??"",[]);throw new t(r.UnsupportedUriProtocol)}static create(e){return new l(e)}static getDefault(){return this._default??(l._default=l._moduleResolverFactory())}static set moduleResolverClass(e){this._moduleResolverFactory=e,this._default=null}}l.mocks={},l.cachedModules=new s(30),l._default=null,l._moduleResolverFactory=()=>{const e=i.getDefault();return new l(e.url)};export{l as ArcadeModuleResolver};
|
package/arcade/Feature.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"./Dictionary.js";import
|
|
5
|
+
import{ArcadeDate as e}from"./ArcadeDate.js";import{DateTimeReferenceFieldIndex as t}from"./arcadeTimeUtils.js";import{configureDeepClone as i}from"./deepClone.js";import r from"./Dictionary.js";import{ArcadeExecutionError as s,ExecutionErrorCodes as n}from"./executionError.js";import a from"./ImmutableArray.js";import{a as o,b as l,c as u,t as f,k as c,f as d,d as h}from"../chunks/languageUtils.js";import m from"../geometry/Geometry.js";import y from"../geometry/Point.js";import{fromJSON as _}from"../geometry/support/jsonUtils.js";import{convertToGeometry as p}from"../layers/graphics/featureConversionUtils.js";class b{constructor(){this.arcadeDeclaredClass="esri.arcade.Feature",this._optimizedGeomDefinition=null,this._geometry=null,this.attributes=null,this._layer=null,this._datesfixed=!0,this.dateTimeReferenceFieldIndex=null,this.contextTimeReference=null,this.immutable=!0,this._datefields=null,this.immutable=!0}static createFromGraphic(e,i){const r=new b;return r.contextTimeReference=i??null,r._geometry=null!=e.geometry?e.geometry:null,void 0===e.attributes||null===e.attributes?r.attributes={}:r.attributes=e.attributes,e._sourceLayer?(r._layer=e._sourceLayer,r._datesfixed=!1):e._layer?(r._layer=e._layer,r._datesfixed=!1):e.layer&&"fields"in e.layer?(r._layer=e.layer,r._datesfixed=!1):e.sourceLayer&&"fields"in e.sourceLayer&&(r._layer=e.sourceLayer,r._datesfixed=!1),r._layer&&!1===r._datesfixed&&(void 0!==r._layer.dateTimeReferenceFieldIndex?r.dateTimeReferenceFieldIndex=r._layer.dateTimeReferenceFieldIndex:r.dateTimeReferenceFieldIndex=t.createFromLayer(r._layer)),r}static createFromArcadeFeature(e){if(e instanceof b){const t=new b;return t._datesfixed=e._datesfixed,t.attributes=e.attributes,t._geometry=e._geometry,t._optimizedGeomDefinition=e._optimizedGeomDefinition,e._layer&&(t._layer=e._layer),t.dateTimeReferenceFieldIndex=e.dateTimeReferenceFieldIndex,t.contextTimeReference=e.contextTimeReference,t}const t={};for(const i of e.keys())t[i]=e.field(i);return b.createFromGraphicLikeObject(e.geometry(),t,e.fullSchema(),e.contextTimeReference)}static createFromOptimisedFeature(e,t,i){const r=new b;return r._geometry=e.geometry?{geometry:e.geometry}:null,r._optimizedGeomDefinition=i,r.attributes=e.attributes||{},r._layer=t,r._datesfixed=!1,r}static createFromArcadeDictionary(e){const t=new b;return t.attributes=e.field("attributes"),null!==t.attributes&&t.attributes instanceof r?(t.attributes=t.attributes.attributes,null===t.attributes&&(t.attributes={})):t.attributes={},t._geometry=e.field("geometry"),null!==t._geometry&&(t._geometry instanceof r?t._geometry=b.parseGeometryFromDictionary(t._geometry):t._geometry instanceof m||(t._geometry=null)),t}static createFromGraphicLikeObject(e,i,r=null,s){const n=new b;return n.contextTimeReference=s??null,null===i&&(i={}),n.attributes=i,n._geometry=null!=e?e:null,n._layer=r,n._layer&&(n._datesfixed=!1,void 0!==n._layer.dateTimeReferenceFieldIndex?n.dateTimeReferenceFieldIndex=n._layer.dateTimeReferenceFieldIndex:n.dateTimeReferenceFieldIndex=t.createFromLayer(n._layer)),n}repurposeFromGraphicLikeObject(e,t,i=null){null===t&&(t={}),this.attributes=t,this._geometry=e??null,this._layer=i,this._layer?this._datesfixed=!1:this._datesfixed=!0}get layerPreferredTimeZone(){return this.dateTimeReferenceFieldIndex?.layerPreferredTimeZone??""}fieldSourceTimeZone(e){return this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)??""}castToText(t=!1){let i="";!1===this._datesfixed&&this._fixDates();for(const r in this.attributes){""!==i&&(i+=",");const s=this.attributes[r];null==s?i+=JSON.stringify(r)+":null":o(s)||l(s)||u(s)?i+=JSON.stringify(r)+":"+JSON.stringify(s):s instanceof m?i+=JSON.stringify(r)+":"+f(s):s instanceof a||s instanceof Array?i+=JSON.stringify(r)+":"+f(s,null,t):s instanceof e?i+=t?JSON.stringify(r)+":"+JSON.stringify(s.getTime()):JSON.stringify(r)+":"+s.stringify():null!==s&&"object"==typeof s&&void 0!==s.castToText&&(i+=JSON.stringify(r)+":"+s.castToText(t))}return'{"geometry":'+(null===this.geometry()?"null":f(this.geometry()))+',"attributes":{'+i+"}}"}_fixDates(){if(null!==this._datefields)return this._datefields.length>0&&this._fixDateFields(this._datefields),void(this._datesfixed=!0);const e=[],t=this._layer.fields;for(let i=0;i<t.length;i++){const r=t[i],s=r.type;"date"!==s&&"esriFieldTypeDate"!==s||e.push(r.name)}this._datefields=e,e.length>0&&this._fixDateFields(e),this._datesfixed=!0}isUnknownDateTimeField(e){return"unknown"===this.dateTimeReferenceFieldIndex?.fieldTimeZone(e)}_fixDateFields(t){this.attributes={...this.attributes};const i=this.contextTimeReference?.timeZone??"system";for(let r=0;r<t.length;r++){let s=this.attributes[t[r]];if(null===s);else if(void 0===s){for(const n in this.attributes)if(n.toLowerCase()===t[r].toLowerCase()){if(s=this.attributes[n],null!==s){const t=this.isUnknownDateTimeField(n);c(s)?this.attributes[n]=s:s instanceof Date?this.attributes[n]=t?e.unknownDateJSToArcadeDate(s):e.dateJSAndZoneToArcadeDate(s,i):this.attributes[n]=t?e.unknownEpochToArcadeDate(s):e.epochToArcadeDate(s,i)}break}}else{const n=this.isUnknownDateTimeField(t[r]);c(s)?this.attributes[t[r]]=s:s instanceof Date?this.attributes[t[r]]=n?e.unknownDateJSToArcadeDate(s):e.dateJSAndZoneToArcadeDate(s,i):this.attributes[t[r]]=n?e.unknownEpochToArcadeDate(s):e.epochToArcadeDate(s,i)}}}geometry(){return null===this._geometry||this._geometry instanceof m||(this._optimizedGeomDefinition?(this._geometry=_(p(this._geometry,this._optimizedGeomDefinition.geometryType,this._optimizedGeomDefinition.hasZ,this._optimizedGeomDefinition.hasM)),this._geometry.spatialReference=this._optimizedGeomDefinition.spatialReference):this._geometry=_(this._geometry)),this._geometry}field(e){!1===this._datesfixed&&this._fixDates();const t=this.attributes[e];if(void 0!==t)return t;const i=e.toLowerCase();for(const r in this.attributes)if(r.toLowerCase()===i)return this.attributes[r];if(this._hasFieldDefinition(i))return null;throw new s(null,n.FieldNotFound,null,{key:e})}_hasFieldDefinition(e){if(null===this._layer)return!1;for(let t=0;t<this._layer.fields.length;t++){if(this._layer.fields[t].name.toLowerCase()===e)return!0}return!1}setField(t,i){if(this.immutable)throw new s(null,n.Immutable,null);if(i instanceof Date&&(i=this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(i):e.dateJSToArcadeDate(i)),!1===d(i))throw new s(null,n.TypeNotAllowedInFeature,null);const r=t.toLowerCase();if(void 0===this.attributes[t]){for(const e in this.attributes)if(e.toLowerCase()===r)return void(this.attributes[e]=i);this.attributes[t]=i}else this.attributes[t]=i}hasField(e){const t=e.toLowerCase();if(void 0!==this.attributes[e])return!0;for(const i in this.attributes)if(i.toLowerCase()===t)return!0;return!!this._hasFieldDefinition(t)}keys(){let e=[];const t={};for(const i in this.attributes)e.push(i),t[i.toLowerCase()]=1;if(null!==this._layer)for(let i=0;i<this._layer.fields.length;i++){const r=this._layer.fields[i];1!==t[r.name.toLowerCase()]&&e.push(r.name)}return e=e.sort(),e}static parseGeometryFromDictionary(e){const t=b._convertDictionaryToJson(e,!0);return void 0!==t.hasm&&(t.hasM=t.hasm,delete t.hasm),void 0!==t.hasz&&(t.hasZ=t.hasz,delete t.hasz),void 0!==t.spatialreference&&(t.spatialReference=t.spatialreference,delete t.spatialreference),void 0!==t.rings&&(t.rings=this._fixPathArrays(t.rings,!0===t.hasZ,!0===t.hasZ)),void 0!==t.paths&&(t.paths=this._fixPathArrays(t.paths,!0===t.hasZ,!0===t.hasM)),void 0!==t.points&&(t.points=this._fixPointArrays(t.points,!0===t.hasZ,!0===t.hasM)),_(t)}static _fixPathArrays(e,t,i){const r=[];if(e instanceof Array)for(let s=0;s<e.length;s++)r.push(this._fixPointArrays(e[s],t,i));else if(e instanceof a)for(let s=0;s<e.length();s++)r.push(this._fixPointArrays(e.get(s),t,i));return r}static _fixPointArrays(e,t,i){const r=[];if(e instanceof Array)for(let s=0;s<e.length;s++){const n=e[s];n instanceof y?t&&i?r.push([n.x,n.y,n.z,n.m]):t?r.push([n.x,n.y,n.z]):i?r.push([n.x,n.y,n.m]):r.push([n.x,n.y]):n instanceof a?r.push(n.toArray()):r.push(n)}else if(e instanceof a)for(let s=0;s<e.length();s++){const n=e.get(s);n instanceof y?t&&i?r.push([n.x,n.y,n.z,n.m]):t?r.push([n.x,n.y,n.z]):i?r.push([n.x,n.y,n.m]):r.push([n.x,n.y]):n instanceof a?r.push(n.toArray()):r.push(n)}return r}static _convertDictionaryToJson(e,t=!1){const i={};for(const s in e.attributes){let n=e.attributes[s];n instanceof r&&(n=b._convertDictionaryToJson(n)),t?i[s.toLowerCase()]=n:i[s]=n}return i}static parseAttributesFromDictionary(e){const t={};for(const i in e.attributes){const r=e.attributes[i];if(!d(r))throw new s(null,n.InvalidParameter,null);t[i]=r}return t}static fromJson(e,t){let i=null;null!==e.geometry&&void 0!==e.geometry&&(i=_(e.geometry));const r={};if(null!==e.attributes&&void 0!==e.attributes)for(const a in e.attributes){const t=e.attributes[a];if(null===t)r[a]=t;else{if(!(u(t)||l(t)||o(t)||c(t)))throw new s(null,n.InvalidParameter,null);r[a]=t}}return b.createFromGraphicLikeObject(i,r,null,t??null)}fullSchema(){return this._layer}gdbVersion(){if(null===this._layer)return"";const e=this._layer.gdbVersion;return void 0===e?"":""===e&&this._layer.capabilities&&this._layer.capabilities.isVersioned?"SDE.DEFAULT":e}castAsJson(e){const t={attributes:{},geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null};for(const i in this.attributes){const r=this.attributes[i];void 0!==r&&(t.attributes[i]=h(r,e))}return t}async castAsJsonAsync(e=null,t){return this.castAsJson(t)}}i(b);export{b as default};
|
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/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"./Dictionary.js";import n from"./Feature.js";import{i as t,u as o,R as l,I as r,v as a,w as s,x as i,y as c,j as u,c as p,a as m,g,z as d,A as f,B as h,m as y,b,p as w,o as S}from"../chunks/languageUtils.js";import{addFunctionDeclaration as v}from"./treeAnalysis.js";import{A as x}from"../chunks/array.js";import{registerFunctions as M}from"./functions/date.js";import{registerFunctions as F,geometryMember as C}from"./functions/geometry.js";import{registerFunctions as I}from"./functions/geomsync.js";import{registerFunctions as A}from"./functions/maths.js";import{registerFunctions as _}from"./functions/stats.js";import{registerFunctions as O}from"./functions/string.js";import{isPromiseLike as k}from"../core/promiseUtils.js";import E from"../geometry/Geometry.js";import R from"../geometry/SpatialReference.js";import{ArcadeModuleLoader as G}from"./ArcadeModuleLoader.js";import{ArcadeModule as B}from"./ArcadeModule.js";import{NativeFunction as $,ArcadeFunction as j,ScopeMarshalledFunction as N,wrapModuleScopedResponse as L}from"./FunctionWrapper.js";import{ArcadeExecutionError as U,ExecutionErrorCodes as D,ArcadeCompilationError as P,ArcadeUncompilableError as K}from"./executionError.js";class T extends j{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new U(e,D.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,o,l){return l(e,n,((n,r,a)=>{a=a.map((n=>!t(n)||n instanceof N?n:L(n,e,l)));const s=this.call(o,{arguments:a});return k(s)?s.then((e=>L(e,o,l))):s}))}}function q(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function W(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return ue(e,n);case"VariableDeclaration":return ce(e,n);case"BlockStatement":case"Program":return oe(e,n);case"FunctionDeclaration":return ie(e,n);case"ImportDeclaration":return re(e,n);case"ExportNamedDeclaration":return ae(e,n);case"ReturnStatement":return le(e,n);case"IfStatement":return te(e,n);case"ExpressionStatement":return ee(e,n);case"AssignmentExpression":return Z(e,n);case"UpdateExpression":return Q(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return de(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return H(e,n);case"ForInStatement":return Y(e,n);case"WhileStatement":return X(e,n);case"Identifier":return ye(e,n);case"MemberExpression":return pe(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return be(e,n);case"UnaryExpression":return me(e,n);case"BinaryExpression":return fe(e,n);case"LogicalExpression":return he(e,n);case"ArrayExpression":return ge(e,n);case"ObjectExpression":return J(e,n);case"Property":return z(e,n);case"Array":throw new P(e,D.NeverReach,n);default:throw new P(e,D.Unrecognised,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];se(l.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===l.key.type?"'"+l.key.name+"'":V(e,l.key))+",'ObjectExpression'),lang.aCheck("+V(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function z(e,n){throw new P(e,D.NeverReach,n)}function Y(e,n){const t=Fe(e),o=Fe(e),l=Fe(e);let r="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(r+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),se(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Me(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(r+="lang.chkAssig('"+i+"',runtimeCtx); \n"),r+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",r+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",r+="var "+o+"="+t+".length; \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (lc.isImmutableArray("+t+")) {",r+="var "+o+"="+t+".length(); \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",r+="var "+o+"="+t+".keys(); \n",r+="for(var "+l+"=0; "+l+"<"+o+".length; "+l+"++) {\n",r+=s+"="+o+"["+l+"];\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",e.isAsync&&(r+="else if (lc.isFeatureSet("+t+")) {",r+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",r+="for(var "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+l+"!=null; "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n"),r+="else { lastStatement = lc.voidOperation; } \n",r}function H(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Fe(e),l=Fe(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+l+" = "+V(e,n.test)+"; ",t+="if ("+l+"===false) { break; } else if ("+l+"!==true) { lang.error('"+D.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function Q(e,n){let t=null,o="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?o=V(e,n.argument.property):(o="'"+n.argument.property.name+"'",se(n.argument.property.name)),"lang.memberupdate("+t+","+o+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new U(e,D.InvalidIdentifier,n)}function X(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Fe(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${D.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function Z(e,n){const t=V(e,n.right);let o=null,l="";if("MemberExpression"===n.left.type)return o=V(e,n.left.object),!0===n.left.computed?l=V(e,n.left.property):(l="'"+n.left.property.name+"'",se(n.left.property.name)),"lang.assignmember("+o+","+l+",'"+n.operator+"',"+t+")";if(o=n.left.name.toLowerCase(),se(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+o+"'])";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[o]+"'])"}if(void 0!==e.globalScope[o])return"gscope['"+o+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+o+"'])";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[o]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(o))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(o).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(o).manglename+"'])";const l={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(o,l),"gscope[lang.chkAssig('"+l.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+l.manglename+"'])"}throw new U(e,D.InvalidIdentifier,n)}function ee(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function ne(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function te(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new P(e,D.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${ne(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+te(e,n.alternate):` else {\n ${ne(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function oe(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function le(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function re(e,n){const t=n.specifiers[0].local.name.toLowerCase();se(t);const o=e.libraryResolver?.loadLibrary(t),l=Me(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=De(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeReference:e.timeReference??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[l]=o.uri;let r="";if(r=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+r;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+r;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Me(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+r}function ae(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function se(e){if("iif"===e)throw new K;if("decode"===e)throw new K;if("when"===e)throw new K}function ie(e,n){const t=n.id.name.toLowerCase();se(t);let o="",l=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),l=!0):(o=Me(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const r={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();se(t);const o=Me(e);r.localScope._SymbolsMap[t]=o,r.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=oe(r,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=oe(r,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),l?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function ce(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function ue(e,n){let t=null===n.init?null:V(e,n.init);t===a&&(t=null);const o=n.id.name.toLowerCase();if(se(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Me(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const l=Me(e);return e.globalScope._SymbolsMap[o]=l,e.mangleMap[o]=l,"gscope['"+l+"']="+t+"; "}function pe(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",se(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function me(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function ge(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function de(e,n){try{const t=[];let o=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[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function fe(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function he(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new P(e,D.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new P(e,D.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new P(null,D.LogicExpressionOrAnd,null)}catch(t){throw t}}function ye(e,n){try{const t=n.name.toLowerCase();if(se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new P(e,D.InvalidIdentifier,n)}catch(t){throw t}}function be(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",se(n.callee.property.name));let o="[";for(let l=0;l<n.arguments.length;l++)l>0&&(o+=", "),o+=V(e,n.arguments[l]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new P(e,D.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return we(e,n);if("when"===t)return Se(e,n);if("decode"===t)return ve(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const l={manglename:Me(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,l),o="gscope[lang.chkAssig('"+l.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new P(e,D.FunctionNotFound,n)}catch(t){throw t}}function we(e,n){try{if(3!==n.arguments.length)throw new P(e,D.WrongNumberOfParameters,n);const t=Fe(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Se(e,n){try{if(n.arguments.length<3)throw new P(e,D.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new P(e,D.WrongNumberOfParameters,n);const t=Fe(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ve(e,n){try{if(n.arguments.length<2)throw new P(e,D.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new P(e,D.WrongNumberOfParameters,n);const t=Fe(e),o=Fe(e);let l="var ";for(let r=1;r<n.arguments.length-1;r+=2)l+=`${o} = ${V(e,n.arguments[r])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(e,n.arguments[r+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n ${l}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const xe={};function Me(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Fe(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}M(xe,W),O(xe,W),A(xe,W),F(xe,W),_(xe,W),xe.iif=function(e,n){try{return W(e,n,((t,o,l)=>{throw new U(e,D.Unrecognised,n)}))}catch(t){throw t}},xe.decode=function(e,n){try{return W(e,n,((t,o,l)=>{throw new U(e,D.Unrecognised,n)}))}catch(t){throw t}},xe.when=function(e,n){try{return W(e,n,((t,o,l)=>{throw new U(e,D.Unrecognised,n)}))}catch(t){throw t}};const Ce={};for(const Pe in xe)Ce[Pe]=new $(xe[Pe]);I(xe,W);for(const Pe in xe)xe[Pe]=new $(xe[Pe]);const Ie=function(){};Ie.prototype=xe;const Ae=function(){};function _e(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Oe(t,o,l,r){const a=l?new Ae:new Ie;t||(t={}),o||(o={});const s=new e({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});s.immutable=!1,a._SymbolsMap={textformatting:1,infinity:1,pi:1},a.textformatting=s,a.infinity=Number.POSITIVE_INFINITY,a.pi=Math.PI;for(const e in o)a[e]=o[e],a._SymbolsMap[e]=1;for(const e in t)a._SymbolsMap[e]=1,t[e]&&"esri.Graphic"===t[e].declaredClass?a[e]=n.createFromGraphic(t[e],r??null):a[e]=t[e];return a}Ae.prototype=Ce;const ke={fixSpatialReference:c,parseArguments:q,standardFunction:W};function Ee(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:W,standardFunctionAsync:W,evaluateIdentifier:Ge};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)xe[e]=new $(t.functions[e]),Ie.prototype[e]=xe[e];for(let e=0;e<t.signatures.length;e++)v(t.signatures[e],"sync")}else{for(const e in t.functions)Ce[e]=new $(t.functions[e]),Ae.prototype[e]=Ce[e];for(let e=0;e<t.signatures.length;e++)v(t.signatures[e],"async")}}function Re(e,n){return e(n)}function Ge(e,n){const t=n.name;if("_SymbolsMap"===t)throw new U(e,D.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack[e.localStack.length-1][t])return e.localStack[e.localStack.length-1][t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack[e.localStack.length-1][n])return e.localStack[e.localStack.length-1][n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const o=e.mangleMap[t];return void 0!==o?e.globalScope[o]:void 0}Ee([x],"sync"),Ee([x],"async");let Be=0;const $e={error(e){throw new U(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value&&e.value.then?e.value.then(r,a):(Be++,Be%100==0?setTimeout((()=>{Be=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push([]),n.depthCounter.depth>64)throw new U(null,D.MaximumCallDepth,null);const t=e.apply(this,arguments);return k(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)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new U(n,D.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new U(n,D.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>u(e),aCheck(e,n){if(t(e)){if("ArrayExpression"===n)throw new U(null,D.NoFunctionInArray,null);if("ObjectExpression"===n)throw new U(null,D.NoFunctionInDictionary,null);throw new U(null,D.NoFunctionInTemplateLiteral,null)}return e===a?null:e},Dictionary:e,Feature:n,UserDefinedCompiledFunction:T,dictionary(n){const o={},l=new Map;for(let e=0;e<n.length;e+=2){if(t(n[e+1]))throw new U(null,D.NoFunctionInDictionary,null);if(!1===p(n[e]))throw new U(null,D.KeyMustBeString,null);let r=n[e].toString();const s=r.toLowerCase();l.has(s)?r=l.get(s):l.set(s,r),n[e+1]===a?o[r]=null:o[r]=n[e+1]}const r=new e(o);return r.immutable=!1,r},strCheck(e){if(!1===p(e))throw new U(null,D.KeyMustBeString,null);return e},unary(e,n){if(m(e)){if("!"===n)return!e;if("-"===n)return-1*g(e);if("+"===n)return 1*g(e);if("~"===n)return~g(e);throw new U(null,D.UnsupportedUnaryOperator,null)}if("-"===n)return-1*g(e);if("+"===n)return 1*g(e);if("~"===n)return~g(e);throw new U(null,D.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===m(e))throw new U(null,D.LogicExpressionOrAnd,null);return e},logical(e,n,t){if(m(e)&&m(n))switch(t){case"||":return e||n;case"&&":return e&&n;default:throw new U(null,D.LogicExpressionOrAnd,null)}throw new U(null,D.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return h(g(e),g(n),t);case"==":case"=":return f(e,n);case"!=":return!f(e,n);case"<":case">":case"<=":case">=":return d(e,n,t);case"+":return p(e)||p(n)?u(e)+u(n):g(e)+g(n);case"-":return g(e)-g(n);case"*":return g(e)*g(n);case"/":return g(e)/g(n);case"%":return g(e)%g(n);default:throw new U(null,D.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===a?null:e;case"/=":return g(t)/g(e);case"*=":return g(t)*g(e);case"-=":return g(t)-g(e);case"+=":return p(t)||p(e)?u(t)+u(e):g(t)+g(e);case"%=":return g(t)%g(e);default:throw new U(null,D.UnsupportedOperator,null)}},update(e,n,t,o){const l=g(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,t,o)=>null===e?null:n.createFromGraphicLikeObject(e.geometry,e.attributes,t,o.timeReference),memberupdate(n,t,o,l){let r;if(y(n)){if(!b(t))throw new U(null,D.ArrayAccessorMustBeNumber,null);if(t<0&&(t=n.length+t),t<0||t>=n.length)throw new U(null,D.OutOfBounds,null);r=g(n[t]),n[t]="++"===o?r+1:r-1}else if(n instanceof e){if(!1===p(t))throw new U(null,D.KeyAccessorMustBeString,null);if(!0!==n.hasField(t))throw new U(null,D.FieldNotFound,null,{key:t});r=g(n.field(t)),n.setField(t,"++"===o?r+1:r-1)}else if(w(n)){if(!1===p(t))throw new U(null,D.KeyAccessorMustBeString,null);if(!0!==n.hasField(t))throw new U(null,D.FieldNotFound,null);r=g(n.field(t)),n.setField(t,"++"===o?r+1:r-1)}else{if(S(n))throw new U(null,D.Immutable,null);if(!(n instanceof Ue))throw new U(null,D.InvalidIdentifier,null);if(!1===p(t))throw new U(null,D.ModuleAccessorMustBeString,null);if(!0!==n.hasGlobal(t))throw new U(null,D.ModuleExportNotFound,null);r=g(n.global(t)),n.setGlobal(t,"++"===o?r+1:r-1)}return!1===l?r:"++"===o?r+1:r-1},assignmember(n,t,o,l){if(y(n)){if(!b(t))throw new U(null,D.ArrayAccessorMustBeNumber,null);if(t<0&&(t=n.length+t),t<0||t>n.length)throw new U(null,D.OutOfBounds,null);if(t===n.length){if("="!==o)throw new U(null,D.OutOfBounds,null);n[t]=this.assign(l,o,n[t])}else n[t]=this.assign(l,o,n[t])}else if(n instanceof e){if(!1===p(t))throw new U(null,D.KeyAccessorMustBeString,null);if(!0===n.hasField(t))n.setField(t,this.assign(l,o,n.field(t)));else{if("="!==o)throw new U(null,D.FieldNotFound,null);n.setField(t,this.assign(l,o,null))}}else if(w(n)){if(!1===p(t))throw new U(null,D.KeyAccessorMustBeString,null);if(!0===n.hasField(t))n.setField(t,this.assign(l,o,n.field(t)));else{if("="!==o)throw new U(null,D.FieldNotFound,null);n.setField(t,this.assign(l,o,null))}}else{if(S(n))throw new U(null,D.Immutable,null);if(!(n instanceof Ue))throw new U(null,D.InvalidIdentifier,null);if(!1===p(t))throw new U(null,D.ModuleAccessorMustBeString,null);if(!n.hasGlobal(t))throw new U(null,D.ModuleExportNotFound,null);n.setGlobal(t,this.assign(l,o,n.global(t)))}},member(n,t){if(null===n)throw new U(null,D.MemberOfNull,null);if(n instanceof e||w(n)){if(p(t))return n.field(t);throw new U(null,D.InvalidMemberAccessKey,null)}if(n instanceof E){if(p(t))return C(n,t,null,null);throw new U(null,D.InvalidMemberAccessKey,null)}if(y(n)){if(b(t)&&isFinite(t)&&Math.floor(t)===t){if(t<0&&(t=n.length+t),t>=n.length||t<0)throw new U(null,D.OutOfBounds,null);return n[t]}throw new U(null,D.InvalidMemberAccessKey,null)}if(p(n)){if(b(t)&&isFinite(t)&&Math.floor(t)===t){if(t<0&&(t=n.length+t),t>=n.length||t<0)throw new U(null,D.OutOfBounds,null);return n[t]}throw new U(null,D.InvalidMemberAccessKey,null)}if(S(n)){if(b(t)&&isFinite(t)&&Math.floor(t)===t){if(t<0&&(t=n.length()+t),t>=n.length()||t<0)throw new U(null,D.OutOfBounds,null);return n.get(t)}throw new U(null,D.InvalidMemberAccessKey,null)}if(n instanceof Ue){if(p(t))return n.global(t);throw new U(null,D.InvalidMemberAccessKey,null)}throw new U(null,D.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 o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,o,l){if(!(e instanceof Ue))throw new U(null,D.FunctionNotFound,null);const r=e.global(o);if(!1===t(r))throw new U(null,D.CallNonFunction,null);return r.call(l,{preparsed:!0,arguments:n})}};function je(e){console.log(e)}function Ne(e,n,c=!1){null===n&&(n={vars:{},customfunctions:{}});let u=null;e.usesModules&&(u=new G(null,e.loadedModules));const p={isAsync:c,globalScope:_e(n.vars,c?Ce:xe,n.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:n.customfunctions,libraryResolver:u,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:je,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let m=V(p,e);""===m&&(m="lc.voidOperation; "),p.undeclaredGlobalsInFunctions.size>0&&p.undeclaredGlobalsInFunctions.forEach((e=>{throw new P(n,D.InvalidIdentifier,e.node)}));let g="";g=c?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+m+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+m+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const d=p.moduleFactory,f=p.moduleFactoryMap,h=p.exports,y={};for(const t in h)y[t]=void 0!==p.mangleMap[t]?p.mangleMap[t]:t;const b={lc:o,lang:$e,mangles:p.mangleMap,postProcess(e){if(e instanceof l&&(e=e.value),e instanceof r&&(e=e.value),e===a&&(e=null),e===s)throw new U(null,D.IllegalResult,null);if(e===i)throw new U(null,D.IllegalResult,null);if(t(e))throw new U(null,D.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=R.WebMercator);const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,moduleFactory:d,moduleFactoryMap:f,mangleMap:this.mangles,moduleSingletons:{},exports:h,gdefs:{},exportmangle:y,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",g).bind(b)}async function Le(){return Ee([await import("./functions/geomasync.js")],"async"),!0}class Ue extends B{constructor(e){super(null),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const o=this.moduleContext.globalScope,l=e.toLowerCase();if(t(n))throw new U(null,D.AssignModuleFunction,null);o[this.moduleContext.exportmangle[l]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const o=n[this.moduleContext.exportmangle[e]];if(void 0===o)throw new U(null,D.InvalidIdentifier,null);if(t(o)&&!(o instanceof N)){const t=new N;return t.fn=o,t.parameterEvaluator=W,t.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=t,t}return o}}function De(e,n,t=!1){const l={isAsync:t,moduleFactory:n.moduleFactory,moduleFactoryMap:{},libraryResolver:new G(null,e.loadedModules),globalScope:_e(n.vars,t?Ce:xe,n.customfunctions),customfunctions:n.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:je,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor,services:n.services,symbols:{symbolCounter:0}};let r=V(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=t?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};for(const o in c)u[o]=void 0!==l.mangleMap[o]?l.mangleMap[o]:o;const p={lc:o,lang:$e,mangles:l.mangleMap,prepareModule:e=>new Ue(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new R({wkid:102100}));const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{T as UserDefinedCompiledFunction,Ne as compileScript,Le as enableAsyncSupport,Re as executeScript,Ee as extend,ke as functionHelper};
|
|
5
|
+
import{ArcadeModule as e}from"./ArcadeModule.js";import{ArcadeModuleLoader as n}from"./ArcadeModuleLoader.js";import t from"./Dictionary.js";import{ArcadeExecutionError as o,ExecutionErrorCodes as l,ArcadeCompilationError as r,ArcadeUncompilableError as a}from"./executionError.js";import s from"./Feature.js";import{NativeFunction as i,ArcadeFunction as c,ScopeMarshalledFunction as u,wrapModuleScopedResponse as p}from"./FunctionWrapper.js";import{i as m,u as g,R as d,I as f,v as h,w as y,x as b,y as w,j as S,c as v,a as x,g as M,z as F,A as C,B as I,m as A,b as _,p as O,o as k}from"../chunks/languageUtils.js";import{addFunctionDeclaration as E}from"./treeAnalysis.js";import{A as R}from"../chunks/array.js";import{registerFunctions as G}from"./functions/date.js";import{registerFunctions as B,geometryMember as $}from"./functions/geometry.js";import{registerFunctions as j}from"./functions/geomsync.js";import{registerFunctions as N}from"./functions/maths.js";import{registerFunctions as L}from"./functions/stats.js";import{registerFunctions as U}from"./functions/string.js";import{isPromiseLike as D}from"../core/promiseUtils.js";import P from"../geometry/Geometry.js";import K from"../geometry/SpatialReference.js";class T extends c{constructor(e,n){super(),this.paramCount=n,this.fn=e}createFunction(e){return(...n)=>{if(n.length!==this.paramCount)throw new o(e,l.WrongNumberOfParameters,null);return this.fn(...n)}}call(e,n){return this.fn(...n.arguments)}marshalledCall(e,n,t,o){return o(e,n,((n,l,r)=>{r=r.map((n=>!m(n)||n instanceof u?n:p(n,e,o)));const a=this.call(t,{arguments:r});return D(a)?a.then((e=>p(e,t,o))):a}))}}function q(e,n){const t=[];for(let o=0;o<n.arguments.length;o++)t.push(V(e,n.arguments[o]));return t}function W(e,n,t){try{return t(e,null,n.arguments)}catch(o){throw o}}function V(e,n){try{switch(n.type){case"EmptyStatement":return"lc.voidOperation";case"VariableDeclarator":return ue(e,n);case"VariableDeclaration":return ce(e,n);case"BlockStatement":case"Program":return oe(e,n);case"FunctionDeclaration":return ie(e,n);case"ImportDeclaration":return re(e,n);case"ExportNamedDeclaration":return ae(e,n);case"ReturnStatement":return le(e,n);case"IfStatement":return te(e,n);case"ExpressionStatement":return ee(e,n);case"AssignmentExpression":return Z(e,n);case"UpdateExpression":return Q(e,n);case"BreakStatement":return"break";case"ContinueStatement":return"continue";case"TemplateLiteral":return de(e,n);case"TemplateElement":return JSON.stringify(n.value?n.value.cooked:"");case"ForStatement":return H(e,n);case"ForInStatement":return Y(e,n);case"WhileStatement":return X(e,n);case"Identifier":return ye(e,n);case"MemberExpression":return pe(e,n);case"Literal":return null===n.value||void 0===n.value?"null":JSON.stringify(n.value);case"CallExpression":return be(e,n);case"UnaryExpression":return me(e,n);case"BinaryExpression":return fe(e,n);case"LogicalExpression":return he(e,n);case"ArrayExpression":return ge(e,n);case"ObjectExpression":return J(e,n);case"Property":return z(e,n);case"Array":throw new r(e,l.NeverReach,n);default:throw new r(e,l.Unrecognised,n)}}catch(t){throw t}}function J(e,n){let t="lang.dictionary([";for(let o=0;o<n.properties.length;o++){const l=n.properties[o];se(l.key.name);o>0&&(t+=","),t+="lang.strCheck("+("Identifier"===l.key.type?"'"+l.key.name+"'":V(e,l.key))+",'ObjectExpression'),lang.aCheck("+V(e,l.value)+", 'ObjectExpression')"}return t+="])",t}function z(e,n){throw new r(e,l.NeverReach,n)}function Y(e,n){const t=Fe(e),o=Fe(e),l=Fe(e);let r="var "+t+" = "+V(e,n.right)+";\n";"VariableDeclaration"===n.left.type&&(r+=V(e,n.left));let a="VariableDeclaration"===n.left.type?n.left.declarations[0].id.name:n.left.name;a=a.toLowerCase(),se(a);let s="";null!==e.localScope&&(void 0!==e.localScope[a]?s="lscope['"+a+"']":void 0!==e.localScope._SymbolsMap[a]&&(s="lscope['"+e.localScope._SymbolsMap[a]+"']"));let i="";if(""===s)if(void 0!==e.globalScope[a])s="gscope['"+a+"']";else if(void 0!==e.globalScope._SymbolsMap[a])s="gscope['"+e.globalScope._SymbolsMap[a]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(a))s="gscope['"+e.undeclaredGlobalsInFunctions.get(a).manglename+"']",i=e.undeclaredGlobalsInFunctions.get(a).manglename;else{const t={manglename:Me(e),node:n.left};e.undeclaredGlobalsInFunctions.set(a,t),s="gscope['"+t.manglename+"']",i=t.manglename}return i&&(r+="lang.chkAssig('"+i+"',runtimeCtx); \n"),r+="if ("+t+"===null) { lastStatement = lc.voidOperation; }\n ",r+="else if (lc.isArray("+t+") || lc.isString("+t+")) {",r+="var "+o+"="+t+".length; \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (lc.isImmutableArray("+t+")) {",r+="var "+o+"="+t+".length(); \n",r+="for(var "+l+"=0; "+l+"<"+o+"; "+l+"++) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",r+="else if (( "+t+" instanceof lang.Dictionary) || ( "+t+" instanceof lang.Feature)) {",r+="var "+o+"="+t+".keys(); \n",r+="for(var "+l+"=0; "+l+"<"+o+".length; "+l+"++) {\n",r+=s+"="+o+"["+l+"];\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n",e.isAsync&&(r+="else if (lc.isFeatureSet("+t+")) {",r+="var "+o+"="+t+".iterator(runtimeCtx.abortSignal); \n",r+="for(var "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx); "+l+"!=null; "+l+"=lang. graphicToFeature( yield "+o+".next(),"+t+", runtimeCtx)) {\n",r+=s+"="+l+";\n",r+=V(e,n.body),r+="\n}\n",r+=" lastStatement = lc.voidOperation; \n",r+=" \n}\n"),r+="else { lastStatement = lc.voidOperation; } \n",r}function H(e,n){let t="lastStatement = lc.voidOperation; \n";null!==n.init&&(t+=V(e,n.init)+"; ");const o=Fe(e),r=Fe(e);return t+="var "+o+" = true; ",t+="\n do { ",null!==n.update&&(t+=" if ("+o+"===false) {\n "+V(e,n.update)+" \n}\n "+o+"=false; \n"),null!==n.test&&(t+="var "+r+" = "+V(e,n.test)+"; ",t+="if ("+r+"===false) { break; } else if ("+r+"!==true) { lang.error('"+l.BooleanConditionRequired+"'); }\n"),t+=V(e,n.body),null!==n.update&&(t+="\n "+V(e,n.update)),t+="\n"+o+" = true; \n} while(true); lastStatement = lc.voidOperation; ",t}function Q(e,n){let t=null,r="";if("MemberExpression"===n.argument.type)return t=V(e,n.argument.object),!0===n.argument.computed?r=V(e,n.argument.property):(r="'"+n.argument.property.name+"'",se(n.argument.property.name)),"lang.memberupdate("+t+","+r+",'"+n.operator+"',"+n.prefix+")";if(t=n.argument.name.toLowerCase(),se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lang.update(lscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.localScope._SymbolsMap[t])return"lang.update(lscope, '"+e.localScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")"}if(void 0!==e.globalScope[t])return"lang.update(gscope, '"+t+"','"+n.operator+"',"+n.prefix+")";if(void 0!==e.globalScope._SymbolsMap[t])return"lang.update(gscope, '"+e.globalScope._SymbolsMap[t]+"','"+n.operator+"',"+n.prefix+")";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"lang.update(gscope,lang.chkAssig( '"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"lang.update(gscope, lang.chkAssig('"+o.manglename+"',runtimeCtx),'"+n.operator+"',"+n.prefix+")"}throw new o(e,l.InvalidIdentifier,n)}function X(e,n){let t="lastStatement = lc.voidOperation; \n";const o=Fe(e);return t+=`\n var ${o} = true;\n do {\n ${o} = ${V(e,n.test)};\n if (${o}==false) {\n break;\n }\n if (${o}!==true) {\n lang.error('${l.BooleanConditionRequired}');\n }\n ${V(e,n.body)}\n }\n while (${o} !== false);\n lastStatement = lc.voidOperation;\n `,t}function Z(e,n){const t=V(e,n.right);let r=null,a="";if("MemberExpression"===n.left.type)return r=V(e,n.left.object),!0===n.left.computed?a=V(e,n.left.property):(a="'"+n.left.property.name+"'",se(n.left.property.name)),"lang.assignmember("+r+","+a+",'"+n.operator+"',"+t+")";if(r=n.left.name.toLowerCase(),se(r),null!==e.localScope){if(void 0!==e.localScope[r])return"lscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+r+"'])";if(void 0!==e.localScope._SymbolsMap[r])return"lscope['"+e.localScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', lscope['"+e.localScope._SymbolsMap[r]+"'])"}if(void 0!==e.globalScope[r])return"gscope['"+r+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+r+"'])";if(void 0!==e.globalScope._SymbolsMap[r])return"gscope['"+e.globalScope._SymbolsMap[r]+"']=lang.assign("+t+",'"+n.operator+"', gscope['"+e.globalScope._SymbolsMap[r]+"'])";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(r))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(r).manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+e.undeclaredGlobalsInFunctions.get(r).manglename+"'])";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(r,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]=lang.assign("+t+",'"+n.operator+"', gscope['"+o.manglename+"'])"}throw new o(e,l.InvalidIdentifier,n)}function ee(e,n){return"AssignmentExpression"===n.expression.type?"lastStatement = lc.voidOperation; "+V(e,n.expression)+"; \n ":(n.expression.type,"lastStatement = "+V(e,n.expression)+"; ")}function ne(e,n){return"BlockStatement"===n.type?V(e,n):"ReturnStatement"===n.type||"BreakStatement"===n.type||"ContinueStatement"===n.type?V(e,n)+"; ":"UpdateExpression"===n.type?"lastStatement = "+V(e,n)+"; ":"ExpressionStatement"===n.type?V(e,n):"ObjectExpression"===n.type?"lastStatement = "+V(e,n)+"; ":V(e,n)+"; "}function te(e,n){if("AssignmentExpression"===n.test.type||"UpdateExpression"===n.test.type)throw new r(e,l.BooleanConditionRequired,n);return`if (lang.mustBoolean(${V(e,n.test)}, runtimeCtx) === true) {\n ${ne(e,n.consequent)}\n } `+(null!==n.alternate?"IfStatement"===n.alternate.type?" else "+te(e,n.alternate):` else {\n ${ne(e,n.alternate)}\n }\n`:" else {\n lastStatement = lc.voidOperation;\n }\n")}function oe(e,n){let t="";for(let o=0;o<n.body.length;o++)"EmptyStatement"!==n.body[o].type&&("ReturnStatement"===n.body[o].type||"BreakStatement"===n.body[o].type||"ContinueStatement"===n.body[o].type?t+=V(e,n.body[o])+"; \n":"UpdateExpression"===n.body[o].type||"ObjectExpression"===n.body[o].type?t+="lastStatement = "+V(e,n.body[o])+"; \n":t+=V(e,n.body[o])+" \n");return t}function le(e,n){if(null===n.argument)return"return lc.voidOperation";return"return "+V(e,n.argument)}function re(e,n){const t=n.specifiers[0].local.name.toLowerCase();se(t);const o=e.libraryResolver?.loadLibrary(t),l=Me(e);void 0===e.moduleFactory[o.uri]&&(e.moduleFactory[o.uri]=De(o.syntax,{interceptor:e.interceptor,services:e.services,moduleFactory:e.moduleFactory,lrucache:e.lrucache,timeReference:e.timeReference??null,libraryResolver:e.libraryResolver,customfunctions:e.customfunctions,vars:{}},e.isAsync)),e.moduleFactoryMap[l]=o.uri;let r="";if(r=e.isAsync?"(yield lang.loadModule('"+l+"', runtimeCtx) ); ":"lang.loadModule('"+l+"', runtimeCtx); ",void 0!==e.globalScope[t])return"gscope['"+t+"']="+r;if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']="+r;let a="";return e.undeclaredGlobalsInFunctions.has(t)?(a=e.undeclaredGlobalsInFunctions.get(t).manglename,e.undeclaredGlobalsInFunctions.delete(t)):a=Me(e),e.globalScope._SymbolsMap[t]=a,e.mangleMap[t]=a,"gscope[lang.setAssig('"+a+"', runtimeCtx)]="+r}function ae(e,n){const t=V(e,n.declaration);if("FunctionDeclaration"===n.declaration.type)e.exports[n.declaration.id.name.toLowerCase()]="function";else if("VariableDeclaration"===n.declaration.type)for(const o of n.declaration.declarations)e.exports[o.id.name.toLowerCase()]="variable";return t}function se(e){if("iif"===e)throw new a;if("decode"===e)throw new a;if("when"===e)throw new a}function ie(e,n){const t=n.id.name.toLowerCase();se(t);let o="",l=!1;void 0!==e.globalScope[t]?o=t:void 0!==e.globalScope._SymbolsMap[t]?o=e.globalScope._SymbolsMap[t]:e.undeclaredGlobalsInFunctions.has(t)?(o=e.undeclaredGlobalsInFunctions.get(t).manglename,e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o,e.undeclaredGlobalsInFunctions.delete(t),l=!0):(o=Me(e),e.globalScope._SymbolsMap[t]=o,e.mangleMap[t]=o);const r={isAsync:e.isAsync,console:e.console,exports:e.exports,undeclaredGlobalsInFunctions:e.undeclaredGlobalsInFunctions,customfunctions:e.customfunctions,moduleFactory:e.moduleFactory,moduleFactoryMap:e.moduleFactoryMap,libraryResolver:e.libraryResolver,lrucache:e.lrucache,interceptor:e.interceptor,services:e.services,symbols:e.symbols,mangleMap:e.mangleMap,localScope:{_SymbolsMap:{}},depthCounter:e.depthCounter,globalScope:e.globalScope};let a="new lang.UserDefinedCompiledFunction( lang.functionDepthchecker(function() { var lastStatement = lc.voidOperation; \n var lscope = runtimeCtx.localStack[runtimeCtx.localStack.length-1];\n";for(let s=0;s<n.params.length;s++){const t=n.params[s].name.toLowerCase();se(t);const o=Me(e);r.localScope._SymbolsMap[t]=o,r.mangleMap[t]=o,a+="lscope['"+o+"']=arguments["+s.toString()+"];\n"}return!0===e.isAsync?(a+="return lang.__awaiter(this, void 0, void 0, function* () {\n",a+=oe(r,n.body)+"\n return lastStatement; ",a+="}); }",a+=", runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"):(a+=oe(r,n.body)+"\n return lastStatement; }, runtimeCtx),"+n.params.length+")",a+="\n lastStatement = lc.voidOperation; \n"),l?"gscope[lang.setAssig('"+o+"', runtimeCtx)]="+a:"gscope['"+o+"']="+a}function ce(e,n){const t=[];for(let o=0;o<n.declarations.length;o++)t.push(V(e,n.declarations[o]));return t.join("\n")+" \n lastStatement= lc.voidOperation; \n"}function ue(e,n){let t=null===n.init?null:V(e,n.init);t===h&&(t=null);const o=n.id.name.toLowerCase();if(se(o),null!==e.localScope){if(void 0!==e.localScope[o])return"lscope['"+o+"']="+t+"; ";if(void 0!==e.localScope._SymbolsMap[o])return"lscope['"+e.localScope._SymbolsMap[o]+"']="+t+"; ";{const n=Me(e);return e.localScope._SymbolsMap[o]=n,e.mangleMap[o]=n,"lscope['"+n+"']="+t+"; "}}if(void 0!==e.globalScope[o])return"gscope['"+o+"']="+t+"; ";if(void 0!==e.globalScope._SymbolsMap[o])return"gscope['"+e.globalScope._SymbolsMap[o]+"']="+t+"; ";if(e.undeclaredGlobalsInFunctions.has(o)){const n=e.undeclaredGlobalsInFunctions.get(o).manglename;return e.globalScope._SymbolsMap[o]=n,e.mangleMap[o]=n,e.undeclaredGlobalsInFunctions.delete(o),"gscope[lang.setAssig('"+n+"', runtimeCtx)]="+t+"; "}const l=Me(e);return e.globalScope._SymbolsMap[o]=l,e.mangleMap[o]=l,"gscope['"+l+"']="+t+"; "}function pe(e,n){try{let t;return!0===n.computed?t=V(e,n.property):(t="'"+n.property.name+"'",se(n.property.name)),"lang.member("+V(e,n.object)+","+t+")"}catch(t){throw t}}function me(e,n){try{return"lang.unary("+V(e,n.argument)+",'"+n.operator+"')"}catch(t){throw t}}function ge(e,n){try{const t=[];for(let o=0;o<n.elements.length;o++)"Literal"===n.elements[o].type?t.push(V(e,n.elements[o])):t.push("lang.aCheck("+V(e,n.elements[o])+",'ArrayExpression')");return"["+t.join(",")+"]"}catch(t){throw t}}function de(e,n){try{const t=[];let o=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[o]?"lang.castString(lang.aCheck("+V(e,n.expressions[o])+", 'TemplateLiteral'))":""),o++);return"(["+t.join(",")+"]).join('')"}catch(t){throw t}}function fe(e,n){try{return"lang.binary("+V(e,n.left)+","+V(e,n.right)+",'"+n.operator+"')"}catch(t){throw t}}function he(e,n){try{if("AssignmentExpression"===n.left.type||"UpdateExpression"===n.left.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("AssignmentExpression"===n.right.type||"UpdateExpression"===n.right.type)throw new r(e,l.LogicalExpressionOnlyBoolean,n);if("&&"===n.operator||"||"===n.operator)return"(lang.logicalCheck("+V(e,n.left)+") "+n.operator+" lang.logicalCheck("+V(e,n.right)+"))";throw new r(null,l.LogicExpressionOrAnd,null)}catch(t){throw t}}function ye(e,n){try{const t=n.name.toLowerCase();if(se(t),null!==e.localScope){if(void 0!==e.localScope[t])return"lscope['"+t+"']";if(void 0!==e.localScope._SymbolsMap[t])return"lscope['"+e.localScope._SymbolsMap[t]+"']"}if(void 0!==e.globalScope[t])return"gscope['"+t+"']";if(void 0!==e.globalScope._SymbolsMap[t])return"gscope['"+e.globalScope._SymbolsMap[t]+"']";if(null!==e.localScope){if(e.undeclaredGlobalsInFunctions.has(t))return"gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";const o={manglename:Me(e),node:n.argument};return e.undeclaredGlobalsInFunctions.set(t,o),"gscope[lang.chkAssig('"+o.manglename+"',runtimeCtx)]"}throw new r(e,l.InvalidIdentifier,n)}catch(t){throw t}}function be(e,n){try{if("MemberExpression"===n.callee.type){let t;!0===n.callee.computed?t=V(e,n.callee.property):(t="'"+n.callee.property.name+"'",se(n.callee.property.name));let o="[";for(let l=0;l<n.arguments.length;l++)l>0&&(o+=", "),o+=V(e,n.arguments[l]);return o+="]",e.isAsync?"(yield lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx))":"lang.callModuleFunction("+V(e,n.callee.object)+","+o+","+t+",runtimeCtx)"}if("Identifier"!==n.callee.type)throw new r(e,l.FunctionNotFound,n);const t=n.callee.name.toLowerCase();if("iif"===t)return we(e,n);if("when"===t)return Se(e,n);if("decode"===t)return ve(e,n);let o="";if(null!==e.localScope&&(void 0!==e.localScope[t]?o="lscope['"+t+"']":void 0!==e.localScope._SymbolsMap[t]&&(o="lscope['"+e.localScope._SymbolsMap[t]+"']")),""===o)if(void 0!==e.globalScope[t])o="gscope['"+t+"']";else if(void 0!==e.globalScope._SymbolsMap[t])o="gscope['"+e.globalScope._SymbolsMap[t]+"']";else if(null!==e.localScope)if(e.undeclaredGlobalsInFunctions.has(t))o="gscope[lang.chkAssig('"+e.undeclaredGlobalsInFunctions.get(t).manglename+"',runtimeCtx)]";else{const l={manglename:Me(e),node:n.argument};e.undeclaredGlobalsInFunctions.set(t,l),o="gscope[lang.chkAssig('"+l.manglename+"',runtimeCtx)]"}if(""!==o){let t="[";for(let o=0;o<n.arguments.length;o++)o>0&&(t+=", "),t+=V(e,n.arguments[o]);return t+="]",e.isAsync?"(yield lang.callfunc("+o+","+t+",runtimeCtx) )":"lang.callfunc("+o+","+t+",runtimeCtx)"}throw new r(e,l.FunctionNotFound,n)}catch(t){throw t}}function we(e,n){try{if(3!==n.arguments.length)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n\n if (${t} === true) {\n return ${V(e,n.arguments[1])};\n }\n else if (${t} === false) {\n return ${V(e,n.arguments[2])};\n }\n else {\n lang.error('ExecutionErrorCodes.BooleanConditionRequired');\n }\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function Se(e,n){try{if(n.arguments.length<3)throw new r(e,l.WrongNumberOfParameters,n);if(n.arguments.length%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e);let o="var ";for(let l=0;l<n.arguments.length-1;l+=2)o+=`${t} = lang.mustBoolean(${V(e,n.arguments[l])}, runtimeCtx);\n if (${t} === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n ${o}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}function ve(e,n){try{if(n.arguments.length<2)throw new r(e,l.WrongNumberOfParameters,n);if(2===n.arguments.length)return`(${V(e,n.arguments[1])})`;if((n.arguments.length-1)%2==0)throw new r(e,l.WrongNumberOfParameters,n);const t=Fe(e),o=Fe(e);let a="var ";for(let l=1;l<n.arguments.length-1;l+=2)a+=`${o} = ${V(e,n.arguments[l])};\n if (lang.binary(${o}, ${t}, "==") === true ) {\n return ${V(e,n.arguments[l+1])}\n }\n`;return`${e.isAsync?"(yield (function() { \n return lang.__awaiter(this, void 0, void 0, function* () {":"function() {"}\n var ${t} = ${V(e,n.arguments[0])};\n ${a}\n return ${V(e,n.arguments[n.arguments.length-1])}\n ${e.isAsync?"})}()))":"}()"}`}catch(t){throw t}}const xe={};function Me(e){return e.symbols.symbolCounter++,"_T"+e.symbols.symbolCounter.toString()}function Fe(e){return e.symbols.symbolCounter++,"_Tvar"+e.symbols.symbolCounter.toString()}G(xe,W),U(xe,W),N(xe,W),B(xe,W),L(xe,W),xe.iif=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.decode=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}},xe.when=function(e,n){try{return W(e,n,((t,r,a)=>{throw new o(e,l.Unrecognised,n)}))}catch(t){throw t}};const Ce={};for(const Pe in xe)Ce[Pe]=new i(xe[Pe]);j(xe,W);for(const Pe in xe)xe[Pe]=new i(xe[Pe]);const Ie=function(){};Ie.prototype=xe;const Ae=function(){};function _e(e,n,t){const o={};e||(e={}),t||(t={}),o._SymbolsMap={},o.textformatting=1,o.infinity=1,o.pi=1;for(const l in n)o[l]=1;for(const l in t)o[l]=1;for(const l in e)o[l]=1;return o}function Oe(e,n,o,l){const r=o?new Ae:new Ie;e||(e={}),n||(n={});const a=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});a.immutable=!1,r._SymbolsMap={textformatting:1,infinity:1,pi:1},r.textformatting=a,r.infinity=Number.POSITIVE_INFINITY,r.pi=Math.PI;for(const t in n)r[t]=n[t],r._SymbolsMap[t]=1;for(const t in e)r._SymbolsMap[t]=1,e[t]&&"esri.Graphic"===e[t].declaredClass?r[t]=s.createFromGraphic(e[t],l??null):r[t]=e[t];return r}Ae.prototype=Ce;const ke={fixSpatialReference:w,parseArguments:q,standardFunction:W};function Ee(e,n){const t={mode:n,compiled:!0,functions:{},signatures:[],standardFunction:W,standardFunctionAsync:W,evaluateIdentifier:Ge};for(let o=0;o<e.length;o++)e[o].registerFunctions(t);if("sync"===n){for(const e in t.functions)xe[e]=new i(t.functions[e]),Ie.prototype[e]=xe[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"sync")}else{for(const e in t.functions)Ce[e]=new i(t.functions[e]),Ae.prototype[e]=Ce[e];for(let e=0;e<t.signatures.length;e++)E(t.signatures[e],"async")}}function Re(e,n){return e(n)}function Ge(e,n){const t=n.name;if("_SymbolsMap"===t)throw new o(e,l.InvalidIdentifier,null);if(e.localStack.length>0){if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.localStack[e.localStack.length-1][t])return e.localStack[e.localStack.length-1][t];const n=e.mangleMap[t];if(void 0!==n&&void 0!==e.localStack[e.localStack.length-1][n])return e.localStack[e.localStack.length-1][n]}if("_t"!==t.substr(0,2).toLowerCase()&&void 0!==e.globalScope[t])return e.globalScope[t];if(1===e.globalScope._SymbolsMap[t])return e.globalScope[t];const r=e.mangleMap[t];return void 0!==r?e.globalScope[r]:void 0}Ee([R],"sync"),Ee([R],"async");let Be=0;const $e={error(e){throw new o(null,e,null)},__awaiter:(e,n,t,o)=>new Promise(((t,l)=>{function r(e){try{s(o.next(e))}catch(n){l(n)}}function a(e){try{s(o.throw(e))}catch(n){l(n)}}function s(e){e.done?t(e.value):e.value&&e.value.then?e.value.then(r,a):(Be++,Be%100==0?setTimeout((()=>{Be=0,r(e.value)}),0):r(e.value))}s((o=o.apply(e,n||[])).next())})),functionDepthchecker:(e,n)=>function(){if(n.depthCounter.depth++,n.localStack.push([]),n.depthCounter.depth>64)throw new o(null,l.MaximumCallDepth,null);const t=e.apply(this,arguments);return D(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)},chkAssig(e,n){if(void 0===n.gdefs[e])throw new o(n,l.InvalidIdentifier,null);return e},mustBoolean(e,n){if(!0===e||!1===e)return e;throw new o(n,l.BooleanConditionRequired,null)},setAssig:(e,n)=>(n.gdefs[e]=1,e),castString:e=>S(e),aCheck(e,n){if(m(e)){if("ArrayExpression"===n)throw new o(null,l.NoFunctionInArray,null);if("ObjectExpression"===n)throw new o(null,l.NoFunctionInDictionary,null);throw new o(null,l.NoFunctionInTemplateLiteral,null)}return e===h?null:e},Dictionary:t,Feature:s,UserDefinedCompiledFunction:T,dictionary(e){const n={},r=new Map;for(let t=0;t<e.length;t+=2){if(m(e[t+1]))throw new o(null,l.NoFunctionInDictionary,null);if(!1===v(e[t]))throw new o(null,l.KeyMustBeString,null);let a=e[t].toString();const s=a.toLowerCase();r.has(s)?a=r.get(s):r.set(s,a),e[t+1]===h?n[a]=null:n[a]=e[t+1]}const a=new t(n);return a.immutable=!1,a},strCheck(e){if(!1===v(e))throw new o(null,l.KeyMustBeString,null);return e},unary(e,n){if(x(e)){if("!"===n)return!e;if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)}if("-"===n)return-1*M(e);if("+"===n)return 1*M(e);if("~"===n)return~M(e);throw new o(null,l.UnsupportedUnaryOperator,null)},logicalCheck(e){if(!1===x(e))throw new o(null,l.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 o(null,l.LogicExpressionOrAnd,null)}throw new o(null,l.LogicExpressionOrAnd,null)},binary(e,n,t){switch(t){case"|":case"<<":case">>":case">>>":case"^":case"&":return I(M(e),M(n),t);case"==":case"=":return C(e,n);case"!=":return!C(e,n);case"<":case">":case"<=":case">=":return F(e,n,t);case"+":return v(e)||v(n)?S(e)+S(n):M(e)+M(n);case"-":return M(e)-M(n);case"*":return M(e)*M(n);case"/":return M(e)/M(n);case"%":return M(e)%M(n);default:throw new o(null,l.UnsupportedOperator,null)}},assign(e,n,t){switch(n){case"=":return e===h?null:e;case"/=":return M(t)/M(e);case"*=":return M(t)*M(e);case"-=":return M(t)-M(e);case"+=":return v(t)||v(e)?S(t)+S(e):M(t)+M(e);case"%=":return M(t)%M(e);default:throw new o(null,l.UnsupportedOperator,null)}},update(e,n,t,o){const l=M(e[n]);return e[n]="++"===t?l+1:l-1,!1===o?l:"++"===t?l+1:l-1},graphicToFeature:(e,n,t)=>null===e?null:s.createFromGraphicLikeObject(e.geometry,e.attributes,n,t.timeReference),memberupdate(e,n,r,a){let s;if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>=e.length)throw new o(null,l.OutOfBounds,null);s=M(e[n]),e[n]="++"===r?s+1:s-1}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null,{key:n});s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0!==e.hasField(n))throw new o(null,l.FieldNotFound,null);s=M(e.field(n)),e.setField(n,"++"===r?s+1:s-1)}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!0!==e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);s=M(e.global(n)),e.setGlobal(n,"++"===r?s+1:s-1)}return!1===a?s:"++"===r?s+1:s-1},assignmember(e,n,r,a){if(A(e)){if(!_(n))throw new o(null,l.ArrayAccessorMustBeNumber,null);if(n<0&&(n=e.length+n),n<0||n>e.length)throw new o(null,l.OutOfBounds,null);if(n===e.length){if("="!==r)throw new o(null,l.OutOfBounds,null);e[n]=this.assign(a,r,e[n])}else e[n]=this.assign(a,r,e[n])}else if(e instanceof t){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else if(O(e)){if(!1===v(n))throw new o(null,l.KeyAccessorMustBeString,null);if(!0===e.hasField(n))e.setField(n,this.assign(a,r,e.field(n)));else{if("="!==r)throw new o(null,l.FieldNotFound,null);e.setField(n,this.assign(a,r,null))}}else{if(k(e))throw new o(null,l.Immutable,null);if(!(e instanceof Ue))throw new o(null,l.InvalidIdentifier,null);if(!1===v(n))throw new o(null,l.ModuleAccessorMustBeString,null);if(!e.hasGlobal(n))throw new o(null,l.ModuleExportNotFound,null);e.setGlobal(n,this.assign(a,r,e.global(n)))}},member(e,n){if(null===e)throw new o(null,l.MemberOfNull,null);if(e instanceof t||O(e)){if(v(n))return e.field(n);throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof P){if(v(n))return $(e,n,null,null);throw new o(null,l.InvalidMemberAccessKey,null)}if(A(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(v(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length+n),n>=e.length||n<0)throw new o(null,l.OutOfBounds,null);return e[n]}throw new o(null,l.InvalidMemberAccessKey,null)}if(k(e)){if(_(n)&&isFinite(n)&&Math.floor(n)===n){if(n<0&&(n=e.length()+n),n>=e.length()||n<0)throw new o(null,l.OutOfBounds,null);return e.get(n)}throw new o(null,l.InvalidMemberAccessKey,null)}if(e instanceof Ue){if(v(n))return e.global(n);throw new o(null,l.InvalidMemberAccessKey,null)}throw new o(null,l.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 o=n.moduleFactory[t]({vars:{},moduleSingletons:n.moduleSingletons,depthCounter:n.depthCounter,console:n.console,abortSignal:n.abortSignal,isAsync:n.isAsync,services:n.services,lrucache:n.lrucache,timeReference:n.timeReference??null,interceptor:n.interceptor},n.spatialReference);return n.moduleSingletons[t]=o,o},callModuleFunction(e,n,t,r){if(!(e instanceof Ue))throw new o(null,l.FunctionNotFound,null);const a=e.global(t);if(!1===m(a))throw new o(null,l.CallNonFunction,null);return a.call(r,{preparsed:!0,arguments:n})}};function je(e){console.log(e)}function Ne(e,t,a=!1){null===t&&(t={vars:{},customfunctions:{}});let s=null;e.usesModules&&(s=new n(null,e.loadedModules));const i={isAsync:a,globalScope:_e(t.vars,a?Ce:xe,t.customfunctions),moduleFactory:{},moduleFactoryMap:{},undeclaredGlobalsInFunctions:new Map,customfunctions:t.customfunctions,libraryResolver:s,localScope:null,mangleMap:{},depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let c=V(i,e);""===c&&(c="lc.voidOperation; "),i.undeclaredGlobalsInFunctions.size>0&&i.undeclaredGlobalsInFunctions.forEach((e=>{throw new r(t,l.InvalidIdentifier,e.node)}));let u="";u=a?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+c+"\n return lastStatement; }); } \n return this.postProcess(yield mainBody()); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+c+"\n return lastStatement; } \n return this.postProcess(mainBody()); ";const p=i.moduleFactory,w=i.moduleFactoryMap,S=i.exports,v={};for(const n in S)v[n]=void 0!==i.mangleMap[n]?i.mangleMap[n]:n;const x={lc:g,lang:$e,mangles:i.mangleMap,postProcess(e){if(e instanceof d&&(e=e.value),e instanceof f&&(e=e.value),e===h&&(e=null),e===y)throw new o(null,l.IllegalResult,null);if(e===b)throw new o(null,l.IllegalResult,null);if(m(e))throw new o(null,l.IllegalResult,null);return e},prepare(e,n){let t=e.spatialReference;null==t&&(t=K.WebMercator);const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,moduleFactory:p,moduleFactoryMap:w,mangleMap:this.mangles,moduleSingletons:{},exports:S,gdefs:{},exportmangle:v,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:{depth:1}}}};return new Function("context","spatialReference",u).bind(x)}async function Le(){return Ee([await import("./functions/geomasync.js")],"async"),!0}class Ue extends e{constructor(e){super(null),this.moduleContext=e}hasGlobal(e){return void 0===this.moduleContext.exports[e]&&(e=e.toLowerCase()),void 0!==this.moduleContext.exports[e]}setGlobal(e,n){const t=this.moduleContext.globalScope,r=e.toLowerCase();if(m(n))throw new o(null,l.AssignModuleFunction,null);t[this.moduleContext.exportmangle[r]]=n}global(e){const n=this.moduleContext.globalScope;e=e.toLowerCase();const t=n[this.moduleContext.exportmangle[e]];if(void 0===t)throw new o(null,l.InvalidIdentifier,null);if(m(t)&&!(t instanceof u)){const o=new u;return o.fn=t,o.parameterEvaluator=W,o.context=this.moduleContext,n[this.moduleContext.exportmangle[e]]=o,o}return t}}function De(e,t,o=!1){const l={isAsync:o,moduleFactory:t.moduleFactory,moduleFactoryMap:{},libraryResolver:new n(null,e.loadedModules),globalScope:_e(t.vars,o?Ce:xe,t.customfunctions),customfunctions:t.customfunctions,localScope:null,mangleMap:{},undeclaredGlobalsInFunctions:new Map,depthCounter:{depth:1},exports:{},console:je,lrucache:t.lrucache,timeReference:t.timeReference??null,interceptor:t.interceptor,services:t.services,symbols:{symbolCounter:0}};let r=V(l,e);""===r&&(r="lc.voidOperation; ");let a="";a=o?"var runtimeCtx=this.prepare(context, true);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \nreturn lang.__awaiter(this, void 0, void 0, function* () {\n\n function mainBody() {\n var lastStatement=lc.voidOperation;\n return lang.__awaiter(this, void 0, void 0, function* () {\n"+r+"\n return lastStatement; }); } \n yield mainBody(); \n return this.prepareModule(runtimeCtx); }); ":"var runtimeCtx=this.prepare(context, false);\n var lc = this.lc; var lang = this.lang; var gscope=runtimeCtx.globalScope; \n function mainBody() {\n var lastStatement=lc.voidOperation;\n "+r+"\n return lastStatement; } \n mainBody(); \n return this.prepareModule(runtimeCtx); ";const s=l.moduleFactory,i=l.moduleFactoryMap,c=l.exports,u={};for(const n in c)u[n]=void 0!==l.mangleMap[n]?l.mangleMap[n]:n;const p={lc:g,lang:$e,mangles:l.mangleMap,prepareModule:e=>new Ue(e),prepare(e,n){let t=e.spatialReference;null==t&&(t=new K({wkid:102100}));const o=Oe(e.vars,e.customfunctions,n,e.timeReference);return{localStack:[],isAsync:n,exports:c,exportmangle:u,gdefs:{},moduleFactory:s,moduleFactoryMap:i,moduleSingletons:e.moduleSingletons,mangleMap:this.mangles,spatialReference:t,globalScope:o,abortSignal:void 0===e.abortSignal||null===e.abortSignal?{aborted:!1}:e.abortSignal,localScope:null,services:e.services,console:e.console??je,lrucache:e.lrucache,timeReference:e.timeReference??null,interceptor:e.interceptor,symbols:{symbolCounter:0},depthCounter:e.depthCounter}}};return new Function("context","spatialReference",a).bind(p)}export{T as UserDefinedCompiledFunction,Ne as compileScript,Le as enableAsyncSupport,Re as executeScript,Ee as extend,ke as functionHelper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{UnknownTimeZone as e,ArcadeDateError as t,ArcadeDateErrorCodes as i}from"./ArcadeDate.js";import n from"../layers/support/FieldsIndex.js";import a from"../time/TimeReference.js";import{
|
|
5
|
+
import{UnknownTimeZone as e,ArcadeDateError as t,ArcadeDateErrorCodes as i}from"./ArcadeDate.js";import n from"../layers/support/FieldsIndex.js";import a from"../time/TimeReference.js";import{convertLegacyTimeZone as r}from"../time/timeReferenceUtils.js";import{Zone as s,SystemZone as d,FixedOffsetZone as o,IANAZone as f}from"luxon";function l(e){return e instanceof a}function m(n){if(!n)return null;if(l(n)&&(n=c(n.toJSON())),n instanceof s)return n;if("unknown"===n.toLowerCase())return e.instance;if("system"===n.toLowerCase())return d.instance;if("utc"===n.toLowerCase())return o.utcInstance;if(/^[\+\-]?[0-9]{1,2}([:][0-9]{2})?$/.test(n)){const e=o.parseSpecifier("UTC"+(n.startsWith("+")||n.startsWith("-")?"":"+")+n);if(e)return e}const a=f.create(n);if(!a.isValid)throw new t(i.TimeZoneNotRecognised);return a}function c(e){return e?.timeZoneIANA?e?.timeZoneIANA:e?.timeZone?r(e,""):""}class T{constructor(){this.dateTimeReferenceMetaData=null,this._fieldTimeZoneIndex={},this._fieldIndex=null,this._ianaPreferred=null,this._ianaTimeInfo=null,this._ianaEditFields=null,this._ianaLayerDateFields=null}static create(e,t){const i=new T;return i.dateTimeReferenceMetaData=t,i._fieldIndex=e instanceof n?e:new n(e),i}static createFromLayer(e){if(!e)return null;if(!e.fieldsIndex)return!e.declaredClass&&e.fields?T.create(e.fields,e):null;const t=new T;return t._fieldIndex=e.fieldsIndex,t.dateTimeReferenceMetaData={timeInfo:e?.timeInfo?.toJSON()??null,editFieldsInfo:e?.editFieldsInfo?.toJSON()??null,dateFieldsTimeReference:e?.dateFieldsTimeReference?.toJSON()??null,preferredTimeReference:e?.preferredTimeReference?.toJSON()??null,datesInUnknownTimezone:!0===e?.datesInUnknownTimezone},t}fieldTimeZone(e){const t=this._fieldIndex?.get(e);if(!t)return null;if("date"!==t.type&&"esriFieldTypeDate"!==t.type)return null;const i=this._fieldTimeZoneIndex[t.name];if(void 0!==i)return i;const n=[{field:this.dateTimeReferenceMetaData?.editFieldsInfo?.creationDateField,timeReference:this.dateTimeReferenceMetaData?.editFieldsInfo?.dateFieldsTimeReference,isunknown:!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone},{field:this.dateTimeReferenceMetaData?.editFieldsInfo?.editDateField,timeReference:this.dateTimeReferenceMetaData?.editFieldsInfo?.dateFieldsTimeReference,isunknown:!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone},{field:this.dateTimeReferenceMetaData?.timeInfo?.startTimeField,timeReference:this.dateTimeReferenceMetaData?.timeInfo?.timeReference,isunknown:!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone},{field:this.dateTimeReferenceMetaData?.timeInfo?.endTimeField,timeReference:this.dateTimeReferenceMetaData?.timeInfo?.timeReference,isunknown:!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone}];for(const r of n)if(r.field===t.name){const e=this.convertToIANA(r.timeReference,r.isunknown);return this._fieldTimeZoneIndex[t.name]=e,e}const a=this.convertToIANA(this.dateTimeReferenceMetaData?.dateFieldsTimeReference,this.dateTimeReferenceMetaData?.datesInUnknownTimezone);return this._fieldTimeZoneIndex[t.name]=a,a}convertToIANA(e,t){return t?"unknown":c(e)}get layerPreferredTimeZone(){if(null!==this._ianaPreferred)return this._ianaPreferred;this._ianaPreferred="";const e=this.dateTimeReferenceMetaData?.preferredTimeReference;return this._ianaPreferred=this.convertToIANA(e,!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone),this._ianaPreferred}get layerTimeInfoTimeZone(){if(null!==this._ianaTimeInfo)return this._ianaTimeInfo;this._ianaTimeInfo="";const e=this.dateTimeReferenceMetaData?.timeInfo?.timeReference;return this._ianaTimeInfo=this.convertToIANA(e,!1),this._ianaTimeInfo}get layerEditFieldsTimeZone(){if(null!==this._ianaEditFields)return this._ianaEditFields;this._ianaEditFields="";const e=this.dateTimeReferenceMetaData?.editFieldsInfo?.dateFieldsTimeReference;return this._ianaEditFields=this.convertToIANA(e,this.dateTimeReferenceMetaData?.datesInUnknownTimezone),this._ianaEditFields}get layerDateFieldsTimeZone(){if(null!==this._ianaLayerDateFields)return this._ianaLayerDateFields;this._ianaLayerDateFields="";const e=this.dateTimeReferenceMetaData?.dateFieldsTimeReference;return this._ianaLayerDateFields=this.convertToIANA(e,!0===this.dateTimeReferenceMetaData?.datesInUnknownTimezone),this._ianaLayerDateFields}}export{T as DateTimeReferenceFieldIndex,m as convertTimeReference,c as convertToIANA};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{$ as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import o from"../support/FeatureSet.js";import l from"../support/IdSet.js";import d from"../support/OrderbyClause.js";import{IdState as u,layerGeometryEsriConstants as f,FeatureServiceDatabaseType as c}from"../support/shared.js";import{isSingleField as h,toWhereClause as p,predictType as g,scanForField as _,reformulateWithoutField as m}from"../support/sqlUtils.js";import{calculateStat as y}from"../support/stats.js";import b from"../support/StatsField.js";import{createMD5Hash as w,outputTypes as F}from"../../../core/MD5.js";import{WhereClause as I}from"../../../core/sql/WhereClause.js";import S from"../../../geometry/SpatialReference.js";import x from"../../../layers/support/Field.js";import k from"../../../layers/support/FieldsIndex.js";import{FeatureSetError as D,FeatureSetErrorCodes as A}from"../support/errorsupport.js";function j(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class C extends o{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return u.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new k([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new b;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof I?i.expression:I.create(i.expression,r),e.typeofstat=j(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof I?i.expression:I.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=f.point,this.typeIdField="",this.types=null,this.spatialReference=new S({wkid:4326});this.fields=[];const a=new b;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=I.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new x;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,h(s.expression)){const e=this._parent.getField(p(s.expression,c.Standardised));if(!e)throw new D(A.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(g(s.expression,this._parent.fields));const e=new x;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new x;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&h(n.workingexpr)?p(n.workingexpr,c.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new D(A.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new D(A.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,o){if(""!==e)return new l([],[],!0,null);let u=null;const f={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===_(i,this._decodedStatsfield[n].tofieldname)){f.nowhereclause=!0,i=null;break}if(null!==s){f.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,f.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,f.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(o),u=!0===f.nowhereclause?new l(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new l(n._candidates.slice(0),n._known.slice(0),!0===f.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),u}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===f.nowhereclause)u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}u=new l(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new d(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return u}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=m(e,t.tofieldname,p(t.workingexpr,c.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=m(e,t.tofieldname,p(t.expression,c.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const o=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:o};else{if(o!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=y("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=y("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=y("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=y("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=y("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=y("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return w(t,F.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){o._featuresetFunctions.groupby=function(e,t){return new C({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{C as default};
|
|
5
|
+
import e from"../../../Graphic.js";import{$ as t}from"../../../chunks/languageUtils.js";import{SqlExpressionAdapted as i,OriginalField as s,AdaptedFeatureSet as n}from"./Adapted.js";import r from"./AttributeFilter.js";import a from"./OrderBy.js";import{FeatureSetError as o,FeatureSetErrorCodes as l}from"../support/errorsupport.js";import d from"../support/FeatureSet.js";import u from"../support/IdSet.js";import f from"../support/OrderbyClause.js";import{IdState as c,layerGeometryEsriConstants as h,FeatureServiceDatabaseType as p}from"../support/shared.js";import{isSingleField as g,toWhereClause as _,predictType as m,scanForField as y,reformulateWithoutField as b}from"../support/sqlUtils.js";import{calculateStat as w}from"../support/stats.js";import F from"../support/StatsField.js";import{createMD5Hash as I,outputTypes as S}from"../../../core/MD5.js";import{WhereClause as x}from"../../../core/sql/WhereClause.js";import k from"../../../geometry/SpatialReference.js";import D from"../../../layers/support/Field.js";import A from"../../../layers/support/FieldsIndex.js";function j(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class C extends d{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return c.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,n=1;const r=this._parent?this._parent.getFieldsIndex():new A([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+n.toString(),n++)}for(const i of this._config.statsfields){const e=new F;e.field=i.name,e.tofieldname=i.name,e.workingexpr=i.expression instanceof x?i.expression:x.create(i.expression,r),e.typeofstat=j(i.statistic),this._decodedStatsfield.push(e)}this._decodedGroupbyfield=[];for(const i of this._config.groupbyfields){const e={name:i.name,singlefield:null,tofieldname:i.name,expression:i.expression instanceof x?i.expression:x.create(i.expression,r)};this._decodedGroupbyfield.push(e)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=h.point,this.typeIdField="",this.types=null,this.spatialReference=new k({wkid:4326});this.fields=[];const a=new F;a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=x.create(this._parent.objectIdField,this._parent.getFieldsIndex()),a.typeofstat="MIN",this._decodedStatsfield.push(a);for(const s of this._decodedGroupbyfield){const t=new D;if(s.name=this._nextUniqueName(e),t.name=s.tofieldname,t.alias=t.name,g(s.expression)){const e=this._parent.getField(_(s.expression,p.Standardised));if(!e)throw new o(l.AggregationFieldNotFound);s.name=e.name,s.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),t.type=e.type}else{t.type=this._convertToEsriFieldType(m(s.expression,this._parent.fields));const e=new D;e.name=s.name,e.alias=e.name,this.phsyicalgroupbyfields.push(s.name),this._adaptedFields.push(new i(e,s.expression)),this._candosimplegroupby=!1}this.fields.push(t)}if(this._adaptedFields.length>0)for(const i of this._parent.fields)this._adaptedFields.push(new s(i));for(let i=0;i<this._decodedStatsfield.length;i++){const t=new D;let s=null;const n=this._decodedStatsfield[i];n.field=this._nextUniqueName(e),n.tofieldname===this.objectIdField&&(this._internalObjectIdField=n.field),t.name=n.tofieldname,t.alias=t.name;const r=null!==n.workingexpr&&g(n.workingexpr)?_(n.workingexpr,p.Standardised):"";switch(this._decodedStatsfield[i].typeofstat){case"SUM":if(""!==r){if(s=this._parent.getField(r),!s)throw new o(l.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"MIN":case"MAX":if(""!==r){if(s=this._parent.getField(r),!s)throw new o(l.AggregationFieldNotFound);t.type=s.type}else t.type="double";break;case"COUNT":t.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==r&&(s=this._parent.getField(r),!s))throw new o(l.AggregationFieldNotFound);t.type="double"}this.fields.push(t)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,s){-1!==t&&this._featureCache[t];const n=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,n)?(await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,i,s)):"success"}async _getFilteredSet(e,t,i,s,o){if(""!==e)return new u([],[],!0,null);let l=null;const d={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i)for(let n=0;n<this._decodedStatsfield.length;n++)if(!0===y(i,this._decodedStatsfield[n].tofieldname)){d.nowhereclause=!0,i=null;break}if(null!==s){d.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,d.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,d.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(o),l=!0===d.nowhereclause?new u(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new u(n._candidates.slice(0),n._known.slice(0),!0===d.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),l}let c=this._parent;if(this._adaptedFields.length>0&&(c=new n({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===d.nowhereclause)l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:c,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=c;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new r({parentfeatureset:e,whereclause:t})}l=new u(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new a({parentfeatureset:e,orderbyclause:new f(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return l}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=b(e,t.tofieldname,_(t.workingexpr,p.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=b(e,t.tofieldname,_(t.expression,p.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const i of this._decodedGroupbyfield)i.tofieldname!==i.name&&t.push({field:i.tofieldname,newfield:i.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i);this._checkCancelled(i);const s=e._candidates.length;this._refineKnowns(e,t);e._candidates.length;return e._candidates.length,e}_expandPagedSet(e,t,i,s,n){return this._expandPagedSetFeatureSet(e,t,i,s,n)}async _getPhysicalPage(t,i,s){if(!0===t.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(t,t.pagesDefinition.resultRecordCount,s,[]);const n=await this._getAgregagtePhysicalPage(t,i,s);for(const r of n){const t={geometry:r.geometry,attributes:{}},i={};for(const e in r.attributes)i[e.toLowerCase()]=r.attributes[e];for(const e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(const e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new e(t)}return n.length}_sequentialGetPhysicalItem(e,t,i,s){return new Promise(((n,r)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?n(s.length):this._nextAggregateItem(e,t,i,s,(r=>{null===r?n(s.length):(t-=1,n(this._sequentialGetPhysicalItem(e,t,i,s)))}),r)}))}_nextAggregateItem(e,i,s,n,r,a){try{t(e.pagesDefinition.internal.iterator.next()).then((t=>{if(null===t)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);n.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,r(null)}else e.pagesDefinition.internal.fullyResolved=!0,r(null);else{const o=this._generateAggregateHash(t);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[t],id:o};else{if(o!==e.pagesDefinition.internal.workingItem.id){const s=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return n.push(s),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(s.attributes[this.objectIdField]),i-=1,e.pagesDefinition.internal.workingItem={features:[t],id:o},void r(s)}e.pagesDefinition.internal.workingItem.features.push(t)}this._nextAggregateItem(e,i,s,n,r,a)}}),a)}catch(o){a(o)}}_calculateFieldStat(e,t,i){const s=[];for(let n=0;n<e.features.length;n++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[n]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":i.attributes[t.tofieldname]=w("min",s,-1);break;case"MAX":i.attributes[t.tofieldname]=w("max",s,-1);break;case"SUM":i.attributes[t.tofieldname]=w("sum",s,-1);break;case"COUNT":i.attributes[t.tofieldname]=s.length;break;case"VAR":i.attributes[t.tofieldname]=w("var",s,-1);break;case"STDDEV":i.attributes[t.tofieldname]=w("stddev",s,-1);break;case"AVG":i.attributes[t.tofieldname]=w("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(t){const i={attributes:{},geometry:null};for(const e of this._decodedGroupbyfield){const s=e.singlefield?t.features[0].attributes[e.singlefield]:e.expression.calculateValue(t.features[0]);i.attributes[e.tofieldname]=s}for(const e of this._decodedStatsfield)this._calculateFieldStat(t,e,i);const s=[];for(let e=0;e<this._decodedStatsfield.length;e++)s.push(this._calculateFieldStat(t,this._decodedStatsfield[e],i));return this._featureCache[i.attributes[this.objectIdField]]=new e({attributes:i.attributes,geometry:i.geometry}),i}_generateAggregateHash(e){let t="";for(const i of this._decodedGroupbyfield){const s=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return I(t,S.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d._featuresetFunctions.groupby=function(e,t){return new C({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}export{C as default};
|