WebStyleSymbol.js 2.5 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Logger.js";import{isSome as o}from"../core/maybe.js";import{throwIfAborted as r}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{enumeration as l}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import p from"../portal/Portal.js";import{r as a,w as m}from"../chunks/persistableUrlUtils.js";import c from"./Symbol.js";import{Thumbnail as n}from"./support/Thumbnail.js";var y;const h=e.getLogger("esri.symbols.WebStyleSymbol");let u=y=class extends c{constructor(t){super(t),this.styleName=null,this.portal=null,this.styleUrl=null,this.thumbnail=null,this.name=null,this.type="web-style"}get fetchCacheKey(){const t=o(this.portal)?this.portal:p.getDefault(),e=t.user?t.user.username:null;return`${this.styleName}:${this.styleUrl}:${this.name}:${e}:${t.url}`}read(t,e){this.portal=e?e.portal:void 0,super.read(t,e)}clone(){return new y({name:this.name,styleUrl:this.styleUrl,styleName:this.styleName,portal:this.portal})}fetchSymbol(t){return this._fetchSymbol("webRef",t)}fetchCIMSymbol(t){return this._fetchSymbol("cimRef",t)}async _fetchSymbol(t,e){const s=o(e)?e.cache:null,l=s?this.fetchCacheKey:null;if(o(s)){const t=s.get(l);if(t)return t.clone()}const i=await f();r(e);const p=i.resolveWebStyleSymbol(this,{portal:this.portal},t,e);p.catch((t=>{h.error("#fetchSymbol()","Failed to create symbol from style",t)}));const a=await p;return"webRef"===t&&"point-3d"===a.type||"cimRef"===t&&"cim"===a.type?(o(s)&&s.set(l,a.clone()),a):null}};function f(){return import("./support/webStyleSymbolUtils.js")}t([s({json:{write:!1}})],u.prototype,"color",void 0),t([s({type:String,json:{write:!0}})],u.prototype,"styleName",void 0),t([s({type:p,json:{write:!1}})],u.prototype,"portal",void 0),t([s({type:String,json:{read:a,write:m}})],u.prototype,"styleUrl",void 0),t([s({type:n,json:{read:!1}})],u.prototype,"thumbnail",void 0),t([s({type:String,json:{write:!0}})],u.prototype,"name",void 0),t([l({styleSymbolReference:"web-style"},{readOnly:!0})],u.prototype,"type",void 0),t([s()],u.prototype,"fetchCacheKey",null),u=y=t([i("esri.symbols.WebStyleSymbol")],u);const b=u;export{b as default};