// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../request ../../core/Error ../../core/lang ../../core/typedArrayUtil ../../geometry/support/UintArray".split(" "),function(m,p,h,q,r,t){function u(a){if(a.service.tileServers?.length){var b=a.service.tileServers;b=`${b&&b.length?b[a.row%b.length]:a.service.url}/tilemap/${a.level}/${a.row}/${a.col}/${a.width}/${a.height}`}else b=`${a.service.url}/tilemap/${a.level}/${a.row}/${a.col}/${a.width}/${a.height}`;(a=a.service.query)&&(b=`${b}?${a}`);return b}class n{constructor(a){if(!a?.location)throw new h("tilemap:missing-location", "Location missing from tilemap response");if(!1===a.valid)throw new h("tilemap:invalid","Tilemap response was marked as invalid");if(!a.data)throw new h("tilemap:missing-data","Data missing from tilemap response");if(!Array.isArray(a.data))throw new h("tilemap:data-mismatch","Data must be an array of numbers");if(a.data.length!==a.location.width*a.location.height)throw new h("tilemap:data-mismatch","Number of data items does not match width/height of tilemap");const {location:b,data:g}=a;this.location= Object.freeze(q.clone(b));let k=a=!0;const e=t.newUintArray(Math.ceil(this.location.width*this.location.height/32));let f=0;for(let d=0;d>5;const g=this._availability;return 0>b||b>g.length?"unknown":g[b]&1<c.data).catch(c=>{if(422===c?.details?.httpStatus)return{location:{top:k,left:e,width:f,height:d},valid:!0,data:Array(f*d).fill(0)};throw c;}).then(c=>{if(c.location&&(c.location.top!==k||c.location.left!== e||c.location.width!==f||c.location.height!==d))throw new h("tilemap:location-mismatch","Tilemap response for different location than requested",{response:c,definition:{top:k,left:e,width:f,height:d}});return n.fromJSON(c)})}static fromJSON(a){return Object.freeze(new n(a))}}m.Tilemap=n;m.tilemapDefinitionId=function(a){return`${a.level}/${a.row}/${a.col}/${a.width}/${a.height}`};Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});