/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../request","../../geometry/Extent","../../geometry/Point","../../geometry/SpatialReference","../../layers/support/RasterInfo","../utils","../support/FeatureSet"],(function(e,t,a,l,n,i,s,r,u){"use strict";function o(e,t,a){return d.apply(this,arguments)}function d(){return(d=t._asyncToGenerator((function*(e,t,o){var d,f,c,p,m,h,g;const v=r.parseUrl(e),{renderingRule:y,sourceJSON:S}=t||{},V=y?JSON.stringify(y.rasterFunctionDefinition||y):null,b=r.encode({...v.query,renderingRule:V,f:"json"}),x=r.asValidOptions(b,o);e=v.path;const D=S||(yield a(e,x).then((e=>e.data))),R=D.hasRasterAttributeTable?a(`${e}/rasterAttributeTable`,x):null,T=D.hasColormap?a(`${e}/colormap`,x):null,O=D.hasHistograms?a(`${e}/histograms`,x):null,I=D.currentVersion>=10.3?a(`${e}/keyProperties`,x):null,J=D.hasMultidimensions?a(`${e}/multidimensionalInfo`,x):null,N=yield Promise.allSettled([R,T,O,I,J]);let P=null;if(D.minValues&&D.minValues.length===D.bandCount){P=[];for(let e=0;e<D.minValues.length;e++)P.push({min:D.minValues[e],max:D.maxValues[e],avg:D.meanValues[e],stddev:D.stdvValues[e]})}const w=l.fromJSON(D.extent),z=Math.ceil(w.width/D.pixelSizeX-.1),C=Math.ceil(w.height/D.pixelSizeY-.1),M=i.fromJSON(D.spatialReference||D.extent.spatialReference),$="fulfilled"===N[0].status&&N[0].value?u.fromJSON(N[0].value.data):null,_="fulfilled"===N[1].status?null==(d=N[1].value)?void 0:d.data.colormap:null,k="fulfilled"===N[2].status?null==(f=N[2].value)?void 0:f.data.histograms:null,E="fulfilled"===N[3].status&&null!=(c=null==(p=N[3].value)?void 0:p.data)?c:{},j="fulfilled"===N[4].status?null==(m=N[4].value)?void 0:m.data.multidimensionalInfo:null;null!=j&&null!=(h=j.variables)&&h.length&&j.variables.forEach((e=>{var t;null!=(t=e.statistics)&&t.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))}));const{defaultVariable:q,serviceDataType:A}=D;q&&q!==E.DefaultVariable&&(E.DefaultVariable=q),A&&A.includes("esriImageServiceDataTypeVector")&&!A.includes(E.DataType)&&(E.DataType=A.replace("esriImageServiceDataType",""));let F=D.noDataValue;return null!=(g=D.noDataValues)&&g.length&&D.noDataValues.some((e=>e!==F))&&(F=D.noDataValues),new s({width:z,height:C,bandCount:D.bandCount,extent:l.fromJSON(D.extent),spatialReference:M,pixelSize:new n({x:D.pixelSizeX,y:D.pixelSizeY,spatialReference:M}),pixelType:D.pixelType.toLowerCase(),statistics:P,attributeTable:$,colormap:_,histograms:k,keyProperties:E,noDataValue:F,multidimensionalInfo:j})}))).apply(this,arguments)}function f(e,t,a){return o(e,{sourceJSON:t},a)}function c(e,t,a){return o(e,{renderingRule:t},a)}e.fetchServiceRasterInfo=f,e.generateRasterInfo=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
