12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Handles.js";import o from"../../core/Logger.js";import{isNone as n,destroyMaybe as s,isSome as i,applySome as a,unwrapOr as h}from"../../core/maybe.js";import{watch as m,syncAndInitial as p}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../views/3d/environment/CloudyWeather.js";import d from"../../views/3d/environment/FoggyWeather.js";import w from"../../views/3d/environment/RainyWeather.js";import u from"../../views/3d/environment/SnowyWeather.js";import v from"../../views/3d/environment/SunnyWeather.js";import{validateWeatherType as g}from"../../views/3d/environment/weather.js";import{WeatherState as _,WeatherError as f}from"./enums.js";const j="esri.widgets.Weather.WeatherViewModel",W=o.getLogger(j);let b=class extends t{constructor(e){super(e),this.view=null,this._handles=new r,this._settingWeather=!1,this._weatherByType={sunny:new v,cloudy:new c,rainy:new w,snowy:new u,foggy:new d}}initialize(){this._handles.add([m((()=>this.current),(e=>{this._settingWeather||n(e)||(this._weatherByType={...this._weatherByType,[e.type]:e})}),p)])}destroy(){this._handles=s(this._handles)}get state(){const e=this.view;return n(e)||!e.ready?_.Disabled:i(this.error)?this.error===f.NotVisible?_.Ready:_.Error:_.Ready}get error(){const e=this.view;return n(e)||!e.ready?null:"3d"!==e.type?f.UnsupportedView:"local"===e.viewingMode?f.LocalScene:e.environment.atmosphereEnabled?e.environmentManager.weatherVisible?null:f.NotVisible:f.NoAtmosphere}get current(){const e=a(this._environment,(e=>e.weather));return h(e,this._weatherByType.sunny)}set current(e){a(this._environment,(t=>t.weather=e))}get test(){return{...this._weatherByType}}get _environment(){const e=this.view;return i(e)&&"3d"===e.type?e.environment:null}setWeatherByType(e){if(!g(e,W))return;const t=this._environment;i(t)&&(this._settingWeather=!0,t.weather=this._weatherByType[e],this._settingWeather=!1)}setSnowCoverEnabled(e){const t=this.current;"snowCover"in t&&(t.snowCover=e?"enabled":"disabled")}};e([l()],b.prototype,"view",void 0),e([l()],b.prototype,"state",null),e([l()],b.prototype,"error",null),e([l()],b.prototype,"current",null),e([l()],b.prototype,"_environment",null),b=e([y(j)],b);const B=b;export{B as default};
|