@arcgis/core 4.34.0-next.38 → 4.34.0-next.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Color.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{00f3fe4a09bbdbc8f8b4.js → 00ae094cc21bc42faa54.js} +1 -1
- package/assets/esri/core/workers/chunks/{7e04b4592128e884b58c.js → 0f51e51db83f303ce5a6.js} +1 -1
- package/assets/esri/core/workers/chunks/{6e82c1d1e02e320ec5e7.js → 14d3039f92b0d96944f0.js} +1 -1
- package/assets/esri/core/workers/chunks/{54658c87396223d85abd.js → 1cbd59918c60a1a21494.js} +1 -1
- package/assets/esri/core/workers/chunks/{7c97c4c8c2cf73835517.js → 1cd15aa69f85ecfa32b0.js} +1 -1
- package/assets/esri/core/workers/chunks/21a9f9c0cc1cde2fee90.js +1 -0
- package/assets/esri/core/workers/chunks/{21aaf2dede61f28727a9.js → 2ae0bda04fd5386b462f.js} +1 -1
- package/assets/esri/core/workers/chunks/{49eac96a01931b8c4ace.js → 364fb103cb139f26b455.js} +1 -1
- package/assets/esri/core/workers/chunks/3af4a410ff0bca7ba2e3.js +1 -0
- package/assets/esri/core/workers/chunks/{8ad95fe91ba0a9f284a2.js → 3f7d7dc05e63fc50325e.js} +1 -1
- package/assets/esri/core/workers/chunks/4970d439d9648e97fd5a.js +1 -0
- package/assets/esri/core/workers/chunks/{48369e4c340413c531ff.js → 4e6e5677b90b00622146.js} +1 -1
- package/assets/esri/core/workers/chunks/{257428fff4bef42716e0.js → 4f3c187a7cb2b1444281.js} +1 -1
- package/assets/esri/core/workers/chunks/{31c6716d9ca188d3b870.js → 554c789f4e875d7e6fd5.js} +1 -1
- package/assets/esri/core/workers/chunks/{a939d2af7e4a359c7b4d.js → 560bb06cf1bf30df4af3.js} +1 -1
- package/assets/esri/core/workers/chunks/{80a930881a99ceda240a.js → 5f11fff5bc16fdec42db.js} +1 -1
- package/assets/esri/core/workers/chunks/{9155dbfce5ef2c25bbbf.js → 791b3130b34b52160c1f.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b2d40a2ce2594ce8eef.js → 95f0c15d83d1f38e01d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{3488e88882f40199ab33.js → a85acb948cc7d22be592.js} +1 -1
- package/assets/esri/core/workers/chunks/{7159e7a3274e64b337ce.js → b481807b31e59cce9931.js} +1 -1
- package/assets/esri/core/workers/chunks/{d29f894491618931d92a.js → bc27cdd7c415ab166536.js} +1 -1
- package/assets/esri/core/workers/chunks/c474800508e3ad5ce9d7.js +1 -0
- package/assets/esri/core/workers/chunks/{23a85252e4164354553e.js → c52314b987c63cd630f7.js} +1 -1
- package/assets/esri/core/workers/chunks/{022091e5240b9d872dd2.js → d1635a7ab0c204852237.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8c85ba6451b5dfc2fc0.js → da228aed337f492456cc.js} +1 -1
- package/assets/esri/core/workers/chunks/ddeaf688d72b2873c4ac.js +1 -0
- package/assets/esri/core/workers/chunks/e08b2e9213d35f85916f.js +1 -0
- package/assets/esri/core/workers/chunks/e6d08230adb90b9a2a17.js +1 -0
- package/colorUtils.js +1 -1
- package/config.js +1 -1
- package/core/AsyncUpdate.js +1 -1
- package/core/Collection.js +1 -1
- package/core/Evented.js +1 -1
- package/core/MultiOriginJSONSupport.js +1 -1
- package/core/ReadOnlyMultiOriginJSONSupport.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/kernel.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/WaterSymbol3DLayer.js +1 -1
- package/views/2d/engine/AFeatureContainer.js +1 -1
- package/views/2d/engine/Bitmap.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/webgl/ClippingInfo.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/TiledDisplayObject.js +1 -1
- package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/TestDisplayObject.js +1 -1
- package/views/2d/grid/GridView2D.js +1 -1
- package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
- package/views/2d/layers/BaseLayerView2D.js +1 -1
- package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
- package/views/2d/layers/CatalogDynamicGroupLayerView2D.js +1 -1
- package/views/2d/layers/CatalogFootprintLayerView2D.js +1 -1
- package/views/2d/layers/CatalogLayerView2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MapImageLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/OGCFeatureLayerView2D.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/WMSLayerView2D.js +1 -1
- package/views/2d/layers/WMTSLayerView2D.js +1 -1
- package/views/2d/layers/features/support/TileStore.js +1 -1
- package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
- package/views/3d/layers/CatalogDynamicGroupLayerView3D.js +1 -1
- package/views/3d/layers/CatalogFootprintLayerView3D.js +1 -1
- package/views/3d/layers/CatalogLayerView3D.js +1 -1
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/OGCFeatureLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/TileLayerView3D.js +1 -1
- package/views/3d/layers/WMSLayerView3D.js +1 -1
- package/views/3d/layers/WMTSLayerView3D.js +1 -1
- package/views/3d/layers/graphics/GraphicStateTracking.js +1 -1
- package/views/3d/support/LimitGraphicsMap.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/View.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/layers/CatalogDynamicGroupLayerView.d.ts +1 -1
- package/views/layers/CatalogDynamicGroupLayerView.js +1 -1
- package/views/layers/CatalogFootprintLayerView.d.ts +1 -1
- package/views/layers/CatalogFootprintLayerView.js +1 -1
- package/views/layers/CatalogLayerView.d.ts +1 -1
- package/views/layers/CatalogLayerView.js +1 -1
- package/views/layers/FeatureLayerView.d.ts +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/LayerView.js +1 -1
- package/views/layers/OGCFeatureLayerView.d.ts +1 -1
- package/views/layers/OGCFeatureLayerView.js +1 -1
- package/views/layers/PointCloudLayerView.d.ts +1 -1
- package/views/layers/PointCloudLayerView.js +1 -1
- package/views/layers/RefreshableLayerView.js +1 -1
- package/views/layers/StreamLayerView.d.ts +1 -1
- package/views/layers/StreamLayerView.js +1 -1
- package/views/layers/WMSLayerView.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
- package/widgets/Compass/CompassViewModel.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/Home/HomeViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/GeolocationPositioning.js +1 -1
- package/widgets/support/GoTo.d.ts +1 -1
- package/widgets/support/GoTo.js +1 -1
- package/assets/esri/core/workers/chunks/508c302fed242956d3b7.js +0 -1
- package/assets/esri/core/workers/chunks/60d889c58a542e59b07b.js +0 -1
- package/assets/esri/core/workers/chunks/7617fe2fbf223c108f1e.js +0 -1
- package/assets/esri/core/workers/chunks/9595b39e882f9a9ac839.js +0 -1
- package/assets/esri/core/workers/chunks/9ffbd5216aa0a45a4199.js +0 -1
- package/assets/esri/core/workers/chunks/a5c0b365b9f55e63ab52.js +0 -1
- package/assets/esri/core/workers/chunks/d5262c95116d3bdfd117.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as
|
|
5
|
+
import{__decorate as r}from"tslib";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";const s=s=>{const t=s;let a=class extends t{get availableFields(){return this.layer.fieldsIndex.fields.map(r=>r.name)}};return r([e()],a.prototype,"layer",void 0),r([e({readOnly:!0})],a.prototype,"availableFields",null),a=r([o("esri.views.layers.OGCFeatureLayerView")],a),a};export{s as OGCFeatureLayerView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as r}from"tslib";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";const t=t=>{const s=t;let
|
|
5
|
+
import{__decorate as r}from"tslib";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";const t=t=>{const s=t;let i=class extends s{constructor(...r){super(...r),this.layer=null}get availableFields(){return[]}highlight(r,e){throw new Error("Not implemented")}queryFeatures(){throw new Error("Not implemented")}queryFeatureCount(){throw new Error("Not implemented")}createQuery(){throw new Error("Not implemented")}queryExtent(){throw new Error("Not implemented")}};return r([e()],i.prototype,"layer",void 0),r([e()],i.prototype,"availableFields",null),i=r([o("esri.views.layers.PointCloudLayerView")],i),i};export{t as PointCloudLayerView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as r}from"tslib";import e from"../../core/Logger.js";import{isAbortError as s}from"../../core/promiseUtils.js";import{on as o}from"../../core/reactiveUtils.js";import"../../core/has.js";import"../../core/RandomLCG.js";import"../../core/Error.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";const i=i=>{const a=i;let c=class extends a{initialize(){this.addHandles(o(()=>this.layer,"refresh",r=>{this.doRefresh(r.dataChanged).catch(r=>{s(r)||e.getLogger(this).error(r)})}),"RefreshableLayerView")}};return c=r([t("esri.views.layers.RefreshableLayerView")],c),c};export{i as
|
|
5
|
+
import{__decorate as r}from"tslib";import e from"../../core/Logger.js";import{isAbortError as s}from"../../core/promiseUtils.js";import{on as o}from"../../core/reactiveUtils.js";import"../../core/has.js";import"../../core/RandomLCG.js";import"../../core/Error.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";const i=i=>{const a=i;let c=class extends a{initialize(){this.addHandles(o(()=>this.layer,"refresh",r=>{this.doRefresh(r.dataChanged).catch(r=>{s(r)||e.getLogger(this).error(r)})}),"RefreshableLayerView")}};return c=r([t("esri.views.layers.RefreshableLayerView")],c),c};export{i as RefreshableLayerView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as s}from"tslib";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import o from"../../layers/support/FeatureFilter.js";const r=r=>{const i=r;let n=class extends i{resume(){this._isUserPaused=!1,this.suspended||this._doResume()}pause(){this._isUserPaused=!0,this.suspended||this._doPause()}disconnect(){this._doDisconnect()}connect(){this._doConnect()}clear(){this._doClear()}constructor(...s){super(...s),this._isUserPaused=!1,this.filter=null}get connectionStatus(){return(this._isUserPaused||this.suspended)&&"connected"===this._streamConnectionStatus?"paused":this._streamConnectionStatus}_onSuspendedChange(s){s?this._doPause():this._isUserPaused||this._doResume()}};return s([e()],n.prototype,"_isUserPaused",void 0),s([e({readOnly:!0})],n.prototype,"connectionStatus",null),s([e({type:o})],n.prototype,"filter",void 0),n=s([t("esri.views.layers.StreamLayerView")],n),n};export{r as
|
|
5
|
+
import{__decorate as s}from"tslib";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import o from"../../layers/support/FeatureFilter.js";const r=r=>{const i=r;let n=class extends i{resume(){this._isUserPaused=!1,this.suspended||this._doResume()}pause(){this._isUserPaused=!0,this.suspended||this._doPause()}disconnect(){this._doDisconnect()}connect(){this._doConnect()}clear(){this._doClear()}constructor(...s){super(...s),this._isUserPaused=!1,this.filter=null}get connectionStatus(){return(this._isUserPaused||this.suspended)&&"connected"===this._streamConnectionStatus?"paused":this._streamConnectionStatus}_onSuspendedChange(s){s?this._doPause():this._isUserPaused||this._doResume()}};return s([e()],n.prototype,"_isUserPaused",void 0),s([e({readOnly:!0})],n.prototype,"connectionStatus",null),s([e({type:o})],n.prototype,"filter",void 0),n=s([t("esri.views.layers.StreamLayerView")],n),n};export{r as StreamLayerView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{destroyMaybe as r}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{ExportWMSImageParameters as a}from"../../layers/support/ExportWMSImageParameters.js";import{combineTimeExtent as i}from"../../layers/support/timeSupport.js";const m=m=>{const n=m;let c=class extends n{initialize(){this.exportImageParameters=new a({layer:this.layer})}destroy(){this.exportImageParameters=r(this.exportImageParameters)}get exportImageVersion(){return this.exportImageParameters?.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}get timeExtent(){return i(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtLocation(e,r){const{layer:s}=this;if(!e)throw new t("wmslayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:p}=s;if(!p)throw new t("wmslayerview:fetchPopupFeatures","popupEnabled should be true",{popupEnabled:p});const a=this.createFetchPopupFeaturesQuery(e);if(!a)return[];const{extent:i,width:m,height:n,x:c,y:h}=a;if(!(i&&m&&n))throw new t("wmslayerview:fetchPopupFeatures","WMSLayer does not support fetching features.",{extent:i,width:m,height:n});const u=await s.fetchFeatureInfo(i,m,n,c,h);return o(r),u}};return e([s()],c.prototype,"exportImageParameters",void 0),e([s({readOnly:!0})],c.prototype,"exportImageVersion",null),e([s()],c.prototype,"layer",void 0),e([s({readOnly:!0})],c.prototype,"timeExtent",null),c=e([p("esri.views.layers.WMSLayerView")],c),c};export{m as WMSLayerView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../Viewpoint.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{SlideThumbnail as c}from"../../webdoc/support/SlideThumbnail.js";import p from"../../webmap/Bookmark.js";import l
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../Viewpoint.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{SlideThumbnail as c}from"../../webdoc/support/SlideThumbnail.js";import p from"../../webmap/Bookmark.js";import{GoTo as l}from"../support/GoTo.js";const m=o.ofType(p),u={width:128,height:128,format:"png"},k={takeScreenshot:!0,captureViewpoint:!0,captureRotation:!0,captureScale:!0,captureTimeExtent:!0},w={time:!0};let d=class extends(l(a)){constructor(t){super(t),this.capabilities={...w},this.activeBookmark=null,this.view=null}destroy(){this.view=null,this._set("activeBookmark",null)}castCapabilities(t){return{...w,...t}}get bookmarks(){return this.view?.map?.bookmarks??new m}set bookmarks(t){this._overrideIfSome("bookmarks",t)}set defaultCreateOptions(t){this._set("defaultCreateOptions",{...k,...t})}get defaultCreateOptions(){return k}set defaultEditOptions(t){this._set("defaultEditOptions",{...k,...t})}get defaultEditOptions(){return k}get state(){const{view:t}=this;return t&&!t.ready?"loading":"ready"}async createBookmark(t){const{view:e,defaultCreateOptions:o,capabilities:a}=this;if(!e)throw new i("create-bookmark:invalid-view","Cannot create a bookmark without a view.");const{takeScreenshot:r,screenshotSettings:n,captureViewpoint:s,captureRotation:c,captureScale:l,captureTimeExtent:m}={...o,...t},u=r?await this._createThumbnail(n):void 0,k=a.time&&m&&null!=e.timeExtent?e.timeExtent.clone():void 0;return new p({...u&&{thumbnail:u},...m&&{timeExtent:k},...s&&{viewpoint:this._createViewpoint({view:e,captureScale:l,captureRotation:c})}})}async editBookmark(t,e){if(!t)return t;const{view:o,defaultEditOptions:a}=this;if(!o)throw new i("edit-bookmark:invalid-view","Cannot edit a bookmark without a view.");const{takeScreenshot:r,screenshotSettings:n,captureViewpoint:s,captureRotation:c,captureScale:p,captureTimeExtent:l}={...a,...e},m=r?await this._createThumbnail(n):void 0;return m&&(t.thumbnail=m),s&&(t.viewpoint=this._createViewpoint({view:o,captureScale:p,captureRotation:c})),l&&null!=o.timeExtent&&(t.timeExtent=o.timeExtent.clone()),this.emit("bookmark-edit",{bookmark:t}),t}goTo(t){const{capabilities:e,view:o}=this;if(!o)throw new i("go-to:invalid-view","Cannot go to a bookmark without a view");const a=t?.viewpoint;if(!a)throw new i("go-to:invalid-bookmark","Cannot go to a bookmark that does not contain a 'viewpoint'.",{bookmark:t});this._set("activeBookmark",t);const r=this.callGoTo({target:a}),n=t?.timeExtent;return e.time&&n&&(o.timeExtent=n),this.emit("bookmark-select",{bookmark:t}),r.catch(()=>{}).then(()=>this._set("activeBookmark",null)),r}async _createThumbnail(t){const{view:e}=this;if(!e)throw new i("bookmark:invalid-view","Cannot create slide thumbnail without a view");const o=await e.takeScreenshot({...u,...t});return new c({url:o.dataUrl})}_createViewpoint({view:t,captureRotation:o,captureScale:i}){const a=t.viewpoint?.clone();return new e({targetGeometry:t.extent?.clone(),rotation:(o?a?.rotation:null)??0,scale:(i?a?.scale:null)??0})}};t([r()],d.prototype,"capabilities",void 0),t([n("capabilities")],d.prototype,"castCapabilities",null),t([r({readOnly:!0})],d.prototype,"activeBookmark",void 0),t([r({type:m})],d.prototype,"bookmarks",null),t([r()],d.prototype,"defaultCreateOptions",null),t([r()],d.prototype,"defaultEditOptions",null),t([r({readOnly:!0})],d.prototype,"state",null),t([r()],d.prototype,"view",void 0),d=t([s("esri.widgets.Bookmarks.BookmarksViewModel")],d);const h=d;export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import o from"../../core/Accessor.js";import{initial as i,watch as e}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getGoToDuration as s}from"../../views/2d/navigation/duration.js";import{canShowNorth as n}from"./utils.js";import d
|
|
5
|
+
import{__decorate as t}from"tslib";import o from"../../core/Accessor.js";import{initial as i,watch as e}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getGoToDuration as s}from"../../views/2d/navigation/duration.js";import{canShowNorth as n}from"./utils.js";import{GoTo as d}from"../support/GoTo.js";let h=class extends(d(o)){constructor(t){super(t),this.orientation={x:0,y:0,z:0},this.view=null,this._updateForCamera=this._updateForCamera.bind(this),this._updateForRotation=this._updateForRotation.bind(this),this._updateRotationWatcher=this._updateRotationWatcher.bind(this)}initialize(){this._watchForView(i)}destroy(){this.view=null}get canShowNorth(){return n(this.view)}get state(){return!this.view?.ready||"2d"===this.view.type&&!this.view.constraints.rotationEnabled?"disabled":this.canShowNorth?"compass":"rotation"}reset(){this.view?.ready&&("2d"===this.view?.type?this.callGoTo({target:{rotation:0},options:{animationMode:"always",duration:s()}}):this.callGoTo({target:{heading:0}}))}_updateForRotation(t){null!=t&&this._set("orientation",{z:t})}_updateForCamera(t){if(!t)return;const o=-t.heading;this._set("orientation",{x:0,y:0,z:o})}_updateRotationWatcher(t){this.removeAllHandles(),this._watchForView(),t&&this.addHandles("2d"===t.type?e(()=>t?.rotation,this._updateForRotation,i):e(()=>t?.camera,this._updateForCamera,i))}_watchForView(t){this.addHandles(e(()=>this.view,this._updateRotationWatcher,t))}};t([r({readOnly:!0})],h.prototype,"canShowNorth",null),t([r({readOnly:!0})],h.prototype,"orientation",void 0),t([r({readOnly:!0})],h.prototype,"state",null),t([r()],h.prototype,"view",void 0),h=t([a("esri.widgets.Compass.CompassViewModel")],h);const p=h;export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import L from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as P,getLocale as j}from"../../intl/locale.js";const S=new p([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let T=class extends(L(r)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then(()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(P(()=>{t().then(()=>{b(this.messages,this.formats)})})),v().then(()=>{this.formatterAvailable=!0}).catch(t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(a(()=>this.view,this._handleViewChange,h),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new g({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||S){return(await W(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach(t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new g({format:e}))}o&&e.add(o)}),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>W(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===j()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))})}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:j()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i}),r=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),n=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(r)},{once:!0,initial:!0}),x.view)}};async function W(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return F.includes(t)}t([d({type:i.ofType(g)})],T.prototype,"conversions",void 0),t([l("conversions")],T.prototype,"castConversions",null),t([d({type:p})],T.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],T.prototype,"formats",void 0),t([d()],T.prototype,"messages",void 0),t([d()],T.prototype,"mode",null),t([d()],T.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],T.prototype,"state",null),t([d({types:f})],T.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],T.prototype,"storage",null),t([d()],T.prototype,"storageEnabled",void 0),t([d()],T.prototype,"storageType",void 0),t([d({readOnly:!0})],T.prototype,"waitingForConversions",null),t([d()],T.prototype,"view",void 0),T=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],T);const A=T;export{A as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import{GoTo as L}from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as P,getLocale as j}from"../../intl/locale.js";const S=new p([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let T=class extends(L(r)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then(()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(P(()=>{t().then(()=>{b(this.messages,this.formats)})})),v().then(()=>{this.formatterAvailable=!0}).catch(t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(a(()=>this.view,this._handleViewChange,h),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new g({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||S){return(await W(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach(t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new g({format:e}))}o&&e.add(o)}),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>W(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===j()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))})}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:j()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i}),r=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),n=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(r)},{once:!0,initial:!0}),x.view)}};async function W(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return F.includes(t)}t([d({type:i.ofType(g)})],T.prototype,"conversions",void 0),t([l("conversions")],T.prototype,"castConversions",null),t([d({type:p})],T.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],T.prototype,"formats",void 0),t([d()],T.prototype,"messages",void 0),t([d()],T.prototype,"mode",null),t([d()],T.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],T.prototype,"state",null),t([d({types:f})],T.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],T.prototype,"storage",null),t([d()],T.prototype,"storageEnabled",void 0),t([d()],T.prototype,"storageType",void 0),t([d({readOnly:!0})],T.prototype,"waitingForConversions",null),t([d()],T.prototype,"view",void 0),T=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],T);const A=T;export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{directionalPadMoveOnceDuration as n}from"./constants.js";import{css as s}from"./css.js";import{angleToUnitVector as r,toUnitVector as v,vectorToClosestAngle as m}from"./utils.js";import a
|
|
5
|
+
import{__decorate as t}from"tslib";import{EventedAccessor as e}from"../../core/Evented.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{directionalPadMoveOnceDuration as n}from"./constants.js";import{css as s}from"./css.js";import{angleToUnitVector as r,toUnitVector as v,vectorToClosestAngle as m}from"./utils.js";import{GoTo as a}from"../support/GoTo.js";let d=class extends(a(e)){constructor(t){super(t),this._initialAngle=void 0,this._movementVector=void 0,this._widgetCenter=void 0,this._anyAngleMovementEnabled=!1,this._movementTimeout=void 0,this._disabled=!1,this._moveOnceDuration=n,this.angle=void 0,this.speed=1,this.view=null,this.beginFollowingPointer=(t,e)=>{if(this.disabled)return;this._widgetCenter=e;const o=this._pointerLocationToVector(t);if(void 0===o)return;const i=this._resolveClosestAngle(t,o);void 0!==i&&(this._emitMove(r(i)),this.angle=i,this._initialAngle=i,this._setMovementTimeout(()=>{void 0===this._widgetCenter&&this._stopMovement()}),document.addEventListener("pointermove",this._onPointerMove,{passive:!0}),document.addEventListener("pointerup",this._onPointerUp,{passive:!0,once:!0}))},this.moveOnce=t=>{const e=r(t);this._emitMove(e),this._setMovementTimeout(this._stopMovement)},this._pointerLocationToVector=t=>{if(void 0===this._widgetCenter)return;const{x:e,y:o}=v(this._widgetCenter,t);return{x:e,y:-o}},this._resolveClosestAngle=(t,e)=>{const o=t.target,i=o?.getAttribute?.("data-angle"),n=o?.classList?.contains(s.compassButton);if(n)return;const r=Number.parseInt(i??"",10);return Number.isNaN(r)?m(e):r},this._onPointerMove=t=>{if(0===t.buttons)return void this._stopMovement();const e=this._pointerLocationToVector(t);if(void 0===e)return;this._setMovementTimeout(void 0);const o=this._resolveClosestAngle(t,e);if(void 0===o)return void this._emitStop();const i=r(o),n=null!=this._initialAngle&&this._initialAngle!==o;this._anyAngleMovementEnabled||=n;const s=this._anyAngleMovementEnabled?e:i;(s.x!==this._movementVector?.x||s.y!==this._movementVector?.y)&&(this.angle=o,this._emitMove(s))},this._onPointerUp=()=>{void 0===this._movementTimeout?this._stopMovement():this._widgetCenter=void 0},this._stopMovement=()=>{this._emitStop(),this._widgetCenter=void 0,this._initialAngle=void 0,this._anyAngleMovementEnabled=!1,document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._stopMovement),this._setMovementTimeout(void 0)},this.on("move-start",()=>this.view?.mapViewNavigation.begin()),this.on("move-direction-change",({vector:{x:t,y:e}})=>this.view?.mapViewNavigation.continuousPanVector({x:t*this.speed,y:e*this.speed})),this.on("move-stop",()=>this.view?.mapViewNavigation.stop())}destroy(){this._stopMovement()}get disabled(){const{view:t,_disabled:e,supported:o}=this;return!1===t?.ready||e||!o}set disabled(t){this._disabled=t}get rotation(){return this.view?.rotation??this._get("rotation")??0}set rotation(t){this.view?this.view.constraints.rotationEnabled&&this.callGoTo({target:{rotation:t},options:{animate:0===t&&void 0}}):this._set("rotation",t)}get supported(){return null==this.view||"2d"===this.view.type}get state(){const{disabled:t,angle:e}=this;return t?"disabled":null!=e?"moving":"ready"}_setMovementTimeout(t){clearTimeout(this._movementTimeout),this._movementTimeout=void 0===t?void 0:setTimeout(()=>{this._movementTimeout=void 0,t()},this._moveOnceDuration)}_emitMove(t){null==this._movementVector&&this._emitMoveStartEvent({vector:t});const e=this._movementVector;this._movementVector=t,this._emitMoveDirectionChangeEvent({vector:t,oldVector:e})}_emitStop(){this.angle=void 0,void 0!==this._movementVector&&(this._emitMoveStopEvent({oldVector:this._movementVector}),this._movementVector=void 0)}_emitMoveStartEvent(t){this.emit("move-start",{...t,type:"move-start"})}_emitMoveDirectionChangeEvent(t){this.emit("move-direction-change",{...t,type:"move-direction-change"})}_emitMoveStopEvent(t){this.emit("move-stop",{...t,type:"move-stop"})}};t([o()],d.prototype,"_initialAngle",void 0),t([o()],d.prototype,"_movementVector",void 0),t([o()],d.prototype,"_widgetCenter",void 0),t([o()],d.prototype,"_anyAngleMovementEnabled",void 0),t([o()],d.prototype,"_movementTimeout",void 0),t([o()],d.prototype,"_disabled",void 0),t([o()],d.prototype,"_moveOnceDuration",void 0),t([o()],d.prototype,"disabled",null),t([o()],d.prototype,"angle",void 0),t([o({type:Number,range:{min:0,max:100}})],d.prototype,"speed",void 0),t([o()],d.prototype,"rotation",null),t([o()],d.prototype,"supported",null),t([o({readOnly:!0})],d.prototype,"state",null),t([o()],d.prototype,"view",void 0),d=t([i("esri.widgets.DirectionalPad.DirectionalPadViewModel")],d);const h=d;export{h as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,formatTimestamp as m,convertDateFormatToIntlOptions as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as f}from"../../intl/locale.js";import{fetchServiceDescription as g}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as D,defaultTimePattern as S}from"../../support/dateUtils.js";import{system as C}from"../../time/constants.js";import{shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import I from"../support/GoTo.js";import{DateTime as L,FixedOffsetZone as j,IANAZone as R}from"luxon";function P(e){return e.map(e=>({locale:e,parts:f(e)})).filter(({parts:e})=>!!e)}function E(e,t){return e.find(({parts:e})=>O(e.language,t.language)&&e.region===t.region)?.locale??e.find(({parts:e})=>O(e.language,t.language))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function O(e,t){return e===t||N(e)&&N(t)}function V(e){return"esri.rest.support.Stop"===e?.declaredClass}let k=class extends(I(i)){constructor(e){super(e),this._debouncedSolveHandler=s(async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}}),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=3,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=void 0,this.departureIsoTime=void 0,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l(()=>this.layer,e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d(()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null,e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)},{once:!0}))}},u),l(()=>[this.layer,this.view],async()=>{this._layerView=await this._getRouteLayerView()},u),n(()=>this._layerView,["create","delete","update"],e=>{this._debouncedSolveHandler(e).catch(e=>{if(!a(e))throw e})})]);const e=p(this.view?.timeZone??C),t=L.fromMillis(Date.now());this.departureIsoDate=t.toFormat(D,A(e)),this.departureIsoTime=t.toFormat(S,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=f(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=L.fromJSDate(e,{zone:j.instance(t)}),i=L.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=L.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:v("short-date"),n=v("short-time");return m(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case 4:return"unauthenticated";case 3:return"disabled";case 0:return"initializing";case 2:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=V(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||2===this._serviceDescriptionStatus)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter(({geometry:e})=>null!=e).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}i.stops.forEach(e=>e.sequence=null),this._routeController=new AbortController;const{signal:d}=this._routeController;let h=null;try{h=await i.solve(u,{signal:d})}catch(c){if(!a(c)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:c});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of h.stops)null==r.geometry&&(r.name=null);return i.update(h),this._set("lastRoute",h),e.zoomToSolvedRoute&&this.zoomToRoute(),h}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find(({name:t,usageType:r})=>t===e&&"cost"===r)??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=L.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:j.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=0;const t=await g(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=1}catch(t){if(a(t))return void(this._serviceDescriptionStatus=3);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=4);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=2,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find(({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase()),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find(({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase());return o??t}};e([h()],k.prototype,"_directionsLanguage",null),e([h()],k.prototype,"_layerView",void 0),e([h()],k.prototype,"_routeController",void 0),e([h()],k.prototype,"_serviceDescriptionStatus",void 0),e([h()],k.prototype,"apiKey",void 0),e([h()],k.prototype,"autoSolve",void 0),e([h()],k.prototype,"defaultTravelMode",void 0),e([h()],k.prototype,"departureTime",void 0),e([h()],k.prototype,"formattedEta",null),e([h({readOnly:!0})],k.prototype,"impedanceAttribute",null),e([h()],k.prototype,"lastError",void 0),e([h({readOnly:!0})],k.prototype,"lastRoute",void 0),e([h()],k.prototype,"layer",void 0),e([h({type:Number,range:{min:2,max:50},nonNullable:!0})],k.prototype,"maxStops",void 0),e([h({type:w,nonNullable:!0})],k.prototype,"routeParameters",void 0),e([h({readOnly:!0})],k.prototype,"selectedNetworkFeatures",null),e([h({type:T})],k.prototype,"selectedTravelMode",null),e([h({readOnly:!0})],k.prototype,"serviceDescription",void 0),e([h({readOnly:!0})],k.prototype,"state",null),e([h({readOnly:!0})],k.prototype,"timeAttribute",null),e([h()],k.prototype,"travelModes",null),e([h()],k.prototype,"view",void 0),e([h()],k.prototype,"zoomToRoute",null),k=e([c("esri.widgets.Directions.DirectionsViewModel")],k);const z=k;export{z as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as a}from"../../core/promiseUtils.js";import{watch as l,on as n,syncAndInitial as u,when as d}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{resolveTimeZone as p,formatTimestamp as m,convertDateFormatToIntlOptions as v}from"../../intl/date.js";import{getLocale as y,getLocaleParts as f}from"../../intl/locale.js";import{fetchServiceDescription as g}from"../../rest/networkService.js";import w from"../../rest/support/RouteParameters.js";import _ from"../../rest/support/Stop.js";import T from"../../rest/support/TravelMode.js";import{defaultDatePattern as D,defaultTimePattern as S}from"../../support/dateUtils.js";import{system as C}from"../../time/constants.js";import{shortTimeZoneName as b}from"../../time/timeZoneUtils.js";import{DepartureTimeOption as M}from"./support/directionsUtils.js";import{getDefaultLocaleOptions as A}from"../support/dateUtils.js";import{GoTo as I}from"../support/GoTo.js";import{DateTime as L,FixedOffsetZone as j,IANAZone as R}from"luxon";function P(e){return e.map(e=>({locale:e,parts:f(e)})).filter(({parts:e})=>!!e)}function E(e,t){return e.find(({parts:e})=>O(e.language,t.language)&&e.region===t.region)?.locale??e.find(({parts:e})=>O(e.language,t.language))?.locale}function U(e){return"esri.Graphic"===e?.declaredClass}function N(e){return"no"===e||"nb"===e}function O(e,t){return e===t||N(e)&&N(t)}function V(e){return"esri.rest.support.Stop"===e?.declaredClass}let k=class extends(I(i)){constructor(e){super(e),this._debouncedSolveHandler=s(async e=>{switch(e.type){case"create":if("complete"!==e.state)return;break;case"delete":break;case"update":switch(e.state){case"start":return void(this._networkFeatureUpdated=!1);case"active":return void(this._networkFeatureUpdated=!0);case"complete":if(!this._networkFeatureUpdated)return}}if(!((this.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2)&&this.autoSolve)try{await this.getDirections({zoomToSolvedRoute:!1})}catch(t){o.getLogger(this).error(t)}}),this._highlight=null,this._loadController=null,this._loadPromise=null,this._networkFeatureUpdated=!1,this._layerView=null,this._routeController=null,this._serviceDescriptionStatus=3,this.apiKey=void 0,this.autoSolve=!0,this.defaultTravelMode=null,this.departureIsoDate=void 0,this.departureIsoTime=void 0,this.departureOption=M.NOW,this.departureTime="now",this.lastError=null,this.lastRoute=null,this.layer=null,this.maxStops=50,this.routeParameters=new w({directionsLengthUnits:"kilometers",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,returnZ:!0,useTimeWindows:!1}),this.serviceDescription=null,this.view=null}initialize(){this.addHandles([l(()=>this.layer,e=>{if(null!=e){for(;e.stops.length<2;)e.stops.add(new _);this._set("defaultTravelMode",null),this.addHandles(d(()=>this.serviceDescription?e.routeInfo?.analysisSettings?.travelMode:null,e=>{this.defaultTravelMode=this._resolveDefaultTravelMode(e)},{once:!0}))}},u),l(()=>[this.layer,this.view],async()=>{this._layerView=await this._getRouteLayerView()},u),n(()=>this._layerView,["create","delete","update"],e=>{this._debouncedSolveHandler(e).catch(e=>{if(!a(e))throw e})})]);const e=p(this.view?.timeZone??C),t=L.fromMillis(Date.now());this.departureIsoDate=t.toFormat(D,A(e)),this.departureIsoTime=t.toFormat(S,A(e))}get _directionsLanguage(){const e=this.serviceDescription?.directionsSupportedLanguages;if(!e)return;const t=this.routeParameters.directionsLanguage??y(),r=f(t),i=r?.language,o=r?.region;if(!i)return;return E(P(e),{language:i,region:o})}get formattedEta(){const e=this.layer?.routeInfo?.endTime,t=this.layer?.routeInfo?.endTimeOffset;if(this.departureOption===M.UNSPECIFIED||!e||!t)return null;const r=L.fromJSDate(e,{zone:j.instance(t)}),i=L.fromJSDate(e,{zone:R.create(p(this.view?.timeZone??C))}),o=L.fromJSDate(new Date,{zone:R.create(p(this.view?.timeZone??C))}),s=o.year===i.year&&o.month===i.month&&o.day===i.day,a=i.offset===t?void 0:b,l=s?void 0:v("short-date"),n=v("short-time");return m(r.toISO(),{...l,...n,timeZoneName:a})}get impedanceAttribute(){const e=this.routeParameters.travelMode?.impedanceAttributeName??this.routeParameters.impedanceAttribute??this.serviceDescription?.impedance??null;return this.getCostAttribute(e)}get selectedNetworkFeatures(){return this._layerView?.selectedNetworkFeatures??null}get selectedTravelMode(){return this.serviceDescription?this.defaultTravelMode??this.serviceDescription.defaultTravelMode??this.serviceDescription.supportedTravelModes?.[0]??null:null}set selectedTravelMode(e){this._override("selectedTravelMode",e)}get state(){if(this._routeController)return"routing";if(this.lastError)return"error";switch(this._serviceDescriptionStatus){case 4:return"unauthenticated";case 3:return"disabled";case 0:return"initializing";case 2:return"error";default:return"ready"}}get timeAttribute(){const e=this.routeParameters.travelMode?.timeAttributeName??this.routeParameters.directionsTimeAttribute??this.serviceDescription?.directionsTimeAttribute??null;return this.getCostAttribute(e)}get travelModes(){const e=this.serviceDescription?.supportedTravelModes?.slice()??[];return null==this.defaultTravelMode||e.includes(this.defaultTravelMode)||e.unshift(this.defaultTravelMode),e}async load(){if(this._loadPromise)return this._loadPromise;this._loadPromise=this._load(),await this._loadPromise,this._loadPromise=null}async highlight(e){if(this.clearHighlights(),!this.view||!this.layer)return;const t=await this.view.whenLayerView(this.layer);this._highlight=t.highlight(e)}clearHighlights(){null!=this._highlight&&(this._highlight.remove(),this._highlight=null)}centerAt(e){if(!this.view)return;const t=V(e)||U(e)?e.geometry:e;t&&this.callGoTo({target:t})}clearResults(){this._set("lastRoute",null),this.layer?.removeResult()}async create(e){await(this._layerView?.create(e))}async getDirections(e={zoomToSolvedRoute:!0}){const{apiKey:t,layer:i,state:o}=this;if(!i)throw new r("directions-view-model:missing-route-layer","A route layer must be associated with the view model.");if("unauthenticated"===o||"initializing"===o||"disabled"===o||2===this._serviceDescriptionStatus)throw new r("directions-view-model:not-loaded","Cannot get directions until view model loads.");null!=this._routeController&&(this._routeController.abort(),this._routeController=null);const{startTime:s,startTimeIsUTC:l}=this._getStartTimeParameters(),n=this.view?.spatialReference??null,u=this.routeParameters.clone();u.set({apiKey:t,directionsLanguage:this._directionsLanguage,outSpatialReference:n,startTime:s,startTimeIsUTC:l}),this.selectedTravelMode&&(u.travelMode=this.selectedTravelMode);if(i.stops.filter(({geometry:e})=>null!=e).length<2){const e=new r("directions-view-model:not-enough-stops","Not enough stops for routing");throw this._set("lastError",e),e}i.stops.forEach(e=>e.sequence=null),this._routeController=new AbortController;const{signal:d}=this._routeController;let h=null;try{h=await i.solve(u,{signal:d})}catch(c){if(!a(c)){const e=new r("directions-view-model:unable-to-route","Unable to route to these addresses",{error:c});throw this._set("lastError",e),this.clearResults(),e}}finally{this._routeController=null}this._set("lastError",null);for(const r of h.stops)null==r.geometry&&(r.name=null);return i.update(h),this._set("lastRoute",h),e.zoomToSolvedRoute&&this.zoomToRoute(),h}getCostAttribute(e){return(this.serviceDescription?.networkDataset?.networkAttributes??[]).find(({name:t,usageType:r})=>t===e&&"cost"===r)??null}remove(e){this._layerView?.remove(e)}reset(){this.clearHighlights(),this.clearResults(),null!=this.layer&&(this.layer.removeAll(),this.layer.stops=new t([new _,new _]))}save(){if(!this.layer)throw new r("directions-view-model:missing-layer","save() requires a layer");return this.layer.save()}saveAs(e,t={}){if(!this.layer)throw new r("directions-view-model:missing-layer","saveAs() requires a layer");return this.layer.saveAs(e,t)}async startEditing(){this._layerView&&(this._layerView.interactive=!0)}async stopEditing(){this._layerView&&(this._layerView.interactive=!1)}updateDepartureTime(){if(this.departureIsoDate&&this.departureIsoTime)switch(this.departureOption){case M.NOW:this.departureTime="now";break;case M.DEPART_AT:{const e=L.fromISO(`${this.departureIsoDate}T${this.departureIsoTime}`,{zone:j.instance(0)});this.departureTime=e.toJSDate();break}case M.UNSPECIFIED:this.departureTime=null}}zoomToRoute(){const{view:e,layer:t}=this,r=t?.routeInfo?.geometry?.extent;if(!e||!r)return;const i=r.width>r.height,o=r.clone().expand(i?2:1);this.callGoTo({target:o})}async _getRouteLayerView(){return this.view&&this.layer?this.view.whenLayerView(this.layer):null}_getStartTimeParameters(){if("now"===this.departureTime){return{startTime:this.serviceDescription?.capabilities.supportsNow??!1?"now":new Date,startTimeIsUTC:!0}}return null==this.departureTime?{startTime:void 0,startTimeIsUTC:void 0}:{startTime:this.departureTime,startTimeIsUTC:!1}}async _load(){if(null==this.layer)return;null!=this._loadController&&(this._loadController.abort(),this._loadController=null),this._loadController=new AbortController;const{signal:e}=this._loadController;try{this._serviceDescriptionStatus=0;const t=await g(this.layer.url,this.apiKey,{signal:e});this._set("serviceDescription",t),this._serviceDescriptionStatus=1}catch(t){if(a(t))return void(this._serviceDescriptionStatus=3);if("identity-manager:user-aborted"===t.name)return void(this._serviceDescriptionStatus=4);const e=new r("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:t});throw this._serviceDescriptionStatus=2,this._set("lastError",e),e}finally{this._loadController=null}}_resolveDefaultTravelMode(e){if(null==this.serviceDescription)return null;const{defaultTravelMode:t,supportedTravelModes:r}=this.serviceDescription,i=/^<(?<name>.*)>$/i.exec(e.name)?.groups?.name;if(i){const o=r?.find(({name:e})=>e.toLocaleLowerCase()===i.trim().toLocaleLowerCase()),s=o??t;return T.fromJSON({...s?.toJSON(),...e.toJSON()})}const o=r?.find(({name:t})=>t.toLocaleLowerCase()===e.name.toLocaleLowerCase());return o??t}};e([h()],k.prototype,"_directionsLanguage",null),e([h()],k.prototype,"_layerView",void 0),e([h()],k.prototype,"_routeController",void 0),e([h()],k.prototype,"_serviceDescriptionStatus",void 0),e([h()],k.prototype,"apiKey",void 0),e([h()],k.prototype,"autoSolve",void 0),e([h()],k.prototype,"defaultTravelMode",void 0),e([h()],k.prototype,"departureTime",void 0),e([h()],k.prototype,"formattedEta",null),e([h({readOnly:!0})],k.prototype,"impedanceAttribute",null),e([h()],k.prototype,"lastError",void 0),e([h({readOnly:!0})],k.prototype,"lastRoute",void 0),e([h()],k.prototype,"layer",void 0),e([h({type:Number,range:{min:2,max:50},nonNullable:!0})],k.prototype,"maxStops",void 0),e([h({type:w,nonNullable:!0})],k.prototype,"routeParameters",void 0),e([h({readOnly:!0})],k.prototype,"selectedNetworkFeatures",null),e([h({type:T})],k.prototype,"selectedTravelMode",null),e([h({readOnly:!0})],k.prototype,"serviceDescription",void 0),e([h({readOnly:!0})],k.prototype,"state",null),e([h({readOnly:!0})],k.prototype,"timeAttribute",null),e([h()],k.prototype,"travelModes",null),e([h()],k.prototype,"view",void 0),e([h()],k.prototype,"zoomToRoute",null),k=e([c("esri.widgets.Directions.DirectionsViewModel")],k);const z=k;export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Point.js";import{project as g,initializeProjection as f}from"../../geometry/projectionUtils.js";import m from"../../geometry/SpatialReference.js";import{getPointFromGeometry as y}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as _}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as C}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToClusteredFeatures as E,browseClusteredFeatures as V,zoomToFeature as j}from"../Popup/actions.js";import{triggerAction as L,isClusterFeature as A,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as x,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import T from"../support/AnchorElementViewModel.js";import S from"../support/GoTo.js";const B="location-scale-handle",H=()=>[j.clone()],U=()=>[E.clone(),V.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(S(T)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=g(i,t),G||(G=await Promise.all([await import("../../geometry/operators/intersectsOperator.js"),await import("../../geometry/operators/proximityOperator.js")]));const[a,n]=G;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=y(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),l(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),l(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),l(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>L({event:e,viewModel:this,view:this.view})),u(()=>!this.waitingForResult,()=>this._waitingForResultChange(),h),l(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),l(()=>this.view?.scale,()=>this._viewScaleChange()),u(()=>!this.visible,()=>this.browseClusterEnabled=!1),l(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await x(this),await O(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(j.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await _(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await _(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=y(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(B),this.addHandles([l(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{a(e)||r.getLogger(this).error(e)})),u(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&C(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:M})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:M,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c()],z.prototype,"initialDisplayMode",void 0),e([c({type:d})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({type:m})],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import r from"../../core/Logger.js";import{debounce as o,isAbortError as a}from"../../core/promiseUtils.js";import n from"../../core/ReactiveSet.js";import{watch as l,when as u,sync as h}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Point.js";import{project as g,initializeProjection as f}from"../../geometry/projectionUtils.js";import m from"../../geometry/SpatialReference.js";import{getPointFromGeometry as y}from"../../geometry/support/geometryUtils.js";import{geographicToWebMercator as w}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as F}from"../../layers/LayerConstants.js";import v from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as _}from"../../symbols/support/symbolUtils.js";import{system as b}from"../../time/constants.js";import{highlightsSupported as C}from"../../views/support/layerViewUtils.js";import P from"../Feature/FeatureViewModel.js";import{ActionsCollection as M,zoomToClusteredFeatures as E,browseClusteredFeatures as V,zoomToFeature as j}from"../Popup/actions.js";import{triggerAction as L,isClusterFeature as A,getSelectedTarget as I,removeClusteredFeaturesForBrowsing as R,displayClusterExtent as x,browseAggregateFeatures as O}from"../Popup/actionUtils.js";import T from"../support/AnchorElementViewModel.js";import{GoTo as S}from"../support/GoTo.js";const B="location-scale-handle",H=()=>[j.clone()],U=()=>[E.clone(),V.clone()];let G=null;function Z(e,t){return"building-scene"===e||"map-image"===e||"tile"===e||"imagery"===e||"2d"===t&&"imagery-tile"===e}let z=class extends(S(T)){constructor(e){super(e),this._pendingPromises=new n,this._fetchFeaturesController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this.actions=new M,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode="feature",this.selectedClusterBoundaryFeature=new t({symbol:new v({outline:{width:1.5,color:"cyan"},style:"none"})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=o(async e=>{const{spatialReference:t}=this,i=this.selectedFeature?.geometry?.type,s=this.location??e;if(i&&"mesh"!==i&&t&&s&&this.selectedFeature)if("point"!==i)try{const e=this.selectedFeature;let i=e.geometry;const r=this._getHighlightLayer(e),o=e.getObjectId();if(!r||!this.view)return;if(o){const e=this.view?.allLayerViews.find(e=>e.layer.uid===r.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:a}=await e.queryFeatures(s);i=a[0]?.geometry}if(!i||"mesh"===i.type)return;i=g(i,t),G||(G=await Promise.all([await import("../../geometry/operators/intersectsOperator.js"),await import("../../geometry/operators/proximityOperator.js")]));const[a,n]=G;if(!a.execute(i,s)){const t=n.getNearestCoordinate(i,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(o){a(o)||r.getLogger(this).error(o)}else this.location=y(this.selectedFeature.geometry)??s})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),l(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),l(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),l(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),l(()=>this.location,e=>this._locationChange(e)),l(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),l(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),l(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),l(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",e=>L({event:e,viewModel:this,view:this.view})),u(()=>!this.waitingForResult,()=>this._waitingForResultChange(),h),l(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),l(()=>this.view?.scale,()=>this._viewScaleChange()),u(()=>!this.visible,()=>this.browseClusterEnabled=!1),l(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const e=this._get("allActions")||new M;e.removeAll();const{actions:t,defaultActions:i,defaultPopupTemplateEnabled:s,includeDefaultActions:r,selectedFeature:o}=this,a=r?i.concat(t):t,n=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),l=n?.actions,u=n?.overwriteActions?l:l?.concat(a)??a;return u?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){const e=this._get("defaultActions")||new M;return e.removeAll(),e.addMany(A(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){const t=e||[];this._set("features",t);const{pendingPromisesCount:i,promiseCount:s,selectedFeatureIndex:r}=this,o=s&&t.length;"list"!==this.initialDisplayMode?o&&i&&-1===r?this.selectedFeatureIndex=0:o&&-1!==r||(this.selectedFeatureIndex=t.length?0:-1):(!o||o&&i===s)&&(this.selectedFeatureIndex=-1)}set location(e){let t=e;const i=this.spatialReference?.isWebMercator,s=e?.spatialReference?.isWGS84;s&&i&&(t=w(e)),this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")||[]}set promises(e){this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),(e=e.slice()).forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const{features:e,selectedFeatureIndex:t}=this;if(-1===t)return null;return e[t]||null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){const{view:e,map:t}=this;return e?e.ready?"ready":"disabled":t?"ready":"disabled"}get timeZone(){return this.view?.timeZone??b}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!(!(!!this._fetchFeaturesController||this.pendingPromisesCount>0)||0!==this.featureCount)}centerAtLocation(){const{view:e}=this,t=I(this);return t&&e?this.callGoTo({target:{target:t,scale:e.scale}}):Promise.reject(new s("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}zoomTo(e){return this.callGoTo(e)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new s("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:e,view:i});return i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){const t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:i}=t;delete t.fetchFeatures,i&&this._setFetchFeaturesPromises(t.location);const s=["actionsMenuOpen","collapsed"];for(const r of s)delete t[r];this.set(t)}triggerAction(e){const t=this.allActions.at(e);t&&!t.disabled&&this.emit("trigger-action",{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){R(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const{view:e,selectedFeature:t}=this;"2d"===e?.type?A(t)?(await x(this),await O(this)):r.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",t):r.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",t)}handleViewClick(e){this._fetchFeaturesAndOpen(e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(j.disabled="waiting-for-target"===e)}_clearBrowsedClusterGraphics(){const e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(i);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(A(this.selectedFeature))return this.browseClusterEnabled=!1,this.visible=!1,void this.clear();this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:s}=this;s&&i&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:s,featureViewModels:r}=this;if(null==i)return;const o=((i-1)*s+t)%t,a=o+s;r.slice(o,a).forEach((t,i)=>{t&&(t.graphic??=e[o+i])})}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:s}=this;if(!e||!s)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&(s.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),A(e))return;return e.symbol=await _(e),this._selectedClusterFeature=e,void s.graphics.add(this._selectedClusterFeature)}const r=e.sourceLayer?.type;if("map-image"!==r&&"imagery"!==r&&"imagery-tile"!==r||(e.symbol=await _(e)),!i&&t||!e.geometry){if(i&&!e.geometry){await this.centerAtLocation();const e=s.center?.clone();e&&(this.location=e)}}else this.location=y(e.geometry)}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(e){const{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",[])}_updateFeatureVMs(){const{selectedFeature:e,features:t,featureViewModels:i,view:s,spatialReference:r,map:o,timeZone:a,location:n}=this;if(A(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;const l=i.slice(),u=[];t.forEach((t,i)=>{if(!t)return;let h=null;if(l.some((e,i)=>(e&&e.graphic===t&&(h=e,l.splice(i,1)),!!h)),h)u[i]=h;else{const l=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:r,graphic:t===e?t:null,location:n,map:o,view:s,timeZone:a});u[i]=l}}),l.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureViewModels",u)}async _getScreenPoint(e,t){const{spatialReference:i,view:s}=this;if(!s)return null;await(s?.when());const r=e?.spatialReference;return r&&i?(await f(r,i,null,t),s.toScreen(e)):null}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:s}),{signal:s,event:i})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const s=new AbortController,{signal:r}=s;this._fetchFeaturesController=s;const o=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:r,event:i});return o.catch(()=>{}).then(()=>{this._fetchFeaturesController=null}),o}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e,{view:s}=this;this.removeHandles(B),this.addHandles([l(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{a(e)||r.getLogger(this).error(e)})),u(()=>!this.visible,()=>{this.removeHandles(B)},{once:!0})],B);const{pendingFeatures:o}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e});s?.popup&&"open"in s.popup&&s.popup.open({location:t??void 0,promises:o})}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const{layer:t,sourceLayer:i}=e;return i&&"layer"in i&&i.layer?i.layer:"map-notes"===i?.type||"subtype-group"===i?.type?i:t??i}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(Z(t.type,i))return e;const s=e.getObjectId();if(null!=s)return s;const r="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||F:null,o=e.attributes;return o&&r&&o[r]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:s,view:r,visible:o}=this;if(!r||!s||!o)return;const a=this._getHighlightLayer(i);if(!a)return;const n=this._getHighlightLayerView(r,a);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&C(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,a,r.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}_updateFeatures(e){const{features:t}=this,i=e.filter(e=>!t.includes(e));i?.length&&(this.features=t.concat(i))}};e([c()],z.prototype,"_fetchFeaturesController",void 0),e([c({type:M})],z.prototype,"actions",void 0),e([c({readOnly:!0})],z.prototype,"active",null),e([c()],z.prototype,"activeFeature",void 0),e([c({readOnly:!0})],z.prototype,"allActions",null),e([c()],z.prototype,"autoCloseEnabled",void 0),e([c()],z.prototype,"browseClusterEnabled",void 0),e([c()],z.prototype,"content",void 0),e([c({type:M,readOnly:!0})],z.prototype,"defaultActions",null),e([c({type:Boolean})],z.prototype,"defaultPopupTemplateEnabled",void 0),e([c({readOnly:!0})],z.prototype,"featureCount",null),e([c()],z.prototype,"featurePage",void 0),e([c({value:[]})],z.prototype,"features",null),e([c()],z.prototype,"featuresPerPage",void 0),e([c()],z.prototype,"featureMenuOpen",void 0),e([c()],z.prototype,"featureMenuTitle",void 0),e([c()],z.prototype,"featureViewModelAbilities",void 0),e([c({readOnly:!0})],z.prototype,"featureViewModels",void 0),e([c()],z.prototype,"highlightEnabled",void 0),e([c()],z.prototype,"includeDefaultActions",void 0),e([c()],z.prototype,"initialDisplayMode",void 0),e([c({type:d})],z.prototype,"location",null),e([c()],z.prototype,"map",null),e([c({readOnly:!0})],z.prototype,"pendingPromisesCount",null),e([c({readOnly:!0})],z.prototype,"promiseCount",null),e([c()],z.prototype,"promises",null),e([c({readOnly:!0})],z.prototype,"selectedClusterBoundaryFeature",void 0),e([c({value:null,readOnly:!0})],z.prototype,"selectedFeature",null),e([c({value:-1})],z.prototype,"selectedFeatureIndex",null),e([c({readOnly:!0})],z.prototype,"selectedFeatureViewModel",null),e([c({type:m})],z.prototype,"spatialReference",null),e([c({readOnly:!0})],z.prototype,"state",null),e([c()],z.prototype,"timeZone",null),e([c()],z.prototype,"title",void 0),e([c()],z.prototype,"updateLocationEnabled",void 0),e([c()],z.prototype,"view",void 0),e([c()],z.prototype,"visible",void 0),e([c({readOnly:!0})],z.prototype,"waitingForContents",null),e([c({readOnly:!0})],z.prototype,"waitingForResult",null),e([c()],z.prototype,"zoomFactor",void 0),e([c()],z.prototype,"zoomToLocation",void 0),e([c()],z.prototype,"centerAtLocation",null),z=e([p("esri.widgets.Features.FeaturesViewModel")],z);export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as i}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import l from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../webdoc/Widgets.js";import u from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as p}from"../../webmap/utils.js";import y from"../support/GoTo.js";function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(t)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o(()=>this.view?.map,e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=i(async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)})},a),o(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},n),o(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),o(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e})])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site));return t.sort((e,t)=>{const i=e.name,s=t.name;return i.localeCompare(s,void 0,{sensitivity:"base"})})}filterSites(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}));return t.sort((e,t)=>{const i=e.name,s=t.name;return i.localeCompare(s,void 0,{sensitivity:"base"})})}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach(e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)}),!i)){let e=null;t.forEach(t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"quad-in-out"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)}),t.floors=new s(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new u({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new f({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)})}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)}),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)}),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new l("floorfilter:unsupported-map","Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter(e=>"feature"===e.type||"scene"===e.type),n=i.items.filter(e=>"map-image"===e.type);if(n?.length>0&&o){await Promise.all(n.map(e=>e.load()));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach(t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach(t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)})})}a?.length>0&&a.forEach(t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach(t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})})}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach(e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})})}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,f=await s.queryFeatures(r);if(f?.features?.length>0){const e=f.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,u=s?.fieldsIndex.get(h)?.name||h,p=s?.fieldsIndex.get(d)?.name||d,y=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&u&&p&&y&&e.forEach(e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[u],d=s[p],c=s[y];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})})}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:i,facility:l}=this,r=[];t.levels.levelsInfo.forEach(e=>{const{id:t,facilityId:s}=e;l&&s===l?i&&t===i&&r.push(t):r.push(t)}),e.floorInfo.viewAllLevelIds=new s(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri.widgets.FloorFilter.FloorFilterViewModel")],m);const F=m;export{F as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as i}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import l from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../webdoc/Widgets.js";import u from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as p}from"../../webmap/utils.js";import{GoTo as y}from"../support/GoTo.js";function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(t)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o(()=>this.view?.map,e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=i(async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)})},a),o(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},n),o(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),o(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e})])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site));return t.sort((e,t)=>{const i=e.name,s=t.name;return i.localeCompare(s,void 0,{sensitivity:"base"})})}filterSites(e){let t=e;this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}));return t.sort((e,t)=>{const i=e.name,s=t.name;return i.localeCompare(s,void 0,{sensitivity:"base"})})}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach(e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)}),!i)){let e=null;t.forEach(t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"quad-in-out"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)}),t.floors=new s(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new u({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new f({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)})}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)}),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&i.push(e.id)})}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach(e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)}),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new l("floorfilter:unsupported-map","Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter(e=>"feature"===e.type||"scene"===e.type),n=i.items.filter(e=>"map-image"===e.type);if(n?.length>0&&o){await Promise.all(n.map(e=>e.load()));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach(t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach(t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)})})}a?.length>0&&a.forEach(t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach(t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})})}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach(e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})})}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,f=await s.queryFeatures(r);if(f?.features?.length>0){const e=f.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,u=s?.fieldsIndex.get(h)?.name||h,p=s?.fieldsIndex.get(d)?.name||d,y=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&u&&p&&y&&e.forEach(e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[u],d=s[p],c=s[y];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})})}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:i,facility:l}=this,r=[];t.levels.levelsInfo.forEach(e=>{const{id:t,facilityId:s}=e;l&&s===l?i&&t===i&&r.push(t):r.push(t)}),e.floorInfo.viewAllLevelIds=new s(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri.widgets.FloorFilter.FloorFilterViewModel")],m);const F=m;export{F as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as o}from"tslib";import t from"../../Viewpoint.js";import i from"../../core/Error.js";import{EventedAccessor as e}from"../../core/Evented.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import s
|
|
5
|
+
import{__decorate as o}from"tslib";import t from"../../Viewpoint.js";import i from"../../core/Error.js";import{EventedAccessor as e}from"../../core/Evented.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{GoTo as s}from"../support/GoTo.js";let l=class extends(s(e)){constructor(o){super(o),this._initialViewpoint=null,this._goingHomeController=null,this.go=this.go.bind(this)}destroy(){this._cancelGo(),this.view=null}get state(){return this.view?.ready?this._goingHomeController?"going-home":"ready":"disabled"}set view(o){this._initialViewpoint=null,this._set("view",o),o&&o.when().then(()=>{this.view===o&&(this._initialViewpoint=o.viewpoint.clone(),this.notifyChange("viewpoint"))})}get viewpoint(){return this._get("viewpoint")||this._initialViewpoint}set viewpoint(o){this._set("viewpoint",o)}async go(){if(!this.view?.ready)throw new i("home:disabled-state","Cannot go when disabled.");this._cancelGo(),this.emit("go");const o=new AbortController;this._goingHomeController=o;try{await(this.view?.when()),await this.callGoTo({target:this.viewpoint,options:{signal:o.signal}})}catch(t){}this._goingHomeController=null}cancelGo(){this._cancelGo()}_cancelGo(){const{_goingHomeController:o}=this;o&&o.abort(),this._goingHomeController=null}};o([r()],l.prototype,"_goingHomeController",void 0),o([r({readOnly:!0})],l.prototype,"state",null),o([r()],l.prototype,"view",null),o([r({type:t})],l.prototype,"viewpoint",null),o([r()],l.prototype,"go",null),o([r()],l.prototype,"cancelGo",null),l=o([n("esri.widgets.Home.HomeViewModel")],l);const p=l;export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import J from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=x.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(q,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new l("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>this.messages),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return u(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),n.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===z){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import l from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{mappedFind as u}from"../../core/maybe.js";import{eachAlways as c,after as h}from"../../core/promiseUtils.js";import{watch as p,initial as g,whenOnce as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../geometry/Point.js";import S from"../../geometry/SpatialReference.js";import{getPointFromGeometry as _,getPointWithElevation as v}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as w}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";import x from"../../portal/Portal.js";import{isApiKeyApplicable as L}from"../../support/apiKeyUtils.js";import I from"../../symbols/PictureMarkerSymbol.js";import T from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/TextSymbol.js";import{highlightsSupported as F}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import j from"./LocatorSearchSource.js";import C from"./SearchSource.js";import{isArcGISWorldGeocoder as G,meteredArcGISLocatorUrl as O,isProxiedArcGISWorldGeocoder as A,isMeteredArcGISWorldGeocoder as N}from"./support/locatorUtils.js";import{supported as D,getCurrentPosition as M,positionToPoint as V}from"../support/geolocationUtils.js";import{GoTo as J}from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const k=()=>b("esri/widgets/Search/t9n/Search"),H="highlight",B=i.ofType({key:e=>e.layer?"layer":"locator",base:C,typeMap:{layer:P,locator:j}}),Q=S.WGS84,Z="esri/images/search/search-symbol-32.png",q=/<[\s\S]*?>/g,z=-1;let K=class extends(J(a)){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new B,this.defaultSymbols={point:new I({url:t(Z),size:24,width:24,height:24}),polyline:new R({color:[130,130,130,1],width:2}),polygon:new T({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=x.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new B,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await k();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([p(()=>[this.includeDefaultSources,this.view,this.portal],()=>this._update(),g),w(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=z}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:z}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new B;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||D()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=D();if(e&&!t){const e=new l("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});n.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===z)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(q,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce((e,t)=>e+(t.results?.length??0),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new l("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw n.getLogger(this).error(e),e}const t=(async()=>{try{const t=await M(),r=await V({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new l("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw n.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new l("select:missing-source","Cannot select without a source.",{source:o});throw n.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,a=o.resultSymbol||this._getDefaultSymbol(e),u=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,h=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new l("select:missing-feature","Cannot select without a feature.",{feature:d});throw n.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,w=y?_(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=w?v(w,t):Promise.resolve(w)},x=await c(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;a instanceof E&&(a.text=e.name);const T=t&&h?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const j=L?d:new r({geometry:y,symbol:a,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&j.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[j],location:I}),L&&F(L)&&!G&&this._highlightFeature({graphic:j,layerView:L}),!L&&u&&t&&t.graphics.push(j),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",j),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce((e,t)=>e+(t.results?.length??0),0)??null),this.emit("suggest-complete",o),o}async when(){await d(()=>!this.updating)}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=c([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await d(()=>this.messages),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map(e=>{if(!1===e.placefinding)return;const t=G(e.url)&&L(e.url)?{url:O}:null,r=j.fromJSON({...e,...t}),s=r.url;if(G(s)||A(s)||N(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0}).filter(o)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach(e=>e?.destroy()),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map(e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map(e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then(e=>{i.layer=e}),i}).filter(o).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find(e=>e.id===t.subLayer);if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find(e=>e.id===t.subLayer);if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new l("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return n.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return h(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?_(e.geometry):e instanceof f?e:Array.isArray(e)&&2===e.length?new f({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return u(e,({results:e})=>e?.[0])??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),n.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===z){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)})}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new l("search:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getResultsFromSource(e,s,t))}):o.push(this._getResultsFromSource(e,s,t)),c(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new l("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw n.getLogger(this).error(e),e}return s===z?r.forEach((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))}):o.push(this._getSuggestionsFromSource(e,s,t)),c(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference??Q,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({exactMatch:a,location:o,maxResults:l,sourceIndex:t,spatialReference:i,suggestResult:e,view:n},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Q,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return u(this.results??[],({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null})??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(H)}async _getLayerView(e){const{view:t}=this;if(!e||!t)return null;const{layer:r,sourceLayer:s}=e,o=r??s;return o&&"building-component"!==o.type&&"subtype-sublayer"!==o.type?(await t.when(),t.whenLayerView(o)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o,sourceLayer:i}=t,l=o??i,{objectIdField:a}=l,n=(a&&s?.[a])??null,u=r.highlight(n??t);this.addHandles(u,H)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([m()],K.prototype,"_searching",void 0),e([m()],K.prototype,"_updatingPromise",void 0),e([m({readOnly:!0,value:null})],K.prototype,"activeSource",null),e([m()],K.prototype,"activeSourceIndex",null),e([m()],K.prototype,"allPlaceholder",null),e([m({readOnly:!0})],K.prototype,"allSources",null),e([m()],K.prototype,"autoNavigate",void 0),e([m()],K.prototype,"autoSelect",void 0),e([m({type:s})],K.prototype,"defaultPopupTemplate",void 0),e([m({readOnly:!0})],K.prototype,"defaultSources",void 0),e([m()],K.prototype,"defaultSymbols",void 0),e([m()],K.prototype,"includeDefaultSources",void 0),e([m()],K.prototype,"locationEnabled",null),e([m()],K.prototype,"maxInputLength",void 0),e([m()],K.prototype,"maxResults",void 0),e([m()],K.prototype,"maxSuggestions",void 0),e([m()],K.prototype,"messages",void 0),e([m()],K.prototype,"minSuggestCharacters",void 0),e([m({readOnly:!0})],K.prototype,"placeholder",null),e([m()],K.prototype,"popupEnabled",void 0),e([m({type:s})],K.prototype,"popupTemplate",void 0),e([m({type:x})],K.prototype,"portal",void 0),e([m()],K.prototype,"resultCount",void 0),e([m()],K.prototype,"resultGraphicEnabled",void 0),e([m({readOnly:!0})],K.prototype,"resultGraphic",void 0),e([m({readOnly:!0})],K.prototype,"results",void 0),e([m({readOnly:!0})],K.prototype,"selectedSuggestion",void 0),e([m()],K.prototype,"searchAllEnabled",void 0),e([m({readOnly:!0})],K.prototype,"selectedResult",void 0),e([m()],K.prototype,"searchTerm",null),e([m({type:B})],K.prototype,"sources",void 0),e([m({readOnly:!0})],K.prototype,"state",null),e([m()],K.prototype,"suggestionDelay",void 0),e([m()],K.prototype,"suggestionCount",void 0),e([m({readOnly:!0})],K.prototype,"suggestions",void 0),e([m()],K.prototype,"suggestionsEnabled",void 0),e([m({readOnly:!0})],K.prototype,"updating",null),e([m()],K.prototype,"view",void 0),e([m()],K.prototype,"clear",null),K=e([y("esri.widgets.Search.SearchViewModel")],K);const W=K;export{W as default};
|