/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import{property as t,subclass as o}from"../../core/accessorSupport/decorators.js";import l from"../../geometry/SpatialReference.js";import r from"../support/TileInfo.js";import i from"../support/TileInfoTilemapCache.js";import{TilemapCache as a}from"../support/TilemapCache.js";import{reader as n}from"../../core/accessorSupport/decorators/reader.js";const s=s=>{const p=s;let c=class extends p{constructor(){super(...arguments),this.copyright=null,this.minScale=0,this.maxScale=0,this.spatialReference=null,this.tileInfo=null,this.tilemapCache=null}destroy(){this.tilemapCache?.destroy?.()}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}get supportsBlankTile(){return this.version>=10.2}readTilemapCache(e,t,o){const l=t.capabilities?.includes("Tilemap");let{minLOD:n,maxLOD:s,minScale:p,maxScale:c}=t;if(null==n&&null==s&&(0!==p||0!==c)){const e=e=>Math.round(1e4*e)/1e4;p=e(p||t.tileInfo.lods[0].scale),c=e(c||t.tileInfo.lods[t.tileInfo.lods.length-1].scale);for(const o of t.tileInfo.lods){const t=e(o.scale);n=t>=p?o.level:n,s=t>=c?o.level:s}}if(l)return new a({layer:this,minLOD:n,maxLOD:s});if(t.tileInfo){const e=new r;return e.read(t.tileInfo,o),new i(e,n,s)}return null}};return e([t({json:{read:{source:"copyrightText"}}})],c.prototype,"copyright",void 0),e([t()],c.prototype,"minScale",void 0),e([n("service","minScale")],c.prototype,"readMinScale",null),e([t()],c.prototype,"maxScale",void 0),e([n("service","maxScale")],c.prototype,"readMaxScale",null),e([t({type:l})],c.prototype,"spatialReference",void 0),e([t({readOnly:!0})],c.prototype,"supportsBlankTile",null),e([t({type:r})],c.prototype,"tileInfo",void 0),e([t()],c.prototype,"tilemapCache",void 0),e([n("service","tilemapCache",["capabilities","tileInfo"])],c.prototype,"readTilemapCache",null),e([t()],c.prototype,"version",void 0),c=e([o("esri.layers.mixins.ArcGISCachedService")],c),c};export{s as ArcGISCachedService};
