@vertigis/arcgis-extensions 48.2.0 → 48.2.2

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.
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = &quot;48.2.0&quot;</span></div><div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = &quot;48.2.2&quot;</span></div><div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
2
2
  </div><div class="tsd-comment tsd-typography"></div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@vertigis/arcgis-extensions</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
@@ -1 +1 @@
1
- import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as s}from"../Entity.js";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{isBasemapExtension as n,isBookmark as o,isGroundExtension as r,isLayerPreset as p,isMenu as h,isTableExtension as m,ItemType as l}from"../ItemType.js";import{TableExtension as d}from"../data/TableExtension.js";import{layerToParentJsonCache as c}from"../json/LayerJson.js";import{applyJsonToWebMap as b}from"../json/WebMapJson.js";import{applyJsonToWebScene as _}from"../json/WebSceneJson.js";import{LayerPreset as u}from"../layer-preset/LayerPreset.js";import{Menu as w}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as E}from"../support/ArcGISRequestHelper.js";import{FormatSettings as f}from"../support/FormatSettings.js";import{InitializableCollectionProxy as x}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as y}from"../support/ReadOnlyInitializableCollection.js";import{serializable as M}from"../support/Serializable.js";import{WellKnownBasemap as g}from"../support/esri.js";import{ReadOnlyCollection as I}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent as v,createStandardBasemap as S,getStandardBasemapId as z,isStandardBasemap as O}from"../utilities/basemaps.js";import{checkArg as A}from"../utilities/checkArg.js";import{compare as P}from"../utilities/collection.js";import{load as T}from"../utilities/esri.js";import{isGroupLayerExtension as C}from"../utilities/extensions.js";import{filter as V}from"../utilities/iterable.js";import{isWMTSLayer as k,layersAreEquivalent as j}from"../utilities/layers.js";import{getLogger as B}from"../utilities/log.js";import{getMapSpatialReference as L,isMap as N,isWebMap as R,isWebScene as W}from"../utilities/mapping.js";import{toPortalItem as H}from"../utilities/portal.js";import{parallelEach as J}from"../utilities/promise.js";import{onCollectionPropertyChange as F,onEach as q}from"../utilities/watch.js";import{BasemapExtension as G}from"./BasemapExtension.js";import{Bookmark as D}from"./Bookmark.js";import{GroundExtension as U}from"./GroundExtension.js";import{MapConstraints as $}from"./MapConstraints.js";import{UnsupportedLayerExtension as X}from"./UnsupportedLayerExtension.js";import{_assignLayerExtensions as Y}from"./_LayerExtension.js";import{LayerExtensionCollectionImpl as K}from"./_LayerExtensionCollectionImpl.js";const Q=B("MapExtension");let Z=class extends s{get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?W(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":W(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new E),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 a("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=U.create({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new a("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=p(e)?e:new u(e);this._initialLayerPreset=t}get _spatialReference(){return L(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&&Q.error({message:"An error occurred while initializing context menu.",error:e})}})()}isSwitchingMap=!1;_layerViews=new t;get _allLayerViews(){const e=i=>{const s=[i];return t.isCollection(i.sublayerViews)?s.push(...i.sublayerViews.toArray().flatMap(e)):t.isCollection(i.layerViews)&&s.push(...i.layerViews.toArray().flatMap(e)),s};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}tableExtensions;allLayerExtensions;_itemType=l.MAP_EXTENSION;_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(e){super(e);let s={...e};this._basemapOptions=new ee(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new t,this.constraints=new $,this.watch(["_map","_scene"],(e=>{e&&(q(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),q(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:a,webScene:n,initialViewMode:o,map:r,basemapOptions:p}=s;if(this._webMap=a,this._webScene=n,this._webMapItem=se(a),this._webSceneItem=se(n),this.initialViewMode=o,W(r)&&n)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(N(r)&&a)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(W(r)||R(r)||N(r))this.assignProperties({basemapOptions:p}),this._skipBasemapOptions=!!p;else{const{layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n,...o}=s;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n},s=o,a&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(s),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new ie(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 instanceof X||!e.dynamicallyAddedLayer))}getAllFeatureSources(e=()=>!0){const t=[],i=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())s(t);if(C(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())i(t)},s=i=>{t.push(i);for(const t of i.sublayerExtensions.initializedItems.filter(e).toArray())s(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())i(t);for(const i of this.tableExtensions.initializedItems.filter(e).toArray())t.push(i);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())i(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())i(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(A("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),t.basemap=this.map.basemap,await this.switchMap(t),this.notifyChange("viewMode"),this.notifyChange("title")}async switchMap(e){if(A("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await oe(e);const t=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:s}=this;this._setMap(e),this._updateBookmarks();const a=[];for(const e of this.map.layers.toArray()){const i=[...V(t.entries(),(([t])=>j(t,e)))];if(1===i.length){const[t]=i;a.push((async()=>{const i=t[1];await i._switchLayer(e),this._layerExtensions._register(i)})())}else{const t=this._layerExtensions._forLayer(e);t&&t.layer!==e&&a.push(t._switchLayer(e))}}for(const e of this.map.tables.toArray()){const t=[...V(i.entries(),(([t])=>j(t,e)))];if(1===t.length){const[i]=t;a.push((async()=>{const t=i[1];await t._switchTable(e),this.tableExtensions.add(t)})())}else{const t=this.tableExtensions.forTable(e);t&&t.table!==e&&a.push(t._switchTable(e))}}this.map.basemap&&s&&v(this.map.basemap,s.basemap)&&a.push((async()=>{await s._switchBasemap(this.map.basemap),this.basemapExtension=s})()),await Promise.all(a),this.isInitialized&&await this._initializeChildren(),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new a("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=se(e),await T(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.notifyChange("webMap"),this.notifyChange("initialViewMode"),this.notifyChange("title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new a("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=se(e),await T(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.notifyChange("webScene"),this.notifyChange("initialViewMode"),this.notifyChange("title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;ae(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;ae(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,i=(t?this._scene:this._map)?.layers.toArray()??[],s=e.filter((e=>!i.includes(e.layer)&&!i.some((t=>e.layer&&j(t,e.layer)))));Y(this.layerExtensions,s)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,i=(t?this._map:this._scene)?.layers.toArray();let s=(t?this._scene:this._map)?.layers.toArray()??[];return s=s.filter((e=>!i.find((t=>j(t,e))))),this.layerExtensions.concat(s.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>!(t instanceof X||"initial"===e)||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?P(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(m(e)?e:d.create(e),t)},onMatch:(e,t,i,s)=>{m(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>m(t)?t===e:!!d._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(n(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=G.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:(P(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(n(e)?e:G.create(e),t)},onMatch:(e,t,i,s)=>{n(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(n(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return v(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&J(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(!r(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=>o(e)?e:new D(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?h(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=w.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>{c.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 c.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(N(e)||R(e)||W(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,i){await J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>v(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),W(t)?await _(s,t,i):await b(s,t,i)}_createFormatSettings(){return new f}_createLayerExtensionCollection(){return new K(this)}_createTableExtensionCollection(){return new te(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:i,webScene:s,...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([oe(this.map),T(this._webMapItem),T(this._webSceneItem)]),ne(this._webMapItem,"webMap","Web Map"),ne(this._webSceneItem,"webScene","Web Scene")):await oe(this.map),t&&(!n(t)&&t.basemap?this.basemapExtension=G.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find((e=>n(e)&&v(this.map.basemap,e.toJSON().basemap)));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,i=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),i&&(this.map.basemap.title=i)}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 J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new t(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>this.layerExtensions.remove(e);const i=new t(this.tableExtensions.filter((e=>!!e.table)));if(i.remove=e=>this.tableExtensions.remove(e),yield e,yield i,this.basemapExtension){const e=new t;e.add(this.basemapExtension),yield e}const s=new t;s.add(this.groundExtension),yield s}_initMapFromProperties(e){const t=e.map;N(t)||R(t)||W(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!ae(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!ae(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){W(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),this.notifyChange("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=G.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0))}e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;this.notifyChange("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));this.groundExtension._setMapExtension(void 0)}this.map.ground&&!this._groundExtensions.has(this.map.ground)&&this._groundExtensions.set(this.map.ground,U.create({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e&&e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this.notifyChange("groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e?.isWebMercator&&await J([g.SATELLITE,g.HYBRID_VECTOR,g.STREETS_VECTOR,g.TOPO_VECTOR,g.STREETS_NAVIGATION_VECTOR,g.STREETS_NIGHT_VECTOR,g.TERRAIN_VECTOR,g.DARK_GRAY_VECTOR,g.GRAY_VECTOR,g.OCEANS_VECTOR,g.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await S(e);v(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(G.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)}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),R(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach((e=>{this.bookmarks.add(new D({source:"map",title:e.name,viewpoint:e.viewpoint}))})):W(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},i=new D(t);this.bookmarks.add(i)}))}};Z=e([M],Z);export{Z as MapExtension};class ee extends x{isExplicitlyModified=!1;_mapExtension;constructor(e){super(new t),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,i=!0){const s=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>s(e.basemap?.id)===t)),O(e.basemap)&&a>=0){if(!i)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 te extends x{get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new I(new t)}_mapExtension;_tableExtensionMap=new WeakMap;_uninitializedTableExtensions=new Set;constructor(e){super(),this._mapExtension=e,F(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)})),this._mapExtension.watch("map.tables.length",(()=>this.notifyChange("length")))}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new te(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return A("id",e).isNotMissing(),this.find((t=>t._tableId===e))}forTable(e){if(A("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(A("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const i=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),i&&i!==e&&this._onRemoved(i),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:i?[i]:[],target:this};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("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("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,i)=>e(this._forTable(t),this._forTable(i)))),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=d.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class ie extends y{get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>C(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;constructor(e){super(),this._mapExtension=e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return A("id",e).isNotMissing(),this.find((t=>t._layerId===e))}forLayer(e){return A("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,i){if("change"===e){const s=new t;s.addMany(i.added);const a=s.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),n=new t;n.addMany(i.removed);const o=n.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),r=new t;r.addMany(i.moved);const p=r.flatten((e=>C(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:a,removed:o,moved:p,target:this})}return super.emit(e,i)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function se(e){if("object"!=typeof e||!e?.baseMap)return H(e)}function ae(e){return"object"!=typeof e||e&&!e.baseMap}function ne(e,t,i){if(e?.type&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function oe(e){await T(e),e.basemap&&(await T(e.basemap),e.basemap.baseLayers.filter((e=>k(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=z(e.basemap)??e.basemap.id)}
1
+ import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{EntityBase as s}from"../Entity.js";import{InvalidOperationError as a}from"../InvalidOperationError.js";import{isBasemapExtension as n,isBookmark as o,isGroundExtension as r,isLayerPreset as p,isMenu as h,isTableExtension as m,ItemType as l}from"../ItemType.js";import{TableExtension as d}from"../data/TableExtension.js";import{layerToParentJsonCache as c}from"../json/LayerJson.js";import{applyJsonToWebMap as b}from"../json/WebMapJson.js";import{applyJsonToWebScene as _}from"../json/WebSceneJson.js";import{LayerPreset as u}from"../layer-preset/LayerPreset.js";import{Menu as w}from"../menus/Menu.js";import{DefaultArcGISRequestHelper as E}from"../support/ArcGISRequestHelper.js";import{FormatSettings as f}from"../support/FormatSettings.js";import{InitializableCollectionProxy as x}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection as y}from"../support/ReadOnlyInitializableCollection.js";import{serializable as M}from"../support/Serializable.js";import{WellKnownBasemap as g}from"../support/esri.js";import{ReadOnlyCollection as I}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent as v,createStandardBasemap as S,getStandardBasemapId as z,isStandardBasemap as O}from"../utilities/basemaps.js";import{checkArg as A}from"../utilities/checkArg.js";import{compare as P}from"../utilities/collection.js";import{load as T}from"../utilities/esri.js";import{isGroupLayerExtension as C}from"../utilities/extensions.js";import{filter as V}from"../utilities/iterable.js";import{isWMTSLayer as k,layersAreEquivalent as j}from"../utilities/layers.js";import{getLogger as B}from"../utilities/log.js";import{getMapSpatialReference as L,isMap as N,isWebMap as R,isWebScene as W}from"../utilities/mapping.js";import{toPortalItem as H}from"../utilities/portal.js";import{parallelEach as J}from"../utilities/promise.js";import{onCollectionPropertyChange as F,onEach as q}from"../utilities/watch.js";import{BasemapExtension as G}from"./BasemapExtension.js";import{Bookmark as D}from"./Bookmark.js";import{GroundExtension as U}from"./GroundExtension.js";import{MapConstraints as $}from"./MapConstraints.js";import{UnsupportedLayerExtension as X}from"./UnsupportedLayerExtension.js";import{_assignLayerExtensions as Y}from"./_LayerExtension.js";import{LayerExtensionCollectionImpl as K}from"./_LayerExtensionCollectionImpl.js";const Q=B("MapExtension");let Z=class extends s{get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?W(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":W(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new E),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 a("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=U.create({ground:this.map?.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new a("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=p(e)?e:new u(e);this._initialLayerPreset=t}get _spatialReference(){return L(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&&Q.error({message:"An error occurred while initializing context menu.",error:e})}})()}isSwitchingMap=!1;_layerViews=new t;get _allLayerViews(){const e=i=>{const s=[i];return t.isCollection(i.sublayerViews)?s.push(...i.sublayerViews.toArray().flatMap(e)):t.isCollection(i.layerViews)&&s.push(...i.layerViews.toArray().flatMap(e)),s};return this._layerViews.toArray().flatMap(e)}get layerExtensions(){return this._layerExtensions}tableExtensions;allLayerExtensions;_itemType=l.MAP_EXTENSION;_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(e){super(e);let s={...e};this._basemapOptions=new ee(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new t,this.constraints=new $,this.watch(["_map","_scene"],(e=>{e&&(q(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),q(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:a,webScene:n,initialViewMode:o,map:r,basemapOptions:p}=s;if(this._webMap=a,this._webScene=n,this._webMapItem=se(a),this._webSceneItem=se(n),this.initialViewMode=o,W(r)&&n)throw new i("Cannot specify webScene property if map is initialized to a WebScene instance.");if(N(r)&&a)throw new i("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(W(r)||R(r)||N(r))this.assignProperties({basemapOptions:p}),this._skipBasemapOptions=!!p;else{const{layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n,...o}=s;this._deferredProperties={layerExtensions:e,tableExtensions:t,groundExtension:i,basemapOptions:a,basemapExtension:n},s=o,a&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(s),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new ie(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 instanceof X||!e.dynamicallyAddedLayer))}getAllFeatureSources(e=()=>!0){const t=[],i=a=>{a.hasFeatures&&t.push(a);for(const t of a.sublayerExtensions.initializedItems.filter(e).toArray())s(t);if(C(a))for(const t of a.layerExtensions.initializedItems.filter(e).toArray())i(t)},s=i=>{t.push(i);for(const t of i.sublayerExtensions.initializedItems.filter(e).toArray())s(t)};for(const t of this.layerExtensions.initializedItems.filter(e).toArray())i(t);for(const i of this.tableExtensions.initializedItems.filter(e).toArray())t.push(i);if(this.basemapExtension){for(const t of this.basemapExtension.baseLayerExtensions.initializedItems.filter(e).toArray())i(t);for(const t of this.basemapExtension.referenceLayerExtensions.initializedItems.filter(e).toArray())i(t)}return t}isSupportedViewMode(e){return e===this.viewMode||!(!this.webMap&&!this.webScene)&&("scene"===e?!!this.webScene:!!this.webMap)}async switchViewMode(e){if(A("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),t.basemap=this.map?.basemap,await this.switchMap(t),this.notifyChange("viewMode"),this.notifyChange("title")}async switchMap(e){if(A("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await oe(e);const t=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:s}=this;this._setMap(e),this._updateBookmarks();const a=[];for(const e of this.map.layers.toArray()){const i=[...V(t.entries(),(([t])=>j(t,e)))];if(1===i.length){const[t]=i;a.push((async()=>{const i=t[1];await i._switchLayer(e),this._layerExtensions._register(i)})())}else{const t=this._layerExtensions._forLayer(e);t&&t.layer!==e&&a.push(t._switchLayer(e))}}for(const e of this.map.tables.toArray()){const t=[...V(i.entries(),(([t])=>j(t,e)))];if(1===t.length){const[i]=t;a.push((async()=>{const t=i[1];await t._switchTable(e),this.tableExtensions.add(t)})())}else{const t=this.tableExtensions.forTable(e);t&&t.table!==e&&a.push(t._switchTable(e))}}this.map.basemap&&s&&v(this.map.basemap,s.basemap)&&a.push((async()=>{await s._switchBasemap(this.map.basemap),this.basemapExtension=s})()),await Promise.all(a),this.isInitialized&&await this._initializeChildren(),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new a("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=se(e),await T(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.notifyChange("webMap"),this.notifyChange("initialViewMode"),this.notifyChange("title")}async setWebScene(e){if(!e&&this.webScene&&!this.webMap)throw new a("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=se(e),await T(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.notifyChange("webScene"),this.notifyChange("initialViewMode"),this.notifyChange("title")}getDefaults(){const e=super.getDefaults();return e.initialViewMode="map",e}async _createScene(){if(!this._scene&&this.webScene)return this._createScenePromise=this._createScenePromise??(async()=>{const e=(await import("@arcgis/core/WebScene")).default;ae(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;ae(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,i=(t?this._scene:this._map)?.layers.toArray()??[],s=e.filter((e=>!i.includes(e.layer)&&!i.some((t=>e.layer&&j(t,e.layer)))));Y(this.layerExtensions,s)}},serialize:e=>{if(this._deferredProperties?.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,i=(t?this._map:this._scene)?.layers.toArray();let s=(t?this._scene:this._map)?.layers.toArray()??[];return s=s.filter((e=>!i.find((t=>j(t,e))))),this.layerExtensions.concat(s.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>!(t instanceof X||"initial"===e)||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?P(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(m(e)?e:d.create(e),t)},onMatch:(e,t,i,s)=>{m(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>m(t)?t===e:!!d._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(n(e))this.basemapExtension=e;else{if(this.basemapExtension)return this.basemapExtension.assignPropertiesAsync(e);this.basemapExtension=G.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:(P(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(n(e)?e:G.create(e),t)},onMatch:(e,t,i,s)=>{n(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(n(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return v(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&J(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(!r(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=>o(e)?e:new D(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?h(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=w.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>{c.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 c.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(N(e)||R(e)||W(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,i){await J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>v(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),W(t)?await _(s,t,i):await b(s,t,i)}_createFormatSettings(){return new f}_createLayerExtensionCollection(){return new K(this)}_createTableExtensionCollection(){return new te(this)}async _onInitialize(){await super._onInitialize();const{basemapOptions:e,basemapExtension:t,webMap:i,webScene:s,...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([oe(this.map),T(this._webMapItem),T(this._webSceneItem)]),ne(this._webMapItem,"webMap","Web Map"),ne(this._webSceneItem,"webScene","Web Scene")):await oe(this.map),t&&(!n(t)&&t.basemap?this.basemapExtension=G.create(t):await this.assignPropertiesAsync({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),e){const t=e.find((e=>n(e)&&v(this.map.basemap,e.toJSON().basemap)));if(t){const e=t.toJSON().basemap?.id??t.basemap?.id,i=t.toJSON().basemap?.title;await t._switchBasemap(this.map.basemap),this.basemapExtension=t,e&&(this.map.basemap.id=e),i&&(this.map.basemap.title=i)}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 J(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new t(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>this.layerExtensions.remove(e);const i=new t(this.tableExtensions.filter((e=>!!e.table)));if(i.remove=e=>this.tableExtensions.remove(e),yield e,yield i,this.basemapExtension){const e=new t;e.add(this.basemapExtension),yield e}const s=new t;s.add(this.groundExtension),yield s}_initMapFromProperties(e){const t=e.map;N(t)||R(t)||W(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!ae(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!ae(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){W(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),this.notifyChange("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=G.create({basemap:this.map.basemap}),this._basemapOptions.addInternal(e,0))}e.mapExtension!==this&&e._setMapExtension(this),this._basemapExtension=e}else this._basemapExtension=void 0;this.notifyChange("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));this.groundExtension._setMapExtension(void 0)}this.map.ground&&!this._groundExtensions.has(this.map.ground)&&this._groundExtensions.set(this.map.ground,U.create({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e&&e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this.notifyChange("groundExtension")}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e?.isWebMercator&&await J([g.SATELLITE,g.HYBRID_VECTOR,g.STREETS_VECTOR,g.TOPO_VECTOR,g.STREETS_NAVIGATION_VECTOR,g.STREETS_NIGHT_VECTOR,g.TERRAIN_VECTOR,g.DARK_GRAY_VECTOR,g.GRAY_VECTOR,g.OCEANS_VECTOR,g.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await S(e);v(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(G.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)}_updateBookmarks(){this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),R(this.map)&&this.map.bookmarks?.length>0?this.map.bookmarks.forEach((e=>{this.bookmarks.add(new D({source:"map",title:e.name,viewpoint:e.viewpoint}))})):W(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},i=new D(t);this.bookmarks.add(i)}))}};Z=e([M],Z);export{Z as MapExtension};class ee extends x{isExplicitlyModified=!1;_mapExtension;constructor(e){super(new t),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,i=!0){const s=e=>{const t="-vector";return e?.endsWith(t)?e.substring(0,e.length-7):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>s(e.basemap?.id)===t)),O(e.basemap)&&a>=0){if(!i)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 te extends x{get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){return this._mapExtension.map?.tables??new I(new t)}_mapExtension;_tableExtensionMap=new WeakMap;_uninitializedTableExtensions=new Set;constructor(e){super(),this._mapExtension=e,F(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)})),this._mapExtension.watch("map.tables.length",(()=>this.notifyChange("length")))}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(l.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new te(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return A("id",e).isNotMissing(),this.find((t=>t._tableId===e))}forTable(e){if(A("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(A("tableX",e).isNotMissing(),e.mapExtension&&e.mapExtension.tableExtensions.remove(e),e._setMapExtension(this._mapExtension),e.table){const i=this._tableExtensionMap.get(e.table);if(this._tableExtensionMap.set(e.table,e),i&&i!==e&&this._onRemoved(i),this._tables.includes(e.table))if(void 0===t){const t={added:[e],moved:[],removed:i?[i]:[],target:this};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("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("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,i)=>e(this._forTable(t),this._forTable(i)))),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=d.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class ie extends y{get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>C(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;constructor(e){super(),this._mapExtension=e}findById(e){return A("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return A("id",e).isNotMissing(),this.find((t=>t._layerId===e))}forLayer(e){return A("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,i){if("change"===e){const s=new t;s.addMany(i.added);const a=s.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),n=new t;n.addMany(i.removed);const o=n.flatten((e=>C(e)?e.layerExtensions:[])).toArray(),r=new t;r.addMany(i.moved);const p=r.flatten((e=>C(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:a,removed:o,moved:p,target:this})}return super.emit(e,i)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function se(e){if("object"!=typeof e||!e?.baseMap)return H(e)}function ae(e){return"object"!=typeof e||e&&!e.baseMap}function ne(e,t,i){if(e?.type&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}async function oe(e){await T(e),e.basemap&&(await T(e.basemap),e.basemap.baseLayers.filter((e=>k(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=z(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": "48.2.0",
4
+ "version": "48.2.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://dev.azure.com/vertigis/Studio/_git/arcgis-extensions-ts"
@@ -112,7 +112,7 @@
112
112
  "whatwg-fetch": "3.6.20"
113
113
  },
114
114
  "peerDependencies": {
115
- "@arcgis/core": "4.31.2",
115
+ "@arcgis/core": "4.31.6",
116
116
  "tslib": "^2.6.2"
117
117
  },
118
118
  "overrides": {
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 = "48.2.0";
4
+ export declare const version = "48.2.2";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const version="48.2.0";
1
+ export const version="48.2.2";