import{isImageryTileLayer as e}from"../utilities/_layers.js";import{checkArg as r}from"../utilities/checkArg.js";import{LayerDefinition as i}from"./LayerDefinition.js";import{ERR_LAYER_TYPE_MISMATCH as a,applyLayerBaseToEsriApiLayer as l,applyBasemapLayerToEsriApiLayer as s,applyOperationalLayerToEsriApiLayer as y,fromEsriApiLayerToLayerBase as t,fromEsriApiLayerToOperationalLayer as n}from"./_layerHelper.js";export var TiledImageServiceLayer;!function(o){async function c(t,n){r("layerJson",t).isNotMissing(),r("layerJson.layerType",t.layerType).satisfies((e=>!e||"ArcGISTiledImageServiceLayer"===e),a),r("layer",n).isNotMissing().satisfies(e,a),l(t,n),s(t,n),y(t,n),t.hasOwnProperty("layerDefinition")&&null!=t.layerDefinition&&await i.applyToEsriApiLayer(t.layerDefinition,n),t.hasOwnProperty("url")&&(n.url=t.url)}o.esriImageryTileLayerDefaults={legendEnabled:!0,visible:!0,opacity:1,minScale:0,maxScale:0},o.toEsriApiLayer=async function(e){r("layerJson",e).isNotMissing(),r("layerJson.layerType",e.layerType).satisfies((e=>!e||"ArcGISTiledImageServiceLayer"===e),a);const i={};e?.url&&(i.url=e.url);const l=new((await import("@arcgis/core/layers/ImageryTileLayer")).default);return await c(e,l),l},o.applyToEsriApiLayer=c,o.fromEsriApiTileLayer=function(e){return r("layer",e).isNotMissing(),{...t(e,o.esriImageryTileLayerDefaults),...n(e),layerDefinition:i.fromEsriApiLayer(e),layerType:"ArcGISTiledImageServiceLayer",url:e.url}}}(TiledImageServiceLayer||(TiledImageServiceLayer={}));