@arcgis/core 4.31.0-next.20240613 → 4.31.0-next.20240615
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/TimeExtent.js +1 -1
- package/TimeInterval.js +1 -1
- package/UndoRedo.js +1 -1
- package/WebScene.js +1 -1
- package/applications/Components/getDefaultUnits.d.ts +4 -0
- package/applications/Components/getDefaultUnits.js +5 -0
- package/arcade/functions/string.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0f1f32f338b23dc70fd3.js +1 -0
- package/assets/esri/core/workers/chunks/12ba668196848aed4677.js +1 -0
- package/assets/esri/core/workers/chunks/{a6b138f330625d98f856.js → 139bfed231a72b8e479e.js} +1 -1
- package/assets/esri/core/workers/chunks/14eed5c69fe461827d86.js +1 -0
- package/assets/esri/core/workers/chunks/{1ece003ccf1c03fb42d9.js → 1547d7c68ea24fb5b91d.js} +1 -1
- package/assets/esri/core/workers/chunks/{712ba8ad69b1aab6f508.js → 179c0223cff2ae4b9005.js} +1 -1
- package/assets/esri/core/workers/chunks/18f0ee495bd4265ea896.js +1 -0
- package/assets/esri/core/workers/chunks/{7c68dc664c0b4cf2a46b.js → 1a393b00db50eebc0315.js} +1 -1
- package/assets/esri/core/workers/chunks/1d585f1f90dec39ab9d6.js +1 -0
- package/assets/esri/core/workers/chunks/1e7d18668d2444a763c8.js +1 -0
- package/assets/esri/core/workers/chunks/21b2ea67a49d1c8a450d.js +1 -0
- package/assets/esri/core/workers/chunks/222807cfaa2e17d0efea.js +1 -0
- package/assets/esri/core/workers/chunks/23da04765ed7d5b6cabc.js +1 -0
- package/assets/esri/core/workers/chunks/24484bd0185ea0f79760.js +1 -0
- package/assets/esri/core/workers/chunks/28e8313f8dec57fb9eee.js +1 -0
- package/assets/esri/core/workers/chunks/29399c376286b431c681.js +1 -0
- package/assets/esri/core/workers/chunks/{d61e1078e0d3bae71237.js → 30efb53649f9f34cc0c8.js} +1 -1
- package/assets/esri/core/workers/chunks/317fcb69bd430da134da.js +1 -0
- package/assets/esri/core/workers/chunks/{82f982d9dde0ab137403.js → 339929c10fa8366b1615.js} +1 -1
- package/assets/esri/core/workers/chunks/380066c785937dba122c.js +1 -0
- package/assets/esri/core/workers/chunks/{e93e59f6907fa4c1081c.js → 454ee517b0a1ac0d796c.js} +1 -1
- package/assets/esri/core/workers/chunks/{03b4b12cf537c26ced5a.js → 482f7dfc9486a283a529.js} +1 -1
- package/assets/esri/core/workers/chunks/492d7773f6b6ba20a41f.js +1 -0
- package/assets/esri/core/workers/chunks/4edac9bba9a1de1dcb62.js +1 -0
- package/assets/esri/core/workers/chunks/{dcca17cf0c48a97a5fa1.js → 4f2be9fd4ff5b3ad3110.js} +1 -1
- package/assets/esri/core/workers/chunks/{763e6b28b92332894be4.js → 57d7b980be64a7818115.js} +1 -1
- package/assets/esri/core/workers/chunks/{4e2943968517e385bd12.js → 5bf576c840a812658989.js} +1 -1
- package/assets/esri/core/workers/chunks/{c478e789011287e04766.js → 5d6c958876e40952d0cc.js} +1 -1
- package/assets/esri/core/workers/chunks/{98b9987b2932f540fdad.js → 652502e76d5207cb21ad.js} +1 -1
- package/assets/esri/core/workers/chunks/726456bfc733392aaf2b.js +1 -0
- package/assets/esri/core/workers/chunks/7dd61f7da08d4f310e5d.js +1 -0
- package/assets/esri/core/workers/chunks/{de21dffe546dd45dd1fb.js → 7fd9134246a9dbfa603b.js} +1 -1
- package/assets/esri/core/workers/chunks/{397bea971be305ee8a02.js → 81cd82d253d512380fac.js} +1 -1
- package/assets/esri/core/workers/chunks/85471bec9f79bc641ae6.js +1 -0
- package/assets/esri/core/workers/chunks/879768258754731b0da4.js +1 -0
- package/assets/esri/core/workers/chunks/8ab8eabc67ca01cc3d67.js +1 -0
- package/assets/esri/core/workers/chunks/8b82a753e8a396afa7ae.js +1 -0
- package/assets/esri/core/workers/chunks/8d1deed5a045e4953a5f.js +1 -0
- package/assets/esri/core/workers/chunks/91bd37d201595f5081df.js +1 -0
- package/assets/esri/core/workers/chunks/{758cacaad381bbca5d8a.js → 9f5e771280883fd7150e.js} +1 -1
- package/assets/esri/core/workers/chunks/a6d4526296db6b665e35.js +1 -0
- package/assets/esri/core/workers/chunks/{1b4c91833fb7b99c6cfe.js → ad0a87dba95785ad6171.js} +1 -1
- package/assets/esri/core/workers/chunks/adb83f8d9d030dbec92d.js +1 -0
- package/assets/esri/core/workers/chunks/b75020e5d5f463e01e13.js +1 -0
- package/assets/esri/core/workers/chunks/bb149eb195925373f078.js +1 -0
- package/assets/esri/core/workers/chunks/{85219e23fc3f996bda90.js → bd3e20c909bc3e07fe4b.js} +1 -1
- package/assets/esri/core/workers/chunks/{00c49f6c84444e69f3a1.js → bf619b4f34c6152b769e.js} +1 -1
- package/assets/esri/core/workers/chunks/c68a24870946c4a83c20.js +1 -0
- package/assets/esri/core/workers/chunks/{58f950d8facc4c4887fa.js → c7ff5ed235cbe2903353.js} +1 -1
- package/assets/esri/core/workers/chunks/c9a8078402085edf9004.js +1 -0
- package/assets/esri/core/workers/chunks/d3aa4dfcccfd8d47b445.js +1 -0
- package/assets/esri/core/workers/chunks/{2c701416acbaf5702869.js → ea31314541c8033f3c09.js} +1 -1
- package/assets/esri/core/workers/chunks/{b2ddb0aea8f78e4bff0e.js → efb3c2e858973e5bc79e.js} +1 -1
- package/assets/esri/core/workers/chunks/f0e2047de0bb533fd3e2.js +1 -0
- package/assets/esri/core/workers/chunks/fec53ce15ae52f8cb802.js +1 -0
- package/assets/esri/core/workers/chunks/{fca4ed5a2cbdfd986452.js → ff5e6d823d512f87a527.js} +1 -1
- package/chunks/ShadowHighlight.glsl.js +4 -29
- package/chunks/Viewshed.glsl.js +145 -84
- package/grids/MeasuredGrid.js +5 -0
- package/interfaces.d.ts +506 -813
- package/layers/Layer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/mixins/TemporalLayer.js +1 -1
- package/layers/mixins/TemporalSceneLayer.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/FeatureFilter.js +1 -1
- package/layers/support/TimeInfo.js +1 -1
- package/package.json +1 -1
- package/renderers/ClassBreaksRenderer.js +1 -1
- package/renderers/DictionaryRenderer.js +1 -1
- package/renderers/HeatmapRenderer.js +1 -1
- package/renderers/PieChartRenderer.js +1 -1
- package/renderers/SimpleRenderer.js +1 -1
- package/renderers/UniqueValueRenderer.js +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/knowledgeGraph/GraphApplyEdits.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/support/AttachmentQuery.js +1 -1
- package/rest/support/BufferParameters.js +1 -1
- package/rest/support/DensifyParameters.js +1 -1
- package/rest/support/DirectionsFeature.js +1 -1
- package/rest/support/DistanceParameters.js +1 -1
- package/rest/support/IdentifyParameters.js +1 -1
- package/rest/support/ImageGPSInfoParameters.js +1 -1
- package/rest/support/ImageHistogramParameters.js +1 -1
- package/rest/support/ImageIdentifyParameters.js +1 -1
- package/rest/support/ImageParameters.js +1 -1
- package/rest/support/ImageSampleParameters.js +1 -1
- package/rest/support/Query.js +1 -1
- package/rest/support/TopFeaturesQuery.js +1 -1
- package/rest/support/geometryOperationLengthUnit.js +5 -0
- package/smartMapping/renderers/pieChart.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/smartMapping/support/adapters/support/layerUtils.js +1 -1
- package/support/revision.js +1 -1
- package/support/timeUtils.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/effects/EffectDashes.js +1 -1
- package/symbols/cim/rasterizingUtils.js +1 -1
- package/symbols/support/symbolUtils.js +1 -1
- package/time/TimeExtent.d.ts +4 -0
- package/time/TimeExtent.js +5 -0
- package/time/TimeInterval.d.ts +4 -0
- package/time/TimeInterval.js +5 -0
- package/undoredo/support/ServiceVersionInfo.js +1 -1
- package/versionManagement/versionAdapters/SubTypeGroupLayerVersionAdapter.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/webgl/GridView2D.js +5 -0
- package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
- package/views/2d/engine/webgl/shaders/GridPrograms.js +5 -0
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/support/clusterUtils.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js +23 -0
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ViewshedTechniqueConfiguration.js +5 -0
- package/views/MapView.js +1 -1
- package/views/View.js +1 -1
- package/webdoc/support/timeProperties.js +1 -1
- package/webdoc/widgets/TimeSlider.js +1 -1
- package/widgets/Attachments/AttachmentsViewModel.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/RelationshipColumn.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/OrientedImageryViewerViewModelAdapter2D.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/smartMapping/BinaryColorSizeSlider.js +1 -1
- package/widgets/smartMapping/ColorSizeSlider.js +1 -1
- package/assets/esri/core/workers/chunks/04d84f7c9c5b5a6bdf47.js +0 -1
- package/assets/esri/core/workers/chunks/06ea3bb071a83a54f1b2.js +0 -1
- package/assets/esri/core/workers/chunks/0903b492782dca69eb48.js +0 -1
- package/assets/esri/core/workers/chunks/10615d0fc70cf4873f0a.js +0 -1
- package/assets/esri/core/workers/chunks/131546766fd9e78b953e.js +0 -1
- package/assets/esri/core/workers/chunks/1a64e0020d12c251ad4b.js +0 -1
- package/assets/esri/core/workers/chunks/203e5d41b805c875672d.js +0 -1
- package/assets/esri/core/workers/chunks/27dc94db9ed42b237ecb.js +0 -1
- package/assets/esri/core/workers/chunks/29b5f842d66272c93c44.js +0 -1
- package/assets/esri/core/workers/chunks/38b6e897150b627c8228.js +0 -1
- package/assets/esri/core/workers/chunks/3e6b6db24a1aa7798d19.js +0 -1
- package/assets/esri/core/workers/chunks/43e1c935452b489e422e.js +0 -1
- package/assets/esri/core/workers/chunks/43e7770c7cd3199fd3b5.js +0 -1
- package/assets/esri/core/workers/chunks/45310412cb1877c2767f.js +0 -1
- package/assets/esri/core/workers/chunks/5efe1300a39ab9c7bbab.js +0 -1
- package/assets/esri/core/workers/chunks/62f3c23a44351882007c.js +0 -1
- package/assets/esri/core/workers/chunks/6cb177627c0bfc7d78c2.js +0 -1
- package/assets/esri/core/workers/chunks/85afa3c4b08500faf3cb.js +0 -1
- package/assets/esri/core/workers/chunks/912364ec942d974eec82.js +0 -1
- package/assets/esri/core/workers/chunks/97ede2198c6d1cbc02b7.js +0 -1
- package/assets/esri/core/workers/chunks/a8a19e5a7ae4ec16480a.js +0 -1
- package/assets/esri/core/workers/chunks/aa198e898b46c6e89d0b.js +0 -1
- package/assets/esri/core/workers/chunks/b3de9bc3e75476b0a7e9.js +0 -1
- package/assets/esri/core/workers/chunks/ba1ed29c41d4f8a32dbc.js +0 -1
- package/assets/esri/core/workers/chunks/c22c74934d1b33f5c127.js +0 -1
- package/assets/esri/core/workers/chunks/c406e673d2dd7e702af0.js +0 -1
- package/assets/esri/core/workers/chunks/c660649465058ef82045.js +0 -1
- package/assets/esri/core/workers/chunks/cab1438113f204ce70ea.js +0 -1
- package/assets/esri/core/workers/chunks/dc48bb481020ceb05a16.js +0 -1
- package/assets/esri/core/workers/chunks/e331618aecdc2f110e15.js +0 -1
- package/assets/esri/core/workers/chunks/ec06875eac992c640057.js +0 -1
- package/assets/esri/core/workers/chunks/f31bad0ab4cbcb552d3c.js +0 -1
- package/assets/esri/core/workers/chunks/fe59b594d2d8c536e649.js +0 -1
package/TimeExtent.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{deprecatedModule as e}from"./core/deprecate.js";import r from"./core/Logger.js";import t from"./time/TimeExtent.js";e(r.getLogger("esri.TimeExtent"),"esri.TimeExtent",{replacement:"esri.time.TimeExtent",version:"4.31",warnOnce:!0});export{t as default};
|
package/TimeInterval.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{deprecatedModule as e}from"./core/deprecate.js";import r from"./core/Logger.js";import t from"./time/TimeInterval.js";e(r.getLogger("esri.TimeInterval"),"esri.TimeInterval",{replacement:"esri.time.TimeInterval",version:"4.31",warnOnce:!0});export{t as default};
|
package/UndoRedo.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"./chunks/tslib.es6.js";import s from"./core/Accessor.js";import i from"./core/Collection.js";import{whenOnce as o}from"./core/reactiveUtils.js";import{property as a}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import"./core/RandomLCG.js";import{subclass as e}from"./core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"./core/support/UpdatingHandles.js";import{OperationStatus as r}from"./undoredo/OperationStatus.js";import{UndoRedoExecutionMethod as c}from"./undoredo/UndoableOperation.js";import{UndoInvalidError as d,UndoRedoUpdatingError as h,RedoInvalidError as p}from"./undoredo/UndoRedoError.js";let u=class extends s{constructor(){super(...arguments),this._stack=new i,this._stackPosition=-1,this._updatingHandles=new n}get updating(){return this._updatingHandles.updating}get canUndo(){return this.hasUndo&&!this.updating}get hasUndo(){return this._stackPosition>=0}get canRedo(){return this.hasRedo&&!this.updating}get hasRedo(){return this._stackPosition<this._stack.length-1}_truncateForwardStack(){this._stack.splice(this._stackPosition+1,this._stack.length-this._stackPosition).forEach((t=>t.destroy()))}_drainStack(){this._stack.drain((t=>t.destroy())),this._stackPosition=-1}async undo(){if(!this.hasUndo)throw new d;if(this.updating)throw new h;const t=this._stack.getItemAt(this._stackPosition);await this._updatingHandles.addPromise((async()=>{await t.executeUndoRedoOperation(c.Undo),--this._stackPosition,t.canRedo||this._truncateForwardStack()})())}async redo(){if(!this.hasRedo)throw new p;if(this.updating)throw new h;const t=this._stack.getItemAt(this._stackPosition+1);await this._updatingHandles.addPromise((async()=>{await t.executeUndoRedoOperation(c.Redo),++this._stackPosition})())}async inject(t){if(this.updating)throw new h;await this._updatingHandles.addPromise((async()=>{t.status===r.NeverApplied&&await t.executeUndoRedoOperation(c.Apply),t.canUndo?(this._stack.splice(this._stackPosition+1,0,t),this._stackPosition++):this._stackPosition>-1&&(this._stack.splice(0,this._stackPosition+1).forEach((t=>t.destroy())),this._stackPosition=-1)})())}async add(t){if(this.updating)throw new h;await this._updatingHandles.addPromise((async()=>{t.status===r.NeverApplied&&await t.executeUndoRedoOperation(c.Apply),this._stackPosition
|
|
5
|
+
import{_ as t}from"./chunks/tslib.es6.js";import s from"./core/Accessor.js";import i from"./core/Collection.js";import{whenOnce as o}from"./core/reactiveUtils.js";import{property as a}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/Logger.js";import"./core/RandomLCG.js";import{subclass as e}from"./core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"./core/support/UpdatingHandles.js";import{OperationStatus as r}from"./undoredo/OperationStatus.js";import{UndoRedoExecutionMethod as c}from"./undoredo/UndoableOperation.js";import{UndoInvalidError as d,UndoRedoUpdatingError as h,RedoInvalidError as p}from"./undoredo/UndoRedoError.js";let u=class extends s{constructor(){super(...arguments),this._stack=new i,this._stackPosition=-1,this._updatingHandles=new n}get updating(){return this._updatingHandles.updating}get canUndo(){return this.hasUndo&&!this.updating}get hasUndo(){return this._stackPosition>=0}get canRedo(){return this.hasRedo&&!this.updating}get hasRedo(){return this._stackPosition<this._stack.length-1}_truncateForwardStack(){this._stack.splice(this._stackPosition+1,this._stack.length-this._stackPosition).forEach((t=>t.destroy()))}_drainStack(){this._stack.drain((t=>t.destroy())),this._stackPosition=-1}async undo(){if(!this.hasUndo)throw new d;if(this.updating)throw new h;const t=this._stack.getItemAt(this._stackPosition);await this._updatingHandles.addPromise((async()=>{await t.executeUndoRedoOperation(c.Undo),--this._stackPosition,t.canRedo||this._truncateForwardStack()})())}async redo(){if(!this.hasRedo)throw new p;if(this.updating)throw new h;const t=this._stack.getItemAt(this._stackPosition+1);await this._updatingHandles.addPromise((async()=>{await t.executeUndoRedoOperation(c.Redo),++this._stackPosition})())}peekUndo(){return this.canUndo?this._stack.getItemAt(this._stackPosition):null}peekRedo(){return this.canRedo?this._stack.getItemAt(this._stackPosition+1):null}async inject(t){if(this.updating)throw new h;await this._updatingHandles.addPromise((async()=>{t.status===r.NeverApplied&&await t.executeUndoRedoOperation(c.Apply),t.canUndo?(this._stack.splice(this._stackPosition+1,0,t),this._stackPosition++):this._stackPosition>-1&&(this._stack.splice(0,this._stackPosition+1).forEach((t=>t.destroy())),this._stackPosition=-1)})())}async add(t){if(this.updating)throw new h;await this._updatingHandles.addPromise((async()=>{t.status===r.NeverApplied&&await t.executeUndoRedoOperation(c.Apply),this._stackPosition>=-1&&this._truncateForwardStack(),t.canUndo?(this._stack.push(t),this._stackPosition=this._stack.length-1):this._drainStack()})())}async removeTagged(t,s=!1){if(this.updating&&!s)return;await o((()=>!this.updating));const a=new i;for(let i=0;i<this._stack.length;i++){const s=this._stack.getItemAt(i);s.tag===t?(s.destroy(),i===this._stackPosition&&(this._stackPosition=a.length-1)):a.push(s)}this._stack=a,this._stackPosition>a.length-1&&(this._stackPosition=a.length-1)}async clear(t=!1){if(this.updating&&!t)throw new h;await o((()=>!this.updating)),this._drainStack()}};t([a()],u.prototype,"_stack",void 0),t([a()],u.prototype,"_stackPosition",void 0),t([a()],u.prototype,"updating",null),t([a({readOnly:!0})],u.prototype,"canUndo",null),t([a({readOnly:!0})],u.prototype,"hasUndo",null),t([a({readOnly:!0})],u.prototype,"canRedo",null),t([a({readOnly:!0})],u.prototype,"hasRedo",null),u=t([e("esri.UndoRedo")],u);export{u as UndoRedo};
|
package/WebScene.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./TimeExtent.js";import o from"./Viewpoint.js";import s from"./core/Collection.js";import a from"./core/Error.js";import{clone as n}from"./core/lang.js";import l from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import c from"./core/Logger.js";import{destroyMaybe as d}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as m}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as u}from"./core/Promise.js";import{debounce as y}from"./core/promiseUtils.js";import{on as w}from"./core/reactiveUtils.js";import{urlToObject as f,addQueryParameter as g}from"./core/urlUtils.js";import{property as b}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as v}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as _}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as A}from"./core/accessorSupport/originUtils.js";import{readLoadable as I}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import L from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as R}from"./geometry/projection.js";import P from"./geometry/SpatialReference.js";import{validateWebSceneError as V}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as M}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import E from"./portal/PortalItem.js";import{createForItemWrite as C}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as N,typeKeyword as T}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as x}from"./support/basemapUtils.js";import G from"./support/MapFloorInfo.js";import{WebSceneTag as F}from"./support/tagSymbols.js";import{createSchemaValidationError as J,createCopyError as W}from"./support/webSceneUtils.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as B}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as q}from"./webdoc/interfaces.js";import k from"./webdoc/Widgets.js";import{updateItemWithResources as D,saveResources as K}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as H}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as z}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as Q}from"./webdoc/support/thumbnailUtils.js";import X from"./webscene/ApplicationProperties.js";import Y from"./webscene/Environment.js";import Z from"./webscene/InitialViewProperties.js";import ee from"./webscene/Presentation.js";import te from"./webscene/TransportationNetwork.js";import{Version as re}from"./webscene/Version.js";import{getLoader as ie}from"./webscene/support/schemaValidatorLoader.js";var oe;const se=new re(1,34),ae=()=>{const e=8,t=[],r=se.major;for(let i=e;i<=se.minor;i++)t.push(`${r}.${i}`);return t},ne="Web Scene";let le=class extends(l.LoadableMixin(u(h(r)))){constructor(e){super(e),this[oe]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new ee,this.initialViewProperties=new Z,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=y((async(e,t,r)=>{switch(e){case q.SAVE:return this._saveImpl(t);case q.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{c.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(w((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=d(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new re(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${se.major}.${se.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};t.initialState?.environment&&(r.environment=Y.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?P.fromJSON(t.spatialReference):P.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=o.fromJSON(t.initialState.viewpoint));const s=t.initialState?.timeExtent;return null!=s&&(r.timeExtent=i.fromArray(s)),new Z(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??P.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return p(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(I(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=n(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new a("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new a("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw c.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new a("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw c.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(q.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new a("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(H(this.portalItem),this.portalItem?.type!==ne)throw new a("webscene:portal-item-wrong-type",`Portal item needs to have type "${ne}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(C(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await D(this.portalItem,i,this._resourceReferences,r),A(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(q.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=E.from(e);if(!r)throw new a("webscene:portal-item-required","saveAs requires a portal item to save to");H(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=ne,r.portal=i;const o=this._enableVerifyItemRelativeUrls(C(r,"web-scene",!0)),s=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(s,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new a("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:s}),await K(this._resourceReferences,o),this.portalItem=r,m.prototype.read.call(this,{version:s.version,authoringApp:s.authoringApp,authoringAppVersion:s.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?f(r.itemUrl):void 0}),A(o),n&&(this.thumbnailUrl=l?g(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i=!1){if(!M(this.spatialReference))throw new a("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:s,strictSchemaValidationEnabled:n}=r||{};z(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:s});const l=ie();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const r=`webscene did not validate:\n${t.join("\n")}`;c.getLogger(this).error(`${i?"saveAs":"save"}(): ${r}`);const o=t.map((e=>new a("webscene:schema-validation",e)));throw J(o)}}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(W()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Y.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=Q(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new s;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:o,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||O.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}o&&o.length>0&&l.push(i(this.layers,o,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r.filter((e=>"base-elevation"===e.type||"elevation"===e.type)))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new a("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new a("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:f(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!B(t,$.Global))return Promise.reject(new a("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||R(e,t)}else{if(!B(t,$.Local))return Promise.reject(new a("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,s=i(o);if(s&&!r(s))return Promise.reject(new a("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:s,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new a("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=V(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=re.parse(e.version||"","webscene");return se.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=P.WebMercator.toJSON()),e}_updateTypeKeywords(e){N(e,T.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),N(e,T.DEVELOPER_BASEMAP,x(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&x(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||P.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?f(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e?.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new a("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};oe=F,le.version=`${se.major}.${se.minor}`,e([b({type:X,json:{write:!0}})],le.prototype,"applicationProperties",void 0),e([b({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],le.prototype,"clippingArea",void 0),e([_("clippingArea")],le.prototype,"writeClippingArea",null),e([b({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],le.prototype,"clippingEnabled",void 0),e([v("clippingEnabled",["clippingArea"])],le.prototype,"readClippingEnabled",null),e([_("clippingEnabled")],le.prototype,"writeClippingEnabled",null),e([b({type:G,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],le.prototype,"floorInfo",void 0),e([b({type:L,json:{write:!0}})],le.prototype,"heightModelInfo",void 0),e([b({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],le.prototype,"layers",void 0),e([_("layers")],le.prototype,"writeLayers",null),e([b({readOnly:!0,type:re,json:{type:ae(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],le.prototype,"sourceVersion",void 0),e([v("sourceVersion",["version"])],le.prototype,"readSourceVersion",null),e([_("sourceVersion")],le.prototype,"writeSourceVersion",null),e([b({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],le.prototype,"tables",void 0),e([_("tables")],le.prototype,"writeTables",null),e([b()],le.prototype,"thumbnailUrl",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],le.prototype,"authoringApp",null),e([_("authoringApp")],le.prototype,"writeAuthoringApp",null),e([b({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],le.prototype,"authoringAppVersion",null),e([_("authoringAppVersion")],le.prototype,"writeAuthoringAppVersion",null),e([b({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],le.prototype,"ground",void 0),e([_("ground")],le.prototype,"writeGround",null),e([b({type:s.ofType(te),json:{write:!0}})],le.prototype,"transportationNetworks",void 0),e([b({type:ee,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],le.prototype,"presentation",void 0),e([b({type:Z,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new Z({viewingMode:"global",spatialReference:P.WebMercator})}})],le.prototype,"initialViewProperties",void 0),e([v("initialViewProperties",["initialState.timeExtent","initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],le.prototype,"readInitialViewProperties",null),e([b({type:P,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],le.prototype,"spatialReference",null),e([b({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],le.prototype,"viewingMode",null),e([b({type:E})],le.prototype,"portalItem",void 0),e([b()],le.prototype,"resourceInfo",void 0),e([b({type:k,json:{write:!0}})],le.prototype,"widgets",void 0),le=e([S("esri.WebScene")],le);const pe=le;export{pe as default};
|
|
5
|
+
import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import{clone as a}from"./core/lang.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{destroyMaybe as c}from"./core/maybe.js";import{MultiOriginJSONMixin as d,MultiOriginJSONSupport as h}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as u}from"./core/promiseUtils.js";import{on as y}from"./core/reactiveUtils.js";import{urlToObject as w,addQueryParameter as f}from"./core/urlUtils.js";import{property as g}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as v}from"./core/accessorSupport/decorators/subclass.js";import{writer as S}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as _}from"./core/accessorSupport/originUtils.js";import{readLoadable as A}from"./core/accessorSupport/read.js";import I from"./geometry/Extent.js";import j from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as L}from"./geometry/projection.js";import R from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as V}from"./geometry/support/jsonUtils.js";import{isEarth as U}from"./geometry/support/spatialReferenceUtils.js";import M from"./portal/Portal.js";import O from"./portal/PortalItem.js";import{createForItemWrite as E}from"./portal/support/jsonContext.js";import{toggleTypeKeyword as C,typeKeyword as N}from"./portal/support/portalItemUtils.js";import{hasDeveloperBasemapLayer as T}from"./support/basemapUtils.js";import x from"./support/MapFloorInfo.js";import{WebSceneTag as G}from"./support/tagSymbols.js";import{createSchemaValidationError as F,createCopyError as J}from"./support/webSceneUtils.js";import W from"./time/TimeExtent.js";import{ViewingMode as $}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as B}from"./views/support/spatialReferenceSupport.js";import{SaveOperationType as q}from"./webdoc/interfaces.js";import k from"./webdoc/Widgets.js";import{updateItemWithResources as D,saveResources as K}from"./webdoc/support/resourceUtils.js";import{validateSaveAPIKey as H}from"./webdoc/support/saveAPIKeyUtils.js";import{evaluateWriteErrors as z}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as Q}from"./webdoc/support/thumbnailUtils.js";import X from"./webscene/ApplicationProperties.js";import Y from"./webscene/Environment.js";import Z from"./webscene/InitialViewProperties.js";import ee from"./webscene/Presentation.js";import te from"./webscene/TransportationNetwork.js";import{Version as re}from"./webscene/Version.js";import{getLoader as ie}from"./webscene/support/schemaValidatorLoader.js";var oe;const se=new re(1,34),ae=()=>{const e=8,t=[],r=se.major;for(let i=e;i<=se.minor;i++)t.push(`${r}.${i}`);return t},ne="Web Scene";let le=class extends(n.LoadableMixin(m(d(r)))){constructor(e){super(e),this[oe]=!0,this._layersIdGCTimeoutId=void 0,this._updateFromPromise=null,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=void 0,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new ee,this.initialViewProperties=new Z,this.portalItem=null,this.resourceInfo=null,this.widgets=null,this._debouncedSaveOperations=u((async(e,t,r)=>{switch(e){case q.SAVE:return this._saveImpl(t);case q.SAVE_AS:return this._saveAsImpl(r,t)}})),this._resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{p.getLogger(this).error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this.addHandles(y((()=>this.allLayers),"change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this.presentation&&this.presentation.destroy(),this.portalItem=c(this.portalItem)}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){t[r]=this._layersToJSON(e,"operational-layers",i)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new re(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${se.major}.${se.minor}`}writeTables(e,t,r,i){const o=this._layersToJSON(e,"tables",i);o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem?.thumbnailUrl??null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};t.initialState?.environment&&(r.environment=Y.fromJSON(t.initialState.environment)),r.spatialReference=t.spatialReference?R.fromJSON(t.spatialReference):R.WebMercator,r.viewingMode=t.viewingMode??"global",t.initialState?.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint));const o=t.initialState?.timeExtent;return null!=o&&(r.timeExtent=W.fromArray(o)),new Z(r)}get spatialReference(){return this.initialViewProperties?.spatialReference??R.WebMercator}get viewingMode(){return this.initialViewProperties?.viewingMode??"global"}load(e){const t=this.ground;return this.addResolvingPromise(this._loadFromSource().then((()=>{t&&t!==this.ground&&t.destroy()}))),Promise.resolve(this)}loadAll(){return l(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)),this.tables)}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(A(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion?.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground?.layers;!e.baseMap&&t?.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=a(t))}_layersToJSON(e,t,r){const i={...r,layerContainerType:t};return e.map((e=>this._verifyWritableLayer(e,r)?e.write({},i):null)).filter((e=>!!e)).toArray()}_verifyWritableLayer(e,t){return!!e.persistenceEnabled&&("write"in e||(t?.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1))}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw p.getLogger(this).error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const r=!t?.messages;t={messages:[],...t,origin:"web-scene"};const i=super.write(e,t);if(r){const e=t.messages?.filter((e=>"web-document-write:property-required"===e.name))??[];if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw p.getLogger(this).error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(i),i}async save(e){return this._debouncedSaveOperations(q.SAVE,e)}async _saveImpl(e){if(!this.portalItem)throw new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene");if(H(this.portalItem),this.portalItem?.type!==ne)throw new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${ne}"`);const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls(E(this.portalItem,"web-scene",!0)),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await D(this.portalItem,i,this._resourceReferences,r),_(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(q.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=O.from(e);if(!r)throw new s("webscene:portal-item-required","saveAs requires a portal item to save to");H(r),r.id&&(r=r.clone(),r.id=null);const i=r.portal||M.getDefault();await this._ensureLoadBeforeSave(),r.type=ne,r.portal=i;const o=this._enableVerifyItemRelativeUrls(E(r,"web-scene",!0)),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");if(this._updateTypeKeywords(r),await i.signIn(),!i.user)throw new s("webscene:user-not-signed-in","saveAs requires a user to be signed in to the portal");return await i.user.addItem({item:r,folder:t?.folder,data:a}),await K(this._resourceReferences,o),this.portalItem=r,h.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl?w(r.itemUrl):void 0}),_(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await(this.portalItem?.updateThumbnail({thumbnail:this.thumbnailUrl})),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}async _verifySave(e,t,r,i=!1){if(!U(this.spatialReference))throw new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently.");const{ignoreUnsupported:o,requiredPropertyChecksDisabled:a,strictSchemaValidationEnabled:n}=r||{};z(t,{errorName:"webscene:save"},{ignoreUnsupported:o,supplementalUnsupportedErrors:["scenemodification:unsupported"],requiredPropertyChecksDisabled:a});const l=ie();if(n&&l){const t=(await l()).validate(e);if(!t.length)return;const r=`webscene did not validate:\n${t.join("\n")}`;p.getLogger(this).error(`${i?"saveAs":"save"}(): ${r}`);const o=t.map((e=>new s("webscene:schema-validation",e)));throw F(o)}}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(J()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),(e.verifyItemRelativeUrls?.writtenUrls?.length??0)>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment&&(this.initialViewProperties.environment=Y.prototype.clone.apply(e.environment)),!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,this.initialViewProperties.timeExtent=e.timeExtent?.clone()??null,null!=e.clippingArea?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}if(!t.widgetsExcluded)for(const r of e.persistableViewModels)r.updateWebDocument(this);(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize??void 0)}async _updateFromThumbnail(e,t){const r=Q(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem?.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion?.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion?.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}async _loadFromJSON(e,t){const r=new o;await this._validateSpatialReference(),await this._validateHeightModelInfo();const{populateOperationalLayers:i}=await import("./layers/support/layersCreator.js"),{operationalLayers:s,operationalElevationLayers:a,basemapElevationLayers:n}=this._extractOperationalLayers(e),l=[],p={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(p.context.portal=this.portalItem.portal||M.getDefault()),n.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(this.ground.layers,n,e))}if(a.length>0){const e={...p,context:{...p.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",l.push(i(r,a,e))}s&&s.length>0&&l.push(i(this.layers,s,p)),e.tables?.length&&l.push(i(this.tables,e.tables,{...p,context:{...p.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"})),await Promise.allSettled(l),await this._loadObjectsWithLayers(),this.ground.layers.addMany(r.filter((e=>"base-elevation"===e.type||"elevation"===e.type)))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[],t=[...this.allLayers.items];for(const{basemap:r}of this.presentation.slides.items)r&&(t.push(...r.baseLayers.items),t.push(...r.referenceLayers.items));for(const r of t)if("beforeSave"in r&&"function"==typeof r.beforeSave){const t=r.beforeSave();t&&e.push(t)}await Promise.allSettled(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await Promise.allSettled(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:w(e.itemUrl),portal:e.portal||M.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this._resourceReferences={portalItem:e,paths:r.readResourcePaths??[]}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!B(t,$.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||L(e,t)}else{if(!B(t,$.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e?.camera?.position.spatialReference??e?.targetGeometry?.spatialReference,o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=re.parse(e.version||"","webscene");return se.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=R.WebMercator.toJSON()),e}_updateTypeKeywords(e){C(e,N.LOCAL_SCENE,"local"===this.initialViewProperties.viewingMode),C(e,N.DEVELOPER_BASEMAP,T(this.basemap)||this.presentation.slides.some((({basemap:e})=>!!e&&T(e)))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||R.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem?.itemUrl?w(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties?.viewing?.search,t=e=>this.allLayers.some((t=>t.id===e&&t.persistenceEnabled));e?.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};oe=G,le.version=`${se.major}.${se.minor}`,e([g({type:X,json:{write:!0}})],le.prototype,"applicationProperties",void 0),e([g({type:I,json:{read:{source:"clippingArea.geometry",reader:V},write:{target:"clippingArea.geometry"}}})],le.prototype,"clippingArea",void 0),e([S("clippingArea")],le.prototype,"writeClippingArea",null),e([g({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],le.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],le.prototype,"readClippingEnabled",null),e([S("clippingEnabled")],le.prototype,"writeClippingEnabled",null),e([g({type:x,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],le.prototype,"floorInfo",void 0),e([g({type:j,json:{write:!0}})],le.prototype,"heightModelInfo",void 0),e([g({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],le.prototype,"layers",void 0),e([S("layers")],le.prototype,"writeLayers",null),e([g({readOnly:!0,type:re,json:{type:ae(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],le.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],le.prototype,"readSourceVersion",null),e([S("sourceVersion")],le.prototype,"writeSourceVersion",null),e([g({json:{read:!1,write:{enabled:!0,ignoreOrigin:!0}}})],le.prototype,"tables",void 0),e([S("tables")],le.prototype,"writeTables",null),e([g()],le.prototype,"thumbnailUrl",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],le.prototype,"authoringApp",null),e([S("authoringApp")],le.prototype,"writeAuthoringApp",null),e([g({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],le.prototype,"authoringAppVersion",null),e([S("authoringAppVersion")],le.prototype,"writeAuthoringAppVersion",null),e([g({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],le.prototype,"ground",void 0),e([S("ground")],le.prototype,"writeGround",null),e([g({type:o.ofType(te),json:{write:!0}})],le.prototype,"transportationNetworks",void 0),e([g({type:ee,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],le.prototype,"presentation",void 0),e([g({type:Z,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new Z({viewingMode:"global",spatialReference:R.WebMercator})}})],le.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.timeExtent","initialState.environment","initialState.viewpoint","spatialReference","viewingMode"])],le.prototype,"readInitialViewProperties",null),e([g({type:R,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],le.prototype,"spatialReference",null),e([g({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],le.prototype,"viewingMode",null),e([g({type:O})],le.prototype,"portalItem",void 0),e([g()],le.prototype,"resourceInfo",void 0),e([g({type:k,json:{write:!0}})],le.prototype,"widgets",void 0),le=e([v("esri.WebScene")],le);const pe=le;export{pe as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{getDefaultUnitForView as t}from"../../support/getDefaultUnitForView.js";function e(e){return t(e)}export{e as getDefaultUnitForView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../ArcadePortal.js";import e from"../Attachment.js";import r from"../Dictionary.js";import{ArcadeExecutionError as n,ExecutionErrorCodes as a}from"../executionError.js";import{H as o,j as i,P as u,g as s,B as l,K as d,h as p,t as c,o as f,q as h,T as y,r as m,U as g,N as A,V as w,W as I,X as v,Y as U,c as b,Z as j,k as x,m as N,n as P,a as F,b as T,i as C,u as O,s as k}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as L}from"../featureset/support/shared.js";import{convertDirection as S}from"./convertdirection.js";import{XXH as z}from"./hash.js";import{hasSamePortal as D}from"../../core/urlUtils.js";import{generateUUID as R}from"../../core/uuid.js";import H from"../../geometry/Extent.js";import M from"../../geometry/Multipoint.js";import V from"../../geometry/Point.js";import W from"../../geometry/Polygon.js";import J from"../../geometry/Polyline.js";import B from"../../geometry/SpatialReference.js";import Z from"../../portal/Portal.js";function E(t){if("loaded"===t.loadStatus&&t.user?.sourceJSON){return t.user.sourceJSON}return null}function q(t,e){return!!t&&D(t,e?.restUrl||"")}function K(t,e){if(!t||!e)return t===e;if(t.x===e.x&&t.y===e.y){if(t.hasZ){if(t.z!==e.z)return!1}else if(e.hasZ)return!1;if(t.hasM){if(t.m!==e.m)return!1}else if(e.hasM)return!1;return!0}return!1}function X(o,i,u){if(null!==o)if(f(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o)X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else if(h(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.toArray())X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else{if(x(o))return i.updateIntArray([o.toNumber()]),void i.updateUint8Array([241]);if(N(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([257]);if(P(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([263]);if(b(o))return i.updateIntArray([o.length]),i.updateWithString(o),void i.updateUint8Array([41]);if(F(o))i.updateUint8Array([!0===o?1:0,113]);else{if(T(o))return i.updateFloatArray([o]),void i.updateUint8Array([173]);if(o instanceof e)throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof t)throw new n(u.context,a.UnsupportedHashType,u.node);if(!(o instanceof r)){if(m(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof V)return i.updateIntArray([3833836621]),i.updateIntArray([0]),i.updateFloatArray([o.x]),i.updateIntArray([1]),i.updateFloatArray([o.y]),o.hasZ&&(i.updateIntArray([2]),i.updateFloatArray([o.z])),o.hasM&&(i.updateIntArray([3]),i.updateFloatArray([o.m])),i.updateIntArray([3765347959]),void X(o.spatialReference.wkid,i,u);if(o instanceof W){i.updateIntArray([1266616829]);for(let t=0;t<o.rings.length;t++){const e=o.rings[t],r=[];let n=null,a=null;for(let i=0;i<e.length;i++){const u=o.getPoint(t,i);if(0===i)n=u;else if(K(a,u))continue;a=u,i===e.length-1&&K(n,u)||r.push(u)}i.updateIntArray([1397116793,r.length]);for(let t=0;t<r.length;t++){const e=r[t];i.updateIntArray([3962308117,t]),X(e,i,u),i.updateIntArray([2716288009])}i.updateIntArray([2278822459])}return i.updateIntArray([3878477243]),void X(o.spatialReference.wkid,i,u)}if(o instanceof J){i.updateIntArray([4106883559]);for(let t=0;t<o.paths.length;t++){const e=o.paths[t];i.updateIntArray([1397116793,e.length]);for(let r=0;r<e.length;r++)i.updateIntArray([3962308117,r]),X(o.getPoint(t,r),i,u),i.updateIntArray([2716288009]);i.updateIntArray([2278822459])}return i.updateIntArray([2568784753]),void X(o.spatialReference.wkid,i,u)}if(o instanceof M){i.updateIntArray([588535921,o.points.length]);for(let t=0;t<o.points.length;t++){const e=o.getPoint(t);i.updateIntArray([t]),X(e,i,u)}return i.updateIntArray([1700171621]),void X(o.spatialReference.wkid,i,u)}if(o instanceof H)return i.updateIntArray([3483648373]),i.updateIntArray([0]),i.updateFloatArray([o.xmax]),i.updateIntArray([1]),i.updateFloatArray([o.xmin]),i.updateIntArray([2]),i.updateFloatArray([o.ymax]),i.updateIntArray([3]),i.updateFloatArray([o.ymin]),o.hasZ&&(i.updateIntArray([4]),i.updateFloatArray([o.zmax]),i.updateIntArray([5]),i.updateFloatArray([o.zmin])),o.hasM&&(i.updateIntArray([6]),i.updateFloatArray([o.mmax]),i.updateIntArray([7]),i.updateFloatArray([o.mmin])),i.updateIntArray([3622027469]),void X(o.spatialReference.wkid,i,u);if(o instanceof B)return i.updateIntArray([14]),void 0!==o.wkid&&null!==o.wkid&&i.updateIntArray([o.wkid]),o.wkt&&i.updateWithString(o.wkt),void(o.wkt2&&i.updateWithString(o.wkt2));if(C(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(O(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(k(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o===l)throw new n(u.context,a.UnsupportedHashType,u.node);throw new n(u.context,a.UnsupportedHashType,u.node)}if(i.updateUint8Array([223]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.keys()){i.updateIntArray([t.length]),i.updateWithString(t),i.updateUint8Array([251]);X(o.field(t),i,u),i.updateUint8Array([239])}u.map.delete(o),u.currentLength--}i.updateUint8Array([73])}}else i.updateUint8Array([0,139])}function Y(e,x){e.portal=function(e,r){return x(e,r,((n,a,u)=>(o(u,1,1,e,r),new t(i(u[0])))))},e.typeof=function(t,e){return x(t,e,((r,i,s)=>{o(s,1,1,t,e);const l=u(s[0]);if("Unrecognized Type"===l)throw new n(t,a.UnrecognizedType,e);return l}))},e.trim=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).trim())))},e.tohex=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=s(a[0]);return isNaN(i)?i:i.toString(16)}))},e.upper=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toUpperCase())))},e.proper=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,2,t,e);let u=1;2===a.length&&"firstword"===i(a[1]).toLowerCase()&&(u=2);const s=/\s/,l=i(a[0]);let d="",p=!0;for(let t=0;t<l.length;t++){let e=l[t];if(s.test(e))1===u&&(p=!0);else{e.toUpperCase()!==e.toLowerCase()&&(p?(e=e.toUpperCase(),p=!1):e=e.toLowerCase())}d+=e}return d}))},e.lower=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toLowerCase())))},e.guid=function(t,e){return x(t,e,((r,n,a)=>{if(o(a,0,1,t,e),a.length>0)switch(i(a[0]).toLowerCase()){case"digits":return R().replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return R();case"digits-hyphen-braces":return"{"+R()+"}";case"digits-hyphen-parentheses":return"("+R()+")"}return"{"+R()+"}"}))},e.standardizeguid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=i(a[0]);if(""===u||null===u)return"";const s=/^(\{|\()?(?<partA>[0-9a-z]{8})(-?)(?<partB>[0-9a-z]{4})(-?)(?<partC>[0-9a-z]{4})(-?)(?<partD>[0-9a-z]{4})(-?)(?<partE>[0-9a-z]{12})(\}|\))?$/gim.exec(u);if(!s)return"";const l=s.groups;switch(u=l.partA+"-"+l.partB+"-"+l.partC+"-"+l.partD+"-"+l.partE,i(a[1]).toLowerCase()){case"digits":return u.replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return u;case"digits-hyphen-braces":return"{"+u+"}";case"digits-hyphen-parentheses":return"("+u+")"}return"{"+u+"}"}))},e.console=function(t,e){return x(t,e,((e,r,n)=>(0===n.length||(1===n.length?t.console(i(n[0])):t.console(i(n))),l)))},e.mid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=s(a[1]);if(isNaN(u))return"";if(u<0&&(u=0),2===a.length)return i(a[0]).substring(u);let l=s(a[2]);return isNaN(l)?"":(l<0&&(l=0),i(a[0]).substring(u,u+l))}))},e.find=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=0;if(a.length>2){if(u=s(d(a[2],0)),isNaN(u))return-1;u<0&&(u=0)}return i(a[1]).indexOf(i(a[0]),u)}))},e.left=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=s(a[1]);return isNaN(u)?"":(u<0&&(u=0),i(a[0]).substring(0,u))}))},e.right=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=s(a[1]);if(isNaN(u))return"";u<0&&(u=0);return i(a[0]).slice(-u)}))},e.split=function(t,e){return x(t,e,((r,n,a)=>{let u;o(a,2,4,t,e);let l=s(d(a[2],-1));const c=p(d(a[3],!1));if(-1===l||null===l||!0===c?u=i(a[0]).split(i(a[1])):(isNaN(l)&&(l=-1),l<-1&&(l=-1),u=i(a[0]).split(i(a[1]),l)),!1===c)return u;const f=[];for(let t=0;t<u.length&&!(-1!==l&&f.length>=l);t++)""!==u[t]&&void 0!==u[t]&&f.push(u[t]);return f}))},e.text=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,2,t,e),c(a[0],a[1]))))},e.concatenate=function(t,e){return x(t,e,((t,e,r)=>{const n=[];if(r.length<1)return"";if(f(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length;e++)n[e]=c(r[0][e],t);return r.length>1?n.join(r[1]):n.join("")}if(h(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length();e++)n[e]=c(r[0].get(e),t);return r.length>1?n.join(r[1]):n.join("")}for(let a=0;a<r.length;a++)n[a]=c(r[a]);return n.join("")}))},e.reverse=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),f(u[0])){const t=u[0].slice(0);return t.reverse(),t}if(h(u[0])){const t=u[0].toArray().slice(0);return t.reverse(),t}throw new n(t,a.InvalidParameter,e)}))},e.replace=function(t,e){return x(t,e,((r,n,a)=>{o(a,3,4,t,e);const u=i(a[0]),s=i(a[1]),l=i(a[2]);return 4!==a.length||p(a[3])?y(u,s,l):u.replace(s,l)}))},e.schema=function(t,e){return x(t,e,((o,i,u)=>{if(m(u[0])){const e=g(u[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypes=function(t,e){return x(t,e,((i,u,s)=>{if(o(s,1,1,t,e),m(s[0])){const e=w(s[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypecode=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return null;if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.code;return null}return null}throw new n(t,a.InvalidParameter,e)}))},e.subtypename=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return"";if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.name;return""}return""}throw new n(t,a.InvalidParameter,e)}))},e.gdbversion=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0]))return u[0].gdbVersion();throw new n(t,a.InvalidParameter,e)}))},e.domain=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,2,3,t,e),m(l[0])){const e=I(l[0],i(l[1]),void 0===l[2]?void 0:l[2]);return e&&e.domain?"coded-value"===e.domain.type||"codedValue"===e.domain.type?r.convertObjectToArcadeDictionary({type:"codedValue",name:e.domain.name,dataType:L[e.field.type],codedValues:e.domain.codedValues.map((t=>({name:t.name,code:t.code})))},A(t)):r.convertObjectToArcadeDictionary({type:"range",name:e.domain.name,dataType:L[e.field.type],min:e.domain.minValue,max:e.domain.maxValue},A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.domainname=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return v(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.domaincode=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return U(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.urlencode=function(t,e){return x(t,e,((n,a,u)=>{if(o(u,1,1,t,e),null===u[0])return"";if(u[0]instanceof r){let t="";for(const e of u[0].keys()){const r=u[0].field(e);""!==t&&(t+="&"),t+=null===r?encodeURIComponent(e)+"=":encodeURIComponent(e)+"="+encodeURIComponent(r)}return t}return encodeURIComponent(i(u[0]))}))},e.hash=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=new z(0);return X(a[0],i,{context:t,node:e,map:new Map,currentLength:0}),i.digest()}))},e.convertdirection=function(t,e){return x(t,e,((r,n,a)=>(o(a,3,3,t,e),S(a[0],a[1],a[2]))))},e.fromjson=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,1,1,t,e),!1===b(l[0]))throw new n(t,a.InvalidParameter,e);return r.convertJsonToArcade(JSON.parse(i(l[0])),A(t))}))},e.expects=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);return l}))},e.tocharcode=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.charCodeAt(p)}))},e.tocodepoint=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.codePointAt(p)}))},e.fromcharcode=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);const u=i.map((t=>Math.trunc(s(t)))).filter((t=>t>=0&&t<=65535));return 0===u.length?null:String.fromCharCode.apply(null,u)}))},e.fromcodepoint=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);let u;try{u=i.map((t=>Math.trunc(s(t)))).filter((t=>t<=1114111&&t>>>0===t))}catch(l){return null}return 0===u.length?null:String.fromCodePoint.apply(null,u)}))},e.getuser=function(e,u){return x(e,u,((s,l,p)=>{o(p,0,2,e,u);let c=d(p[1],"");if(c=!0===c||!1===c?"":i(c),null!==c&&""!==c)return null;if(0===p.length||p[0]instanceof t){let t=null;if(t=e.services?.portal?e.services.portal:Z.getDefault(),p.length>0){if(!q(p[0].field("url"),t))return null}if(!t)return null;if(""===c){const n=E(t);if(n){const t=JSON.parse(JSON.stringify(n));for(const e of["lastLogin","created","modified"])void 0!==t[e]&&null!==t[e]&&(t[e]=new Date(t[e]));return r.convertObjectToArcadeDictionary(t,A(e))}}return null}throw new n(e,a.InvalidParameter,u)}))},e.getenvironment=function(t,e){return x(t,e,((n,a,i)=>(o(i,0,0,t,e),r.convertObjectToArcadeDictionary(j(A(t),t.spatialReference),A(t),!0))))}}export{Y as registerFunctions};
|
|
5
|
+
import t from"../ArcadePortal.js";import e from"../Attachment.js";import r from"../Dictionary.js";import{ArcadeExecutionError as n,ExecutionErrorCodes as a}from"../executionError.js";import{H as o,j as i,P as u,g as s,B as l,K as d,h as p,t as c,o as f,q as h,T as y,r as m,U as g,N as A,V as w,W as I,X as v,Y as U,c as b,Z as j,k as x,m as N,n as P,a as F,b as T,i as C,u as O,s as k}from"../../chunks/languageUtils.js";import{layerFieldEsriConstants as L}from"../featureset/support/shared.js";import{convertDirection as S}from"./convertdirection.js";import{XXH as z}from"./hash.js";import{hasSamePortal as D}from"../../core/urlUtils.js";import{generateUUID as R}from"../../core/uuid.js";import H from"../../geometry/Extent.js";import M from"../../geometry/Multipoint.js";import V from"../../geometry/Point.js";import W from"../../geometry/Polygon.js";import J from"../../geometry/Polyline.js";import B from"../../geometry/SpatialReference.js";import Z from"../../portal/Portal.js";function E(t){if("loaded"===t.loadStatus&&t.user?.sourceJSON){return t.user.sourceJSON}return null}function q(t,e){return!!t&&D(t,e?.restUrl||"")}function K(t,e){if(!t||!e)return t===e;if(t.x===e.x&&t.y===e.y){if(t.hasZ){if(t.z!==e.z)return!1}else if(e.hasZ)return!1;if(t.hasM){if(t.m!==e.m)return!1}else if(e.hasM)return!1;return!0}return!1}function X(o,i,u){if(null!==o)if(f(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o)X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else if(h(o)){if(i.updateUint8Array([61]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.toArray())X(t,i,u);u.map.delete(o),u.currentLength--}i.updateUint8Array([199])}else{if(x(o))return i.updateIntArray([o.toNumber()]),void i.updateUint8Array([241]);if(N(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([257]);if(P(o))return i.updateIntArray([o.toNumber()]),void i.updateIntArray([263]);if(b(o))return i.updateIntArray([o.length]),i.updateWithString(o),void i.updateUint8Array([41]);if(F(o))i.updateUint8Array([!0===o?1:0,113]);else{if(T(o))return i.updateFloatArray([o]),void i.updateUint8Array([173]);if(o instanceof e)throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof t)throw new n(u.context,a.UnsupportedHashType,u.node);if(!(o instanceof r)){if(m(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o instanceof V)return i.updateIntArray([3833836621]),i.updateIntArray([0]),i.updateFloatArray([o.x]),i.updateIntArray([1]),i.updateFloatArray([o.y]),o.hasZ&&(i.updateIntArray([2]),i.updateFloatArray([o.z])),o.hasM&&(i.updateIntArray([3]),i.updateFloatArray([o.m])),i.updateIntArray([3765347959]),void X(o.spatialReference.wkid,i,u);if(o instanceof W){i.updateIntArray([1266616829]);for(let t=0;t<o.rings.length;t++){const e=o.rings[t],r=[];let n=null,a=null;for(let i=0;i<e.length;i++){const u=o.getPoint(t,i);if(0===i)n=u;else if(K(a,u))continue;a=u,i===e.length-1&&K(n,u)||r.push(u)}i.updateIntArray([1397116793,r.length]);for(let t=0;t<r.length;t++){const e=r[t];i.updateIntArray([3962308117,t]),X(e,i,u),i.updateIntArray([2716288009])}i.updateIntArray([2278822459])}return i.updateIntArray([3878477243]),void X(o.spatialReference.wkid,i,u)}if(o instanceof J){i.updateIntArray([4106883559]);for(let t=0;t<o.paths.length;t++){const e=o.paths[t];i.updateIntArray([1397116793,e.length]);for(let r=0;r<e.length;r++)i.updateIntArray([3962308117,r]),X(o.getPoint(t,r),i,u),i.updateIntArray([2716288009]);i.updateIntArray([2278822459])}return i.updateIntArray([2568784753]),void X(o.spatialReference.wkid,i,u)}if(o instanceof M){i.updateIntArray([588535921,o.points.length]);for(let t=0;t<o.points.length;t++){const e=o.getPoint(t);i.updateIntArray([t]),X(e,i,u)}return i.updateIntArray([1700171621]),void X(o.spatialReference.wkid,i,u)}if(o instanceof H)return i.updateIntArray([3483648373]),i.updateIntArray([0]),i.updateFloatArray([o.xmax]),i.updateIntArray([1]),i.updateFloatArray([o.xmin]),i.updateIntArray([2]),i.updateFloatArray([o.ymax]),i.updateIntArray([3]),i.updateFloatArray([o.ymin]),o.hasZ&&(i.updateIntArray([4]),i.updateFloatArray([o.zmax]),i.updateIntArray([5]),i.updateFloatArray([o.zmin])),o.hasM&&(i.updateIntArray([6]),i.updateFloatArray([o.mmax]),i.updateIntArray([7]),i.updateFloatArray([o.mmin])),i.updateIntArray([3622027469]),void X(o.spatialReference.wkid,i,u);if(o instanceof B)return i.updateIntArray([14]),void 0!==o.wkid&&null!==o.wkid&&i.updateIntArray([o.wkid]),o.wkt&&i.updateWithString(o.wkt),void(o.wkt2&&i.updateWithString(o.wkt2));if(C(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(O(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(k(o))throw new n(u.context,a.UnsupportedHashType,u.node);if(o===l)throw new n(u.context,a.UnsupportedHashType,u.node);throw new n(u.context,a.UnsupportedHashType,u.node)}if(i.updateUint8Array([223]),u.map.has(o)){const t=u.map.get(o);i.updateIntArray([61237541^t])}else{u.map.set(o,u.currentLength++);for(const t of o.keys()){i.updateIntArray([t.length]),i.updateWithString(t),i.updateUint8Array([251]);X(o.field(t),i,u),i.updateUint8Array([239])}u.map.delete(o),u.currentLength--}i.updateUint8Array([73])}}else i.updateUint8Array([0,139])}function Y(e,x){e.portal=function(e,r){return x(e,r,((n,a,u)=>(o(u,1,1,e,r),new t(i(u[0])))))},e.typeof=function(t,e){return x(t,e,((r,i,s)=>{o(s,1,1,t,e);const l=u(s[0]);if("Unrecognized Type"===l)throw new n(t,a.UnrecognizedType,e);return l}))},e.trim=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).trim())))},e.tohex=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=s(a[0]);return isNaN(i)?i:i.toString(16)}))},e.upper=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toUpperCase())))},e.proper=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,2,t,e);let u=1;2===a.length&&"firstword"===i(a[1]).toLowerCase()&&(u=2);const s=/\s/,l=i(a[0]);let d="",p=!0;for(let t=0;t<l.length;t++){let e=l[t];if(s.test(e))1===u&&(p=!0);else{e.toUpperCase()!==e.toLowerCase()&&(p?(e=e.toUpperCase(),p=!1):e=e.toLowerCase())}d+=e}return d}))},e.lower=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,1,t,e),i(a[0]).toLowerCase())))},e.guid=function(t,e){return x(t,e,((r,n,a)=>{if(o(a,0,1,t,e),a.length>0)switch(i(a[0]).toLowerCase()){case"digits":return R().replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return R();case"digits-hyphen-braces":return"{"+R()+"}";case"digits-hyphen-parentheses":return"("+R()+")"}return"{"+R()+"}"}))},e.standardizeguid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=i(a[0]);if(""===u||null===u)return"";const s=/^(\{|\()?(?<partA>[0-9a-z]{8})(-?)(?<partB>[0-9a-z]{4})(-?)(?<partC>[0-9a-z]{4})(-?)(?<partD>[0-9a-z]{4})(-?)(?<partE>[0-9a-z]{12})(\}|\))?$/gim.exec(u);if(!s)return"";const l=s.groups;switch(u=l.partA+"-"+l.partB+"-"+l.partC+"-"+l.partD+"-"+l.partE,i(a[1]).toLowerCase()){case"digits":return u.replace("-","").replace("-","").replace("-","").replace("-","");case"digits-hyphen":return u;case"digits-hyphen-braces":return"{"+u+"}";case"digits-hyphen-parentheses":return"("+u+")"}return"{"+u+"}"}))},e.console=function(t,e){return x(t,e,((e,r,n)=>(0===n.length||(1===n.length?t.console(i(n[0])):t.console(i(n))),l)))},e.mid=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=s(a[1]);if(isNaN(u))return"";if(u<0&&(u=0),2===a.length)return i(a[0]).substring(u);let l=s(a[2]);return isNaN(l)?"":(l<0&&(l=0),i(a[0]).substring(u,u+l))}))},e.find=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,3,t,e);let u=0;if(a.length>2){if(u=s(d(a[2],0)),isNaN(u))return-1;u<0&&(u=0)}return i(a[1]).indexOf(i(a[0]),u)}))},e.left=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);let u=s(a[1]);return isNaN(u)?"":(u<0&&(u=0),i(a[0]).substring(0,u))}))},e.right=function(t,e){return x(t,e,((r,n,a)=>{o(a,2,2,t,e);const u=s(a[1]);if(isNaN(u)||u<=0)return"";return i(a[0]).slice(-u)}))},e.split=function(t,e){return x(t,e,((r,n,a)=>{let u;o(a,2,4,t,e);let l=s(d(a[2],-1));const c=p(d(a[3],!1));if(-1===l||null===l||!0===c?u=i(a[0]).split(i(a[1])):(isNaN(l)&&(l=-1),l<-1&&(l=-1),u=i(a[0]).split(i(a[1]),l)),!1===c)return u;const f=[];for(let t=0;t<u.length&&!(-1!==l&&f.length>=l);t++)""!==u[t]&&void 0!==u[t]&&f.push(u[t]);return f}))},e.text=function(t,e){return x(t,e,((r,n,a)=>(o(a,1,2,t,e),c(a[0],a[1]))))},e.concatenate=function(t,e){return x(t,e,((t,e,r)=>{const n=[];if(r.length<1)return"";if(f(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length;e++)n[e]=c(r[0][e],t);return r.length>1?n.join(r[1]):n.join("")}if(h(r[0])){const t=d(r[2],"");for(let e=0;e<r[0].length();e++)n[e]=c(r[0].get(e),t);return r.length>1?n.join(r[1]):n.join("")}for(let a=0;a<r.length;a++)n[a]=c(r[a]);return n.join("")}))},e.reverse=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),f(u[0])){const t=u[0].slice(0);return t.reverse(),t}if(h(u[0])){const t=u[0].toArray().slice(0);return t.reverse(),t}throw new n(t,a.InvalidParameter,e)}))},e.replace=function(t,e){return x(t,e,((r,n,a)=>{o(a,3,4,t,e);const u=i(a[0]),s=i(a[1]),l=i(a[2]);return 4!==a.length||p(a[3])?y(u,s,l):u.replace(s,l)}))},e.schema=function(t,e){return x(t,e,((o,i,u)=>{if(m(u[0])){const e=g(u[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypes=function(t,e){return x(t,e,((i,u,s)=>{if(o(s,1,1,t,e),m(s[0])){const e=w(s[0]);return e?r.convertObjectToArcadeDictionary(e,A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.subtypecode=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return null;if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.code;return null}return null}throw new n(t,a.InvalidParameter,e)}))},e.subtypename=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0])){const t=w(u[0]);if(!t)return"";if(t.subtypeField&&u[0].hasField(t.subtypeField)){const e=u[0].field(t.subtypeField);for(const r of t.subtypes)if(r.code===e)return r.name;return""}return""}throw new n(t,a.InvalidParameter,e)}))},e.gdbversion=function(t,e){return x(t,e,((r,i,u)=>{if(o(u,1,1,t,e),m(u[0]))return u[0].gdbVersion();throw new n(t,a.InvalidParameter,e)}))},e.domain=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,2,3,t,e),m(l[0])){const e=I(l[0],i(l[1]),void 0===l[2]?void 0:l[2]);return e&&e.domain?"coded-value"===e.domain.type||"codedValue"===e.domain.type?r.convertObjectToArcadeDictionary({type:"codedValue",name:e.domain.name,dataType:L[e.field.type],codedValues:e.domain.codedValues.map((t=>({name:t.name,code:t.code})))},A(t)):r.convertObjectToArcadeDictionary({type:"range",name:e.domain.name,dataType:L[e.field.type],min:e.domain.minValue,max:e.domain.maxValue},A(t)):null}throw new n(t,a.InvalidParameter,e)}))},e.domainname=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return v(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.domaincode=function(t,e){return x(t,e,((r,u,s)=>{if(o(s,2,4,t,e),m(s[0]))return U(s[0],i(s[1]),s[2],void 0===s[3]?void 0:s[3]);throw new n(t,a.InvalidParameter,e)}))},e.urlencode=function(t,e){return x(t,e,((n,a,u)=>{if(o(u,1,1,t,e),null===u[0])return"";if(u[0]instanceof r){let t="";for(const e of u[0].keys()){const r=u[0].field(e);""!==t&&(t+="&"),t+=null===r?encodeURIComponent(e)+"=":encodeURIComponent(e)+"="+encodeURIComponent(r)}return t}return encodeURIComponent(i(u[0]))}))},e.hash=function(t,e){return x(t,e,((r,n,a)=>{o(a,1,1,t,e);const i=new z(0);return X(a[0],i,{context:t,node:e,map:new Map,currentLength:0}),i.digest()}))},e.convertdirection=function(t,e){return x(t,e,((r,n,a)=>(o(a,3,3,t,e),S(a[0],a[1],a[2]))))},e.fromjson=function(t,e){return x(t,e,((u,s,l)=>{if(o(l,1,1,t,e),!1===b(l[0]))throw new n(t,a.InvalidParameter,e);return r.convertJsonToArcade(JSON.parse(i(l[0])),A(t))}))},e.expects=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);return l}))},e.tocharcode=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.charCodeAt(p)}))},e.tocodepoint=function(t,e){return x(t,e,((r,u,l)=>{o(l,1,2,t,e);const p=s(d(l[1],0)),c=i(l[0]);if(0===c.length&&1===l.length)return null;if(c.length<=p||p<0)throw new n(t,a.OutOfBounds,e);return c.codePointAt(p)}))},e.fromcharcode=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);const u=i.map((t=>Math.trunc(s(t)))).filter((t=>t>=0&&t<=65535));return 0===u.length?null:String.fromCharCode.apply(null,u)}))},e.fromcodepoint=function(t,e){return x(t,e,((r,o,i)=>{if(i.length<1)throw new n(t,a.WrongNumberOfParameters,e);let u;try{u=i.map((t=>Math.trunc(s(t)))).filter((t=>t<=1114111&&t>>>0===t))}catch(l){return null}return 0===u.length?null:String.fromCodePoint.apply(null,u)}))},e.getuser=function(e,u){return x(e,u,((s,l,p)=>{o(p,0,2,e,u);let c=d(p[1],"");if(c=!0===c||!1===c?"":i(c),null!==c&&""!==c)return null;if(0===p.length||p[0]instanceof t){let t=null;if(t=e.services?.portal?e.services.portal:Z.getDefault(),p.length>0){if(!q(p[0].field("url"),t))return null}if(!t)return null;if(""===c){const n=E(t);if(n){const t=JSON.parse(JSON.stringify(n));for(const e of["lastLogin","created","modified"])void 0!==t[e]&&null!==t[e]&&(t[e]=new Date(t[e]));return r.convertObjectToArcadeDictionary(t,A(e))}}return null}throw new n(e,a.InvalidParameter,u)}))},e.getenvironment=function(t,e){return x(t,e,((n,a,i)=>(o(i,0,0,t,e),r.convertObjectToArcadeDictionary(j(A(t),t.spatialReference),A(t),!0))))}}export{Y as registerFunctions};
|