// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../chunks/tslib.es6 ../Map ../TimeExtent ../core/Accessor ../core/asyncUtils ../core/Collection ../core/CollectionFlattener ../core/Error ../core/Evented ../core/Handles ../core/handleUtils ../core/has ../core/Loadable ../core/Logger ../core/maybe ../core/Promise ../core/promiseUtils ../core/reactiveUtils ../core/accessorSupport/decorators/property ../core/RandomLCG ../core/accessorSupport/decorators/subclass ../core/support/OwningCollection ../core/support/UpdatingHandles ../geometry/Extent ../geometry/HeightModelInfo ../geometry/SpatialReference ../geometry/support/spatialReferenceUtils ../support/AnalysesCollection ../support/GraphicsCollection ../time/timeZoneUtils ./BasemapView ./LayerViewManager ./Magnifier ./SelectionManager ./Theme ./ToolViewManager ./input/Input ./input/ViewEvents ./navigation/Navigation ./support/DefaultsFromMap".split(" "), function(c,z,A,b,B,n,C,r,D,E,F,W,t,k,g,G,H,f,d,X,I,u,J,K,L,M,N,v,w,p,O,P,x,Q,q,R,S,T,y,U){function V(a){return a.layerViews}var l;b=l=class extends D.EventedMixin(G.EsriPromiseMixin(b)){constructor(a){super(a);this._cursor=this._userSpatialReference=null;this.handles=new E;this.updatingHandles=new J.UpdatingHandles;this.allLayerViews=new C({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:V}); this.fatalError=this.basemapView=this.groundView=null;this.graphics=new w.GraphicsCollection;this.analyses=new v.AnalysesCollection;this.typeSpecificPreconditionsReady=!0;this.layerViews=new n;this.magnifier=new x;this.padding={left:0,top:0,right:0,bottom:0};this.ready=!1;this.spatialReferenceWarningDelay=1E3;this.supportsGround=!0;this.scale=this.type=this.timeExtent=null;this.updating=!1;this.initialExtentRequired=!0;this.input=new S;this.navigation=new y;this.analysisViewManager=this.layerViewManager= null;this.isHeightModelInfoRequired=!1;this.height=this.width=null;this.suspended=this.resizing=!1;this.viewEvents=new T.ViewEvents(this);this.persistableViewModels=new n;this._readyCycleForced=this._isValid=!1;this.theme=this._lockedTimeZone=this._userTimeZone=this._lockedSpatialReference=null;this.handles.add(f.watch(()=>this.preconditionsReady,e=>{const h=this.ready;e?(this._lockedSpatialReference=this.spatialReference,this._lockedTimeZone=this.timeZone,l.views.add(this)):(this._lockedSpatialReference= null,l.views.remove(this));this.notifyChange("spatialReference");if(!e&&h)this.toolViewManager?.detach(),null!=this.analysisViewManager&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown();else if(e&&!h){try{this._startup()}catch(m){queueMicrotask(()=>{this.fatalError=new r("startup-error",null,m)});return}null!=this.analysisViewManager&&this.analysisViewManager.attach();this.toolViewManager.attach()}},f.sync))}initialize(){this.addResolvingPromise(Promise.all([this.loadAsyncDependencies(), this.validate()]).then(()=>{this._isValid=!0;return f.whenOnce(()=>this.ready)}));this.basemapView=new O.BasemapView({view:this});this.layerViewManager=new P({view:this,layerViewImporter:{importLayerView:a=>this.importLayerView(a),hasLayerViewModule:a=>this.hasLayerViewModule(a)},supportsGround:this.supportsGround});this.toolViewManager=new R.ToolViewManager({view:this});this._setupSpatialReferenceLogger();this.selectionManager=new Q({view:this});this.addHandles([f.watch(()=>this.initialExtentRequired, a=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:a},f.syncAndInitial),f.watch(()=>this.ready,a=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=a,this.defaultsFromMap.userSpatialReference=a?this.spatialReference:this._userSpatialReference)},f.sync),f.watch(()=>this._userSpatialReference,a=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=a)},f.syncAndInitial)])}_setupSpatialReferenceLogger(){let a=null;this.addHandles([f.watch(()=>this.defaultsFromMap?.ready, e=>{const h=0a=g.abortMaybe(a)),a=B.createTask(async m=>{try{await H.after(this.spatialReferenceWarningDelay,null,m)}catch{return}finally{a=null}k.getLogger(this).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")}),this.addHandles(e,"spatial-reference-logger-task")):this.removeHandles("spatial-reference-logger-task")},{sync:!0})])}destroy(){this.destroyed||(l.views.remove(this), this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=g.destroyMaybe(this.graphics),this.analyses=g.destroyMaybe(this.analyses),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),g.destroyMaybe(this.analysisViewManager),this.toolViewManager=g.destroyMaybe(this.toolViewManager),this.layerViewManager=g.destroyMaybe(this.layerViewManager),this.selectionManager=g.destroyMaybe(this.selectionManager), this.basemapView=g.destroyMaybe(this.basemapView),this.groundView?.destroy(),this.layerViews?.forEach(a=>a.destroy()),this.layerViews.length=0,this.invalidate(),this._emitter.clear(),this.handles.destroy(),this.map=g.destroyMaybe(this.map),this.updatingHandles.destroy())}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){k.getLogger(this).error("#toMap()","Not implemented on this instance of View");return null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(a){this.toolViewManager&& (this.toolViewManager.activeTool=a)}get animation(){return this._get("animation")}set animation(a){this._set("animation",a)}get center(){return null}get _defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new U.DefaultsFromMap({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:(a,e)=>this.getSpatialReferenceSupport(a,e),...this._defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(a){this._set("extent",a)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError|| !this._isValid||this._readyCycleForced||!this.map||t.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._lockedSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}get resolution(){return 0}set map(a){const e=this._get("map");a!==e&&(a?.destroyed&&(k.getLogger(this).warn("#map","The provided map is already destroyed",{map:a}),a=null),t.isLoadable(a)&&a.load().catch(()=> {}),this.constructed&&!this.destroyed&&(this.forceReadyCycle(),this._lockedSpatialReference=null),this._set("map",a))}get spatialReference(){var a=this._userSpatialReference||this._lockedSpatialReference||this.getDefaultSpatialReference()||null;return a&&this.defaultsFromMap?.required?.heightModelInfo?(a=a.clone(),a.vcsWkid=this.defaultsFromMap.vcsWkid,a.latestVcsWkid=this.defaultsFromMap.latestVcsWkid,a):a}set spatialReference(a){const e=!N.equals(a,this._get("spatialReference"));this._set("_userSpatialReference", a);e&&(this._set("spatialReference",a),this._spatialReferenceChanged(a))}_spatialReferenceChanged(a){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get timeZone(){return this._userTimeZone??this._lockedTimeZone??this.getDefaultTimeZone()??p.system}set timeZone(a){const e=new Set(["etc/utc","etc/gmt","gmt"]),h=new Set(Intl.supportedValuesOf("timeZone").map(m=>m.toLowerCase()));this._userTimeZone=a;a===p.system||a===p.unknown||e.has(a.toLowerCase())||h.has(a.toLowerCase())|| k.getLogger(this).warn("#timeZone",`the parsed value '${a}' may not be a valid IANA time zone`)}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){return this.toolViewManager?.cursor??this._cursor??"default"}set cursor(a){this._cursor=a;this.notifyChange("cursor")}get size(){return[this.width,this.height]}get effectiveTheme(){return this.theme??new q}whenLayerView(a){return this.layerViewManager?.whenLayerView(a)??Promise.reject()}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&& "heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}getDefaultTimeZone(){return null}importLayerView(a){throw new r("importLayerView() not implemented");}hasLayerViewModule(a){return!1}async validate(){}async loadAsyncDependencies(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(a){return null!=this.getSpatialReferenceSupport(a)}when(a,e){this.isResolved()&&!this.ready&&k.getLogger(this).warn("#when()", "Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() \x3d\x3e view.ready).then(...) instead.");return super.when(a,e)}forceReadyCycle(){this.ready&&(f.when(()=>this.destroyed||!1===this.preconditionsReady,()=>this._readyCycleForced=!1,{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(a){this.toolViewManager.tools.add(a);this.activeTool=a}tryFatalErrorRecovery(){this.fatalError=null}};b.views=new n;c.__decorate([d.property()], b.prototype,"_userSpatialReference",void 0);c.__decorate([d.property()],b.prototype,"activeTool",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"allLayerViews",void 0);c.__decorate([d.property()],b.prototype,"groundView",void 0);c.__decorate([d.property()],b.prototype,"animation",null);c.__decorate([d.property()],b.prototype,"basemapView",void 0);c.__decorate([d.property()],b.prototype,"center",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"_defaultsFromMapSettings",null); c.__decorate([d.property()],b.prototype,"defaultsFromMap",null);c.__decorate([d.property()],b.prototype,"fatalError",void 0);c.__decorate([d.property({type:K})],b.prototype,"extent",null);c.__decorate([d.property(u.owningCollectionProperty(w.GraphicsCollection,"graphics"))],b.prototype,"graphics",void 0);c.__decorate([d.property(u.owningCollectionProperty(v.AnalysesCollection,"analyses"))],b.prototype,"analyses",void 0);c.__decorate([d.property({readOnly:!0,type:L})],b.prototype,"heightModelInfo", null);c.__decorate([d.property({readOnly:!0})],b.prototype,"interacting",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"navigating",null);c.__decorate([d.property({readOnly:!0,dependsOn:"fatalError _isValid _readyCycleForced map map.loaded? width height spatialReference _lockedSpatialReference defaultsFromMap.ready typeSpecificPreconditionsReady".split(" ")})],b.prototype,"preconditionsReady",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"typeSpecificPreconditionsReady", void 0);c.__decorate([d.property({type:n,readOnly:!0})],b.prototype,"layerViews",void 0);c.__decorate([d.property()],b.prototype,"resolution",null);c.__decorate([d.property({type:x})],b.prototype,"magnifier",void 0);c.__decorate([d.property({value:null,type:z})],b.prototype,"map",null);c.__decorate([d.property()],b.prototype,"padding",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"ready",void 0);c.__decorate([d.property({type:M})],b.prototype,"spatialReference",null);c.__decorate([d.property()], b.prototype,"spatialReferenceWarningDelay",void 0);c.__decorate([d.property()],b.prototype,"stationary",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"supportsGround",void 0);c.__decorate([d.property({type:A})],b.prototype,"timeExtent",void 0);c.__decorate([d.property({type:String,nonNullable:!0})],b.prototype,"timeZone",null);c.__decorate([d.property()],b.prototype,"tools",null);c.__decorate([d.property()],b.prototype,"toolViewManager",void 0);c.__decorate([d.property({readOnly:!0})], b.prototype,"type",void 0);c.__decorate([d.property({type:Number})],b.prototype,"scale",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"updating",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"initialExtentRequired",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"initialExtent",null);c.__decorate([d.property()],b.prototype,"cursor",null);c.__decorate([d.property({readOnly:!0})],b.prototype,"input",void 0);c.__decorate([d.property({type:y,nonNullable:!0})], b.prototype,"navigation",void 0);c.__decorate([d.property()],b.prototype,"layerViewManager",void 0);c.__decorate([d.property()],b.prototype,"analysisViewManager",void 0);c.__decorate([d.property()],b.prototype,"selectionManager",void 0);c.__decorate([d.property()],b.prototype,"width",void 0);c.__decorate([d.property()],b.prototype,"height",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"resizing",void 0);c.__decorate([d.property({value:null,readOnly:!0})],b.prototype,"size",null);c.__decorate([d.property({readOnly:!0})], b.prototype,"suspended",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"viewEvents",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"persistableViewModels",void 0);c.__decorate([d.property()],b.prototype,"_isValid",void 0);c.__decorate([d.property()],b.prototype,"_readyCycleForced",void 0);c.__decorate([d.property()],b.prototype,"_lockedSpatialReference",void 0);c.__decorate([d.property()],b.prototype,"_userTimeZone",void 0);c.__decorate([d.property()],b.prototype,"_lockedTimeZone", void 0);c.__decorate([d.property({type:q})],b.prototype,"theme",void 0);c.__decorate([d.property({readOnly:!0,type:q})],b.prototype,"effectiveTheme",null);return b=l=c.__decorate([I.subclass("esri.views.View")],b)});