@vertigis/arcgis-extensions 34.0.0 → 34.0.1

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.
@@ -1173,7 +1173,7 @@
1173
1173
  <li class="tsd-description">
1174
1174
  <aside class="tsd-sources">
1175
1175
  <ul>
1176
- <li>Defined in src/mapping/MapExtension.ts:1445</li>
1176
+ <li>Defined in src/mapping/MapExtension.ts:1460</li>
1177
1177
  </ul>
1178
1178
  </aside>
1179
1179
  <div class="tsd-comment tsd-typography">
@@ -1218,7 +1218,7 @@
1218
1218
  <li class="tsd-description">
1219
1219
  <aside class="tsd-sources">
1220
1220
  <ul>
1221
- <li>Defined in src/mapping/MapExtension.ts:1483</li>
1221
+ <li>Defined in src/mapping/MapExtension.ts:1498</li>
1222
1222
  </ul>
1223
1223
  </aside>
1224
1224
  <div class="tsd-comment tsd-typography">
@@ -1240,7 +1240,7 @@
1240
1240
  <li class="tsd-description">
1241
1241
  <aside class="tsd-sources">
1242
1242
  <ul>
1243
- <li>Defined in src/mapping/MapExtension.ts:1490</li>
1243
+ <li>Defined in src/mapping/MapExtension.ts:1505</li>
1244
1244
  </ul>
1245
1245
  </aside>
1246
1246
  <div class="tsd-comment tsd-typography">
@@ -1262,7 +1262,7 @@
1262
1262
  <li class="tsd-description">
1263
1263
  <aside class="tsd-sources">
1264
1264
  <ul>
1265
- <li>Defined in src/mapping/MapExtension.ts:1056</li>
1265
+ <li>Defined in src/mapping/MapExtension.ts:1065</li>
1266
1266
  </ul>
1267
1267
  </aside>
1268
1268
  <div class="tsd-comment tsd-typography">
@@ -1284,7 +1284,7 @@
1284
1284
  <li class="tsd-description">
1285
1285
  <aside class="tsd-sources">
1286
1286
  <ul>
1287
- <li>Defined in src/mapping/MapExtension.ts:1032</li>
1287
+ <li>Defined in src/mapping/MapExtension.ts:1041</li>
1288
1288
  </ul>
1289
1289
  </aside>
1290
1290
  <div class="tsd-comment tsd-typography">
@@ -1306,7 +1306,7 @@
1306
1306
  <li class="tsd-description">
1307
1307
  <aside class="tsd-sources">
1308
1308
  <ul>
1309
- <li>Defined in src/mapping/MapExtension.ts:1497</li>
1309
+ <li>Defined in src/mapping/MapExtension.ts:1512</li>
1310
1310
  </ul>
1311
1311
  </aside>
1312
1312
  <div class="tsd-comment tsd-typography">
@@ -1329,7 +1329,7 @@
1329
1329
  <aside class="tsd-sources">
1330
1330
  <p>Overrides <a href="entity.entitybase.html">EntityBase</a>.<a href="entity.entitybase.html#_getserializableproperties">_getSerializableProperties</a></p>
1331
1331
  <ul>
1332
- <li>Defined in src/mapping/MapExtension.ts:1078</li>
1332
+ <li>Defined in src/mapping/MapExtension.ts:1087</li>
1333
1333
  </ul>
1334
1334
  </aside>
1335
1335
  <div class="tsd-comment tsd-typography">
@@ -1353,7 +1353,7 @@
1353
1353
  <aside class="tsd-sources">
1354
1354
  <p>Overrides <a href="entity.entitybase.html">EntityBase</a>.<a href="entity.entitybase.html#_initializablechildcollections">_initializableChildCollections</a></p>
1355
1355
  <ul>
1356
- <li>Defined in src/mapping/MapExtension.ts:1609</li>
1356
+ <li>Defined in src/mapping/MapExtension.ts:1624</li>
1357
1357
  </ul>
1358
1358
  </aside>
1359
1359
  <div class="tsd-comment tsd-typography">
@@ -1462,7 +1462,7 @@
1462
1462
  <aside class="tsd-sources">
1463
1463
  <p>Overrides <a href="entity.entitybase.html">EntityBase</a>.<a href="entity.entitybase.html#_oninitialize">_onInitialize</a></p>
1464
1464
  <ul>
1465
- <li>Defined in src/mapping/MapExtension.ts:1504</li>
1465
+ <li>Defined in src/mapping/MapExtension.ts:1519</li>
1466
1466
  </ul>
1467
1467
  </aside>
1468
1468
  <div class="tsd-comment tsd-typography">
@@ -1486,7 +1486,7 @@
1486
1486
  <aside class="tsd-sources">
1487
1487
  <p>Overrides <a href="entity.entitybase.html">EntityBase</a>.<a href="entity.entitybase.html#_postinitialize">_postInitialize</a></p>
1488
1488
  <ul>
1489
- <li>Defined in src/mapping/MapExtension.ts:1593</li>
1489
+ <li>Defined in src/mapping/MapExtension.ts:1608</li>
1490
1490
  </ul>
1491
1491
  </aside>
1492
1492
  <div class="tsd-comment tsd-typography">
@@ -1812,7 +1812,7 @@
1812
1812
  <aside class="tsd-sources">
1813
1813
  <p>Overrides <a href="entity.entitybase.html">EntityBase</a>.<a href="entity.entitybase.html#getdefaults">getDefaults</a></p>
1814
1814
  <ul>
1815
- <li>Defined in src/mapping/MapExtension.ts:1019</li>
1815
+ <li>Defined in src/mapping/MapExtension.ts:1028</li>
1816
1816
  </ul>
1817
1817
  </aside>
1818
1818
  <div class="tsd-comment tsd-typography">
@@ -2051,7 +2051,7 @@
2051
2051
  <li class="tsd-description">
2052
2052
  <aside class="tsd-sources">
2053
2053
  <ul>
2054
- <li>Defined in src/mapping/MapExtension.ts:954</li>
2054
+ <li>Defined in src/mapping/MapExtension.ts:963</li>
2055
2055
  </ul>
2056
2056
  </aside>
2057
2057
  <div class="tsd-comment tsd-typography">
@@ -2082,7 +2082,7 @@
2082
2082
  <li class="tsd-description">
2083
2083
  <aside class="tsd-sources">
2084
2084
  <ul>
2085
- <li>Defined in src/mapping/MapExtension.ts:988</li>
2085
+ <li>Defined in src/mapping/MapExtension.ts:997</li>
2086
2086
  </ul>
2087
2087
  </aside>
2088
2088
  <div class="tsd-comment tsd-typography">
@@ -101,7 +101,7 @@
101
101
  <div class="tsd-signature tsd-kind-icon">Feature<wbr>Source<wbr>Predicate<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span>source<span class="tsd-signature-symbol">: </span><a href="../interfaces/data_featuresource.featuresource.html" class="tsd-signature-type" data-tsd-kind="Interface">FeatureSource</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">boolean</span></div>
102
102
  <aside class="tsd-sources">
103
103
  <ul>
104
- <li>Defined in src/mapping/MapExtension.ts:2588</li>
104
+ <li>Defined in src/mapping/MapExtension.ts:2603</li>
105
105
  </ul>
106
106
  </aside>
107
107
  <div class="tsd-comment tsd-typography">
@@ -81,7 +81,7 @@
81
81
  <section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
82
82
  <a name="version-1" class="tsd-anchor"></a>
83
83
  <h3><span class="tsd-flag ts-flagConst">Const</span> version</h3>
84
- <div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;34.0.0&quot;</span><span class="tsd-signature-symbol"> = &quot;34.0.0&quot;</span></div>
84
+ <div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;34.0.1&quot;</span><span class="tsd-signature-symbol"> = &quot;34.0.1&quot;</span></div>
85
85
  <aside class="tsd-sources">
86
86
  <ul>
87
87
  <li>Defined in src/version.ts:4</li>
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import EsriViewpoint from"@arcgis/core/Viewpoint";import{ArgumentError}from"../ArgumentError.js";import{EntityBase}from"../Entity.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{isBasemapExtension,isBookmark,isGroundExtension,isLayerPreset,isMenu,isTableExtension,ItemType}from"../ItemType.js";import{TableExtension}from"../data/TableExtension.js";import{LayerPreset}from"../layer-preset/LayerPreset.js";import{Menu}from"../menus/Menu.js";import{toEsriApiGeometry}from"../portal/Geometry.js";import{WebMap as WebMapJson}from"../portal/WebMap.js";import{WebScene as WebSceneJson}from"../portal/WebScene.js";import{resolveRelativeHrefs}from"../portal/_utils.js";import{DefaultArcGISRequestHelper}from"../support/ArcGISRequestHelper.js";import{FormatSettings}from"../support/FormatSettings.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection}from"../support/ReadOnlyInitializableCollection.js";import{serializable}from"../support/Serializable.js";import{WellKnownBasemap}from"../support/esri.js";import{ReadOnlyCollection}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent,createStandardBasemap,isStandardBasemap}from"../utilities/basemaps.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{isGroupLayerExtension}from"../utilities/extensions.js";import{project}from"../utilities/geometry.js";import{find}from"../utilities/iterable.js";import{layersAreEquivalent}from"../utilities/layers.js";import{getLogger}from"../utilities/log.js";import{getMapSpatialReference,isMap,isWebMap,isWebScene}from"../utilities/mapping.js";import{toPortalItem as toPortalItemBase}from"../utilities/portal.js";import{parallelEach}from"../utilities/promise.js";import{onCollectionPropertyChange,onEach}from"../utilities/watch.js";import{BasemapExtension}from"./BasemapExtension.js";import{Bookmark}from"./Bookmark.js";import{GroundExtension}from"./GroundExtension.js";import{MapConstraints}from"./MapConstraints.js";import{_assignLayerExtensions,LayerExtension}from"./_LayerExtension.js";import{LayerExtensionCollectionBase}from"./support/_LayerExtensionCollection.js";const log=getLogger("MapExtension");let MapExtension=class extends EntityBase{constructor(e){var t;super(e),this.isSwitchingMap=!1,this._layerViews=new Collection,this._itemType=ItemType.MAP_EXTENSION,this._skipBasemapOptions=!1;let i={...e};this._basemapOptions=new BasemapExtensionCollection(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new Collection,this.constraints=new MapConstraints,this.watch(["_map","_scene"],(e=>{e&&(onEach(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),onEach(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:s,webScene:a,initialViewMode:n,map:o,basemapOptions:r}=i;if(this._webMap=s,this._webScene=a,this._webMapItem=toPortalItem(s),this._webSceneItem=toPortalItem(a),this.initialViewMode=n,isWebScene(o)&&a)throw new ArgumentError("Cannot specify webScene property if map is initialized to a WebScene instance.");if(isMap(o)&&s)throw new ArgumentError("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(isWebScene(o)||isWebMap(o)||isMap(o))this.assignProperties({basemapOptions:r}),this._skipBasemapOptions=!!r;else{const{map:e,layerExtensions:t,tableExtensions:s,groundExtension:a,basemapOptions:n,basemapExtension:o,...r}=i;this._deferredProperties={map:e,layerExtensions:t,tableExtensions:s,groundExtension:a,basemapOptions:n,basemapExtension:o},i=r,n&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(i),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new AllLayerExtensionCollectionImpl(this),(null===(t=this.map)||void 0===t?void 0:t.basemap)&&this._onBasemapChange()}get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?isWebScene(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":isWebScene(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),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 InvalidOperationError("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(){var e;return this._groundExtension||(this.groundExtension=new GroundExtension({ground:null===(e=this.map)||void 0===e?void 0:e.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new InvalidOperationError("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=isLayerPreset(e)?e:new LayerPreset(e);this._initialLayerPreset=t}get _spatialReference(){return getMapSpatialReference(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}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&&log.error({message:"An error occurred while initializing context menu.",error:e})}})()}get layerExtensions(){return this._layerExtensions}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(isGroupLayerExtension(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(checkArg("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(checkArg("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await load(e);const t=new Map;this.map.layers.forEach((e=>t.set(e,this.layerExtensions.forLayer(e))));const{basemapExtension:i}=this;this._setMap(e),this._updateBookmarks();const s=[];for(const e of this.map.layers.toArray()){const i=find(t.entries(),(([t])=>layersAreEquivalent(t,e)));i&&s.push((async()=>{const t=i[1];await t._switchLayer(e),this._layerExtensions._register(t)})())}this.map.basemap&&i&&basemapsAreEquivalent(this.map.basemap,i.basemap)&&s.push((async()=>{await i._switchBasemap(this.map.basemap),this.basemapExtension=i})()),this.isInitialized&&s.push(this._initializeChildren()),await Promise.all(s),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new InvalidOperationError("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=toPortalItem(e),await load(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 InvalidOperationError("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=toPortalItem(e),await load(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(){var e;if(!this._scene&&this.webScene)return this._createScenePromise=null!==(e=this._createScenePromise)&&void 0!==e?e:(async()=>{if(isPortalItem(this.webScene)){const e=new((await import("@arcgis/core/WebScene")).default);await this._loadAndApplyPortalItemData(this._webSceneItem,e),this._scene=e}else this._scene=await WebSceneJson.toEsriApiWebScene(this.webScene)})()}async _createMap(){var e;if(!this._map&&this.webMap)return this._createMapPromise=null!==(e=this._createMapPromise)&&void 0!==e?e:(async()=>{if(isPortalItem(this.webMap)){const e=new((await import("@arcgis/core/WebMap")).default);await this._loadAndApplyPortalItemData(this._webMapItem,e),this._map=e}else this._map=await WebMapJson.toEsriApiWebMap(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{var t,i;if(this.map&&e){const s=null!==(i=null===(t="map"===this.viewMode?this._scene:this._map)||void 0===t?void 0:t.layers.toArray())&&void 0!==i?i:[],a=e.filter((e=>!s.includes(e.layer)&&!s.some((t=>LayerExtension._matchesRef(t,e.layer)))));_assignLayerExtensions(this.layerExtensions,a)}},serialize:e=>{var t,i,s,a;if(null===(t=this._deferredProperties)||void 0===t?void 0:t.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,n=null===(i=t?this._map:this._scene)||void 0===i?void 0:i.layers.toArray();let o=null!==(a=null===(s=t?this._scene:this._map)||void 0===s?void 0:s.layers.toArray())&&void 0!==a?a:[];return o=o.filter((e=>!n.find((t=>layersAreEquivalent(t,e))))),this.layerExtensions.concat(o.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>"initial"!==e||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?compare(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(isTableExtension(e)?e:TableExtension.create(e),t)},onMatch:(e,t,i,s)=>{isTableExtension(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>isTableExtension(t)?t===e:!!TableExtension._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.tableExtensions)?null===(t=this._deferredProperties)||void 0===t?void 0:t.tableExtensions:this.tableExtensions.toArray()}},basemapExtension:{serializeModes:["project"],deserialize:e=>{this.map?e?isBasemapExtension(e)?this.basemapExtension=e:this.basemapExtension?this.basemapExtension.assignProperties(e):this.basemapExtension=BasemapExtension.create(e):this.basemapExtension=void 0:this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.basemapExtension)?null===(t=this._deferredProperties)||void 0===t?void 0:t.basemapExtension:this.basemapExtension}},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(compare(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(isBasemapExtension(e)?e:BasemapExtension.create(e),t)},onMatch:(e,t,i,s)=>{isBasemapExtension(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(isBasemapExtension(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return basemapsAreEquivalent(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())))},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.basemapOptions)?null===(t=this._deferredProperties)||void 0===t?void 0:t.basemapOptions:this.basemapOptions.toArray()}},groundExtension:{serializeModes:["initial"],deserialize:e=>{this.map?isGroundExtension(e)?this.groundExtension=e:this.groundExtension.assignProperties(e):this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.groundExtension)?null===(t=this._deferredProperties)||void 0===t?void 0:t.groundExtension:this.groundExtension}},bookmarks:{serialize:()=>this.bookmarks.map((e=>e.toJSON())).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map((e=>isBookmark(e)?e:new Bookmark(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?isMenu(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=Menu.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>({operationalLayers:this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON())),tables:this.tableExtensions.toArray().filter((e=>e.table)).map((e=>({id:e.table.id,title:e.table.title})))}),deserialize:e=>{if(this.map)if(isMap(e)||isWebMap(e)||isWebScene(e)){if(e!==this.map)throw new ArgumentError("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})();else this._deferredProperties={...this._deferredProperties,map:e}}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,i){await parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>basemapsAreEquivalent(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),isWebScene(t)?await WebSceneJson.applyToEsriApiWebScene(s,t,i):await WebMapJson.applyToEsriApiMap(s,t,i)}_createFormatSettings(){return new FormatSettings}_createLayerExtensionCollection(){return new LayerExtensionCollectionImpl(this)}_createTableExtensionCollection(){return new TableExtensionCollectionImpl(this)}async _onInitialize(){var e;await super._onInitialize();const{basemapExtension:t,basemapOptions:i,groundExtension:s,webMap:a,webScene:n,map:o,...r}=null!==(e=this._deferredProperties)&&void 0!==e?e:{};if(i&&this.assignProperties({basemapOptions:i}),this.map||("scene"===this.initialViewMode?this._setMap(new((await import("@arcgis/core/WebScene")).default)):this._setMap(new((await import("@arcgis/core/WebMap")).default))),this.map.basemap&&this._onBasemapChange(),(a||n)&&await this._applyMapProperties("scene"===this.initialViewMode?n:a,this.map),t&&(this.assignProperties({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),s&&this.assignProperties({groundExtension:s}),this._webMapItem||this._webSceneItem){await Promise.all([load(this.map),load(this._webMapItem),load(this._webSceneItem)]),validatePortalItem(this._webMapItem,"webMap","Web Map"),validatePortalItem(this._webSceneItem,"webScene","Web Scene");const e=isWebScene(this.map)?this._webSceneItem:this._webMapItem;await this._loadAndApplyPortalItemData(e)}else await load(this.map);o&&await this._applyMapProperties(o,this.map),this.assignProperties(r),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks(),this.contextMenu&&await this.contextMenu.initialize();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 parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new Collection(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>{this.layerExtensions.remove(e)};const t=new Collection(this.tableExtensions.filter((e=>!!e.table)));if(t.remove=e=>{this.tableExtensions.remove(e)},yield e,yield t,this.basemapExtension){const e=new Collection;e.add(this.basemapExtension),yield e}const i=new Collection;i.add(this.groundExtension),yield i}_initMapFromProperties(e){const t=e.map;isMap(t)||isWebMap(t)||isWebScene(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!isPortalItem(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!isPortalItem(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){var t,i;isWebScene(e)?this._scene=e:this._map=e,this._currentMap=e,(null===(t=this.basemapExtension)||void 0===t?void 0:t.basemap)&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),(null===(i=this.groundExtension)||void 0===i?void 0:i.ground)&&!e.ground&&(e.ground=this.groundExtension.ground),this._notifyChange("map")}async _loadAndApplyPortalItemData(e,t){var i;await load(e);const s=await e.fetchData();resolveRelativeHrefs(s,e),await this._inferLayerTypes(s),(null===(i=this.basemapExtension)||void 0===i?void 0:i.basemap)&&!t&&delete s.baseMap,GroundExtension.isDefaultGround(this.groundExtension.ground)||t||delete s.ground;const a=t||this.map;await load(a),await this._applyMapProperties(s,a,e),a.portalItem=e;const{viewpoint:n,spatialReference:o}=a.initialViewProperties;n&&n.targetGeometry&&!n.targetGeometry.spatialReference.equals(o)&&(a.initialViewProperties.viewpoint.targetGeometry=(await project([n.targetGeometry],o))[0]),n&&n.camera&&(n.camera.position.spatialReference=o.clone())}_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=>e.basemap===this.map.basemap));e||(e=BasemapExtension.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.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._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,new GroundExtension({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this._notifyChange("groundExtension")}async _inferLayerTypes(e){var t;const i=[];if(e.operationalLayers)for(const t of e.operationalLayers)i.push(this._inferLayerType(t));if(e.baseMap&&i.push(this._inferBasemapLayerTypes(e.baseMap)),e.hasOwnProperty("ground")&&i.push(this._inferGroundLayerTypes(e.ground)),null===(t=e.presentation)||void 0===t?void 0:t.slides)for(const t of e.presentation.slides)t.baseMap&&"string"!=typeof t.baseMap&&i.push(this._inferBasemapLayerTypes(t.baseMap));await Promise.all(i)}async _inferBasemapLayerTypes(e){const t=[];if(e.baseMapLayers)for(const i of e.baseMapLayers)t.push(this._inferLayerType(i));await Promise.all(t)}async _inferGroundLayerTypes(e){const t=[];if(e.layers)for(const i of e.layers)t.push(this._inferLayerType(i));await Promise.all(t)}async _inferLayerType(e){if(!e.layerType)if(e.type)e.layerType=e.type;else if(e.url){const t=e.url;if(t.match(".*MapServer/\\d{1,}/?$")||t.match(".*FeatureServer/\\d{1,}/?$"))e.layerType="ArcGISFeatureLayer";else if(t.match(".*StreamServer/?$"))e.layerType="ArcGISStreamLayer";else if(t.match(".*ImageServer/?$")){const i=await this._getLayerData(t);i.cacheType?"Map"===i.cacheType?e.layerType="ArcGISTiledImageServiceLayer":"Elevation"===i.cacheType&&(e.layerType="ArcGISTiledElevationServiceLayer"):e.layerType="ArcGISImageServiceLayer"}else if(t.match(".*MapServer/?$")){const i=await this._getLayerData(t);e.layerType=i.tileInfo?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer"}else if(t.match(".*\\.(csv|txt)$"))e.layerType="CSV";else if(t.match(".*\\.kml$"))e.layerType="KML";else if(t.match(".*SceneServer/layers/\\d{1,}/?$")){const i=await this._getLayerData(t);"3DObject"===i.layerType?e.layerType="ArcGISSceneServiceLayer":"IntegratedMesh"===i.layerType?e.layerType="IntegratedMeshLayer":"PointCloud"===i.layerType&&(e.layerType="PointCloudLayer")}else t.match(".*(\\.xml|rss/?)$")&&(e.layerType="GeoRSS")}else if(e.layers){e.layerType="GroupLayer";const t=[];for(const i of e.layers)t.push(this._inferLayerType(i));await Promise.all(t)}else e.templateUrl&&e.tileInfo?e.layerType="WebTiledLayer":e.featureCollection?e.layerType="ArcGISFeatureLayer":e.styleUrl?e.layerType="VectorTileLayer":e.mapUrl&&(e.layerType="WMS")}async _getLayerData(e){const t=await this.requestHelper.request(e,{query:{f:"json"}});if(!t||!t.data)throw new Error(`Response to request for url ${e} was invalid.`);return t.data}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e&&e.isWebMercator&&await parallelEach([WellKnownBasemap.SATELLITE,WellKnownBasemap.HYBRID_VECTOR,WellKnownBasemap.STREETS_VECTOR,WellKnownBasemap.TOPO_VECTOR,WellKnownBasemap.STREETS_NAVIGATION_VECTOR,WellKnownBasemap.STREETS_NIGHT_VECTOR,WellKnownBasemap.TERRAIN_VECTOR,WellKnownBasemap.DARK_GRAY_VECTOR,WellKnownBasemap.GRAY_VECTOR,WellKnownBasemap.NATIONAL_GEOGRAPHIC,WellKnownBasemap.OCEANS_VECTOR,WellKnownBasemap.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await createStandardBasemap(e);basemapsAreEquivalent(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(BasemapExtension.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(){var e,t,i;this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),isWebMap(this.map)&&(null===(e=this.map.bookmarks)||void 0===e?void 0:e.length)>0?this.map.bookmarks.forEach((e=>{const t=toEsriApiGeometry(e.extent),i=new EsriViewpoint({targetGeometry:t});this.bookmarks.add(new Bookmark({source:"map",title:e.name,viewpoint:i}))})):isWebScene(this.map)&&(null===(i=null===(t=this.map.presentation)||void 0===t?void 0:t.slides)||void 0===i?void 0:i.length)>0&&this.map.presentation.slides.forEach((e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},i=new Bookmark(t);this.bookmarks.add(i)}))}};MapExtension=__decorate([serializable],MapExtension);export{MapExtension};class LayerExtensionCollectionImpl extends LayerExtensionCollectionBase{constructor(e){super(e,"map.layers")}get _mapExtension(){return this._parent}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(ItemType.LAYER_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}}class BasemapExtensionCollection extends InitializableCollectionProxy{constructor(e){super(new Collection),this.isExplicitlyModified=!1,this._mapExtension=e}add(e,t){super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e)}addMany(e,t){super.addMany(e,t),this.isExplicitlyModified=!0}addInternal(e,t,i=!0){const s=e=>{const t="-vector";return(null==e?void 0:e.endsWith(t))?e.substring(0,e.length-t.length):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>{var i;return s(null===(i=e.basemap)||void 0===i?void 0:i.id)===t})),isStandardBasemap(e.basemap)&&a>=0){if(!i)return;super.removeAt(a)}}super.add(e,null!=t?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(){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 TableExtensionCollectionImpl extends InitializableCollectionProxy{constructor(e){super(),this._tableExtensionMap=new WeakMap,this._uninitializedTableExtensions=new Set,this._mapExtension=e,onCollectionPropertyChange(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")))}get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){var e,t;return null!==(t=null===(e=this._mapExtension.map)||void 0===e?void 0:e.tables)&&void 0!==t?t:new ReadOnlyCollection(new Collection)}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(ItemType.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new TableExtensionCollectionImpl(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.table.id===e))}forTable(e){if(checkArg("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(checkArg("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)}this._onAdded(e)}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){this._tables.sort(((t,i)=>e(this._forTable(t),this._forTable(i))))}_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=TableExtension.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class AllLayerExtensionCollectionImpl extends ReadOnlyInitializableCollection{constructor(e){super(),this._mapExtension=e}get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>isGroupLayerExtension(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}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.layer.id===e))}forLayer(e){return checkArg("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,t){if("change"===e){const i=new Collection;i.addMany(t.added);const s=i.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray(),a=new Collection;a.addMany(t.removed);const n=a.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray(),o=new Collection;o.addMany(t.moved);const r=o.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:s,removed:n,moved:r,target:this})}return super.emit(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function toPortalItem(e){if("object"!=typeof e||!e||!e.baseMap)return toPortalItemBase(e)}function isPortalItem(e){return"object"!=typeof e||e&&!e.baseMap}function validatePortalItem(e,t,i){if((null==e?void 0:e.type)&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}
1
+ import{__decorate}from"tslib";import EsriViewpoint from"@arcgis/core/Viewpoint";import{ArgumentError}from"../ArgumentError.js";import{EntityBase}from"../Entity.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{isBasemapExtension,isBookmark,isGroundExtension,isLayerPreset,isMenu,isTableExtension,ItemType}from"../ItemType.js";import{TableExtension}from"../data/TableExtension.js";import{LayerPreset}from"../layer-preset/LayerPreset.js";import{Menu}from"../menus/Menu.js";import{toEsriApiGeometry}from"../portal/Geometry.js";import{WebMap as WebMapJson}from"../portal/WebMap.js";import{WebScene as WebSceneJson}from"../portal/WebScene.js";import{resolveRelativeHrefs}from"../portal/_utils.js";import{DefaultArcGISRequestHelper}from"../support/ArcGISRequestHelper.js";import{FormatSettings}from"../support/FormatSettings.js";import{InitializableCollectionProxy}from"../support/InitializableCollectionProxy.js";import{ReadOnlyInitializableCollection}from"../support/ReadOnlyInitializableCollection.js";import{serializable}from"../support/Serializable.js";import{WellKnownBasemap}from"../support/esri.js";import{ReadOnlyCollection}from"../utilities/ReadOnlyCollection.js";import{basemapsAreEquivalent,createStandardBasemap,isStandardBasemap}from"../utilities/basemaps.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{isGroupLayerExtension}from"../utilities/extensions.js";import{project}from"../utilities/geometry.js";import{find}from"../utilities/iterable.js";import{layersAreEquivalent}from"../utilities/layers.js";import{getLogger}from"../utilities/log.js";import{getMapSpatialReference,isMap,isWebMap,isWebScene}from"../utilities/mapping.js";import{toPortalItem as toPortalItemBase}from"../utilities/portal.js";import{parallelEach}from"../utilities/promise.js";import{onCollectionPropertyChange,onEach}from"../utilities/watch.js";import{BasemapExtension}from"./BasemapExtension.js";import{Bookmark}from"./Bookmark.js";import{GroundExtension}from"./GroundExtension.js";import{MapConstraints}from"./MapConstraints.js";import{_assignLayerExtensions,LayerExtension}from"./_LayerExtension.js";import{LayerExtensionCollectionBase}from"./support/_LayerExtensionCollection.js";const log=getLogger("MapExtension");let MapExtension=class extends EntityBase{constructor(e){var t;super(e),this.isSwitchingMap=!1,this._layerViews=new Collection,this._itemType=ItemType.MAP_EXTENSION,this._skipBasemapOptions=!1;let i={...e};this._basemapOptions=new BasemapExtensionCollection(this),this._groundExtensions=new WeakMap,this._layerExtensions=this._createLayerExtensionCollection(),this.tableExtensions=this._createTableExtensionCollection(),this.formatSettings=this._createFormatSettings(),this._bookmarks=new Collection,this.constraints=new MapConstraints,this.watch(["_map","_scene"],(e=>{e&&(onEach(e.layers,"layerview-create",(e=>{this._layerViews.add(e.layerView)})),onEach(e.layers,"layerview-destroy",(e=>{this._layerViews.remove(e.layerView)})))}));const{webMap:s,webScene:a,initialViewMode:n,map:o,basemapOptions:r}=i;if(this._webMap=s,this._webScene=a,this._webMapItem=toPortalItem(s),this._webSceneItem=toPortalItem(a),this.initialViewMode=n,isWebScene(o)&&a)throw new ArgumentError("Cannot specify webScene property if map is initialized to a WebScene instance.");if(isMap(o)&&s)throw new ArgumentError("Cannot specify webMap property if map is initialized to a 2D Map instance.");if(isWebScene(o)||isWebMap(o)||isMap(o))this.assignProperties({basemapOptions:r}),this._skipBasemapOptions=!!r;else{const{map:e,layerExtensions:t,tableExtensions:s,groundExtension:a,basemapOptions:n,basemapExtension:o,...r}=i;this._deferredProperties={map:e,layerExtensions:t,tableExtensions:s,groundExtension:a,basemapOptions:n,basemapExtension:o},i=r,n&&(this._skipBasemapOptions=!0)}this._initMapFromProperties(i),this.watch("map.basemap",(()=>this._onBasemapChange()),!0),this.watch("map.ground",(()=>this._onGroundChange()),!0),this.allLayerExtensions=new AllLayerExtensionCollectionImpl(this),(null===(t=this.map)||void 0===t?void 0:t.basemap)&&this._onBasemapChange()}get webMap(){return this._webMap}get webScene(){return this._webScene}get map(){return this._currentMap}get viewMode(){return this.map?isWebScene(this.map)?"scene":"map":this.initialViewMode}get initialViewMode(){return this.webMap&&this.webScene?this._initialViewMode||"map":isWebScene(this.map)||this.webScene&&!this.webMap?"scene":"map"}set initialViewMode(e){this._initialViewMode=e}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),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 InvalidOperationError("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(){var e;return this._groundExtension||(this.groundExtension=new GroundExtension({ground:null===(e=this.map)||void 0===e?void 0:e.ground})),this._groundExtension}set groundExtension(e){if(!e)throw new InvalidOperationError("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=isLayerPreset(e)?e:new LayerPreset(e);this._initialLayerPreset=t}get _spatialReference(){return getMapSpatialReference(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}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&&log.error({message:"An error occurred while initializing context menu.",error:e})}})()}get layerExtensions(){return this._layerExtensions}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(isGroupLayerExtension(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(checkArg("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(checkArg("newMap",e).isNotMissing(),e===this.map)return;if(!this.map)return void this._setMap(e);this.isSwitchingMap=!0,this.isInitialized&&await load(e);const t=new Map;this.map.layers.forEach((e=>t.set(e,this.layerExtensions.forLayer(e))));const{basemapExtension:i}=this;this._setMap(e),this._updateBookmarks();const s=[];for(const e of this.map.layers.toArray()){const i=find(t.entries(),(([t])=>layersAreEquivalent(t,e)));if(i)s.push((async()=>{const t=i[1];await t._switchLayer(e),this._layerExtensions._register(t)})());else{const t=this._layerExtensions._forLayer(e);(null==t?void 0:t.layer)!==e&&s.push(t._switchLayer(e))}}this.map.basemap&&i&&basemapsAreEquivalent(this.map.basemap,i.basemap)&&s.push((async()=>{await i._switchBasemap(this.map.basemap),this.basemapExtension=i})()),this.isInitialized&&s.push(this._initializeChildren()),await Promise.all(s),this.isSwitchingMap=!1}async setWebMap(e){if(!e&&this.webMap&&!this.webScene)throw new InvalidOperationError("Cannot unset both webMap and webScene.");this._webMap=e,this._map=void 0,this._createMapPromise=void 0,this._webMapItem=toPortalItem(e),await load(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 InvalidOperationError("Cannot unset both webMap and webScene.");this._webScene=e,this._scene=void 0,this._createScenePromise=void 0,this._webSceneItem=toPortalItem(e),await load(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(){var e;if(!this._scene&&this.webScene)return this._createScenePromise=null!==(e=this._createScenePromise)&&void 0!==e?e:(async()=>{if(isPortalItem(this.webScene)){const e=new((await import("@arcgis/core/WebScene")).default);await this._loadAndApplyPortalItemData(this._webSceneItem,e),this._scene=e}else this._scene=await WebSceneJson.toEsriApiWebScene(this.webScene)})()}async _createMap(){var e;if(!this._map&&this.webMap)return this._createMapPromise=null!==(e=this._createMapPromise)&&void 0!==e?e:(async()=>{if(isPortalItem(this.webMap)){const e=new((await import("@arcgis/core/WebMap")).default);await this._loadAndApplyPortalItemData(this._webMapItem,e),this._map=e}else this._map=await WebMapJson.toEsriApiWebMap(this.webMap)})()}_getSerializableProperties(){return{...super._getSerializableProperties(),layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{var t,i;if(this.map&&e){const s=null!==(i=null===(t="map"===this.viewMode?this._scene:this._map)||void 0===t?void 0:t.layers.toArray())&&void 0!==i?i:[],a=e.filter((e=>!s.includes(e.layer)&&!s.some((t=>e.layer&&(LayerExtension._matchesRef(t,e.layer)||layersAreEquivalent(t,e.layer))))));_assignLayerExtensions(this.layerExtensions,a)}},serialize:e=>{var t,i,s,a;if(null===(t=this._deferredProperties)||void 0===t?void 0:t.layerExtensions)return this._deferredProperties.layerExtensions;{const t="map"===this.viewMode,n=null===(i=t?this._map:this._scene)||void 0===i?void 0:i.layers.toArray();let o=null!==(a=null===(s=t?this._scene:this._map)||void 0===s?void 0:s.layers.toArray())&&void 0!==a?a:[];return o=o.filter((e=>!n.find((t=>layersAreEquivalent(t,e))))),this.layerExtensions.concat(o.map((e=>this._layerExtensions._forLayer(e)))).filter((t=>"initial"!==e||!t.dynamicallyAddedLayer)).toArray()}}},tableExtensions:{serializeModes:["initial","project"],deserialize:e=>{this.map?compare(this.tableExtensions,e,{onNew:(e,t)=>{this.tableExtensions.add(isTableExtension(e)?e:TableExtension.create(e),t)},onMatch:(e,t,i,s)=>{isTableExtension(t)||e.assignProperties(t),i!==s&&this.tableExtensions.reorder(e,s)},equals:(e,t)=>isTableExtension(t)?t===e:!!TableExtension._matchesRef(e,t.table)||e.id===t.id}):this._deferredProperties={...this._deferredProperties,tableExtensions:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.tableExtensions)?null===(t=this._deferredProperties)||void 0===t?void 0:t.tableExtensions:this.tableExtensions.toArray()}},basemapExtension:{serializeModes:["project"],deserialize:e=>{this.map?e?isBasemapExtension(e)?this.basemapExtension=e:this.basemapExtension?this.basemapExtension.assignProperties(e):this.basemapExtension=BasemapExtension.create(e):this.basemapExtension=void 0:this._deferredProperties={...this._deferredProperties,basemapExtension:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.basemapExtension)?null===(t=this._deferredProperties)||void 0===t?void 0:t.basemapExtension:this.basemapExtension}},basemapOptions:{serializeModes:["initial"],deserialize:e=>{this._skipBasemapOptions?this._skipBasemapOptions=!1:(compare(this.basemapOptions,e,{onNew:(e,t)=>{this.basemapOptions.add(isBasemapExtension(e)?e:BasemapExtension.create(e),t)},onMatch:(e,t,i,s)=>{isBasemapExtension(t)||e.assignProperties(t),i!==s&&this.basemapOptions.reorder(e,s)},onMissing:e=>{this.basemapOptions.remove(e)},equals:(e,t)=>{if(isBasemapExtension(t))return t===e;if(e.id&&t.id)return e.id===t.id;{const i=e.toJSON();return basemapsAreEquivalent(i.basemap,t.basemap||t.baseMap)}}}),this.basemapExtension&&this._ensureIsBasemapOption(this.basemapExtension),this.isInitialized&&parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())))},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.basemapOptions)?null===(t=this._deferredProperties)||void 0===t?void 0:t.basemapOptions:this.basemapOptions.toArray()}},groundExtension:{serializeModes:["initial"],deserialize:e=>{this.map?isGroundExtension(e)?this.groundExtension=e:this.groundExtension.assignProperties(e):this._deferredProperties={...this._deferredProperties,groundExtension:e}},serialize:()=>{var e,t;return(null===(e=this._deferredProperties)||void 0===e?void 0:e.groundExtension)?null===(t=this._deferredProperties)||void 0===t?void 0:t.groundExtension:this.groundExtension}},bookmarks:{serialize:()=>this.bookmarks.map((e=>e.toJSON())).toArray(),deserialize:e=>{this.bookmarks.addMany(e.map((e=>isBookmark(e)?e:new Bookmark(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?isMenu(e)?this.contextMenu=e:this.contextMenu?this.contextMenu.assignProperties(e):this.contextMenu=Menu.create(e):this.contextMenu=void 0}},map:{serializeModes:["project"],serialize:()=>({operationalLayers:this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON())),tables:this.tableExtensions.toArray().filter((e=>e.table)).map((e=>({id:e.table.id,title:e.table.title})))}),deserialize:e=>{if(this.map)if(isMap(e)||isWebMap(e)||isWebScene(e)){if(e!==this.map)throw new ArgumentError("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})();else this._deferredProperties={...this._deferredProperties,map:e}}},requestHelper:{serialize:!1}}}async _applyMapProperties(e,t,i){await parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap()));let s=e;const a=this.basemapOptions.find((e=>basemapsAreEquivalent(e.basemap,s.baseMap)));a&&(t.basemap=a.basemap,s={...s,baseMap:{...s.baseMap,title:t.basemap.title}}),isWebScene(t)?await WebSceneJson.applyToEsriApiWebScene(s,t,i):await WebMapJson.applyToEsriApiMap(s,t,i)}_createFormatSettings(){return new FormatSettings}_createLayerExtensionCollection(){return new LayerExtensionCollectionImpl(this)}_createTableExtensionCollection(){return new TableExtensionCollectionImpl(this)}async _onInitialize(){var e;await super._onInitialize();const{basemapExtension:t,basemapOptions:i,groundExtension:s,webMap:a,webScene:n,map:o,...r}=null!==(e=this._deferredProperties)&&void 0!==e?e:{};if(i&&this.assignProperties({basemapOptions:i}),this.map||("scene"===this.initialViewMode?this._setMap(new((await import("@arcgis/core/WebScene")).default)):this._setMap(new((await import("@arcgis/core/WebMap")).default))),this.map.basemap&&this._onBasemapChange(),(a||n)&&await this._applyMapProperties("scene"===this.initialViewMode?n:a,this.map),t&&(this.assignProperties({basemapExtension:t}),await this.basemapExtension._createBackingBasemap()),s&&this.assignProperties({groundExtension:s}),this._webMapItem||this._webSceneItem){await Promise.all([load(this.map),load(this._webMapItem),load(this._webSceneItem)]),validatePortalItem(this._webMapItem,"webMap","Web Map"),validatePortalItem(this._webSceneItem,"webScene","Web Scene");const e=isWebScene(this.map)?this._webSceneItem:this._webMapItem;await this._loadAndApplyPortalItemData(e)}else await load(this.map);o&&await this._applyMapProperties(o,this.map),this.assignProperties(r),this._deferredProperties=void 0,this._initialBasemapExtension=this.basemapExtension,this._updateBookmarks(),this.contextMenu&&await this.contextMenu.initialize();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 parallelEach(this.basemapOptions.toArray(),(e=>e._createBackingBasemap())),this.initialLayerPreset&&await this.initialLayerPreset.applyTo(this)}*_initializableChildCollections(){yield*super._initializableChildCollections();const e=new Collection(this.layerExtensions.filter((e=>!!e.layer)));e.remove=e=>{this.layerExtensions.remove(e)};const t=new Collection(this.tableExtensions.filter((e=>!!e.table)));if(t.remove=e=>{this.tableExtensions.remove(e)},yield e,yield t,this.basemapExtension){const e=new Collection;e.add(this.basemapExtension),yield e}const i=new Collection;i.add(this.groundExtension),yield i}_initMapFromProperties(e){const t=e.map;isMap(t)||isWebMap(t)||isWebScene(t)?this._setMap(t):"scene"===this.initialViewMode?e.webScene&&!isPortalItem(e.webScene)&&(this._deferredProperties={webScene:e.webScene,...this._deferredProperties}):e.webMap&&!isPortalItem(e.webMap)&&(this._deferredProperties={webMap:e.webMap,...this._deferredProperties})}_setMap(e){var t,i;isWebScene(e)?this._scene=e:this._map=e,this._currentMap=e,(null===(t=this.basemapExtension)||void 0===t?void 0:t.basemap)&&!e.basemap&&(e.basemap=this.basemapExtension.basemap),(null===(i=this.groundExtension)||void 0===i?void 0:i.ground)&&!e.ground&&(e.ground=this.groundExtension.ground),this._notifyChange("map")}async _loadAndApplyPortalItemData(e,t){var i;await load(e);const s=await e.fetchData();resolveRelativeHrefs(s,e),await this._inferLayerTypes(s),(null===(i=this.basemapExtension)||void 0===i?void 0:i.basemap)&&!t&&delete s.baseMap,GroundExtension.isDefaultGround(this.groundExtension.ground)||t||delete s.ground;const a=t||this.map;await load(a),await this._applyMapProperties(s,a,e),a.portalItem=e;const{viewpoint:n,spatialReference:o}=a.initialViewProperties;n&&n.targetGeometry&&!n.targetGeometry.spatialReference.equals(o)&&(a.initialViewProperties.viewpoint.targetGeometry=(await project([n.targetGeometry],o))[0]),n&&n.camera&&(n.camera.position.spatialReference=o.clone())}_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=>e.basemap===this.map.basemap));e||(e=BasemapExtension.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.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._groundExtensions.has(this.map.ground)||this._groundExtensions.set(this.map.ground,new GroundExtension({ground:this.map.ground}));const e=this._groundExtensions.get(this.map.ground);e.mapExtension!==this&&e._setMapExtension(this),this._groundExtension=e,this._notifyChange("groundExtension")}async _inferLayerTypes(e){var t;const i=[];if(e.operationalLayers)for(const t of e.operationalLayers)i.push(this._inferLayerType(t));if(e.baseMap&&i.push(this._inferBasemapLayerTypes(e.baseMap)),e.hasOwnProperty("ground")&&i.push(this._inferGroundLayerTypes(e.ground)),null===(t=e.presentation)||void 0===t?void 0:t.slides)for(const t of e.presentation.slides)t.baseMap&&"string"!=typeof t.baseMap&&i.push(this._inferBasemapLayerTypes(t.baseMap));await Promise.all(i)}async _inferBasemapLayerTypes(e){const t=[];if(e.baseMapLayers)for(const i of e.baseMapLayers)t.push(this._inferLayerType(i));await Promise.all(t)}async _inferGroundLayerTypes(e){const t=[];if(e.layers)for(const i of e.layers)t.push(this._inferLayerType(i));await Promise.all(t)}async _inferLayerType(e){if(!e.layerType)if(e.type)e.layerType=e.type;else if(e.url){const t=e.url;if(t.match(".*MapServer/\\d{1,}/?$")||t.match(".*FeatureServer/\\d{1,}/?$"))e.layerType="ArcGISFeatureLayer";else if(t.match(".*StreamServer/?$"))e.layerType="ArcGISStreamLayer";else if(t.match(".*ImageServer/?$")){const i=await this._getLayerData(t);i.cacheType?"Map"===i.cacheType?e.layerType="ArcGISTiledImageServiceLayer":"Elevation"===i.cacheType&&(e.layerType="ArcGISTiledElevationServiceLayer"):e.layerType="ArcGISImageServiceLayer"}else if(t.match(".*MapServer/?$")){const i=await this._getLayerData(t);e.layerType=i.tileInfo?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer"}else if(t.match(".*\\.(csv|txt)$"))e.layerType="CSV";else if(t.match(".*\\.kml$"))e.layerType="KML";else if(t.match(".*SceneServer/layers/\\d{1,}/?$")){const i=await this._getLayerData(t);"3DObject"===i.layerType?e.layerType="ArcGISSceneServiceLayer":"IntegratedMesh"===i.layerType?e.layerType="IntegratedMeshLayer":"PointCloud"===i.layerType&&(e.layerType="PointCloudLayer")}else t.match(".*(\\.xml|rss/?)$")&&(e.layerType="GeoRSS")}else if(e.layers){e.layerType="GroupLayer";const t=[];for(const i of e.layers)t.push(this._inferLayerType(i));await Promise.all(t)}else e.templateUrl&&e.tileInfo?e.layerType="WebTiledLayer":e.featureCollection?e.layerType="ArcGISFeatureLayer":e.styleUrl?e.layerType="VectorTileLayer":e.mapUrl&&(e.layerType="WMS")}async _getLayerData(e){const t=await this.requestHelper.request(e,{query:{f:"json"}});if(!t||!t.data)throw new Error(`Response to request for url ${e} was invalid.`);return t.data}async _createStandardBasemapOptions(){const e=this._spatialReference;!this._basemapOptions.isExplicitlyModified&&e&&e.isWebMercator&&await parallelEach([WellKnownBasemap.SATELLITE,WellKnownBasemap.HYBRID_VECTOR,WellKnownBasemap.STREETS_VECTOR,WellKnownBasemap.TOPO_VECTOR,WellKnownBasemap.STREETS_NAVIGATION_VECTOR,WellKnownBasemap.STREETS_NIGHT_VECTOR,WellKnownBasemap.TERRAIN_VECTOR,WellKnownBasemap.DARK_GRAY_VECTOR,WellKnownBasemap.GRAY_VECTOR,WellKnownBasemap.NATIONAL_GEOGRAPHIC,WellKnownBasemap.OCEANS_VECTOR,WellKnownBasemap.OPEN_STREET_MAP_VECTOR],(async e=>{const t=await createStandardBasemap(e);basemapsAreEquivalent(this.map.basemap,t)?this._basemapOptions.addInternal(this.basemapExtension):this._basemapOptions.addInternal(BasemapExtension.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(){var e,t,i;this.bookmarks.removeMany(this.bookmarks.filter((e=>"map"===e.source))),isWebMap(this.map)&&(null===(e=this.map.bookmarks)||void 0===e?void 0:e.length)>0?this.map.bookmarks.forEach((e=>{const t=toEsriApiGeometry(e.extent),i=new EsriViewpoint({targetGeometry:t});this.bookmarks.add(new Bookmark({source:"map",title:e.name,viewpoint:i}))})):isWebScene(this.map)&&(null===(i=null===(t=this.map.presentation)||void 0===t?void 0:t.slides)||void 0===i?void 0:i.length)>0&&this.map.presentation.slides.forEach((e=>{const t={source:"map",title:e.title.text,viewpoint:e.viewpoint},i=new Bookmark(t);this.bookmarks.add(i)}))}};MapExtension=__decorate([serializable],MapExtension);export{MapExtension};class LayerExtensionCollectionImpl extends LayerExtensionCollectionBase{constructor(e){super(e,"map.layers")}get _mapExtension(){return this._parent}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(ItemType.LAYER_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}}class BasemapExtensionCollection extends InitializableCollectionProxy{constructor(e){super(new Collection),this.isExplicitlyModified=!1,this._mapExtension=e}add(e,t){super.add(e,t),this.isExplicitlyModified=!0,1===this.length&&this._mapExtension.map&&!this._mapExtension.basemapExtension&&(this._mapExtension.basemapExtension=e)}addMany(e,t){super.addMany(e,t),this.isExplicitlyModified=!0}addInternal(e,t,i=!0){const s=e=>{const t="-vector";return(null==e?void 0:e.endsWith(t))?e.substring(0,e.length-t.length):e};let a;if(e.basemap){const t=s(e.basemap.id);if(a=this.findIndex((e=>{var i;return s(null===(i=e.basemap)||void 0===i?void 0:i.id)===t})),isStandardBasemap(e.basemap)&&a>=0){if(!i)return;super.removeAt(a)}}super.add(e,null!=t?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(){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 TableExtensionCollectionImpl extends InitializableCollectionProxy{constructor(e){super(),this._tableExtensionMap=new WeakMap,this._uninitializedTableExtensions=new Set,this._mapExtension=e,onCollectionPropertyChange(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")))}get _collection(){return this._tables.map((e=>this._forTable(e))).concat(Array.from(this._uninitializedTableExtensions))}get _tables(){var e,t;return null!==(t=null===(e=this._mapExtension.map)||void 0===e?void 0:e.tables)&&void 0!==t?t:new ReadOnlyCollection(new Collection)}toJSON(){const e=[];return this.forEach((t=>{e.push(`item://${encodeURIComponent(ItemType.TABLE_EXTENSION)}/${encodeURIComponent(t.id)}`)})),e}clone(){const e=new TableExtensionCollectionImpl(this._mapExtension);return e._tableExtensionMap=this._tableExtensionMap,e}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findByTableId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.table.id===e))}forTable(e){if(checkArg("table",e).isNotMissing(),this._tables.includes(e))return this._forTable(e)}add(e,t){if(checkArg("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)}this._onAdded(e)}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){this._tables.sort(((t,i)=>e(this._forTable(t),this._forTable(i))))}_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=TableExtension.create({table:e});this._tableExtensionMap.set(e,t),t._setMapExtension(this._mapExtension),this._onAdded(t)}return this._tableExtensionMap.get(e)}}class AllLayerExtensionCollectionImpl extends ReadOnlyInitializableCollection{constructor(e){super(),this._mapExtension=e}get _collection(){let e=this._mapExtension.layerExtensions.flatten((e=>isGroupLayerExtension(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}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findByLayerId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.layer.id===e))}forLayer(e){return checkArg("layer",e).isNotMissing(),this.findByLayerId(e.id)}emit(e,t){if("change"===e){const i=new Collection;i.addMany(t.added);const s=i.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray(),a=new Collection;a.addMany(t.removed);const n=a.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray(),o=new Collection;o.addMany(t.moved);const r=o.flatten((e=>isGroupLayerExtension(e)?e.layerExtensions:[])).toArray();super.emit(e,{added:s,removed:n,moved:r,target:this})}return super.emit(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.layer}}function toPortalItem(e){if("object"!=typeof e||!e||!e.baseMap)return toPortalItemBase(e)}function isPortalItem(e){return"object"!=typeof e||e&&!e.baseMap}function validatePortalItem(e,t,i){if((null==e?void 0:e.type)&&e.type!==i)throw new Error(`Invalid portal item type "${e.type}" for property ${t}.`)}
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": "34.0.0",
4
+ "version": "34.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://geocortex.visualstudio.com/Geocortex/_git/geocortex-api-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 = "34.0.0";
4
+ export declare const version = "34.0.1";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const version="34.0.0";
1
+ export const version="34.0.1";