/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import e from"../../../core/Error.js";import{isSingleBand8BitRasterWithStats as r}from"../../../renderers/support/rasterRendererChecks.js";import{createUVRenderer as s,getClassField as t}from"../../../renderers/support/rasterRendererHelper.js";import{processRasterRendererParameters as a}from"../support/utils.js";async function o(s){s=await a(s);const{serviceRasterInfo:o}=s.layer;if(o.bandCount>1)throw new e("raster-class-breaks-renderer:not-supported","Multiband raster is not supported");const{attributeTable:n}=o;if(null==n){if(r(o))return s.classFieldName=s.classFieldName||"value",s;throw new e("raster-unique-value-renderer:not-supported","The source raster does not have an attribute table")}const i=s.classFieldName?.toLowerCase();if(i&&!n.fields.some(e=>e.name.toLowerCase()===i))throw new e("raster-unique-value-renderer:invalid-parameters","A valid 'classfieldName' is required");return i||(s.classFieldName=t(n)?.name),s}async function n(r){r=await o(r);const{classFieldName:t,colors:a,colorRamp:n}=r,i=s(r.layer.serviceRasterInfo,t,a,n);if(null==i)throw new e("raster-unique-value-renderer:not-supported","UniqueValueRenderer is not supported on the provided data source");return{renderer:i,classFieldName:t}}export{n as createRenderer};
