@vertigis/arcgis-extensions 54.14.5 → 54.14.6

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.
@@ -11,7 +11,7 @@
11
11
  <li><a href="../modules/version.html">version</a></li>
12
12
  <li><a href="" aria-current="page">version</a></li></ul>
13
13
  <h1>Variable version<code class="tsd-tag">Const</code></h1></div>
14
- <div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;54.14.5&quot;</span></div>
14
+ <div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;54.14.6&quot;</span></div>
15
15
  <div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
16
16
  </div></div>
17
17
  <div class="col-sidebar">
@@ -1 +1 @@
1
- var e;import{__decorate as t}from"tslib";import s,{}from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as a}from"../Entity.js";import{InvalidOperationError as n}from"../InvalidOperationError.js";import{isBasemapExtension as o,isBookmark as r,isGroundExtension as p,isLayerPreset as h,isMenu as m,isTableExtension as d,ItemType as l}from"../ItemType.js";import{TableExtension as _}from"../data/TableExtension.js";import{layerToParentJsonCache as b}from"../json/LayerJson.js";import{applyJsonToWebMap as c}from"../json/WebMapJson.js";import{applyJsonToWebScene as f}from"../json/WebSceneJson.js";import{LayerPreset as E}from"../layer-preset/LayerPreset.js";import{Menu as x}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as u}from"../support/ArcGISRequestHelper.js";import{FormatSettings as y}from"../support/FormatSettings.js";import{InitializableCollectionProxy as w}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as M}from"../support/ReadOnlyInitializableCollection.js";import{serializable as g}from"../support/Serializable.js";import{WellKnownBasemap as v}from"../support/esri.js";import{createIHandle as I,notifyChange as A,onWatch as S,watch as O,watchEvent as z}from"../support/observableUtils.js";import{ReadOnlyCollection as T}from"../utilities/ReadOnlyCollection.js";import P from"../utilities/_ReferenceCountedHandle.js";import{groundsAreEquivalent as L}from"../utilities/_layers.js";import{basemapsAreEquivalent as V,createStandardBasemap as B,getStandardBasemapId as k,isStandardBasemap as C,isStandardBasemap2D as H}from"../utilities/basemaps.js";import{checkArg as j}from"../utilities/checkArg.js";import{compare as R}from"../utilities/collection.js";import{load as N}from"../utilities/esri.js";import{isGroupLayerExtension as W}from"../utilities/extensions.js";import{filter as J}from"../utilities/iterable.js";import{isWMTSLayer as F,layersAreEquivalent as G}from"../utilities/layers.js";import{getLogger as q}from"../utilities/log.js";import{getMapSpatialReference as K,isMap as D,isWebMap as U,isWebScene as $}from"../utilities/mapping.js";import{toPortalItem as X}from"../utilities/portal.js";import{parallelEach as Y}from"../utilities/promise.js";import{onCollectionPropertyChange as Q,onEach as Z}from"../utilities/watch.js";import{BasemapExtension as ee}from"./BasemapExtension.js";import{Bookmark as te}from"./Bookmark.js";import{GroundExtension as se}from"./GroundExtension.js";import{MapConstraints as ie}from"./MapConstraints.js";import{_assignLayerExtensions as ae}from"./_LayerExtension.js";import{LayerExtensionCollectionImpl as ne}from"./_LayerExtensionCollectionImpl.js";const oe=q("MapExtension");let re=class extends a{static{e=this}static _mapEventHandlesKey="map-extension-map-event-handles";static _sceneEventHandlesKey="map-extension-scene-event-handles";get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?$(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":$(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new u),this._requestHelper}set requestHelper(e){this._requestHelper=e}get basemapExtension(){return this._basemapExtension}set basemapExtension(e){const t=this._basemapExtension;if(t!==e)if(t&&t._setMapExtension(void 0),e){if(e._setMapExtension(this),this.isInitialized&&!e.basemap){if(e.isInitialized)throw e._setMapExtension(void 0),new n("Cannot set MapExtension.basemapExtension without a valid Esri Basemap object");e.initialize()}this._ensureIsBasemapOption(e),this.map&&e.basemap&&e.basemap!==this.map.basemap?this.map.basemap=e.basemap:this._basemapExtension=e}else this.map.basemap=void 0,this._basemapExtension=void 0}get groundExtension(){return this._groundExtension||(this.groundExtension=se.create({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new n("Cannot set map.ground to undefined");const t=this._groundExtension;t!==e&&(t&&t._setMapExtension(void 0),e._setMapExtension(this),e._resolveGround(),e.ground?(this._groundExtensions.set(e.ground,e),this.map&&e.ground!==this.map.ground?this.map.ground=e.ground:this._groundExtension=e):this._groundExtension=e)}get basemapOptions(){return this._basemapOptions}get bookmarks(){return this._bookmarks}get initialBasemapExtension(){return this._initialBasemapExtension}get initialLayerPreset(){return this._initialLayerPreset}set initialLayerPreset(e){if(!e)return void(this._initialLayerPreset=void 0);const t=h(e)?e:new E(e);this._initialLayerPreset=t}get _spatialReference(){return K(this.map)}get webMapItemTitle(){if(this._webMapItem)return this._webMapItem.title}get webSceneItemTitle(){if(this._webSceneItem)return this._webSceneItem.title}get title(){return this._title?this._title:this._webMapItem&&"map"===this.viewMode?this.webMapItemTitle:this._webSceneItem&&"scene"===this.viewMode?this.webSceneItemTitle:void 0}set title(e){this._title=e}formatSettings;constraints;onClick;onHover;onHoverEnd;onInitialized;onViewpointChanged;get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,e&&this.isInitialized&&!e.isInitialized&&(async()=>{try{await e.initialize()}catch(e){e instanceof Error&&oe.error({message:"An error occurred while initializing context menu.",error:e})}})()}_layerViews=new s;get _allLayerViews(){const e=t=>{const i=[t];return s.isCollection(t.sublayerViews)?i.push(...t.sublayerViews.toArray().flatMap(e)):s.isCollection(t.layerViews)&&i.push(...t.layerViews.toArray().flatMap(e)),i};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}get isSwitchingMap(){return this._isSwitchingMap}tableExtensions;allLayerExtensions;_itemType=l.MAP_EXTENSION;_isSwitchingMap=!1;_map;_scene;_deserializedMapPromise;_deserializedViewMode;_deserializedViewModePromise;_deferredProperties;_currentMap;_requestHelper;_basemapExtension;_groundExtension;_basemapOptions;_groundExtensions;_bookmarks;_layerExtensions;_webMap;_webMapItem;_webScene;_webSceneItem;_title;_initialViewMode;_initialLayerPreset;_initialBasemapExtension;_skipBasemapOptions=!1;_createScenePromise;_createMapPromise;_contextMenu;constructor(t){super(t);let a={...t};this._basemapOptions=new pe(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new s,this.constraints=new ie,this._handles.add([O(this,"_map",t=>{t?this._handles.add([Z(t.layers,"layerview-create",e=>{this._layerViews.add(e.layerView)}),Z(t.layers,"layerview-destroy",e=>{this._layerViews.remove(e.layerView)})],e._mapEventHandlesKey):this._handles.remove(e._mapEventHandlesKey)},{sync:!0}),O(this,"_scene",t=>{t?this._handles.add([Z(t.layers,"layerview-create",e=>{this._layerViews.add(e.layerView)}),Z(t.layers,"layerview-destroy",e=>{this._layerViews.remove(e.layerView)})],e._sceneEventHandlesKey):this._handles.remove(e._sceneEventHandlesKey)},{sync:!0})]);const{webMap:n,webScene:o,initialViewMode:r,map:p,basemapOptions:h}=a;if(this._webMap=n,this._webScene=o,this._webMapItem=de(n),this._webSceneItem=de(o),this.initialViewMode=r,$(p)&&o)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(D(p)&&n)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if($(p)||U(p)||D(p))this.assignProperties({basemapOptions:h}),this._skipBasemapOptions=!!h;else{const{layerExtensions:e,tableExtensions:t,groundExtension:s,basemapOptions:i,basemapExtension:n,...o}=a;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:s,basemapOptions:i,basemapExtension:n},a=o,i&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(a),this._handles.add([O(this,"map.basemap",()=>this._onBasemapChange(),{sync:!0}),O(this,"map.ground",()=>this._onGroundChange(),{sync:!0})]),this.allLayerExtensions=new me(this),this.map?.basemap&&this._onBasemapChange()}getLayerExtensionsForView(e=this.viewMode){return(("map"===e?this._map:this._scene)?.layers.toArray()??[]).map(e=>this._layerExtensions._forLayer(e)).filter(e=>!e.dynamicallyAddedLayer)}getAllFeatureSources(e=()=>!0){const t=[],s=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())i(t);if(W(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())s(t)},i=s=>{t.push(s);for(const t of s.sublayerExtensions.initializedItems.filter(e).toArray())i(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())s(t);for(const s of this.tableExtensions.initializedItems.filter(e).toArray())t.push(s);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())s(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())s(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(j("viewMode",e).isNotMissing().satisfies(e=>this.isSupportedViewMode(e),"Unsupported view mode."),this.viewMode===e)return;let t;"scene"===e?(await this._createScene(),t=this._scene):(await this._createMap(),t=this._map),await this.switchMap(t),A(this,"viewMode"),A(this,"title")}async switchMap(t){if(j("newMap",t).isNotMissing(),t===this.map)return;if(!this.map)return void this._setMap(t);this._layerViews.removeAll(),"map"===this.viewMode?this._handles.remove(e._mapEventHandlesKey):this._handles.remove(e._sceneEventHandlesKey),this._isSwitchingMap=!0,this.isInitialized&&await be(t),this._preserveBasemapAndGround(t);const s=new Map(this.map.layers.map(e=>[e,this.layerExtensions.forLayer(e)])),i=new Map(this.map.tables.map(e=>[e,this.tableExtensions.forTable(e)])),{basemapExtension:a}=this;this._setMap(t),this._updateBookmarks();const n=[];for(const e of this.map.layers.toArray()){const t=[...J(s.entries(),([t])=>G(t,e))];if(1===t.length){const[s]=t;n.push((async()=>{const t=s[1];await t._switchLayer(e),this._layerExtensions._register(t)})())}else{const t=this._layerExtensions._forLayer(e);t&&t.layer!==e&&n.push(t._switchLayer(e))}}for(const e of this.map.tables.toArray()){const t=[...J(i.entries(),([t])=>G(t,e))];if(1===t.length){const[s]=t;n.push((async()=>{const t=s[1];await t._switchTable(e),this.tableExtensions.add(t)})())}else{const t=this.tableExtensions.forTable(e);t&&t.table!==e&&n.push(t._switchTable(e))}}this.map.basemap&&a&&V(this.map.basemap,a.basemap)&&n.push((async()=>{await a._switchBasemap(this.map.basemap),this.basemapExtension=a})()),await Promise.all(n),this.isInitialized&&(a&&a!==this.basemapExtension&&(this.basemapOptions.includes(a)||await a.destroy()),await this._initializeChildren()),this._isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new n("Cannot unset both webMap and webScene.");const t=this._map?.basemap;this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=de(e),await N(this._webMapItem),"map"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createMap(),await this.switchMap(this._map),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("scene")),this._cleanPreviousBasemapOptions(t),A(this,"webMap"),A(this,"initialViewMode"),A(this,"title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new n("Cannot unset both webMap and webScene.");const t=this._scene?.basemap;this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=de(e),await N(this._webSceneItem),"scene"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createScene(),await this.switchMap(this._scene),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("map")),this._cleanPreviousBasemapOptions(t),A(this,"webScene"),A(this,"initialViewMode"),A(this,"title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _onDestroy(){await Promise.all([...Array.from(this._layerExtensions,e=>e.destroy()),...Array.from(this.tableExtensions,e=>e.destroy()),...Array.from(this._basemapOptions,e=>e.destroy()),...this._groundExtension?[this._groundExtension.destroy()]:[]]),this._layerExtensions.destroy(),this.tableExtensions.destroy(),this.allLayerExtensions.destroy(),this._basemapOptions.destroy(),this._bookmarks.destroy(),this._layerViews.destroy(),await super._onDestroy()}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;le(this.webScene)?(this._webSceneItem.type="Web Scene",this._scene=new e({portalItem:this._webSceneItem})):this._scene=e.fromJSON(this.webScene)})()}async _createMap(){if(!this._map&&this.webMap)return this._createMapPromise=this._createMapPromise??(async()=>{const e=(await import("@arcgis/core/WebMap")).default;le(this.webMap)?(this._webMapItem.type="Web Map",this._map=new e({portalItem:this._webMapItem})):this._map=e.fromJSON(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{if(this.map&&e){const t="map"===this.viewMode,s=(t?this._scene:this._map)?.layers.toArray()??[],i=e.filter(e=>!s.includes(e.layer)&&!s.some(t=>e.layer&&G(t,e.layer)));ae(this.layerExtensions,i)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,s=(t?this._map:this._scene)?.layers.toArray();let i=(t?this._scene:this._map)?.layers.toArray()??[];return i=i.filter(e=>!s.find(t=>G(t,e))),this.layerExtensions.concat(i.map(e=>this._layerExtensions._forLayer(e))).filter(t=>"initial"!==e||!t.dynamicallyAddedLayer).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?R(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(d(e)?e:_.create(e),t)},onMatch:(e,t,s,i)=>{d(t)||e.assignProperties(t),s!==i&&this.tableExtensions.reorder(e,i)},equals:(e,t)=>d(t)?t===e:!!_._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>this._deferredProperties?.tableExtensions?this._deferredProperties?.tableExtensions:this.tableExtensions.toArray()},basemapExtension:{serializeModes:["project"],deserialize:e=>{if(this.map)if(e)if(o(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=ee.create(e)}else this.basemapExtension=void 0;else this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>this._deferredProperties?.basemapExtension?this._deferredProperties?.basemapExtension:this.basemapExtension},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(R(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(o(e)?e:ee.create(e),t)},onMatch:(e,t,s,i)=>{o(t)||e.assignProperties(t),s!==i&&this.basemapOptions.reorder(e,i)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(o(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const s=e.toJSON();return V(s.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap()))},serialize:()=>this._deferredProperties?.basemapOptions?this._deferredProperties?.basemapOptions:this.basemapOptions.toArray()},groundExtension:{serializeModes:["initial"],deserialize:e=>{if(this.map){if(!p(e))return this.groundExtension.assignPropertiesAsync(e);this.groundExtension=e}else this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>this._deferredProperties?.groundExtension?this._deferredProperties?.groundExtension:this.groundExtension},bookmarks:{serialize:()=>this.bookmarks.map(e=>e.toJSON()).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map(e=>r(e)?e:new te(e)))}},webMap:{serializeModes:["initial"],deserialize:!1},webScene:{serializeModes:["initial"],deserialize:!1},initialLayerPreset:"initial",initialViewMode:{serializeModes:["initial","project"],serialize:e=>"project"===e?this.viewMode:"scene"!==this.initialViewMode||!this.webScene&&this.webMap?"map":"scene",deserialize:e=>{this.viewMode!==e&&(this._deserializedViewMode=e),this._initialViewMode=e},isDefault:(e,t)=>"project"!==t&&"map"===e},formatSettings:"initial",constraints:"initial",title:"initial",onClick:"initial",onHover:"initial",onHoverEnd:"initial",onInitialized:"initial",onViewpointChanged:"initial",contextMenu:{serializeModes:["initial"],deserialize:e=>{e?m(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=x.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>{b.lookup=new WeakMap;const e=this.layerExtensions.toArray().filter(e=>e.layer).map(e=>e._getProjectWebmapJSON()),t=this.tableExtensions.toArray().filter(e=>e.table).map(e=>({id:e.table.id,title:e.table.title}));return b.lookup=void 0,e.length>0||t.length>0?{operationalLayers:e,tables:t}:{}},deserialize:e=>{if(!this.map)throw new i("Cannot specify JSON object for the 'map' property. It must be an ArcGIS API Map instance. To specify JSON, use 'webMap' or 'webScene' instead.");if(D(e)||U(e)||$(e)){if(e!==this.map)throw new i("properties.map","Property 'map' is read-only.")}else this._deserializedMapPromise=(async()=>{this._deserializedViewMode&&this.webMap&&this.webScene&&(this._deserializedViewModePromise=this.switchViewMode(this._deserializedViewMode),await this._deserializedViewModePromise,this._deserializedViewMode=void 0,this._deserializedViewModePromise=void 0),await this._applyMapProperties(e,this.map),this._deserializedMapPromise=void 0})()}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,s){await Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap());let i=e;const a=this.basemapOptions.find(e=>V(e.basemap,i.baseMap));a&&(t.basemap=a.basemap,i={...i,baseMap:{...i.baseMap,title:t.basemap.title}}),$(t)?await f(i,t,s):await c(i,t,s)}_createFormatSettings(){return new y}_createLayerExtensionCollection(){return new ne(this)}_createTableExtensionCollection(){return new he(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:s,webScene:i,...a}=this._deferredProperties??{};if(this.map||("scene"===this.initialViewMode?(await this._createScene(),this._setMap(this._scene)):(await this._createMap(),this._setMap(this._map))),this._webMapItem||this._webSceneItem?(await Promise.all([be(this.map),N(this._webMapItem),N(this._webSceneItem)]),_e(this._webMapItem,"webMap","Web Map"),_e(this._webSceneItem,"webScene","Web Scene")):await be(this.map),t&&(!o(t)&&t.basemap?this.basemapExtension=ee.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find(e=>o(e)&&V(this.map.basemap,e.toJSON().basemap));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,s=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),s&&(this.map.basemap.title=s)}await this.assignPropertiesAsync({basemapOptions:e})}await this.assignPropertiesAsync(a),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks();for(const e of this.layerExtensions.toArray())await e._createBackingLayer();await Promise.all(this.tableExtensions.map(e=>e._createBackingTable()).toArray())}async _postInitialize(){await super._postInitialize(),await this._createStandardBasemapOptions(),await Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap()),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new s(this.layerExtensions.filter(e=>!!e.layer));e.remove=e=>this.layerExtensions.remove(e);const t=new s(this.tableExtensions.filter(e=>!!e.table));if(t.remove=e=>this.tableExtensions.remove(e),yield e,yield t,this.basemapExtension){const e=new s;e.add(this.basemapExtension),yield e}const i=new s;i.add(this.groundExtension),yield i}_preserveBasemapAndGround(e){(!e.basemap||H(e.basemap))&&this.map?.basemap&&H(this.map.basemap)&&(e.basemap=this.map.basemap),this.map?.ground&&e.ground&&L(this.map.ground,e.ground)&&(e.ground=this.map.ground)}_initMapFromProperties(e){const t=e.map;D(t)||U(t)||$(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!le(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!le(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){$(e)?this._scene=e:this._map=e,this._currentMap=e,this.basemapExtension?.basemap&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),this.groundExtension?.ground&&!e.ground&&(e.ground=this.groundExtension.ground),A(this,"map")}_onBasemapChange(){if(this._basemapExtension){if(this.basemapExtension.basemap==this.map.basemap)return;this._basemapExtension._setMapExtension(void 0)}if(this.map.basemap){let e=this.basemapOptions.find(e=>this.map.basemap===e.basemap);if(!e){const t=this.basemapOptions.find(e=>V(e.basemap,this.map.basemap));t?(e=t,e._switchBasemap(this.map.basemap)):(e=ee.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0))}e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;A(this,"basemapExtension")}_onGroundChange(){if(this._groundExtension){if(this.map.ground&&this.groundExtension.ground===this.map.ground)return void(this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,this.groundExtension));{const e=this.groundExtension,t=e.ground;e._setMapExtension(void 0),this.isSwitchingMap&&t&&t!==this._map?.ground&&t!==this._scene?.ground&&t!==this.map?.ground&&(this._groundExtensions.delete(t),e.destroy())}}this.map.ground&&!this._groundExtensions.has(this.map.ground)&&this._groundExtensions.set(this.map.ground,se.create({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e&&e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,A(this,"groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e?.isWebMercator&&await Y([v.SATELLITE,v.HYBRID_VECTOR,v.STREETS_VECTOR,v.TOPO_VECTOR,v.STREETS_NAVIGATION_VECTOR,v.STREETS_NIGHT_VECTOR,v.TERRAIN_VECTOR,v.DARK_GRAY_VECTOR,v.GRAY_VECTOR,v.OCEANS_VECTOR,v.OPEN_STREET_MAP_VECTOR],async e=>{const t=await B(e);V(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(ee.create({basemap:t}),void 0,!1)})}_ensureIsBasemapOption(e){const t=this.basemapOptions.findIndex(t=>t.basemap===e.basemap);t>=0?this._basemapOptions.getItemAt(t)!==e&&(this._basemapOptions.removeAtInternal(t),this._basemapOptions.addInternal(e,t)):this._basemapOptions.addInternal(e,0)}_cleanPreviousBasemapOptions(e){if(e&&!C(e))for(let t=this._basemapOptions.length-1;t>=0;t--){const s=this._basemapOptions.getItemAt(t),i=V(s.basemap,e),a=V(s.basemap,this._map?.basemap)||V(s.basemap,this._scene?.basemap);i&&!a&&this._basemapOptions.removeAtInternal(t)}}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter(e=>"map"===e.source)),U(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach(e=>{this.bookmarks.add(new te({source:"map",title:e.name,viewpoint:e.viewpoint}))}):$(this.map)&&this.map.presentation?.slides?.length>0&&this.map.presentation.slides.forEach(e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},s=new te(t);this.bookmarks.add(s)})}};re=e=t([g],re);export{re as MapExtension};class pe extends w{isExplicitlyModified=!1;_mapExtension;constructor(e){super(new s),this._mapExtension=e}add(e,t){return super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e),this}addMany(e,t){return super.addMany(e,t),this.isExplicitlyModified=!0,this}addInternal(e,t,s=!0){const i=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=i(e.basemap.id);if(a=C(e.basemap)?this.findIndex(e=>i(e.basemap?.id)===t):this.findIndex(t=>V(t.basemap,e.basemap)),a>=0){if(!s)return;super.removeAt(a)}}super.add(e,t??(a>=0?a:void 0))}removeAt(e){const t=super.removeAt(e);return t&&(this.isExplicitlyModified=!0,t===this._mapExtension.basemapExtension&&(e<this.length?this._mapExtension.basemapExtension=this.getItemAt(e):this.length?this._mapExtension.basemapExtension=this.getItemAt(e-1):this._mapExtension.basemapExtension=void 0)),t}removeAll(){return this._mapExtension.basemapExtension=void 0,super.removeAll()}removeAtInternal(e){return super.removeAt(e)}removeAllInternal(){for(;this.length;)this.removeAtInternal(this.length-1)}reorder(e,t){return super.reorder(e,t),this.isExplicitlyModified=!0,e}reorderInternal(e,t){return super.reorder(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.basemap}}class he extends w{get _collection(){return this._tables.map(e=>this._forTable(e)).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new T(new s)}_mapExtension;_tableExtensionMap=new WeakMap;_uninitializedTableExtensions=new Set;_onChangeMapTablesHandle=new P(()=>Q(this._mapExtension,"map.tables",e=>{const t={added:(e.added||[]).map(e=>this._forTable(e)),moved:(e.moved||[]).map(e=>this._forTable(e)),removed:(e.removed||[]).map(e=>this._forTable(e)),target:this};this.emit("change",t)}));_onBeforeAddMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-add",e=>this.emit("before-add",{...e,item:this._forTable(e.item)})]));_onBeforeRemoveMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-remove",e=>this.emit("before-remove",{...e,item:this._forTable(e.item)})]));_onBeforeChangesMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-changes",e=>this.emit("before-changes",{...e})]));_onAfterAddMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-add",e=>this.emit("after-add",{...e,item:this._forTable(e.item)})],e=>{if(null!=e)for(const t of e)this.emit("after-add",{item:this._forTable(t)})}));_onAfterRemoveMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-remove",e=>this.emit("after-remove",{...e,item:this._forTable(e.item)})],(e,t)=>{if(null!=t)for(const e of t)this.emit("after-remove",{item:this._forTable(e)})}));_onAfterChangesMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-changes",e=>this.emit("after-changes",{...e,target:this})],()=>{this.emit("after-changes",{target:this})}));constructor(e){super(),this._mapExtension=e,S(this,"length",()=>O(this._mapExtension,"map.tables.length",()=>A(this,"length"),{sync:!0}))}on(e,t){const s=[];return"change"===e?s.push(this._onChangeMapTablesHandle.add()):"before-add"===e?s.push(this._onBeforeAddMapTablesHandle.add()):"before-remove"===e?s.push(this._onBeforeRemoveMapTablesHandle.add()):"before-changes"===e?s.push(this._onBeforeChangesMapTablesHandle.add()):"after-add"===e?s.push(this._onAfterAddMapTablesHandle.add()):"after-remove"===e?s.push(this._onAfterRemoveMapTablesHandle.add()):"after-changes"===e&&s.push(this._onAfterChangesMapTablesHandle.add()),s.push(super.on(e,t)),I(s)}destroy(){this._onChangeMapTablesHandle.destroy(),this._onBeforeAddMapTablesHandle.destroy(),this._onBeforeRemoveMapTablesHandle.destroy(),this._onBeforeChangesMapTablesHandle.destroy(),this._onAfterAddMapTablesHandle.destroy(),this._onAfterRemoveMapTablesHandle.destroy(),this._onAfterChangesMapTablesHandle.destroy();new Set(this).forEach(e=>this._onRemoved(e)),this._uninitializedTableExtensions.clear(),this._tableExtensionMap=new WeakMap,super.destroy()}toJSON(){const e=[];return this.forEach(t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)}),e}clone(){const e=new he(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return j("id",e).isNotMissing(),this.find(t=>t.id===e)}findByTableId(e){return j("id",e).isNotMissing(),this.find(t=>t._tableId===e)}forTable(e){if(j("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(j("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const s=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),s&&s!==e&&this._onRemoved(s),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:s?[s]:[],target:this};s&&this.emit("after-remove",{item:s}),this.emit("after-add",{item:e}),this.emit("change",t)}else this._tables.reorder(e.table,t);else this._tables.add(e.table,t)}else{this._uninitializedTableExtensions.add(e);const t={added:[e],moved:[],removed:[],target:this};this.emit("after-add",{item:e}),this.emit("change",t)}return this._onAdded(e),this}removeAt(e){const t=this.getItemAt(e);if(void 0!==t){if(this._uninitializedTableExtensions.has(t)){this._uninitializedTableExtensions.delete(t);const e={added:[],moved:[],removed:[t],target:this};this.emit("after-remove",{item:t}),this.emit("change",e)}else this._tables.remove(t.table);return this._onRemoved(t),t}}reorder(e,t){if(e&&this._tables.includes(e.table))return this._tables.reorder(e.table,t),e}sort(e){return this._tables.sort((t,s)=>e(this._forTable(t),this._forTable(s))),this}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.table}_onAdded(e){}_onRemoved(e){e._setMapExtension(void 0)}_forTable(e){for(const e of this._uninitializedTableExtensions)e._resolveTable(),e.table&&(this._tableExtensionMap.set(e.table,e),this._uninitializedTableExtensions.delete(e));if(!this._tableExtensionMap.has(e)){const t=_.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class me extends M{get _collection(){let e=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);return this._mapExtension.basemapExtension&&(e=e.concat(this._mapExtension.basemapExtension.baseLayerExtensions.toArray()).concat(this._mapExtension.basemapExtension.referenceLayerExtensions.toArray())),e=e.concat(this._mapExtension.groundExtension.layerExtensions.toArray()),e}_mapExtension;_onChangeLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,i=a=>{const n=new s(a.added).flatten(e=>W(e)?e.layerExtensions:[]),o=new s(a.moved).flatten(e=>W(e)?e.layerExtensions:[]),r=new s(a.removed).flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(!e.has(s)&&W(s)){const a=s.layerExtensions.on("change",i);e.set(s,a),t.add(a)}for(const s of r){const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))}this.emit("change",{added:n.toArray(),moved:o.toArray(),removed:r.toArray()})};t.add(this._mapExtension.layerExtensions.on("change",i));const a=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of a)if(W(s)){const a=s.layerExtensions.on("change",i);e.set(s,a),t.add(a)}return t.add(Q(this._mapExtension,"basemapExtension.baseLayerExtensions",e=>{this.emit("change",{...e})})),t.add(Q(this._mapExtension,"basemapExtension.referenceLayerExtensions",e=>{this.emit("change",{...e})})),t.add(this._mapExtension.groundExtension.layerExtensions.on("change",e=>{this.emit("change",{...e})})),I(t)});_onAfterAddLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,s=s=>{const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))},i=e=>{const t=e.item;if(W(t)){const e=t.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const t of e)s(t)}s(t)},a=s=>{this.emit("after-add",{...s});const n=s.item;if(W(n)){const o=n.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const n of o)if(this.emit("after-add",{...s,item:n}),!e.has(n)&&W(n)){const s=n.layerExtensions.on("after-add",a),o=n.layerExtensions.on("after-remove",i),r=I([s,o]);e.set(n,r),t.add(r)}}};t.add(this._mapExtension.layerExtensions.on("after-add",a)),t.add(this._mapExtension.layerExtensions.on("after-remove",i));const n=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(W(s)){const n=s.layerExtensions.on("after-add",a),o=s.layerExtensions.on("after-remove",i),r=I([n,o]);e.set(s,r),t.add(r)}return t.add(z(this._mapExtension,"basemapExtension.baseLayerExtensions",["after-add",e=>this.emit("after-add",{...e})])),t.add(z(this._mapExtension,"basemapExtension.referenceLayerExtensions",["after-add",e=>this.emit("after-add",{...e})])),t.add(this._mapExtension.groundExtension.layerExtensions.on("after-add",e=>{this.emit("after-add",{...e})})),I(t)});_onAfterRemoveLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,s=s=>{const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))},i=e=>{this.emit("after-remove",{...e});const t=e.item;if(W(t)){const i=t.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const t of i)this.emit("after-remove",{...e,item:t}),s(t)}s(t)},a=s=>{const n=s.item;if(W(n)){const s=n.layerExtensions.on("after-add",a),o=n.layerExtensions.on("after-remove",i),r=I([s,o]);e.set(n,r),t.add(r)}};t.add(this._mapExtension.layerExtensions.on("after-remove",i)),t.add(this._mapExtension.layerExtensions.on("after-add",a));const n=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(W(s)){const n=s.layerExtensions.on("after-add",a),o=s.layerExtensions.on("after-remove",i),r=I([n,o]);e.set(s,r),t.add(r)}return t.add(z(this._mapExtension,"basemapExtension.baseLayerExtensions",["after-remove",e=>this.emit("after-remove",{...e})])),t.add(z(this._mapExtension,"basemapExtension.referenceLayerExtensions",["after-remove",e=>this.emit("after-remove",{...e})])),t.add(this._mapExtension.groundExtension.layerExtensions.on("after-remove",e=>{this.emit("after-remove",{...e})})),I(t)});constructor(e){super(),this._mapExtension=e}on(e,t){const s=[];return"change"===e?s.push(this._onChangeLayerExtensionsHandle.add()):"after-add"===e?s.push(this._onAfterAddLayerExtensionsHandle.add()):"after-remove"===e&&s.push(this._onAfterRemoveLayerExtensionsHandle.add()),s.push(super.on(e,t)),I(s)}destroy(){this._onChangeLayerExtensionsHandle.destroy(),this._onAfterAddLayerExtensionsHandle.destroy(),this._onAfterRemoveLayerExtensionsHandle.destroy(),super.destroy()}findById(e){return j("id",e).isNotMissing(),this.find(t=>t.id===e)}findByLayerId(e){return j("id",e).isNotMissing(),this.find(t=>t._layerId===e)}forLayer(e){return j("layer",e).isNotMissing(),this.findByLayerId(e.id)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function de(e){if(!(null==e||"object"==typeof e&&e?.baseMap))return X(e)}function le(e){return"object"!=typeof e||e&&!e.baseMap}function _e(e,t,s){if(e?.type&&e.type!==s)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function be(e){await N(e),e.basemap&&(await N(e.basemap),e.basemap.baseLayers.filter(e=>F(e)).map(e=>{const t=e;return t.activeLayer.imageFormat=t.activeLayer.imageFormat??(t.activeLayer.imageFormats?.length>0?t.activeLayer.imageFormats[0]:""),t.activeLayer.styleId=t.activeLayer.styleId??"",t}),e.basemap.id=k(e.basemap)??e.basemap.id)}
1
+ var e;import{__decorate as t}from"tslib";import s,{}from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as a}from"../Entity.js";import{InvalidOperationError as n}from"../InvalidOperationError.js";import{isBasemapExtension as o,isBookmark as r,isGroundExtension as p,isLayerPreset as h,isMenu as m,isTableExtension as d,ItemType as l}from"../ItemType.js";import{TableExtension as _}from"../data/TableExtension.js";import{layerToParentJsonCache as b}from"../json/LayerJson.js";import{applyJsonToWebMap as c}from"../json/WebMapJson.js";import{applyJsonToWebScene as f}from"../json/WebSceneJson.js";import{LayerPreset as E}from"../layer-preset/LayerPreset.js";import{Menu as x}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as u}from"../support/ArcGISRequestHelper.js";import{FormatSettings as y}from"../support/FormatSettings.js";import{InitializableCollectionProxy as w}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as M}from"../support/ReadOnlyInitializableCollection.js";import{serializable as g}from"../support/Serializable.js";import{WellKnownBasemap as v}from"../support/esri.js";import{createIHandle as I,notifyChange as A,onWatch as S,watch as O,watchEvent as z}from"../support/observableUtils.js";import{ReadOnlyCollection as T}from"../utilities/ReadOnlyCollection.js";import P from"../utilities/_ReferenceCountedHandle.js";import{groundsAreEquivalent as L}from"../utilities/_layers.js";import{basemapsAreEquivalent as V,createStandardBasemap as B,getStandardBasemapId as k,isStandardBasemap as C,isStandardBasemap2D as H}from"../utilities/basemaps.js";import{checkArg as j}from"../utilities/checkArg.js";import{compare as R}from"../utilities/collection.js";import{load as N}from"../utilities/esri.js";import{isGroupLayerExtension as W}from"../utilities/extensions.js";import{filter as J}from"../utilities/iterable.js";import{isWMTSLayer as F,layersAreEquivalent as G}from"../utilities/layers.js";import{getLogger as q}from"../utilities/log.js";import{getMapSpatialReference as K,isMap as D,isWebMap as U,isWebScene as $}from"../utilities/mapping.js";import{toPortalItem as X}from"../utilities/portal.js";import{parallelEach as Y}from"../utilities/promise.js";import{onCollectionPropertyChange as Q,onEach as Z}from"../utilities/watch.js";import{BasemapExtension as ee}from"./BasemapExtension.js";import{Bookmark as te}from"./Bookmark.js";import{GroundExtension as se}from"./GroundExtension.js";import{MapConstraints as ie}from"./MapConstraints.js";import{_assignLayerExtensions as ae}from"./_LayerExtension.js";import{LayerExtensionCollectionImpl as ne}from"./_LayerExtensionCollectionImpl.js";const oe=q("MapExtension");let re=class extends a{static{e=this}static _mapEventHandlesKey="map-extension-map-event-handles";static _sceneEventHandlesKey="map-extension-scene-event-handles";get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?$(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":$(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new u),this._requestHelper}set requestHelper(e){this._requestHelper=e}get basemapExtension(){return this._basemapExtension}set basemapExtension(e){const t=this._basemapExtension;if(t!==e)if(t&&t._setMapExtension(void 0),e){if(e._setMapExtension(this),this.isInitialized&&!e.basemap){if(e.isInitialized)throw e._setMapExtension(void 0),new n("Cannot set MapExtension.basemapExtension without a valid Esri Basemap object");e.initialize()}this._ensureIsBasemapOption(e),this.map&&e.basemap&&e.basemap!==this.map.basemap?this.map.basemap=e.basemap:this._basemapExtension=e}else this.map.basemap=void 0,this._basemapExtension=void 0}get groundExtension(){return this._groundExtension||(this.groundExtension=se.create({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new n("Cannot set map.ground to undefined");const t=this._groundExtension;t!==e&&(t&&t._setMapExtension(void 0),e._setMapExtension(this),e._resolveGround(),e.ground?(this._groundExtensions.set(e.ground,e),this.map&&e.ground!==this.map.ground?this.map.ground=e.ground:this._groundExtension=e):this._groundExtension=e)}get basemapOptions(){return this._basemapOptions}get bookmarks(){return this._bookmarks}get initialBasemapExtension(){return this._initialBasemapExtension}get initialLayerPreset(){return this._initialLayerPreset}set initialLayerPreset(e){if(!e)return void(this._initialLayerPreset=void 0);const t=h(e)?e:new E(e);this._initialLayerPreset=t}get _spatialReference(){return K(this.map)}get webMapItemTitle(){if(this._webMapItem)return this._webMapItem.title}get webSceneItemTitle(){if(this._webSceneItem)return this._webSceneItem.title}get title(){return this._title?this._title:this._webMapItem&&"map"===this.viewMode?this.webMapItemTitle:this._webSceneItem&&"scene"===this.viewMode?this.webSceneItemTitle:void 0}set title(e){this._title=e}formatSettings;constraints;onClick;onHover;onHoverEnd;onInitialized;onViewpointChanged;get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,e&&this.isInitialized&&!e.isInitialized&&(async()=>{try{await e.initialize()}catch(e){e instanceof Error&&oe.error({message:"An error occurred while initializing context menu.",error:e})}})()}_layerViews=new s;get _allLayerViews(){const e=t=>{const i=[t];return s.isCollection(t.sublayerViews)?i.push(...t.sublayerViews.toArray().flatMap(e)):s.isCollection(t.layerViews)&&i.push(...t.layerViews.toArray().flatMap(e)),i};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}get isSwitchingMap(){return this._isSwitchingMap}tableExtensions;allLayerExtensions;_itemType=l.MAP_EXTENSION;_isSwitchingMap=!1;_map;_scene;_deserializedMapPromise;_deserializedViewMode;_deserializedViewModePromise;_deferredProperties;_currentMap;_requestHelper;_basemapExtension;_groundExtension;_basemapOptions;_groundExtensions;_bookmarks;_layerExtensions;_webMap;_webMapItem;_webScene;_webSceneItem;_title;_initialViewMode;_initialLayerPreset;_initialBasemapExtension;_skipBasemapOptions=!1;_createScenePromise;_createMapPromise;_contextMenu;constructor(t){super(t);let a={...t};this._basemapOptions=new pe(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new s,this.constraints=new ie,this._handles.add([O(this,"_map",t=>{t?this._handles.add([Z(t.layers,"layerview-create",e=>{this._layerViews.add(e.layerView)}),Z(t.layers,"layerview-destroy",e=>{this._layerViews.remove(e.layerView)})],e._mapEventHandlesKey):this._handles.remove(e._mapEventHandlesKey)},{sync:!0}),O(this,"_scene",t=>{t?this._handles.add([Z(t.layers,"layerview-create",e=>{this._layerViews.add(e.layerView)}),Z(t.layers,"layerview-destroy",e=>{this._layerViews.remove(e.layerView)})],e._sceneEventHandlesKey):this._handles.remove(e._sceneEventHandlesKey)},{sync:!0})]);const{webMap:n,webScene:o,initialViewMode:r,map:p,basemapOptions:h}=a;if(this._webMap=n,this._webScene=o,this._webMapItem=de(n),this._webSceneItem=de(o),this.initialViewMode=r,$(p)&&o)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(D(p)&&n)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if($(p)||U(p)||D(p))this.assignProperties({basemapOptions:h}),this._skipBasemapOptions=!!h;else{const{layerExtensions:e,tableExtensions:t,groundExtension:s,basemapOptions:i,basemapExtension:n,...o}=a;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:s,basemapOptions:i,basemapExtension:n},a=o,i&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(a),this._handles.add([O(this,"map.basemap",()=>this._onBasemapChange(),{sync:!0}),O(this,"map.ground",()=>this._onGroundChange(),{sync:!0})]),this.allLayerExtensions=new me(this),this.map?.basemap&&this._onBasemapChange()}getLayerExtensionsForView(e=this.viewMode){return(("map"===e?this._map:this._scene)?.layers.toArray()??[]).map(e=>this._layerExtensions._forLayer(e)).filter(e=>!e.dynamicallyAddedLayer)}getAllFeatureSources(e=()=>!0){const t=[],s=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())i(t);if(W(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())s(t)},i=s=>{t.push(s);for(const t of s.sublayerExtensions.initializedItems.filter(e).toArray())i(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())s(t);for(const s of this.tableExtensions.initializedItems.filter(e).toArray())t.push(s);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())s(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())s(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(j("viewMode",e).isNotMissing().satisfies(e=>this.isSupportedViewMode(e),"Unsupported view mode."),this.viewMode===e)return;let t;"scene"===e?(await this._createScene(),t=this._scene):(await this._createMap(),t=this._map),await this.switchMap(t),A(this,"viewMode"),A(this,"title")}async switchMap(t){if(j("newMap",t).isNotMissing(),t===this.map)return;if(!this.map)return void this._setMap(t);this._layerViews.removeAll(),"map"===this.viewMode?this._handles.remove(e._mapEventHandlesKey):this._handles.remove(e._sceneEventHandlesKey),this._isSwitchingMap=!0,this.isInitialized&&await be(t),this._preserveBasemapAndGround(t);const s=new Map(this.map.layers.map(e=>[e,this.layerExtensions.forLayer(e)])),i=new Map(this.map.tables.map(e=>[e,this.tableExtensions.forTable(e)])),{basemapExtension:a}=this;this._setMap(t),this._updateBookmarks();const n=[];for(const e of this.map.layers.toArray()){const t=[...J(s.entries(),([t])=>G(t,e))];if(1===t.length){const[s]=t;n.push((async()=>{const t=s[1];await t._switchLayer(e),this._layerExtensions._register(t)})())}else{const t=this._layerExtensions._forLayer(e);t&&t.layer!==e&&n.push(t._switchLayer(e))}}for(const e of this.map.tables.toArray()){const t=[...J(i.entries(),([t])=>G(t,e))];if(1===t.length){const[s]=t;n.push((async()=>{const t=s[1];await t._switchTable(e),this.tableExtensions.add(t)})())}else{const t=this.tableExtensions.forTable(e);t&&t.table!==e&&n.push(t._switchTable(e))}}this.map.basemap&&a&&V(this.map.basemap,a.basemap)&&n.push((async()=>{await a._switchBasemap(this.map.basemap),this.basemapExtension=a})()),await Promise.all(n),this.isInitialized&&(a&&a!==this.basemapExtension&&(this.basemapOptions.includes(a)||await a.destroy()),await this._initializeChildren()),this._isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new n("Cannot unset both webMap and webScene.");const t=this._map?.basemap;this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=de(e),await N(this._webMapItem),"map"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createMap(),await this.switchMap(this._map),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("scene")),this._cleanPreviousBasemapOptions(t),A(this,"webMap"),A(this,"initialViewMode"),A(this,"title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new n("Cannot unset both webMap and webScene.");const t=this._scene?.basemap;this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=de(e),await N(this._webSceneItem),"scene"===this.viewMode&&(e?(this._basemapOptions.isExplicitlyModified||this._basemapOptions.removeAllInternal(),await this._createScene(),await this.switchMap(this._scene),await this._createStandardBasemapOptions(),this._basemapOptions.reorderInternal(this.basemapExtension,0),this._initialBasemapExtension=this.basemapExtension):await this.switchViewMode("map")),this._cleanPreviousBasemapOptions(t),A(this,"webScene"),A(this,"initialViewMode"),A(this,"title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _onDestroy(){await Promise.all([...Array.from(this._layerExtensions,e=>e.destroy()),...Array.from(this.tableExtensions,e=>e.destroy()),...Array.from(this._basemapOptions,e=>e.destroy()),...this._groundExtension?[this._groundExtension.destroy()]:[]]),this._layerExtensions.destroy(),this.tableExtensions.destroy(),this.allLayerExtensions.destroy(),this._basemapOptions.destroy(),this._bookmarks.destroy(),this._layerViews.destroy(),await super._onDestroy()}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;le(this.webScene)?(this._webSceneItem.type="Web Scene",this._scene=new e({portalItem:this._webSceneItem})):this._scene=e.fromJSON(this.webScene)})()}async _createMap(){if(!this._map&&this.webMap)return this._createMapPromise=this._createMapPromise??(async()=>{const e=(await import("@arcgis/core/WebMap")).default;le(this.webMap)?(this._webMapItem.type="Web Map",this._map=new e({portalItem:this._webMapItem})):this._map=e.fromJSON(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{if(this.map&&e){const t="map"===this.viewMode,s=(t?this._scene:this._map)?.layers.toArray()??[],i=e.filter(e=>!s.includes(e.layer)&&!s.some(t=>e.layer&&G(t,e.layer)));ae(this.layerExtensions,i)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,s=(t?this._map:this._scene)?.layers.toArray();let i=(t?this._scene:this._map)?.layers.toArray()??[];return i=i.filter(e=>!s.find(t=>G(t,e))),this.layerExtensions.concat(i.map(e=>this._layerExtensions._forLayer(e))).filter(t=>"initial"!==e||!t.dynamicallyAddedLayer).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?R(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(d(e)?e:_.create(e),t)},onMatch:(e,t,s,i)=>{d(t)||e.assignProperties(t),s!==i&&this.tableExtensions.reorder(e,i)},equals:(e,t)=>d(t)?t===e:!!_._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>this._deferredProperties?.tableExtensions?this._deferredProperties?.tableExtensions:this.tableExtensions.toArray()},basemapExtension:{serializeModes:["project"],deserialize:e=>{if(this.map)if(e)if(o(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=ee.create(e)}else this.basemapExtension=void 0;else this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>this._deferredProperties?.basemapExtension?this._deferredProperties?.basemapExtension:this.basemapExtension},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(this.basemapOptions.length&&(this._basemapOptions.isExplicitlyModified=!0),R(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(o(e)?e:ee.create(e),t)},onMatch:(e,t,s,i)=>{o(t)||e.assignProperties(t),s!==i&&this.basemapOptions.reorder(e,i)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(o(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const s=e.toJSON();return V(s.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap()))},serialize:()=>this._deferredProperties?.basemapOptions?this._deferredProperties?.basemapOptions:this.basemapOptions.toArray()},groundExtension:{serializeModes:["initial"],deserialize:e=>{if(this.map){if(!p(e))return this.groundExtension.assignPropertiesAsync(e);this.groundExtension=e}else this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>this._deferredProperties?.groundExtension?this._deferredProperties?.groundExtension:this.groundExtension},bookmarks:{serialize:()=>this.bookmarks.map(e=>e.toJSON()).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map(e=>r(e)?e:new te(e)))}},webMap:{serializeModes:["initial"],deserialize:!1},webScene:{serializeModes:["initial"],deserialize:!1},initialLayerPreset:"initial",initialViewMode:{serializeModes:["initial","project"],serialize:e=>"project"===e?this.viewMode:"scene"!==this.initialViewMode||!this.webScene&&this.webMap?"map":"scene",deserialize:e=>{this.viewMode!==e&&(this._deserializedViewMode=e),this._initialViewMode=e},isDefault:(e,t)=>"project"!==t&&"map"===e},formatSettings:"initial",constraints:"initial",title:"initial",onClick:"initial",onHover:"initial",onHoverEnd:"initial",onInitialized:"initial",onViewpointChanged:"initial",contextMenu:{serializeModes:["initial"],deserialize:e=>{e?m(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=x.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>{b.lookup=new WeakMap;const e=this.layerExtensions.toArray().filter(e=>e.layer).map(e=>e._getProjectWebmapJSON()),t=this.tableExtensions.toArray().filter(e=>e.table).map(e=>({id:e.table.id,title:e.table.title}));return b.lookup=void 0,e.length>0||t.length>0?{operationalLayers:e,tables:t}:{}},deserialize:e=>{if(!this.map)throw new i("Cannot specify JSON object for the 'map' property. It must be an ArcGIS API Map instance. To specify JSON, use 'webMap' or 'webScene' instead.");if(D(e)||U(e)||$(e)){if(e!==this.map)throw new i("properties.map","Property 'map' is read-only.")}else this._deserializedMapPromise=(async()=>{this._deserializedViewMode&&this.webMap&&this.webScene&&(this._deserializedViewModePromise=this.switchViewMode(this._deserializedViewMode),await this._deserializedViewModePromise,this._deserializedViewMode=void 0,this._deserializedViewModePromise=void 0),await this._applyMapProperties(e,this.map),this._deserializedMapPromise=void 0})()}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,s){await Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap());let i=e;const a=this.basemapOptions.find(e=>V(e.basemap,i.baseMap));a&&(t.basemap=a.basemap,i={...i,baseMap:{...i.baseMap,title:t.basemap.title}}),$(t)?await f(i,t,s):await c(i,t,s)}_createFormatSettings(){return new y}_createLayerExtensionCollection(){return new ne(this)}_createTableExtensionCollection(){return new he(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:s,webScene:i,...a}=this._deferredProperties??{};if(this.map||("scene"===this.initialViewMode?(await this._createScene(),this._setMap(this._scene)):(await this._createMap(),this._setMap(this._map))),this._webMapItem||this._webSceneItem?(await Promise.all([be(this.map),N(this._webMapItem),N(this._webSceneItem)]),_e(this._webMapItem,"webMap","Web Map"),_e(this._webSceneItem,"webScene","Web Scene")):await be(this.map),t&&(!o(t)&&t.basemap?this.basemapExtension=ee.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find(e=>o(e)&&V(this.map.basemap,e.toJSON().basemap));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,s=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),s&&(this.map.basemap.title=s)}await this.assignPropertiesAsync({basemapOptions:e})}await this.assignPropertiesAsync(a),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks();for(const e of this.layerExtensions.toArray())await e._createBackingLayer();await Promise.all(this.tableExtensions.map(e=>e._createBackingTable()).toArray())}async _postInitialize(){await super._postInitialize(),await this._createStandardBasemapOptions(),await Y(this.basemapOptions.toArray(),e=>e._createBackingBasemap()),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new s(this.layerExtensions.filter(e=>!!e.layer));e.remove=e=>this.layerExtensions.remove(e);const t=new s(this.tableExtensions.filter(e=>!!e.table));if(t.remove=e=>this.tableExtensions.remove(e),yield e,yield t,this.basemapExtension){const e=new s;e.add(this.basemapExtension),yield e}const i=new s;i.add(this.groundExtension),yield i}_preserveBasemapAndGround(e){(!e.basemap||H(e.basemap))&&this.map?.basemap&&H(this.map.basemap)&&(e.basemap=this.map.basemap),this.map?.ground&&e.ground&&L(this.map.ground,e.ground)&&(e.ground=this.map.ground)}_initMapFromProperties(e){const t=e.map;D(t)||U(t)||$(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!le(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!le(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){$(e)?this._scene=e:this._map=e,this._currentMap=e,this.basemapExtension?.basemap&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),this.groundExtension?.ground&&!e.ground&&(e.ground=this.groundExtension.ground),A(this,"map")}_onBasemapChange(){if(this._basemapExtension){if(this.basemapExtension.basemap==this.map.basemap)return;this._basemapExtension._setMapExtension(void 0)}if(this.map.basemap){let e=this.basemapOptions.find(e=>this.map.basemap===e.basemap);if(!e){const t=this.basemapOptions.find(e=>V(e.basemap,this.map.basemap));t?(e=t,e._switchBasemap(this.map.basemap)):(e=ee.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0))}e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;A(this,"basemapExtension")}_onGroundChange(){if(this._groundExtension){if(this.map.ground&&this.groundExtension.ground===this.map.ground)return void(this._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,this.groundExtension));{const e=this.groundExtension,t=e.ground;e._setMapExtension(void 0),this.isSwitchingMap&&t&&t!==this._map?.ground&&t!==this._scene?.ground&&t!==this.map?.ground&&(this._groundExtensions.delete(t),e.destroy())}}this.map.ground&&!this._groundExtensions.has(this.map.ground)&&this._groundExtensions.set(this.map.ground,se.create({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e&&e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,A(this,"groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e?.isWebMercator&&await Y([v.SATELLITE,v.HYBRID_VECTOR,v.STREETS_VECTOR,v.TOPO_VECTOR,v.STREETS_NAVIGATION_VECTOR,v.STREETS_NIGHT_VECTOR,v.TERRAIN_VECTOR,v.DARK_GRAY_VECTOR,v.GRAY_VECTOR,v.OCEANS_VECTOR,v.OPEN_STREET_MAP_VECTOR],async e=>{const t=await B(e);V(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(ee.create({basemap:t}),void 0,!1)})}_ensureIsBasemapOption(e){const t=this.basemapOptions.findIndex(t=>t.basemap===e.basemap);t>=0?this._basemapOptions.getItemAt(t)!==e&&(this._basemapOptions.removeAtInternal(t),this._basemapOptions.addInternal(e,t)):this._basemapOptions.addInternal(e,0)}_cleanPreviousBasemapOptions(e){if(e&&!C(e))for(let t=this._basemapOptions.length-1;t>=0;t--){const s=this._basemapOptions.getItemAt(t),i=V(s.basemap,e),a=V(s.basemap,this._map?.basemap)||V(s.basemap,this._scene?.basemap);i&&!a&&this._basemapOptions.removeAtInternal(t)}}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter(e=>"map"===e.source)),U(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach(e=>{this.bookmarks.add(new te({source:"map",title:e.name,viewpoint:e.viewpoint}))}):$(this.map)&&this.map.presentation?.slides?.length>0&&this.map.presentation.slides.forEach(e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},s=new te(t);this.bookmarks.add(s)})}};re=e=t([g],re);export{re as MapExtension};class pe extends w{isExplicitlyModified=!1;_mapExtension;constructor(e){super(new s),this._mapExtension=e}add(e,t){return super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e),this}addMany(e,t){return super.addMany(e,t),this.isExplicitlyModified=!0,this}addInternal(e,t,s=!0){const i=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=i(e.basemap.id);if(a=C(e.basemap)?this.findIndex(e=>i(e.basemap?.id)===t):this.findIndex(t=>V(t.basemap,e.basemap)),a>=0){if(!s)return;super.removeAt(a)}}super.add(e,t??(a>=0?a:void 0))}removeAt(e){const t=super.removeAt(e);return t&&(this.isExplicitlyModified=!0,t===this._mapExtension.basemapExtension&&(e<this.length?this._mapExtension.basemapExtension=this.getItemAt(e):this.length?this._mapExtension.basemapExtension=this.getItemAt(e-1):this._mapExtension.basemapExtension=void 0)),t}removeAll(){return this._mapExtension.basemapExtension=void 0,super.removeAll()}removeAtInternal(e){return super.removeAt(e)}removeAllInternal(){for(;this.length;)this.removeAtInternal(this.length-1)}reorder(e,t){return super.reorder(e,t),this.isExplicitlyModified=!0,e}reorderInternal(e,t){return super.reorder(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.basemap}}class he extends w{get _collection(){return this._tables.map(e=>this._forTable(e)).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new T(new s)}_mapExtension;_tableExtensionMap=new WeakMap;_uninitializedTableExtensions=new Set;_onChangeMapTablesHandle=new P(()=>Q(this._mapExtension,"map.tables",e=>{const t={added:(e.added||[]).map(e=>this._forTable(e)),moved:(e.moved||[]).map(e=>this._forTable(e)),removed:(e.removed||[]).map(e=>this._forTable(e)),target:this};this.emit("change",t)}));_onBeforeAddMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-add",e=>this.emit("before-add",{...e,item:this._forTable(e.item)})]));_onBeforeRemoveMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-remove",e=>this.emit("before-remove",{...e,item:this._forTable(e.item)})]));_onBeforeChangesMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["before-changes",e=>this.emit("before-changes",{...e})]));_onAfterAddMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-add",e=>this.emit("after-add",{...e,item:this._forTable(e.item)})],e=>{if(null!=e)for(const t of e)this.emit("after-add",{item:this._forTable(t)})}));_onAfterRemoveMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-remove",e=>this.emit("after-remove",{...e,item:this._forTable(e.item)})],(e,t)=>{if(null!=t)for(const e of t)this.emit("after-remove",{item:this._forTable(e)})}));_onAfterChangesMapTablesHandle=new P(()=>z(this._mapExtension,"map.tables",["after-changes",e=>this.emit("after-changes",{...e,target:this})],()=>{this.emit("after-changes",{target:this})}));constructor(e){super(),this._mapExtension=e,S(this,"length",()=>O(this._mapExtension,"map.tables.length",()=>A(this,"length"),{sync:!0}))}on(e,t){const s=[];return"change"===e?s.push(this._onChangeMapTablesHandle.add()):"before-add"===e?s.push(this._onBeforeAddMapTablesHandle.add()):"before-remove"===e?s.push(this._onBeforeRemoveMapTablesHandle.add()):"before-changes"===e?s.push(this._onBeforeChangesMapTablesHandle.add()):"after-add"===e?s.push(this._onAfterAddMapTablesHandle.add()):"after-remove"===e?s.push(this._onAfterRemoveMapTablesHandle.add()):"after-changes"===e&&s.push(this._onAfterChangesMapTablesHandle.add()),s.push(super.on(e,t)),I(s)}destroy(){this._onChangeMapTablesHandle.destroy(),this._onBeforeAddMapTablesHandle.destroy(),this._onBeforeRemoveMapTablesHandle.destroy(),this._onBeforeChangesMapTablesHandle.destroy(),this._onAfterAddMapTablesHandle.destroy(),this._onAfterRemoveMapTablesHandle.destroy(),this._onAfterChangesMapTablesHandle.destroy();new Set(this).forEach(e=>this._onRemoved(e)),this._uninitializedTableExtensions.clear(),this._tableExtensionMap=new WeakMap,super.destroy()}toJSON(){const e=[];return this.forEach(t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)}),e}clone(){const e=new he(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return j("id",e).isNotMissing(),this.find(t=>t.id===e)}findByTableId(e){return j("id",e).isNotMissing(),this.find(t=>t._tableId===e)}forTable(e){if(j("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(j("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const s=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),s&&s!==e&&this._onRemoved(s),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:s?[s]:[],target:this};s&&this.emit("after-remove",{item:s}),this.emit("after-add",{item:e}),this.emit("change",t)}else this._tables.reorder(e.table,t);else this._tables.add(e.table,t)}else{this._uninitializedTableExtensions.add(e);const t={added:[e],moved:[],removed:[],target:this};this.emit("after-add",{item:e}),this.emit("change",t)}return this._onAdded(e),this}removeAt(e){const t=this.getItemAt(e);if(void 0!==t){if(this._uninitializedTableExtensions.has(t)){this._uninitializedTableExtensions.delete(t);const e={added:[],moved:[],removed:[t],target:this};this.emit("after-remove",{item:t}),this.emit("change",e)}else this._tables.remove(t.table);return this._onRemoved(t),t}}reorder(e,t){if(e&&this._tables.includes(e.table))return this._tables.reorder(e.table,t),e}sort(e){return this._tables.sort((t,s)=>e(this._forTable(t),this._forTable(s))),this}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.table}_onAdded(e){}_onRemoved(e){e._setMapExtension(void 0)}_forTable(e){for(const e of this._uninitializedTableExtensions)e._resolveTable(),e.table&&(this._tableExtensionMap.set(e.table,e),this._uninitializedTableExtensions.delete(e));if(!this._tableExtensionMap.has(e)){const t=_.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class me extends M{get _collection(){let e=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);return this._mapExtension.basemapExtension&&(e=e.concat(this._mapExtension.basemapExtension.baseLayerExtensions.toArray()).concat(this._mapExtension.basemapExtension.referenceLayerExtensions.toArray())),e=e.concat(this._mapExtension.groundExtension.layerExtensions.toArray()),e}_mapExtension;_onChangeLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,i=a=>{const n=new s(a.added).flatten(e=>W(e)?e.layerExtensions:[]),o=new s(a.moved).flatten(e=>W(e)?e.layerExtensions:[]),r=new s(a.removed).flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(!e.has(s)&&W(s)){const a=s.layerExtensions.on("change",i);e.set(s,a),t.add(a)}for(const s of r){const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))}this.emit("change",{added:n.toArray(),moved:o.toArray(),removed:r.toArray()})};t.add(this._mapExtension.layerExtensions.on("change",i));const a=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of a)if(W(s)){const a=s.layerExtensions.on("change",i);e.set(s,a),t.add(a)}return t.add(Q(this._mapExtension,"basemapExtension.baseLayerExtensions",e=>{this.emit("change",{...e})})),t.add(Q(this._mapExtension,"basemapExtension.referenceLayerExtensions",e=>{this.emit("change",{...e})})),t.add(this._mapExtension.groundExtension.layerExtensions.on("change",e=>{this.emit("change",{...e})})),I(t)});_onAfterAddLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,s=s=>{const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))},i=e=>{const t=e.item;if(W(t)){const e=t.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const t of e)s(t)}s(t)},a=s=>{this.emit("after-add",{...s});const n=s.item;if(W(n)){const o=n.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const n of o)if(this.emit("after-add",{...s,item:n}),!e.has(n)&&W(n)){const s=n.layerExtensions.on("after-add",a),o=n.layerExtensions.on("after-remove",i),r=I([s,o]);e.set(n,r),t.add(r)}}};t.add(this._mapExtension.layerExtensions.on("after-add",a)),t.add(this._mapExtension.layerExtensions.on("after-remove",i));const n=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(W(s)){const n=s.layerExtensions.on("after-add",a),o=s.layerExtensions.on("after-remove",i),r=I([n,o]);e.set(s,r),t.add(r)}return t.add(z(this._mapExtension,"basemapExtension.baseLayerExtensions",["after-add",e=>this.emit("after-add",{...e})])),t.add(z(this._mapExtension,"basemapExtension.referenceLayerExtensions",["after-add",e=>this.emit("after-add",{...e})])),t.add(this._mapExtension.groundExtension.layerExtensions.on("after-add",e=>{this.emit("after-add",{...e})})),I(t)});_onAfterRemoveLayerExtensionsHandle=new P(()=>{const e=new WeakMap,t=new Set,s=s=>{const i=e.get(s);i&&(i.remove(),e.delete(s),t.delete(i))},i=e=>{this.emit("after-remove",{...e});const t=e.item;if(W(t)){const i=t.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const t of i)this.emit("after-remove",{...e,item:t}),s(t)}s(t)},a=s=>{const n=s.item;if(W(n)){const s=n.layerExtensions.on("after-add",a),o=n.layerExtensions.on("after-remove",i),r=I([s,o]);e.set(n,r),t.add(r)}};t.add(this._mapExtension.layerExtensions.on("after-remove",i)),t.add(this._mapExtension.layerExtensions.on("after-add",a));const n=this._mapExtension.layerExtensions.flatten(e=>W(e)?e.layerExtensions:[]);for(const s of n)if(W(s)){const n=s.layerExtensions.on("after-add",a),o=s.layerExtensions.on("after-remove",i),r=I([n,o]);e.set(s,r),t.add(r)}return t.add(z(this._mapExtension,"basemapExtension.baseLayerExtensions",["after-remove",e=>this.emit("after-remove",{...e})])),t.add(z(this._mapExtension,"basemapExtension.referenceLayerExtensions",["after-remove",e=>this.emit("after-remove",{...e})])),t.add(this._mapExtension.groundExtension.layerExtensions.on("after-remove",e=>{this.emit("after-remove",{...e})})),I(t)});constructor(e){super(),this._mapExtension=e}on(e,t){const s=[];return"change"===e?s.push(this._onChangeLayerExtensionsHandle.add()):"after-add"===e?s.push(this._onAfterAddLayerExtensionsHandle.add()):"after-remove"===e&&s.push(this._onAfterRemoveLayerExtensionsHandle.add()),s.push(super.on(e,t)),I(s)}destroy(){this._onChangeLayerExtensionsHandle.destroy(),this._onAfterAddLayerExtensionsHandle.destroy(),this._onAfterRemoveLayerExtensionsHandle.destroy(),super.destroy()}findById(e){return j("id",e).isNotMissing(),this.find(t=>t.id===e)}findByLayerId(e){return j("id",e).isNotMissing(),this.find(t=>t._layerId===e)}forLayer(e){return j("layer",e).isNotMissing(),this.findByLayerId(e.id)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function de(e){if(!(null==e||"object"==typeof e&&e?.baseMap))return X(e)}function le(e){return"object"!=typeof e||e&&!e.baseMap}function _e(e,t,s){if(e?.type&&e.type!==s)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function be(e){await N(e),e.basemap&&(await N(e.basemap),e.basemap.baseLayers.filter(e=>F(e)).map(e=>{const t=e;return t.activeLayer.imageFormat=t.activeLayer.imageFormat??(t.activeLayer.imageFormats?.length>0?t.activeLayer.imageFormats[0]:""),t.activeLayer.styleId=t.activeLayer.styleId??"",t}),e.basemap.id=k(e.basemap)??e.basemap.id)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vertigis/arcgis-extensions",
3
3
  "license": "SEE LICENSE IN LICENSE",
4
- "version": "54.14.5",
4
+ "version": "54.14.6",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://dev.azure.com/vertigis/Studio/_git/arcgis-extensions-ts"
package/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * The current version of the Geocortex ArcGIS Extensions API.
3
3
  */
4
- export declare const version = "54.14.5";
4
+ export declare const version = "54.14.6";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const version="54.14.5";
1
+ export const version="54.14.6";