/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../core/Error","./CloudRaster","./ImageAuxRaster","./ImageServerRaster","./MRFRaster","./TIFFRaster"],(function(e,t,r,s,o,n,a){"use strict";const c=new Map;c.set("CRF",{desc:"Cloud Raster Format",constructor:r}),c.set("MRF",{desc:"Meta Raster Format",constructor:n}),c.set("TIFF",{desc:"GeoTIFF",constructor:a}),c.set("RasterTileServer",{desc:"Raster Tile Server",constructor:o}),c.set("JPG",{desc:"JPG Raster Format",constructor:s}),c.set("PNG",{desc:"PNG Raster Format",constructor:s}),c.set("GIF",{desc:"GIF Raster Format",constructor:s}),c.set("BMP",{desc:"BMP Raster Format",constructor:s});let u=function(){function r(){}return r.open=function(){var r=e._asyncToGenerator((function*(e){const{url:r,ioConfig:s,sourceJSON:o}=e;let n=e.datasetFormat;null==n&&r.lastIndexOf(".")&&(n=r.slice(r.lastIndexOf(".")+1).toUpperCase()),"OVR"===n||"TIF"===n?n="TIFF":"JPG"!==n&&"JPEG"!==n&&"JFIF"!==n||(n="JPG"),r.toLowerCase().includes("/imageserver")&&!r.toLowerCase().includes("/wcsserver")&&(n="RasterTileServer");const a={url:r,sourceJSON:o,datasetFormat:n,ioConfig:s||{bandIds:null,sampling:null}};let u,l;if(this.supportedFormats.has(n)){if("CRF"===n&&!s.enableCRF)throw new t("rasterfactory:open",`cannot open raster: ${r}`);return u=c.get(n).constructor,l=new u(a),yield l.open({signal:e.signal}),l}if(n)throw new t("rasterfactory:open","not a supported format "+n);const i=Array.from(c.keys());let F=0;const d=()=>(n=i[F++],n&&("CRF"!==n||s.enableCRF)?(u=c.get(n).constructor,l=new u(a),l.open({signal:e.signal}).then((()=>l)).catch((()=>d()))):null);return d()}));function s(e){return r.apply(this,arguments)}return s}(),r.register=function(e,t,r){c.has(e.toUpperCase())||c.set(e.toUpperCase(),{desc:t,constructor:r})},e._createClass(r,null,[{key:"supportedFormats",get:function(){const e=new Set;return c.forEach(((t,r)=>e.add(r))),e}}]),r}();return u}));
