/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import e from"../../request.js";import t from"../../geometry/Extent.js";import a from"../../geometry/Point.js";import l from"../../geometry/SpatialReference.js";import i from"../../layers/support/RasterInfo.js";import{parseUrl as s,encode as n,asValidOptions as r}from"../utils.js";import o from"../support/FeatureSet.js";async function u(u,m,f){const p=s(u),{renderingRule:c,sourceJSON:d}=m||{},h=c?JSON.stringify(c.rasterFunctionDefinition||c):null,g=n({...p.query,renderingRule:h,f:"json"}),v=r(g,f);u=p.path;const y=d||await e(u,v).then((e=>e.data)),S=y.hasRasterAttributeTable?e(`${u}/rasterAttributeTable`,v):null,V=y.hasColormap?e(`${u}/colormap`,v):null,x=y.hasHistograms?e(`${u}/histograms`,v):null,b=y.currentVersion>=10.3?e(`${u}/keyProperties`,v):null,D=y.hasMultidimensions?e(`${u}/multidimensionalInfo`,v):null,R=await Promise.allSettled([S,V,x,b,D]);let T=null;if(y.minValues&&y.minValues.length===y.bandCount){T=[];for(let e=0;e{e.statistics?.length&&e.statistics.forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation}))}));const{defaultVariable:P,serviceDataType:E}=y;P&&P!==C.DefaultVariable&&(C.DefaultVariable=P),E&&E.includes("esriImageServiceDataTypeVector")&&!E.includes(C.DataType)&&(C.DataType=E.replace("esriImageServiceDataType",""));let M=y.noDataValue;return y.noDataValues?.length&&y.noDataValues.some((e=>e!==M))&&(M=y.noDataValues),new i({width:w,height:J,bandCount:y.bandCount,extent:t.fromJSON(y.extent),spatialReference:N,pixelSize:new a({x:y.pixelSizeX,y:y.pixelSizeY,spatialReference:N}),pixelType:y.pixelType.toLowerCase(),statistics:T,attributeTable:O,colormap:I,histograms:z,keyProperties:C,noDataValue:M,multidimensionalInfo:$})}function m(e,t,a){return u(e,{sourceJSON:t},a)}function f(e,t,a){return u(e,{renderingRule:t},a)}export{m as fetchServiceRasterInfo,f as generateRasterInfo};