/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../core/Collection.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import{property as i,subclass as s}from"../../core/accessorSupport/decorators.js";import l from"../../geometry/Extent.js";import o from"./TileMatrixSet.js";import a from"./WMTSStyle.js";import{reader as n}from"../../core/accessorSupport/decorators/reader.js";var p;let u=p=class extends r{constructor(t){super(t),this.description=null,this.fullExtent=null,this.fullExtents=null,this.id=null,this.imageFormats=null,this.layer=null,this.parent=null,this.styles=null,this.title=null,this.tileMatrixSetId=null,this.tileMatrixSets=null}readFullExtent(t,e){return(t=e.fullExtent)?l.fromJSON(t):null}readFullExtents(t,e){return e.fullExtents?.length?e.fullExtents.map(t=>l.fromJSON(t)):e.tileMatrixSets?.map(t=>l.fromJSON(t.fullExtent)).filter(t=>t)??[]}get imageFormat(){let t=this._get("imageFormat");return t||(t=this.imageFormats?.length?this.imageFormats[0]:""),t}set imageFormat(t){const e=this.imageFormats;t&&(t.includes("image/")||e&&!e.includes(t))&&(t.includes("image/")||(t="image/"+t),e&&!e.includes(t))?console.error("The layer doesn't support the format of "+t):this._set("imageFormat",t)}get styleId(){let t=this._get("styleId");return t||(t=this.styles?.at(0)?.id??""),t}set styleId(t){this._set("styleId",t)}get tileMatrixSet(){return this.tileMatrixSets?.find(({id:t})=>t===this.tileMatrixSetId)??null}clone(){const t=new p;return this.hasOwnProperty("description")&&(t.description=this.description),this.hasOwnProperty("imageFormats")&&(t.imageFormats=this.imageFormats?.slice()??null),this.hasOwnProperty("imageFormat")&&(t.imageFormat=this.imageFormat),this.hasOwnProperty("fullExtent")&&(t.fullExtent=this.fullExtent?.clone()),this.hasOwnProperty("id")&&(t.id=this.id),this.hasOwnProperty("layer")&&(t.layer=this.layer),this.hasOwnProperty("styleId")&&(t.styleId=this.styleId),this.hasOwnProperty("styles")&&(t.styles=this.styles?.clone()),this.hasOwnProperty("tileMatrixSetId")&&(t.tileMatrixSetId=this.tileMatrixSetId),this.hasOwnProperty("tileMatrixSets")&&(t.tileMatrixSets=this.tileMatrixSets?.clone()),this.hasOwnProperty("title")&&(t.title=this.title),t}};t([i()],u.prototype,"description",void 0),t([i({type:l})],u.prototype,"fullExtent",void 0),t([n("fullExtent",["fullExtent"])],u.prototype,"readFullExtent",null),t([i({readOnly:!0})],u.prototype,"fullExtents",void 0),t([n("fullExtents",["fullExtents","tileMatrixSets"])],u.prototype,"readFullExtents",null),t([i()],u.prototype,"id",void 0),t([i()],u.prototype,"imageFormat",null),t([i({json:{read:{source:"formats"}}})],u.prototype,"imageFormats",void 0),t([i()],u.prototype,"layer",void 0),t([i()],u.prototype,"parent",void 0),t([i()],u.prototype,"styleId",null),t([i({type:e.ofType(a),json:{read:{source:"styles"}}})],u.prototype,"styles",void 0),t([i({json:{write:{ignoreOrigin:!0}}})],u.prototype,"title",void 0),t([i()],u.prototype,"tileMatrixSetId",void 0),t([i({readOnly:!0})],u.prototype,"tileMatrixSet",null),t([i({type:e.ofType(o),json:{read:{source:"tileMatrixSets"}}})],u.prototype,"tileMatrixSets",void 0),u=p=t([s("esri.layers.support.WMTSSublayer")],u);export{u as default};
