Files
2024-02-28 17:06:42 +05:00

2 lines
96 KiB
JavaScript

import{y as Ae}from"./colorUtils-23771bca.js";import{A as c,B as f,C as A,a6 as de,ea as We,a1 as Mt,bV as Z,bb as W,kN as rs,a8 as Nt,kO as os,a9 as Ft,m0 as $t,s as It,aH as Pe,ab as is}from"./index-b5c8f851.js";import{u as x,o as as,r as us,k as ge,h as Dt,q as qe,t as Xe,w as ls,v as Y,x as cs,y as ps,z as hs,A as fs}from"./dataUtils-c2b057a0.js";import{a as ms,v as ds,w as St,C as gs,x as He,e as Te,y as ys,z as ws,E as Vt,H as bs,I as xs,J as Ut,K as vs,M as As,O as Ps}from"./RasterSymbolizer-a162ee17.js";let Ot=class extends de{constructor(){super(...arguments),this.raster=void 0}};c([f({json:{write:!0}})],Ot.prototype,"raster",void 0),Ot=c([A("esri.layers.support.rasterFunctions.AspectFunctionArguments")],Ot);const U=Ot;var Lt;let Wt=Lt=class extends U{clone(){return new Lt({raster:this.raster})}};Wt=Lt=c([A("esri.layers.support.rasterFunctions.AspectFunctionArguments")],Wt);const Ts=Wt,$s=new Set(["slope","aspect","curvature","hillshade","shadedrelief","statistics"]);let S=class extends de{constructor(){super(...arguments),this.functionArguments=null,this.readingBufferSize=0,this.id=-1,this.isNoopProcess=!1,this.rawInputBandIds=[],this.isInputBandIdsSwizzled=!1,this.swizzledBandSelection=[],this.isBranch=!1,this._bindingResult=null}get supportsGPU(){return this._bindingResult.supportsGPU}get flatWebGLFunctionChain(){const t=this.getWebGLProcessorDefinition();if(!t)return null;const e=[t],{parameters:s}=t;let o=s.rasters||s.raster&&[s.raster];for(;o!=null&&o.length;){e.unshift(...o);const n=[];for(let u=0;u<o.length;u++){const{parameters:l}=o[u],p=l.rasters||l.raster&&[l.raster];p!=null&&p.length&&n.push(...p)}o=n}for(let n=e.length-1;n>=0;n--)e[n].isNoopProcess&&e.splice(n,1);let r=!1;for(let n=0;n<e.length;n++){const u=e[n];u.id=e.length-n-1;const{rasters:l}=u.parameters;r=r||l!=null&&l.length>1}const a=e.some(({name:n})=>$s.has(n.toLowerCase()));return{functions:e,hasBranches:r,hasFocalFunction:a}}bind(t,e=!1,s=-1){this.id=s+1;const o=this._getRasterValues();let r=!0;for(let a=0;a<o.length;a++){const n=o[a];if(n!=null&&this._isRasterFunctionValue(n)){const u=n.bind(t,e,this.id+a);if(!u.success)return this._bindingResult=u,u;r=r&&u.supportsGPU}}return!this.rasterInfo||e?(this.sourceRasterInfos=this._getSourceRasterInfos(t),this._bindingResult=this._bindSourceRasters(),this._bindingResult.success&&this._patchRasterInfo(),this._bindingResult.supportsGPU=r&&this._bindingResult.supportsGPU,this.processInputBandIds(),this._bindingResult):(this._bindingResult={success:!0,supportsGPU:!0},this.processInputBandIds(),this._bindingResult)}process(t){const e=this._getRasterValues(),s=e.length===0?t.pixelBlocks??t.primaryPixelBlocks:e.map(o=>this._readRasterValue(o,t));return this._processPixels({...t,pixelBlocks:s})}processInputBandIds(){const t=this._getRasterValues().filter(this._isRasterFunctionValue);let e;if(t.length>1){const r=t.map(n=>n.processInputBandIds()[0]);this.rawInputBandIds=r,this.isInputBandIdsSwizzled=this.rawInputBandIds.some((n,u)=>n!==u);const a=t.filter(n=>n.functionName==="ExtractBand");return a.length&&a.forEach((n,u)=>{n.isInputBandIdsSwizzled=!0,n.swizzledBandSelection=[u,u,u]}),this.rawInputBandIds}const s=t[0];if(s){if(e=s.processInputBandIds(),s.isInputBandIdsSwizzled)return this.rawInputBandIds=e,e}else{e=[];const{bandCount:r}=this.sourceRasterInfos[0];for(let a=0;a<r;a++)e.push(a)}const o=this._getInputBandIds(e);return this.isInputBandIdsSwizzled=o.some((r,a)=>r!==a),this.rawInputBandIds=o,this.rawInputBandIds}getPrimaryRasters(){const t=[],e=[];return this._getPrimaryRasters(this,t,e),{rasters:t,rasterIds:e}}getWebGLProcessorDefinition(){const t=this._getWebGLParameters(),{raster:e,rasters:s}=this.functionArguments;return s&&Array.isArray(s)&&s.length?(t.rasters=s.map(o=>this._isRasterFunctionValue(o)?o.getWebGLProcessorDefinition():typeof o=="number"?{name:"Constant",parameters:{value:o},pixelType:"f32",id:-1,isNoopProcess:!1}:{name:"Identity",parameters:{value:o},pixelType:"f32",id:-1,isNoopProcess:!1}),t.rasters.some(o=>o!=null)||(t.rasters=null)):this._isRasterFunctionValue(e)&&(t.raster=e.getWebGLProcessorDefinition()),{name:this.functionName,parameters:t,pixelType:this.outputPixelType,id:this.id,isNoopProcess:this.isNoopProcess}}_getOutputPixelType(t){return this.outputPixelType==="unknown"?t:this.outputPixelType??t}_getWebGLParameters(){return{}}_getInputBandIds(t){return t}_isOutputRoundingNeeded(){const{outputPixelType:t}=this;return((t==null?void 0:t.startsWith("u"))||(t==null?void 0:t.startsWith("s")))??!1}_getRasterValues(){const{rasterArgumentNames:t}=this;return t[0]==="rasters"?this.functionArguments.rasters??[]:t.flatMap(e=>this.functionArguments[e])}_getSourceRasterInfos(t){const e=this._getRasterValues(),{rasterInfos:s,rasterIds:o}=t;if(e.length===0)return s;const r=e.map(n=>n&&typeof n=="object"&&"bind"in n&&n.rasterInfo?n.rasterInfo:typeof n=="string"&&o.includes(n)?s[o.indexOf(n)]:typeof n!="number"?s[0]:void 0),a=r.find(n=>n)??s[0];return r.forEach((n,u)=>{n===void 0&&(r[u]=a)}),r}_getPrimaryRasterId(t){return t==null?void 0:t.url}_getPrimaryRasters(t,e=[],s=[]){for(let o=0;o<t.sourceRasters.length;o++){const r=t.sourceRasters[o];if(typeof r!="number")if("bind"in r)this._getPrimaryRasters(r,e,s);else{const a=r,n=this._getPrimaryRasterId(a);if(n==null)continue;s.includes(n)||(this.mainPrimaryRasterId===n?(e.unshift(a),s.unshift(n)):(e.push(a),s.push(n)))}}}_isRasterFunctionValue(t){return t!=null&&typeof t=="object"&&"getWebGLProcessorDefinition"in t}_readRasterValue(t,e){const{primaryPixelBlocks:s}=e;if(t==null||t==="$$"){const o=s[0];return o==null?null:o.clone()}if(typeof t=="string"){const o=e.primaryRasterIds.indexOf(t);return o===-1?null:s[o]}if(typeof t=="number"){const o=s[0];if(o==null)return null;const{width:r,height:a,pixelType:n,mask:u}=o,l=u?new Uint8Array(u):null,p=new Float32Array(r*a);p.fill(t);const h=this.sourceRasterInfos[0].bandCount,m=new Array(h).fill(p);return new x({width:r,height:a,pixelType:n,pixels:m,mask:l})}return t.process(e)}_patchRasterInfo(){const{rasterInfo:t}=this;if(!(t!=null&&t.keyProperties))return;const{bandCount:e,keyProperties:s,statistics:o,histograms:r}=t,a=s.BandProperties;a&&a.length!==e&&(t.keyProperties={...s,BandProperties:void 0}),o&&o.length!==e&&(t.statistics=o.length>e?o.slice(0,e):null),r&&r.length!==e&&(t.histograms=r.length>e?r.slice(0,e):null),s.BAND_COUNT&&Number(s.BAND_COUNT)!==e&&(t.keyProperties={...s,BAND_COUNT:typeof s.BAND_COUNT=="string"?String(e):e})}};c([f({json:{write:!0}})],S.prototype,"functionName",void 0),c([f({json:{write:!0}})],S.prototype,"functionArguments",void 0),c([f()],S.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}}),We(i=>i==null?void 0:i.toLowerCase())],S.prototype,"outputPixelType",void 0),c([f({json:{write:!0}})],S.prototype,"mainPrimaryRasterId",void 0),c([f()],S.prototype,"sourceRasters",void 0),c([f({type:[ms],json:{write:!0}})],S.prototype,"sourceRasterInfos",void 0),c([f({json:{write:!0}})],S.prototype,"rasterInfo",void 0),c([f({json:{write:!0}})],S.prototype,"readingBufferSize",void 0),c([f({json:{write:!0}})],S.prototype,"id",void 0),c([f()],S.prototype,"isNoopProcess",void 0),c([f()],S.prototype,"supportsGPU",null),c([f()],S.prototype,"rawInputBandIds",void 0),c([f()],S.prototype,"isInputBandIdsSwizzled",void 0),c([f()],S.prototype,"swizzledBandSelection",void 0),c([f()],S.prototype,"isBranch",void 0),c([f()],S.prototype,"flatWebGLFunctionChain",null),c([f()],S.prototype,"_bindingResult",void 0),S=c([A("esri.layers.support.rasterFunctions.BaseRasterFunction")],S);const V=S;let rt=class extends V{constructor(){super(...arguments),this.functionName="Aspect",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){var s;const t=this.sourceRasterInfos[0];this.isGCS=((s=t.spatialReference)==null?void 0:s.isGeographic)??!1,this.outputPixelType=this._getOutputPixelType("f32");const e=t.clone();return e.pixelType=this.outputPixelType,e.statistics=[{min:-1,max:360,avg:180,stddev:30}],e.histograms=null,e.colormap=null,e.attributeTable=null,e.bandCount=1,this.rasterInfo=e,{success:!0,supportsGPU:!0}}_processPixels(t){var n;const e=(n=t.pixelBlocks)==null?void 0:n[0];if(e==null)return null;const{extent:s,primaryPixelSizes:o}=t,r=o==null?void 0:o[0],a=r??(s?{x:s.width/e.width,y:s.height/e.height}:{x:1,y:1});return ds(e,{resolution:a})}};c([f({json:{write:!0,name:"rasterFunction"}})],rt.prototype,"functionName",void 0),c([f({type:Ts,json:{write:!0,name:"rasterFunctionArguments"}})],rt.prototype,"functionArguments",void 0),c([f()],rt.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],rt.prototype,"isGCS",void 0),rt=c([A("esri.layers.support.rasterFunctions.AspectFunction")],rt);const Ns=rt,Fs=new Set(["+","-","*","/","(",")"]);function Is(i,t){(i=i.replaceAll(" ","")).startsWith("-")&&(i="0"+i),i.startsWith("+")&&(i=i.slice(1,i.length));const e=i.split(""),s=[],o=[];let r="";for(let a=0;a<e.length;a++){const n=e[a];if(Fs.has(n))r!==""&&o.push(parseFloat(r)),s.push(n),r="";else{if(n.toLowerCase()==="b"){a++,r=n.concat(e[a]),o.push(t[parseInt(r[1],10)-1]),r="";continue}r=r.concat(n),a===e.length-1&&o.push(parseFloat(r))}}return{ops:s,nums:o}}function Rs(i,t,e,s){if(typeof e=="number"&&typeof s=="number")return e+s;let o,r,a;typeof e=="number"?(a=s,o=a.length,r=new Float32Array(o),r.fill(e)):(o=e.length,r=e,s.constructor===Number?(a=new Float32Array(o),a.fill(s)):a=s);const n=new Float32Array(o);switch(t){case"+":for(let u=0;u<o;u++)(i==null||i[u])&&(n[u]=r[u]+a[u]);break;case"-":for(let u=0;u<o;u++)(i==null||i[u])&&(n[u]=r[u]-a[u]);break;case"*":for(let u=0;u<o;u++)(i==null||i[u])&&(n[u]=r[u]*a[u]);break;case"/":for(let u=0;u<o;u++)(i==null||i[u])&&a[u]&&(n[u]=r[u]/a[u]);break;case"(":case")":throw new Error("encountered error with custom band index equation")}return n}function ks(i,t){i.splice(t,1);let e=0,s=0;do{e=0,s=0;for(let o=0;o<i.length;o++)if(i[o]==="(")e=o;else if(i[o]===")"){s=o;break}s===e+1&&i.splice(e,2)}while(s===e+1);return i}function Cs(i){if(i.length===1)return{opIndex:0,numIndex:0};let t=0,e=0;for(let a=0;a<i.length;a++)if(i[a]==="(")t=a;else if(i[a]===")"){e=a;break}const s=e===0?i:i.slice(t+1,e);let o=-1;for(let a=0;a<s.length;a++)if(s[a]==="*"||s[a]==="/"){o=a;break}if(o>-1)e>0&&(o+=t+1);else{for(let a=0;a<s.length;a++)if(s[a]==="+"||s[a]==="-"){o=a;break}e>0&&(o+=t+1)}let r=0;for(let a=0;a<o;a++)i[a]==="("&&r++;return{opIndex:o,numIndex:o-r}}function Bs(i,t,e){let s,{ops:o,nums:r}=Is(e,t);if(o.length===0){const a=r.length===1?r[0]:t[0];if(a instanceof Float32Array)return[a];const n=new Float32Array(t[0].length);return typeof a=="number"?n.fill(a):n.set(a),[n]}for(;o.length>0;){const{numIndex:a,opIndex:n}=Cs(o);if(s=Rs(i,o[n],r[a],r[a+1]),o.length===1)break;o=ks(o,n),r.splice(a,2,s)}return[s]}const js=new Mt({0:"custom",1:"ndvi",2:"savi",3:"tsavi",4:"msavi",5:"gemi",6:"pvi",7:"gvitm",8:"sultan",9:"vari",10:"gndvi",11:"sr",12:"ndvi-re",13:"sr-re",14:"mtvi2",15:"rtvi-core",16:"ci-re",17:"ci-g",18:"ndwi",19:"evi",20:"iron-oxide",21:"ferrous-minerals",22:"clay-minerals",23:"wndwi",24:"bai",25:"nbr",26:"ndbi",27:"ndmi",28:"ndsi",29:"mndwi"},{useNumericKeys:!0});function _s(i,t){if(!as(i))return i;const{equation:e,method:s}=t,o=t.bandIndexes.map(p=>p-1),{pixels:r,mask:a}=i;let n;switch(s){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":n=$e(a,r[o[0]],r[o[1]]);break;case"ndwi":n=$e(a,r[o[1]],r[o[0]]);break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":n=Ms(a,r[o[0]],r[o[1]]);break;case"ci-g":case"ci-re":n=Ds(a,r[o[0]],r[o[1]]);break;case"savi":n=Os(a,r[o[0]],r[o[1]],o[2]+1);break;case"tsavi":n=Es(a,r[o[0]],r[o[1]],o[2]+1,o[3]+1,o[4]+1);break;case"msavi":n=Gs(a,r[o[0]],r[o[1]]);break;case"gemi":n=zs(a,r[o[0]],r[o[1]]);break;case"pvi":n=Us(a,r[o[0]],r[o[1]],o[2]+1,o[3]+1);break;case"gvitm":n=Vs(a,[r[o[0]],r[o[1]],r[o[2]],r[o[3]],r[o[4]],r[o[5]]]);break;case"sultan":n=Ls(a,[r[o[0]],r[o[1]],r[o[2]],r[o[3]],r[o[4]],r[o[5]]]);break;case"vari":n=Ws(a,[r[o[0]],r[o[1]],r[o[2]]]);break;case"mtvi2":n=qs(a,[r[o[0]],r[o[1]],r[o[2]]]);break;case"rtvi-core":n=Xs(a,[r[o[0]],r[o[1]],r[o[2]]]);break;case"evi":n=Hs(a,[r[o[0]],r[o[1]],r[o[2]]]);break;case"wndwi":n=Js(a,[r[o[0]],r[o[1]],r[o[2]]],o[3]?o[3]+1:.5);break;case"bai":n=Ks(a,r[o[0]],r[o[1]]);break;case"custom":n=Bs(a,r,e);break;default:return i}const u=a!=null?new Uint8Array(a.length):null;a!=null&&u!=null&&u.set(a);const l=new x({width:i.width,height:i.height,pixelType:"f32",pixels:n,mask:u});return l.updateStatistics(),l}function Ss(i,t,e,s){const{mask:o,pixels:r,width:a,height:n}=i,u=r[e],l=r[t],p=l.length,h=s?new Uint8Array(p):new Float32Array(p),m=s?100:1,g=s?100.5:0;for(let y=0;y<p;y++)if(o==null||o[y]){const d=u[y],v=l[y],b=d+v;b&&(h[y]=(d-v)/b*m+g)}const w=new x({width:a,height:n,mask:o,pixelType:s?"u8":"f32",pixels:[h]});return w.updateStatistics(),w}function O(i){const t=new Float32Array(9);return t[3*i[0]]=1,t[3*i[1]+1]=1,t[3*i[2]+2]=1,t}function $e(i,t,e){const s=e.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r]){const a=t[r],n=e[r],u=a+n;u&&(o[r]=(a-n)/u)}return[o]}function Ms(i,t,e){const s=e.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r]){const a=t[r],n=e[r];n&&(o[r]=a/n)}return[o]}function Ds(i,t,e){const s=t.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r]){const a=t[r],n=e[r];n&&(o[r]=a/n-1)}return[o]}function Os(i,t,e,s){const o=e.length,r=new Float32Array(o);for(let a=0;a<o;a++)if(i==null||i[a]){const n=e[a],u=t[a],l=u+n+s;l&&(r[a]=(u-n)/l*(1+s))}return[r]}function Es(i,t,e,s,o,r){const a=e.length,n=new Float32Array(a),u=-o*s+r*(1+s*s);for(let l=0;l<a;l++)if(i==null||i[l]){const p=e[l],h=t[l],m=o*h+p+u;m&&(n[l]=s*(h-s*p-o)/m)}return[n]}function Gs(i,t,e){const s=e.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r]){const a=e[r],n=t[r];o[r]=.5*(2*(n+1)-Math.sqrt((2*n+1)**2-8*(n-a)))}return[o]}function zs(i,t,e){const s=e.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r]){const a=e[r],n=t[r];if(a!==1){const u=(2*(n*n-a*a)+1.5*n+.5*a)/(n+a+.5);o[r]=u*(1-.25*u)-(a-.125)/(1-a)}}return[o]}function Us(i,t,e,s,o){const r=e.length,a=new Float32Array(r),n=Math.sqrt(1+s*s);for(let u=0;u<r;u++)if(i==null||i[u]){const l=e[u],p=t[u];a[u]=(p-s*l-o)/n}return[a]}function Vs(i,t){const[e,s,o,r,a,n]=t,u=e.length,l=new Float32Array(u);for(let p=0;p<u;p++)(i==null||i[p])&&(l[p]=-.2848*e[p]-.2435*s[p]-.5436*o[p]+.7243*r[p]+.084*a[p]-1.18*n[p]);return[l]}function Ls(i,t){const[e,,s,o,r,a]=t,n=e.length,u=new Float32Array(n),l=new Float32Array(n),p=new Float32Array(n);for(let h=0;h<n;h++)(i==null||i[h])&&(u[h]=a[h]?r[h]/a[h]*100:0,l[h]=e[h]?r[h]/e[h]*100:0,p[h]=o[h]?s[h]/o[h]*(r[h]/o[h])*100:0);return[u,l,p]}function Ws(i,t){const[e,s,o]=t,r=e.length,a=new Float32Array(r);for(let n=0;n<r;n++)if(i==null||i[n])for(n=0;n<r;n++){const u=e[n],l=s[n],p=l+u-o[n];p&&(a[n]=(l-u)/p)}return[a]}function qs(i,t){const[e,s,o]=t,r=e.length,a=new Float32Array(r);for(let n=0;n<r;n++)if(i==null||i[n])for(n=0;n<r;n++){const u=e[n],l=s[n],p=o[n],h=Math.sqrt((2*u+1)**2-6*u-5*Math.sqrt(l)-.5);a[n]=1.5*(1.2*(u-p)-2.5*(l-p))*h}return[a]}function Xs(i,t){const[e,s,o]=t,r=e.length,a=new Float32Array(r);for(let n=0;n<r;n++)if(i==null||i[n])for(n=0;n<r;n++){const u=e[n],l=s[n],p=o[n];a[n]=100*(u-l)-10*(u-p)}return[a]}function Hs(i,t){const[e,s,o]=t,r=e.length,a=new Float32Array(r);for(let n=0;n<r;n++)if(i==null||i[n])for(n=0;n<r;n++){const u=e[n],l=s[n],p=u+6*l-7.5*o[n]+1;p&&(a[n]=2.5*(u-l)/p)}return[a]}function Js(i,t,e=.5){const[s,o,r]=t,a=o.length,n=new Float32Array(a);for(let u=0;u<a;u++)if(i==null||i[u])for(u=0;u<a;u++){const l=s[u],p=o[u],h=r[u],m=l+e*p+(1-e)*h;m&&(n[u]=(l-e*p-(1-e)*h)/m)}return[n]}function Ks(i,t,e){const s=e.length,o=new Float32Array(s);for(let r=0;r<s;r++)if(i==null||i[r])for(r=0;r<s;r++){const a=(.1-t[r])**2+(.06-e[r])**2;a&&(o[r]=1/a)}return[o]}var qt;let kt=qt=class extends U{constructor(){super(...arguments),this.method="custom"}clone(){return new qt({method:this.method,bandIndexes:this.bandIndexes,raster:W(this.raster)})}};c([f({json:{type:String,write:!0}})],kt.prototype,"bandIndexes",void 0),c([Z(js)],kt.prototype,"method",void 0),kt=qt=c([A("esri.layers.support.rasterFunctions.BandArithmeticFunctionArguments")],kt);const Ys=kt,Zs=new Set(["vari","mtvi2","rtvi-core","evi"]);let gt=class extends V{constructor(){super(...arguments),this.functionName="BandArithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const t=this.sourceRasterInfos[0];if(t.bandCount<2)return{success:!1,supportsGPU:!1,error:"band-arithmetic-function: source raster has insufficient amount of raster bands"};const e=t.clone();return e.pixelType=this.outputPixelType,e.statistics=null,e.histograms=null,e.bandCount=this.functionArguments.method==="sultan"?3:1,e.keyProperties={...e.keyProperties,BandProperties:void 0},this.rasterInfo=e,{success:!0,supportsGPU:!["custom","gvitm","sultan"].includes(this.functionArguments.method)}}_processPixels(t){var a;const e=(a=t.pixelBlocks)==null?void 0:a[0];if(e==null)return e;const{method:s,bandIndexes:o}=this.functionArguments,r=o.split(" ").map(n=>parseFloat(n));return _s(e,{method:s,bandIndexes:r,equation:o})}_getWebGLParameters(){const t=this.functionArguments.bandIndexes.split(" ").map(n=>parseFloat(n)-1);t.length===2&&t.push(0);const e=this.isInputBandIdsSwizzled?[0,1,2]:t;let s,o;const r=new Float32Array(3),{method:a}=this.functionArguments;switch(a){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":s=O([e[0],e[1],0]),o="ndxi";break;case"ndwi":s=O([e[1],e[0],0]),o="ndxi";break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":s=O([e[0],e[1],0]),o="sr";break;case"ci-g":case"ci-re":s=O([e[0],e[1],0]),o="ci";break;case"savi":s=O([e[0],e[1],0]),o="savi",r[0]=t[2]+1;break;case"tsavi":s=O([e[0],e[1],0]),o="tsavi",r[0]=t[2]+1,r[1]=t[3]+1,r[2]=t[4]+1;break;case"msavi":s=O([e[0],e[1],0]),o="msavi";break;case"gemi":s=O([e[0],e[1],0]),o="gemi";break;case"pvi":s=O([e[0],e[1],0]),o="tsavi",r[0]=t[2]+1,r[1]=t[3]+1;break;case"vari":s=O([e[0],e[1],e[2]]),o="vari";break;case"mtvi2":s=O([e[0],e[1],e[2]]),o="mtvi2";break;case"rtvi-core":s=O([e[0],e[1],e[2]]),o="rtvicore";break;case"evi":s=O([e[0],e[1],e[2]]),o="evi";break;case"wndwi":s=O([e[0],e[1],0]),o="wndwi",r[0]=t[3]?t[3]+1:.5;break;case"bai":s=O([e[1],e[0],0]),o="bai";break;default:s=O([0,1,2]),o="custom"}return{bandIndexMat3:s,indexType:o,adjustments:r}}_getInputBandIds(t){if(this.functionArguments.method==="custom")return t;const e=this.functionArguments.bandIndexes.split(" ").map(n=>parseFloat(n)-1),s=t.length,o=e.map(n=>n>=s?s-1:n),r=Zs.has(this.functionArguments.method)?3:2,a=o.slice(0,r).map(n=>t[n]);return a.length===2&&a.push(0),a}};c([f({json:{write:!0,name:"rasterFunction"}})],gt.prototype,"functionName",void 0),c([f({type:Ys,json:{write:!0,name:"rasterFunctionArguments"}})],gt.prototype,"functionArguments",void 0),c([f()],gt.prototype,"rasterArgumentNames",void 0),gt=c([A("esri.layers.support.rasterFunctions.BandArithmeticFunction")],gt);const Qs=gt;var Xt;let J=Xt=class extends U{castColormapName(i){if(!i)return null;const t=i.toLowerCase();return gs.includes(t)?t:null}readColorRamp(i){return os(i)}readColorRampName(i,t){if(!i)return null;const e=St.jsonValues.find(s=>s.toLowerCase()===i.toLowerCase());return e?St.fromJSON(e):null}clone(){var i;return new Xt({colormap:W(this.colormap),colormapName:this.colormapName,colorRamp:(i=this.colorRamp)==null?void 0:i.clone(),colorRampName:this.colorRampName})}};c([f({type:[[Number]],json:{write:!0}})],J.prototype,"colormap",void 0),c([f({type:String,json:{write:!0}})],J.prototype,"colormapName",void 0),c([We("colormapName")],J.prototype,"castColormapName",null),c([f({types:rs,json:{write:!0}})],J.prototype,"colorRamp",void 0),c([Nt("colorRamp")],J.prototype,"readColorRamp",null),c([f({type:St.apiValues,json:{type:St.jsonValues,write:St.write}})],J.prototype,"colorRampName",void 0),c([Nt("colorRampName")],J.prototype,"readColorRampName",null),J=Xt=c([A("esri.layers.support.rasterFunctions.ColormapFunctionArguments")],J);const tn=J,en=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[112,75,3],[113,76,3],[114,77,3],[115,77,3],[116,78,3],[117,79,3],[118,79,3],[119,80,3],[121,81,4],[122,82,4],[123,82,4],[124,83,4],[125,84,4],[126,84,4],[127,85,4],[128,86,4],[129,86,4],[130,87,4],[131,88,4],[132,89,4],[133,89,4],[134,90,4],[135,91,4],[136,91,4],[137,92,4],[138,93,4],[139,94,4],[140,94,4],[142,95,5],[143,96,5],[144,96,5],[145,97,5],[146,98,5],[147,99,5],[148,99,5],[149,100,5],[150,101,5],[151,101,5],[152,102,5],[153,103,5],[154,104,5],[155,104,5],[156,105,5],[157,106,5],[158,106,5],[159,107,5],[160,108,5],[161,108,5],[162,109,5],[164,110,6],[165,111,6],[166,111,6],[167,112,6],[168,113,6],[169,113,6],[170,114,6],[171,115,6],[172,116,6],[173,116,6],[174,117,6],[245,0,0],[245,5,0],[245,10,0],[246,15,0],[246,20,0],[246,25,0],[246,30,0],[247,35,0],[247,40,0],[247,45,0],[247,50,0],[247,55,0],[248,60,0],[248,65,0],[248,70,0],[248,75,0],[249,81,0],[249,86,0],[249,91,0],[249,96,0],[250,101,0],[250,106,0],[250,111,0],[250,116,0],[250,121,0],[251,126,0],[251,131,0],[251,136,0],[251,141,0],[252,146,0],[252,151,0],[252,156,0],[252,156,0],[251,159,0],[250,162,0],[249,165,0],[248,168,0],[247,171,0],[246,174,0],[245,177,0],[245,179,0],[244,182,0],[243,185,0],[242,188,0],[241,191,0],[240,194,0],[239,197,0],[238,200,0],[237,203,0],[236,206,0],[235,209,0],[234,212,0],[233,215,0],[232,218,0],[231,221,0],[230,224,0],[230,226,0],[229,229,0],[228,232,0],[227,235,0],[226,238,0],[225,241,0],[224,244,0],[223,247,0],[165,247,0],[163,244,0],[161,240,0],[158,237,0],[156,233,1],[154,230,1],[152,227,1],[149,223,1],[147,220,1],[145,216,1],[143,213,1],[140,210,2],[138,206,2],[136,203,2],[134,200,2],[132,196,2],[129,193,2],[127,189,2],[125,186,3],[123,183,3],[120,179,3],[118,176,3],[116,172,3],[114,169,3],[111,166,3],[109,162,4],[107,159,4],[105,155,4],[103,152,4],[100,149,4],[98,145,4],[96,142,4],[94,138,5],[91,135,5],[89,132,5],[87,128,5],[85,125,5],[82,121,5],[80,118,5],[78,115,6],[76,111,6],[73,108,6],[71,105,6],[69,101,6],[67,98,6],[65,94,6],[62,91,7],[60,88,7],[58,84,7],[56,81,7],[53,77,7],[51,74,7],[49,71,7],[47,67,8],[44,64,8],[42,60,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8]],sn=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[245,20,0],[245,24,0],[245,29,0],[245,31,0],[247,33,0],[247,33,0],[247,37,0],[247,41,0],[247,41,0],[247,41,0],[247,45,0],[247,45,0],[247,47,0],[247,49,0],[247,49,0],[247,54,0],[247,54,0],[247,56,0],[247,58,0],[247,58,0],[250,62,0],[250,62,0],[250,62,0],[250,67,0],[250,67,0],[250,67,0],[250,69,0],[250,71,0],[250,71,0],[250,75,0],[250,75,0],[250,78,0],[250,79,0],[250,79,0],[250,79,0],[250,81,0],[250,83,0],[250,83,0],[250,87,0],[250,87,0],[250,90,0],[250,92,0],[252,93,0],[252,93,0],[252,97,0],[252,97,0],[252,97,0],[252,97,0],[252,101,0],[252,101,0],[252,101,0],[252,101,0],[252,105,0],[252,105,0],[252,107,0],[252,109,0],[252,109,0],[252,113,13],[255,118,20],[255,119,23],[255,121,25],[255,126,33],[255,132,38],[255,133,40],[255,135,43],[255,141,48],[255,144,54],[255,150,59],[255,152,61],[255,153,64],[255,159,69],[255,163,77],[255,165,79],[255,168,82],[255,174,87],[255,176,92],[255,181,97],[255,183,99],[255,186,102],[255,191,107],[255,197,115],[255,201,120],[255,203,123],[255,205,125],[255,209,130],[255,214,138],[255,216,141],[255,218,143],[255,224,150],[255,228,156],[255,234,163],[255,236,165],[255,238,168],[255,243,173],[255,248,181],[255,252,186],[253,252,186],[250,252,187],[244,250,180],[238,247,176],[234,246,173],[231,245,169],[223,240,163],[217,237,157],[211,235,150],[205,233,146],[200,230,142],[195,227,136],[189,224,132],[184,222,126],[180,220,123],[174,217,119],[169,214,114],[163,212,108],[160,210,105],[154,207,101],[148,204,96],[143,201,93],[138,199,88],[134,197,84],[130,194,81],[126,191,77],[117,189,70],[115,186,68],[112,184,64],[106,181,60],[100,179,55],[94,176,49],[92,174,47],[90,173,45],[81,168,37],[75,166,33],[71,163,28],[66,160,24],[62,158,21],[56,156,14],[51,153,0],[51,153,0],[51,153,0],[50,150,0],[50,150,0],[50,150,0],[50,150,0],[49,148,0],[49,148,0],[49,148,0],[48,145,0],[48,145,0],[48,145,0],[48,145,0],[48,143,0],[48,143,0],[48,143,0],[48,143,0],[47,140,0],[47,140,0],[47,140,0],[47,140,0],[46,138,0],[46,138,0],[46,138,0],[46,138,0],[45,135,0],[45,135,0],[45,135,0],[45,135,0],[44,133,0],[44,133,0],[44,133,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[42,128,0],[42,128,0],[42,128,0],[42,125,0],[42,125,0],[42,125,0],[42,125,0],[41,122,0],[41,122,0],[41,122,0],[41,122,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[39,117,0],[39,117,0],[39,117,0],[39,117,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0]];function ye(i,t){const e=[],s=[];for(let r=0;r<i.length-1;r++)e.push({type:"algorithmic",algorithm:"esriHSVAlgorithm",fromColor:i[r].slice(1),toColor:i[r+1].slice(1)}),s.push(i[r+1][0]-i[r][0]);const o=i[i.length-1][0];return He({type:"multipart",colorRamps:e},{numColors:o,weights:t=t??s})}function nn(){return ye([[0,0,191,191],[51,0,0,255],[102,255,0,255],[153,255,0,127],[204,191,63,127],[256,20,20,20]])}function rn(){const i=ye([[0,255,255,255],[70,0,255,0],[80,205,173,193],[100,150,150,150],[110,120,51,100],[130,120,100,200],[140,28,3,144],[160,6,0,55],[180,10,25,30],[201,6,7,27]]);for(let t=i.length;t<256;t++)i.push([6,27,7]);return i}function on(){return He({type:"algorithmic",algorithm:"esriHSVAlgorithm",fromColor:[0,0,0],toColor:[255,255,255]})}function an(){const i=[];for(let t=0;t<256;t++){const e=[];for(let s=0;s<3;s++)e.push(Math.round(255*Math.random()));i.push(e)}return i}function un(){return ye([[0,38,41,54],[69,79,82,90],[131,156,156,156],[256,253,253,241]],[.268,.238,.495])}function ln(i){let t;switch(i){case"elevation":t=nn();break;case"gray":t=on();break;case"hillshade":t=un();break;case"ndvi":t=en;break;case"ndvi2":t=rn();break;case"ndvi3":t=sn;break;case"random":t=an()}return t?(t=t.map((e,s)=>[s,...e]),t):null}let Q=class extends V{constructor(){super(...arguments),this.functionName="Colormap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isNoopProcess=!0}_bindSourceRasters(){const t=this.sourceRasterInfos[0];if(t.bandCount>1)return{success:!1,supportsGPU:!1,error:"colormap-function: source data must be single band"};let{colormap:e,colormapName:s,colorRamp:o,colorRampName:r}=this.functionArguments;if(!(e!=null&&e.length))if(o)e=Te(o,{interpolateAlpha:!0});else if(r){const n=ys(r);n&&(e=Te(n))}else s&&(e=ln(s));if(!(e!=null&&e.length))return{success:!1,supportsGPU:!1,error:"colormap-function: missing colormap argument"};this.outputPixelType=this._getOutputPixelType("u8");const a=t.clone();return a.pixelType=this.outputPixelType,a.colormap=e,a.bandCount=1,this.rasterInfo=a,{success:!0,supportsGPU:!0}}_processPixels(t){var e;return(e=t.pixelBlocks)==null?void 0:e[0]}};c([f({json:{write:!0,name:"rasterFunction"}})],Q.prototype,"functionName",void 0),c([f({type:tn,json:{write:!0,name:"rasterFunctionArguments"}})],Q.prototype,"functionArguments",void 0),c([f()],Q.prototype,"rasterArgumentNames",void 0),c([f()],Q.prototype,"isNoopProcess",void 0),c([f({json:{write:!0}})],Q.prototype,"indexedColormap",void 0),Q=c([A("esri.layers.support.rasterFunctions.ColormapFunction")],Q);const cn=Q;var Ht;let Ct=Ht=class extends U{constructor(){super(...arguments),this.rasters=[]}writeRasters(i,t){t.rasters=i.map(e=>typeof e=="number"||typeof e=="string"?e:e.toJSON())}clone(){return new Ht({rasters:W(this.rasters)})}};c([f({json:{write:!0}})],Ct.prototype,"rasters",void 0),c([Ft("rasters")],Ct.prototype,"writeRasters",null),Ct=Ht=c([A("esri.layers.support.rasterFunctions.CompositeBandFunctionArguments")],Ct);const pn=Ct;let yt=class extends V{constructor(){super(...arguments),this.functionName="CompositeBand",this.functionArguments=null,this.rasterArgumentNames=["rasters"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,e=t[0];this.outputPixelType=this._getOutputPixelType(e.pixelType);const s=e.clone();if(s.attributeTable=null,s.colormap=null,s.pixelType=this.outputPixelType,s.bandCount=t.map(({bandCount:r})=>r).reduce((r,a)=>r+a),t.every(({statistics:r})=>r!=null&&r.length)){const r=[];t.forEach(({statistics:a})=>a!=null&&r.push(...a)),s.statistics=r}if(t.every(({histograms:r})=>r!=null&&r.length)){const r=[];t.forEach(({histograms:a})=>a!=null&&r.push(...a)),s.histograms=r}s.bandCount>1&&(s.colormap=null,s.attributeTable=null);const o=t.every(r=>{var a;return(a=r.keyProperties.BandProperties)==null?void 0:a.length})?t.flatMap(r=>r.keyProperties.BandProperties):void 0;return s.keyProperties={...s.keyProperties,BandProperties:o},this.rasterInfo=s,{success:!0,supportsGPU:s.bandCount<=3}}_processPixels(t){const{pixelBlocks:e}=t;return e?(e==null?void 0:e[0])==null?null:us(e):null}_getWebGLParameters(){return{bandCount:this.rasterInfo.bandCount}}};c([f({json:{write:!0,name:"rasterFunction"}})],yt.prototype,"functionName",void 0),c([f({type:pn,json:{write:!0,name:"rasterFunctionArguments"}})],yt.prototype,"functionArguments",void 0),c([f()],yt.prototype,"rasterArgumentNames",void 0),yt=c([A("esri.layers.support.rasterFunctions.CompositeBandFunction")],yt);const hn=yt;var Jt;let Bt=Jt=class extends U{constructor(){super(...arguments),this.contrastOffset=0,this.brightnessOffset=0}clone(){return new Jt({contrastOffset:this.contrastOffset,brightnessOffset:this.brightnessOffset,raster:this.raster})}};c([f({json:{write:!0}})],Bt.prototype,"contrastOffset",void 0),c([f({json:{write:!0}})],Bt.prototype,"brightnessOffset",void 0),Bt=Jt=c([A("esri.layers.support.rasterFunctions.ContrastBrightnessFunctionArguments")],Bt);const fn=Bt;let ot=class extends V{constructor(){super(...arguments),this.functionName="ContrastBrightness",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const{sourceRasterInfos:t}=this,e=t[0];if(e.pixelType!=="u8")return{success:!1,supportsGPU:!1,error:"Only unsigned 8 bit raster is supported by ContrastBrightness function."};this.outputPixelType=this._getOutputPixelType("u8");const s=e.clone();s.colormap=null,s.statistics=null,s.histograms=null,this.rasterInfo=s;const{contrastOffset:o,brightnessOffset:r}=this.functionArguments;return this.lookup=ws(o,r),{success:!0,supportsGPU:!0}}_processPixels(t){var s;const e=(s=t.pixelBlocks)==null?void 0:s[0];return e==null?null:ge(e,{lut:e.pixels.map(()=>this.lookup),offset:0,outputPixelType:"u8"})}_getWebGLParameters(){const{contrastOffset:t,brightnessOffset:e}=this.functionArguments;return{contrastOffset:t,brightnessOffset:e}}};c([f({json:{write:!0,name:"rasterFunction"}})],ot.prototype,"functionName",void 0),c([f({type:fn,json:{write:!0,name:"rasterFunctionArguments"}})],ot.prototype,"functionArguments",void 0),c([f()],ot.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],ot.prototype,"lookup",void 0),ot=c([A("esri.layers.support.rasterFunctions.ContrastBrightnessFunction")],ot);const mn=ot,N={userDefined:-1,lineDetectionHorizontal:0,lineDetectionVertical:1,lineDetectionLeftDiagonal:2,lineDetectionRightDiagonal:3,gradientNorth:4,gradientWest:5,gradientEast:6,gradientSouth:7,gradientNorthEast:8,gradientNorthWest:9,smoothArithmeticMean:10,smoothing3x3:11,smoothing5x5:12,sharpening3x3:13,sharpening5x5:14,laplacian3x3:15,laplacian5x5:16,sobelHorizontal:17,sobelVertical:18,sharpen:19,sharpen2:20,pointSpread:21,none:255},dn={plus:1,minus:2,times:3,sqrt:4,power:5,abs:10,divide:23,exp:25,exp10:26,exp2:27,int:30,float:32,ln:35,log10:36,log2:37,mod:44,negate:45,roundDown:48,roundUp:49,square:53,floatDivide:64,floorDivide:65},L={bitwiseAnd:11,bitwiseLeftShift:12,bitwiseNot:13,bitwiseOr:14,bitwiseRightShift:15,bitwiseXOr:16,booleanAnd:17,booleanNot:18,booleanOr:19,booleanXOr:20,equalTo:24,greaterThan:28,greaterThanEqual:29,lessThan:33,lessThanEqual:34,isNull:31,notEqual:46},H={acos:6,asin:7,atan:8,atanh:9,cos:21,cosh:22,sin:51,sinh:52,tan:56,tanh:57,acosh:59,asinh:60,atan2:61},gn={majority:38,max:39,mean:40,med:41,min:42,minority:43,range:47,stddev:54,sum:55,variety:58,majorityIgnoreNoData:66,maxIgnoreNoData:67,meanIgnoreNoData:68,medIgnoreNoData:69,minIgnoreNoData:70,minorityIgnoreNoData:71,rangeIgnoreNoData:72,stddevIgnoreNoData:73,sumIgnoreNoData:74,varietyIgnoreNoData:75},Je={setNull:50,conditional:78},Ne={...dn,...L,...H,...gn,...Je};function we(i,t,e,s,o){const r=Math.floor(s/2);for(let n=0;n<r;n++)for(let u=0;u<t;u++)i[n*t+u]=i[(o-1-n)*t+u],i[(e-1-n)*t+u]=i[(e-o+n)*t+u];const a=Math.floor(o/2);for(let n=0;n<e;n++){const u=n*t;for(let l=0;l<a;l++)i[u+l]=i[u+o-1-l],i[u+t-l-1]=i[u+t+l-o]}}const j=new Map;function yn(i){const t=Math.sqrt(i.length),e=i.slice(0,t),s=[1];for(let o=1;o<t;o++){let r=null;for(let a=0;a<t;a++){const n=i[a+o*t],u=i[a];if(r==null)if(u===0){if(n)return{separable:!1,row:null,col:null}}else r=n/u;else if(n/u!==r)return{separable:!1,row:null,col:null}}if(r==null)return{separable:!1,row:null,col:null};s.push(r)}return{separable:!0,row:e,col:s}}function Fe(i,t,e,s,o,r,a){const n=new Float32Array(t*e),u=r.length,l=a?0:s,p=a?s:0,h=a?1:t;for(let m=l;m<e-l;m++){const g=m*t;for(let w=p;w<t-p;w++){if(o&&!o[g+w])continue;let y=0;for(let d=0;d<u;d++)y+=i[g+w+(d-s)*h]*r[d];n[g+w]=y}}return n}function wn(i,t,e,s,o,r,a){const n=new Float32Array(t*e),u=Math.floor(s/2),l=Math.floor(o/2);for(let p=u;p<e-u;p++){const h=p*t;for(let m=l;m<t-l;m++){if(r&&!r[h+m])continue;let g=0;for(let w=0;w<s;w++)for(let y=0;y<o;y++)g+=i[h+m+(w-u)*t+y-l]*a[w*o+y];n[h+m]=g}}return n}function bn(i,t,e=!0){const{pixels:s,width:o,height:r,pixelType:a,mask:n}=i,u=s.length,l=[],{kernel:p,rows:h,cols:m}=t;for(let g=0;g<u;g++){const w=wn(s[g],o,r,h,m,n,p);e&&we(w,o,r,h,m),l.push(w)}return new x({width:o,height:r,pixelType:a,pixels:l,mask:n})}function xn(i,t,e,s=!0){const{pixels:o,width:r,height:a,pixelType:n,mask:u}=i,l=o.length,p=[],h=t.length,m=e.length,g=Math.floor(h/2),w=Math.floor(m/2);for(let y=0;y<l;y++){let d=Fe(o[y],r,a,g,u,t,!0);d=Fe(d,r,a,w,u,e,!1),s&&we(d,r,a,h,m),p.push(d)}return new x({width:r,height:a,pixelType:n,pixels:p,mask:u})}function vn(i,t){const e=yn(t.kernel),s=t.mirrorEdges!==!1,o=e.separable?xn(i,e.row,e.col,s):bn(i,t,s),{outputPixelType:r}=t;return r&&o.clamp(r),o}j.set(N.none,[0,0,0,0,1,0,0,0,0]),j.set(N.lineDetectionHorizontal,[-1,-1,-1,2,2,2,-1,-1,-1]),j.set(N.lineDetectionVertical,[-1,2,-1,-1,2,-1,-1,2,-1]),j.set(N.lineDetectionLeftDiagonal,[2,-1,-1,-1,2,-1,-1,-1,2]),j.set(N.lineDetectionRightDiagonal,[-1,-1,2,-1,2,-1,2,-1,-1]),j.set(N.gradientNorth,[-1,-2,-1,0,0,0,1,2,1]),j.set(N.gradientWest,[-1,0,1,-2,0,2,-1,0,1]),j.set(N.gradientEast,[1,0,-1,2,0,-2,1,0,-1]),j.set(N.gradientSouth,[1,2,1,0,0,0,-1,-2,-1]),j.set(N.gradientNorthEast,[0,-1,-2,1,0,-1,2,1,0]),j.set(N.gradientNorthWest,[-2,-1,0,-1,0,1,0,1,2]),j.set(N.smoothArithmeticMean,[.111111111111,.111111111111,.111111111111,.111111111111,.111111111111,.111111111111,.111111111111,.111111111111,.111111111111]),j.set(N.smoothing3x3,[.0625,.125,.0625,.125,.25,.125,.0625,.125,.0625]),j.set(N.smoothing5x5,[1,1,1,1,1,1,4,4,4,1,1,4,12,4,1,1,4,4,4,1,1,1,1,1,1]),j.set(N.sharpening3x3,[-1,-1,-1,-1,9,-1,-1,-1,-1]),j.set(N.sharpening5x5,[-1,-3,-4,-3,-1,-3,0,6,0,-3,-4,6,21,6,-4,-3,0,6,0,-3,-1,-3,-4,-3,-1]),j.set(N.laplacian3x3,[0,-1,0,-1,4,-1,0,-1,0]),j.set(N.laplacian5x5,[0,0,-1,0,0,0,-1,-2,-1,0,-1,-2,17,-2,-1,0,-1,-2,-1,0,0,0,-1,0,0]),j.set(N.sobelHorizontal,[-1,-2,-1,0,0,0,1,2,1]),j.set(N.sobelVertical,[-1,0,1,-2,0,2,-1,0,1]),j.set(N.sharpen,[0,-.25,0,-.25,2,-.25,0,-.25,0]),j.set(N.sharpen2,[-.25,-.25,-.25,-.25,3,-.25,-.25,-.25,-.25]),j.set(N.pointSpread,[-.627,.352,-.627,.352,2.923,.352,-.627,.352,-.627]);var Kt;let it=Kt=class extends U{constructor(){super(...arguments),this.rows=3,this.cols=3,this.kernel=[0,0,0,0,1,0,0,0,0]}set convolutionType(i){this._set("convolutionType",i);const t=j.get(i);if(!t||i===N.userDefined||i===N.none)return;const e=Math.sqrt(t.length);this._set("kernel",t),this._set("cols",e),this._set("rows",e)}clone(){return new Kt({cols:this.cols,rows:this.rows,kernel:[...this.kernel],convolutionType:this.convolutionType,raster:W(this.raster)})}};c([f({json:{type:Number,write:!0}})],it.prototype,"rows",void 0),c([f({json:{type:Number,write:!0}})],it.prototype,"cols",void 0),c([f({json:{name:"type",type:Number,write:!0}})],it.prototype,"convolutionType",null),c([f({json:{type:[Number],write:!0}})],it.prototype,"kernel",void 0),it=Kt=c([A("esri.layers.support.rasterFunctions.ConvolutionFunctionArguments")],it);const An=it,Ie=25;let wt=class extends V{constructor(){super(...arguments),this.functionName="Convolution",this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{convolutionType:t,rows:e,cols:s,kernel:o}=this.functionArguments;if(!Object.values(N).includes(t))return{success:!1,supportsGPU:!1,error:`convolution-function: the specified kernel type is not supported ${t}`};if(t!==N.none&&e*s!==o.length)return{success:!1,supportsGPU:!1,error:"convolution-function: the specified rows and cols do not match the length of the kernel"};const r=this.sourceRasterInfos[0];this.outputPixelType=this._getOutputPixelType(r.pixelType);const a=r.clone();a.pixelType=this.outputPixelType;const n=[N.none,N.sharpen,N.sharpen2,N.sharpening3x3,N.sharpening5x5];return this.outputPixelType==="u8"||n.includes(t)||(a.statistics=null,a.histograms=null),a.colormap=null,a.attributeTable=null,this.rasterInfo=a,{success:!0,supportsGPU:o.length<=Ie}}_processPixels(t){var n;const e=(n=t.pixelBlocks)==null?void 0:n[0];if(e==null||this.functionArguments.convolutionType===N.none)return e;let{kernel:s,rows:o,cols:r}=this.functionArguments;const a=s.reduce((u,l)=>u+l);return a!==0&&a!==1&&(s=s.map(u=>u/a)),vn(e,{kernel:s,rows:o,cols:r,outputPixelType:this.outputPixelType})}_getWebGLParameters(){let{kernel:t}=this.functionArguments;const e=t.reduce((o,r)=>o+r);e!==0&&e!==1&&(t=t.map(o=>o/e));const s=new Float32Array(Ie);return s.set(t),{kernelRows:this.functionArguments.rows,kernelCols:this.functionArguments.cols,kernel:s,clampRange:Dt(this.outputPixelType)}}};c([f({json:{write:!0,name:"rasterFunction"}})],wt.prototype,"functionName",void 0),c([f({type:An,json:{write:!0,name:"rasterFunctionArguments"}})],wt.prototype,"functionArguments",void 0),c([f()],wt.prototype,"rasterArgumentNames",void 0),wt=c([A("esri.layers.support.rasterFunctions.ConvolutionFunction")],wt);const Pn=wt;var Yt;const Ke=new Mt({0:"standard",1:"platform",2:"profile"},{useNumericKeys:!0});let bt=Yt=class extends U{constructor(){super(...arguments),this.curvatureType="standard",this.zFactor=1}readCurvatureType(i,t){return Ke.fromJSON(t.type??t.curvatureType??0)}clone(){return new Yt({curvatureType:this.curvatureType,zFactor:this.zFactor,raster:this.raster})}};c([f({json:{write:{target:"type"}}}),Z(Ke)],bt.prototype,"curvatureType",void 0),c([Nt("curvatureType",["type","curvatureType"])],bt.prototype,"readCurvatureType",null),c([f({type:Number,json:{write:!0}})],bt.prototype,"zFactor",void 0),bt=Yt=c([A("esri.layers.support.rasterFunctions.CurvatureFunctionArguments")],bt);const Tn=bt;let at=class extends V{constructor(){super(...arguments),this.functionName="Curvature",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){var e;this.outputPixelType=this._getOutputPixelType("f32");const t=this.sourceRasterInfos[0].clone();return t.pixelType=this.outputPixelType,t.statistics=null,t.histograms=null,t.colormap=null,t.attributeTable=null,t.bandCount=1,this.rasterInfo=t,this.isGCS=((e=t.spatialReference)==null?void 0:e.isGeographic)??!1,{success:!0,supportsGPU:!0}}_processPixels(t){var p;const e=(p=t.pixelBlocks)==null?void 0:p[0];if(e==null)return null;const{zFactor:s,curvatureType:o}=this.functionArguments,{extent:r,primaryPixelSizes:a}=t,n=a==null?void 0:a[0],u=n??(r?{x:r.width/e.width,y:r.height/e.height}:{x:1,y:1}),l=this.isGCS&&s>=1?s*Vt:s;return bs(e,{zFactor:l,curvatureType:o,resolution:u})}_getWebGLParameters(){const{zFactor:t,curvatureType:e}=this.functionArguments;return{curvatureType:e,zFactor:this.isGCS&&t>=1?t*Vt:t}}};c([f({json:{write:!0,name:"rasterFunction"}})],at.prototype,"functionName",void 0),c([f({type:Tn,json:{write:!0,name:"rasterFunctionArguments"}})],at.prototype,"functionArguments",void 0),c([f()],at.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],at.prototype,"isGCS",void 0),at=c([A("esri.layers.support.rasterFunctions.CurvatureFunction")],at);const $n=at;var Zt;let K=Zt=class extends U{constructor(){super(...arguments),this.bandIds=[],this.bandNames=[],this.bandWavelengths=[],this.missingBandAction=qe.bestMatch}clone(){var i,t,e;return new Zt({bandIds:(i=this.bandIds)==null?void 0:i.slice(),bandNames:(t=this.bandNames)==null?void 0:t.slice(),bandWavelengths:(e=this.bandWavelengths)==null?void 0:e.slice(),missingBandAction:this.missingBandAction,method:this.method,wavelengthMatchTolerance:this.wavelengthMatchTolerance})}};c([f({json:{write:!0}})],K.prototype,"bandIds",void 0),c([f({json:{write:!0}})],K.prototype,"bandNames",void 0),c([f({json:{write:!0}})],K.prototype,"bandWavelengths",void 0),c([Z({0:"name",1:"wavelength",2:"id"})],K.prototype,"method",void 0),c([f({json:{write:!0}})],K.prototype,"missingBandAction",void 0),c([f({json:{write:!0}})],K.prototype,"wavelengthMatchTolerance",void 0),K=Zt=c([A("esri.layers.support.rasterFunctions.ExtractBandFunctionArguments")],K);const Nn=K;let xt=class extends V{constructor(){super(...arguments),this.functionName="ExtractBand",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){var v;const{functionArguments:t,sourceRasterInfos:e}=this,s=e[0],{method:o,bandNames:r,bandWavelengths:a,bandIds:n,missingBandAction:u}=t,l=(r==null?void 0:r.length)&&(o==="name"||o!=="id"&&!(n!=null&&n.length)),p=(a==null?void 0:a.length)&&(o==="wavelength"||o!=="id"&&!(n!=null&&n.length)),h=u===qe.fail,m=l?this._matchBandNames(s,r):p?this._matchBandWavelengths(s,a,h):this._matchBandIds(s,n,h);if(m==null)return{success:!1,supportsGPU:!1,error:`extract-band-function: Invalid ${l?"band names":p?"band wavelengths":"band ids"} for the imagery data source`};this.functionArguments.bandIds=m,this.functionArguments.method="id",this.outputPixelType=this._getOutputPixelType("f32");const g=s.clone();g.pixelType=this.outputPixelType,g.bandCount=m.length;const{statistics:w,histograms:y}=g;w!=null&&w.length&&(g.statistics=m.map(b=>w[b]||w[w.length-1])),y!=null&&y.length&&(g.histograms=m.map(b=>y[b]||y[y.length-1]));let d=(v=g.keyProperties)==null?void 0:v.BandProperties;return d!=null&&d.length&&(d=m.map(b=>b>=d.length?d[d.length-1]:d[b]),g.keyProperties={...g.keyProperties,BandProperties:d}),this.rasterInfo=g,{success:!0,supportsGPU:g.bandCount<=3}}_processPixels(t){var r;const e=(r=t.pixelBlocks)==null?void 0:r[0];if(e==null)return null;const s=e.pixels.length,o=this.functionArguments.bandIds.map(a=>a>=s?s-1:a);return e.extractBands(o)}_getWebGLParameters(){let t;if(this.isInputBandIdsSwizzled)t=this.swizzledBandSelection.length?this.swizzledBandSelection:[0,1,2];else{t=[...this.functionArguments.bandIds],t.length===0?t=[0,1,2]:t.length<3&&(t[1]=t[1]??t[0],t[2]=t[2]??t[1]);for(let e=0;e<3;e++)t[e]=Math.min(t[e],2)}return{bandIndexMat3:O(t)}}_getInputBandIds(t){const e=t.length;return this.functionArguments.bandIds.map(s=>s>=e?e-1:s).map(s=>t[s])}_matchBandNames(t,e){const s=t.bandInfos.map(({name:r})=>r.toLowerCase()),o=[];for(let r=0;r<e.length;r++){const a=e[r].toLowerCase();let n=s.indexOf(a);if(n===-1&&a==="nearinfrared"&&(n=s.findIndex(u=>u.startsWith("nearinfrared_1")),n===-1&&(n=s.findIndex(u=>u.startsWith("nearinfrared")))),n===-1)return null;o.push(n)}return o}_matchBandIds(t,e,s){const{bandCount:o}=t;return!(e!=null&&e.length)||s&&e.some(r=>r<0||r>=o)?null:e}_matchBandWavelengths(t,e,s){const{bandInfos:o}=t,r=[];for(let u=0;u<o.length;u++){const{minWavelength:l,maxWavelength:p}=o[u];if(!l||!p)return null;r.push({minWavelength:l,maxWavelength:p})}const{wavelengthMatchTolerance:a}=this.functionArguments,n=[];for(let u=0;u<e.length;u++){const l=e[u];let p=!1,h=-1,m=Number.MAX_VALUE;for(let g=0;g<r.length;g++){const w=r[g],y=l>=w.minWavelength&&l<=w.maxWavelength,d=Math.abs(l-(w.minWavelength+w.maxWavelength)/2);y?d<m&&(p=!0,h=g,m=d):!p&&d<m&&(h=g,m=d)}if(!p&&a&&m<a&&(p=!0),!p&&s)return null;n.push(h)}return n}};c([f({json:{write:!0,name:"rasterFunction"}})],xt.prototype,"functionName",void 0),c([f({type:Nn,json:{write:!0,name:"rasterFunctionArguments"}})],xt.prototype,"functionArguments",void 0),c([f()],xt.prototype,"rasterArgumentNames",void 0),xt=c([A("esri.layers.support.rasterFunctions.ExtractBandFunction")],xt);const Fn=xt;var Qt;let ut=Qt=class extends U{constructor(){super(...arguments),this.rasters=[],this.processAsMultiband=!0}writeRasters(i,t){t.rasters=i.map(e=>typeof e=="number"||typeof e=="string"?e:e.toJSON())}clone(){return new Qt({operation:this.operation,processAsMultiband:this.processAsMultiband,rasters:W(this.rasters)})}};c([f({json:{write:!0}})],ut.prototype,"operation",void 0),c([f({json:{write:!0}})],ut.prototype,"rasters",void 0),c([Ft("rasters")],ut.prototype,"writeRasters",null),c([f({json:{write:!0}})],ut.prototype,"processAsMultiband",void 0),ut=Qt=c([A("esri.layers.support.rasterFunctions.LocalFunctionArguments")],ut);const In=ut,E=new Map;function Rn(i){return E.get(i)}E.set(H.acos,[0,Math.PI]),E.set(H.asin,[-Math.PI/2,Math.PI/2]),E.set(H.atan,[-Math.PI/2,Math.PI/2]),E.set(H.cos,[-1,1]),E.set(H.sin,[-1,1]),E.set(L.booleanAnd,[0,1]),E.set(L.booleanNot,[0,1]),E.set(L.booleanOr,[0,1]),E.set(L.booleanXOr,[0,1]),E.set(L.equalTo,[0,1]),E.set(L.notEqual,[0,1]),E.set(L.greaterThan,[0,1]),E.set(L.greaterThanEqual,[0,1]),E.set(L.lessThan,[0,1]),E.set(L.lessThanEqual,[0,1]),E.set(L.isNull,[0,1]);const Re=[0,2,2,2,1,2,1,1,1,1,1,2,2,1,2,2,2,2,1,2,2,1,1,2,2,1,1,1,2,2,1,1,1,2,2,1,1,1,999,999,999,999,999,999,2,1,2,999,1,1,2,1,1,1,999,999,1,1,999,1,1,2,999,999,2,2,999,999,999,999,999,999,999,999,999,999,3,999,3];function kn(i,t=!1){const e=i.map(n=>n.mask),s=e.filter(n=>n!=null),o=i[0].pixels[0].length;if(s.length===0)return new Uint8Array(o).fill(255);const r=s[0],a=new Uint8Array(r);if(s.length===1)return a;if(!t){for(let n=1;n<s.length;n++){const u=s[n];for(let l=0;l<a.length;l++)a[l]&&(a[l]=u[l]?255:0)}return a}if(s.length!==e.length)return new Uint8Array(o).fill(255);for(let n=1;n<s.length;n++){const u=s[n];for(let l=0;l<a.length;l++)a[l]===0&&(a[l]=u[l]?255:0)}return a}function Cn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]+o[n]);return a}function Bn(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand("f32",o);return r.set(s),r}function jn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]-o[n]);return a}function _n(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]*o[n]);return a}function Sn(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand(e,o);for(let a=0;a<o;a++)t&&!t[a]||(r[a]=Math.sign(s[a])*Math.floor(Math.abs(s[a])));return r}function Ye(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]/o[n]);return a}function Mn(i,t,e){return Ye(i,t,"f32")}function Dn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=Math.floor(s[n]/o[n]));return a}function On(i,t,e,s){const o=i[0],r=o.length,a=x.createEmptyBand(e,r);if(s===H.atanh){for(let u=0;u<r;u++)if(t[u]){const l=o[u];Math.abs(l)>=1?t[u]=0:a[u]=Math.atanh(l)}return a}const n=s===H.asin?Math.asin:Math.acos;for(let u=0;u<r;u++)if(t[u]){const l=o[u];Math.abs(l)>1?t[u]=0:a[u]=n(l)}return a}function En(i,t,e,s){const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s(o[n]));return a}function Gn(i,t,e,s){const[o,r]=i,a=o.length,n=x.createEmptyBand(e,a);for(let u=0;u<a;u++)t&&!t[u]||(n[u]=s(o[u],r[u]));return n}function zn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]&o[n]);return a}function Un(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]<<o[n]);return a}function Vn(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand(e,o);for(let a=0;a<o;a++)t&&!t[a]||(r[a]=~s[a]);return r}function Ln(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]|o[n]);return a}function Wn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]>>o[n]);return a}function qn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]^o[n]);return a}function Xn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]&&o[n]?1:0);return a}function Hn(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand(e,o);for(let a=0;a<o;a++)t&&!t[a]||(r[a]=s[a]?0:1);return r}function Jn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]||o[n]?1:0);return a}function Kn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=(s[n]?1:0)^(o[n]?1:0));return a}function Yn(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]===o[n]?1:0);return a}function be(i,t,e,s){const[o]=i,r=o.length,a=x.createEmptyBand(e,r),n=s===Math.E;for(let u=0;u<r;u++)t&&!t[u]||(a[u]=n?Math.exp(o[u]):s**o[u]);return a}function Zn(i,t,e){return be(i,t,e,10)}function Qn(i,t,e){return be(i,t,e,2)}function tr(i,t,e){return be(i,t,e,Math.E)}function xe(i,t,e,s){const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(o[n]<=0?t[n]=0:a[n]=s(o[n]));return a}function er(i,t,e){return xe(i,t,e,Math.log10)}function sr(i,t,e){return xe(i,t,e,Math.log2)}function nr(i,t,e){return xe(i,t,e,Math.log)}function rr(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]>o[n]?1:0);return a}function or(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]>=o[n]?1:0);return a}function ir(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]<o[n]?1:0);return a}function ar(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]<=o[n]?1:0);return a}function ur(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand(e,o);if(!t)return r;for(let a=0;a<o;a++)r[a]=t[a]?0:1;return r}function lr(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]%o[n]);return a}function cr(i,t,e){const[s]=i,o=s.length,r=x.createEmptyBand(e,o);for(let a=0;a<o;a++)t&&!t[a]||(r[a]=-s[a]);return r}function pr(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t&&!t[n]||(a[n]=s[n]===o[n]?0:1);return a}function hr(i,t,e){const[s,o]=i,r=s.length,a=x.createEmptyBand(e,r),n=new Uint8Array(r);for(let u=0;u<r;u++)t!=null&&!t[u]||s[u]!==0||(a[u]=o[u],n[u]=255);return{band:a,mask:n}}function ke(i,t,e){const[s,o,r]=i,a=s.length,n=x.createEmptyBand(e,a);for(let u=0;u<a;u++)t&&!t[u]||(n[u]=s[u]?o[u]:r[u]);return n}function Ce(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n]){let u=o[n];for(let l=1;l<s;l++){const p=i[l][n];u<p&&(u=p)}a[n]=u}return a}function Be(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n]){let u=o[n];for(let l=1;l<s;l++){const p=i[l][n];u>p&&(u=p)}a[n]=u}return a}function je(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n]){let u=o[n],l=u;for(let p=1;p<s;p++){const h=i[p][n];l<h?l=h:u>h&&(u=h)}a[n]=l-u}return a}function _e(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n]){let u=0;for(let l=0;l<s;l++)u+=i[l][n];a[n]=u/s}return a}function Se(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n])for(let u=0;u<s;u++){const l=i[u];a[n]+=l[n]}return a}function Me(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)if(!t||t[n]){const u=new Float32Array(s);let l=0;for(let h=0;h<s;h++){const m=i[h];l+=m[n],u[h]=m[n]}l/=s;let p=0;for(let h=0;h<s;h++)p+=(u[h]-l)**2;a[n]=Math.sqrt(p/s)}return a}function De(i,t,e){const s=i.length;if(s<2)return i[0];const o=Math.floor(s/2),[r]=i,a=r.length,n=x.createEmptyBand(e,a),u=new Float32Array(s),l=s%2==1;for(let p=0;p<a;p++)if(!t||t[p]){for(let h=0;h<s;h++)u[h]=i[h][p];u.sort(),n[p]=l?u[o]:(u[o]+u[o-1])/2}return n}function Ze(i,t,e){const[s,o]=i;if(o==null)return s;const r=s.length,a=x.createEmptyBand(e,r);for(let n=0;n<r;n++)t[n]&&(s[n]===o[n]?a[n]=s[n]:t[n]=0);return a}function Oe(i,t,e){const s=i.length;if(s<=2)return Ze(i,t,e);const o=i[0].length,r=x.createEmptyBand(e,o),a=new Map;for(let n=0;n<o;n++)if(!t||t[n]){let u;a.clear();for(let h=0;h<s;h++)u=i[h][n],a.set(u,a.has(u)?a.get(u)+1:1);let l=0,p=0;for(const h of a.keys())l=a.get(h),l>p&&(p=l,u=h);r[n]=u}return r}function Ee(i,t,e){const s=i.length;if(s<=2)return Ze(i,t,e);const o=i[0].length,r=x.createEmptyBand(e,o),a=new Map;for(let n=0;n<o;n++)if(!t||t[n]){let u;a.clear();for(let h=0;h<s;h++)u=i[h][n],a.set(u,a.has(u)?a.get(u)+1:1);let l=0,p=i.length;for(const h of a.keys())l=a.get(h),l<p&&(p=l,u=h);r[n]=u}return r}function Ge(i,t,e){const s=i.length;if(s<2)return i[0];const[o]=i,r=o.length,a=x.createEmptyBand(e,r),n=new Set;for(let u=0;u<r;u++)if(!t||t[u]){let l;n.clear();for(let p=0;p<s;p++)l=i[p][u],n.add(l);a[u]=n.size}return a}const M=new Map,zt=new Map,P=new Map,_=new Map;function fr(){M.size||(M.set(4,Math.sqrt),M.set(6,Math.acos),M.set(7,Math.asin),M.set(8,Math.atan),M.set(9,Math.atanh),M.set(10,Math.abs),M.set(21,Math.cos),M.set(22,Math.cosh),M.set(48,Math.floor),M.set(49,Math.ceil),M.set(51,Math.sin),M.set(52,Math.sinh),M.set(56,Math.tan),M.set(57,Math.tanh),M.set(59,Math.acosh),M.set(60,Math.asinh),M.set(65,Math.floor),zt.set(5,Math.pow),zt.set(61,Math.atan2),P.set(1,Cn),P.set(2,jn),P.set(3,_n),P.set(11,zn),P.set(12,Un),P.set(13,Vn),P.set(14,Ln),P.set(15,Wn),P.set(16,qn),P.set(17,Xn),P.set(18,Hn),P.set(19,Jn),P.set(20,Kn),P.set(23,Ye),P.set(24,Yn),P.set(25,tr),P.set(26,Zn),P.set(27,Qn),P.set(28,rr),P.set(29,or),P.set(30,Sn),P.set(31,ur),P.set(32,Bn),P.set(33,ir),P.set(34,ar),P.set(35,nr),P.set(36,er),P.set(37,sr),P.set(44,lr),P.set(45,cr),P.set(46,pr),P.set(64,Mn),P.set(65,Dn),P.set(76,ke),P.set(78,ke),_.set(38,Oe),_.set(39,Ce),_.set(40,_e),_.set(41,De),_.set(42,Be),_.set(43,Ee),_.set(47,je),_.set(54,Me),_.set(55,Se),_.set(58,Ge),_.set(66,Oe),_.set(67,Ce),_.set(68,_e),_.set(69,De),_.set(70,Be),_.set(71,Ee),_.set(72,je),_.set(73,Me),_.set(74,Se),_.set(75,Ge))}function mr(i,t,e,s){let[o,r]=Dt(e);const a=e.startsWith("u")||e.startsWith("s");a&&(o-=1e-5,r+=1e-5);for(let n=0;n<t.length;n++)if(t[n]){const u=i[n];isNaN(u)||u<o||u>r?t[n]=0:s[n]=a?Math.round(u):u}}function dr(i,t,e={}){fr();let s=kn(i,t>=66&&t<=75);const{outputPixelType:o="f32"}=e,r=!_.has(t)||e.processAsMultiband,a=r?i[0].pixels.length:1,n=[];for(let l=0;l<a;l++){const p=_.has(t)&&!r?i.flatMap(g=>g.pixels):i.map(g=>g.pixels[l]);let h,m=!0;if(t===Je.setNull){const g=hr(p,s,o);h=g.band,s=g.mask,m=!1}else P.has(t)?h=P.get(t)(p,s,"f64"):M.has(t)?h=t===H.asin||t===H.acos||t===H.atanh?On(p,s,"f64",t):En(p,s,"f64",M.get(t)):zt.has(t)?h=Gn(p,s,"f64",zt.get(t)):_.has(t)?h=_.get(t)(p,s,"f64"):(h=p[0],m=!1);if(m&&t!==L.isNull&&!E.has(t)){const g=x.createEmptyBand(o,h.length);s||(s=new Uint8Array(h.length).fill(255)),mr(h,s,o,g),h=g}n.push(h)}const u=i[0];return new x({width:u.width,height:u.height,pixelType:o,mask:t===L.isNull?null:s,pixels:n})}let vt=class extends V{constructor(){super(...arguments),this.functionName="Local",this.functionArguments=null,this.rasterArgumentNames=["rasters"]}_bindSourceRasters(){const{sourceRasterInfos:t}=this,e=t[0],{bandCount:s}=e,{processAsMultiband:o}=this.functionArguments;if(t.some(p=>p.bandCount!==s))return{success:!1,supportsGPU:!1,error:"local-function: input rasters do not have same band count"};const{operation:r,rasters:a}=this.functionArguments,n=Re[r];if(!(n===999||a.length===n||a.length<=1&&n===1))return{success:!1,supportsGPU:!1,error:`local-function: the length of functionArguments.rasters does not match operation's requirement: ${n}`};this.outputPixelType=this._getOutputPixelType("f32");const u=e.clone();u.pixelType=this.outputPixelType,u.statistics=null,u.histograms=null,u.colormap=null,u.attributeTable=null,u.bandCount=n!==999||o?s:1;const l=Rn(r);if(l){u.statistics=[];for(let p=0;p<u.bandCount;p++)u.statistics[p]={min:l[0],max:l[1],avg:(l[0]+l[1])/2,stddev:(l[0]+l[1])/10}}return this.rasterInfo=u,{success:!0,supportsGPU:u.bandCount===1&&n<=3&&(r<11||r>16)}}_processPixels(t){const{pixelBlocks:e}=t;return e==null||e.some(s=>s==null)?null:dr(e,this.functionArguments.operation,{processAsMultiband:this.functionArguments.processAsMultiband,outputPixelType:this.outputPixelType??void 0})}_getWebGLParameters(){var u;const{operation:t}=this.functionArguments,e=Re[t],s=((u=Object.keys(Ne).find(l=>Ne[l]===t))==null?void 0:u.toLowerCase())??"undefined",o=this.outputPixelType??"f32";let[r,a]=Dt(o);const n=o.startsWith("u")||o.startsWith("s");return n&&(r-=1e-4,a+=1e-4),{imageCount:e,operationName:s,domainRange:[r,a],isOutputRounded:n}}};c([f({json:{write:!0,name:"rasterFunction"}})],vt.prototype,"functionName",void 0),c([f({type:In,json:{write:!0,name:"rasterFunctionArguments"}})],vt.prototype,"functionArguments",void 0),c([f()],vt.prototype,"rasterArgumentNames",void 0),vt=c([A("esri.layers.support.rasterFunctions.LocalFunction")],vt);const gr=vt;var te;let lt=te=class extends U{constructor(){super(...arguments),this.includedRanges=null,this.noDataValues=null,this.noDataInterpretation=Xe.matchAny}get normalizedNoDataValues(){const{noDataValues:i}=this;if(!(i!=null&&i.length))return null;let t=!1;const e=i.map(s=>{if(typeof s=="number")return t=!0,[s];if(typeof s=="string"){const o=s.trim().split(" ").filter(r=>r.trim()!=="").map(r=>Number(r));return t=t||o.length>0,o.length===0?null:o}return null});return t?e:null}clone(){var i,t;return new te({includedRanges:((i=this.includedRanges)==null?void 0:i.slice())??[],noDataValues:((t=this.noDataValues)==null?void 0:t.slice())??[],noDataInterpretation:this.noDataInterpretation})}};c([f({json:{write:!0}})],lt.prototype,"includedRanges",void 0),c([f({json:{write:!0}})],lt.prototype,"noDataValues",void 0),c([f()],lt.prototype,"normalizedNoDataValues",null),c([f({json:{write:!0}})],lt.prototype,"noDataInterpretation",void 0),lt=te=c([A("esri.layers.support.rasterFunctions.MaskFunctionArguments")],lt);const yr=lt;let ct=class extends V{constructor(){super(...arguments),this.functionName="Mask",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:e}=t;this.outputPixelType=this._getOutputPixelType(e),t.pixelType=this.outputPixelType,this.rasterInfo=t;const{includedRanges:s,normalizedNoDataValues:o}=this.functionArguments;if(!(s!=null&&s.length)&&!(o!=null&&o.length))return{success:!1,supportsGPU:!1,error:"missing includedRanges or noDataValues argument"};let r=[];for(let n=0;n<t.bandCount;n++){const u=ls(e,s==null?void 0:s.slice(2*n,2*n+2),o==null?void 0:o[n]);if(u==null){r=null;break}r.push(u)}this.lookups=r;const a=o!=null&&o.every(n=>{var u;return(n==null?void 0:n.length)===((u=o[0])==null?void 0:u.length)});return{success:!0,supportsGPU:(!s||s.length<=2*Y)&&(!o||a&&o[0].length<=Y)}}_processPixels(t){var l;const e=(l=t.pixelBlocks)==null?void 0:l[0];if(e==null)return null;const{outputPixelType:s,lookups:o}=this,{includedRanges:r,noDataInterpretation:a,normalizedNoDataValues:n}=this.functionArguments,u=a===Xe.matchAll;return cs(e,{includedRanges:r,noDataValues:n,outputPixelType:s,matchAll:u,lookups:o})}_getWebGLParameters(){var r;const{includedRanges:t,normalizedNoDataValues:e}=this.functionArguments,s=new Float32Array(Y);s.fill($t),(r=e==null?void 0:e[0])!=null&&r.length&&s.set(e[0]);const o=new Float32Array(Y);for(let a=0;a<o.length;a+=2)o[a]=(t==null?void 0:t[a])??-$t,o[a+1]=(t==null?void 0:t[a+1])??$t;return t&&t.length&&o.set(t),{bandCount:this.sourceRasterInfos[0].bandCount,noDataValues:s,includedRanges:o}}};c([f({json:{write:!0,name:"rasterFunction"}})],ct.prototype,"functionName",void 0),c([f({type:yr,json:{write:!0,name:"rasterFunctionArguments"}})],ct.prototype,"functionArguments",void 0),c([f()],ct.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],ct.prototype,"lookups",void 0),ct=c([A("esri.layers.support.rasterFunctions.MaskFunction")],ct);const wr=ct;var ee;let At=ee=class extends U{constructor(){super(...arguments),this.visibleBandID=0,this.infraredBandID=1,this.scientificOutput=!1}clone(){const{visibleBandID:i,infraredBandID:t,scientificOutput:e}=this;return new ee({visibleBandID:i,infraredBandID:t,scientificOutput:e})}};c([f({json:{write:!0}})],At.prototype,"visibleBandID",void 0),c([f({json:{write:!0}})],At.prototype,"infraredBandID",void 0),c([f({json:{write:!0}})],At.prototype,"scientificOutput",void 0),At=ee=c([A("esri.layers.support.rasterFunctions.NDVIFunctionArguments")],At);const br=At;let Pt=class extends V{constructor(){super(...arguments),this.functionName="NDVI",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{scientificOutput:t,visibleBandID:e,infraredBandID:s}=this.functionArguments;this.outputPixelType=this._getOutputPixelType(t?"f32":"u8");const o=this.sourceRasterInfos[0],r=Math.max(e,s);if(o.bandCount<2||r>=o.bandCount)return{success:!1,supportsGPU:!1,error:"ndvi-function: source raster has insufficient amount of raster bands"};const a=o.clone();a.pixelType=this.outputPixelType,a.colormap=null,a.histograms=null,a.bandCount=1,a.keyProperties={...a.keyProperties,BandProperties:void 0};const[n,u,l,p]=t?[-1,1,0,.1]:[0,200,100,10];return a.statistics=[{min:n,max:u,avg:l,stddev:p}],this.rasterInfo=a,{success:!0,supportsGPU:!0}}_processPixels(t){var a;const e=(a=t.pixelBlocks)==null?void 0:a[0];if(e==null)return null;const{visibleBandID:s,infraredBandID:o,scientificOutput:r}=this.functionArguments;return Ss(e,s,o,!r)}_getWebGLParameters(){const{visibleBandID:t,infraredBandID:e,scientificOutput:s}=this.functionArguments,o=this.isInputBandIdsSwizzled?[0,1,2]:[e,t,0];return{bandIndexMat3:O(o),scaled:!s}}_getInputBandIds(t){const{visibleBandID:e,infraredBandID:s}=this.functionArguments;return[s,e,0].map(o=>t[o])}};c([f({json:{write:!0,name:"rasterFunction"}})],Pt.prototype,"functionName",void 0),c([f({type:br,json:{write:!0,name:"rasterFunctionArguments"}})],Pt.prototype,"functionArguments",void 0),c([f()],Pt.prototype,"rasterArgumentNames",void 0),Pt=c([A("esri.layers.support.rasterFunctions.NDVIFunction")],Pt);const xr=Pt;var se;let tt=se=class extends U{constructor(){super(...arguments),this.inputRanges=null,this.outputValues=null,this.noDataRanges=null,this.allowUnmatched=!1,this.isLastInputRangeInclusive=!1}clone(){return new se({inputRanges:[...this.inputRanges],outputValues:[...this.outputValues],noDataRanges:[...this.noDataRanges],allowUnmatched:this.allowUnmatched,isLastInputRangeInclusive:this.isLastInputRangeInclusive})}};c([f({json:{write:!0}})],tt.prototype,"inputRanges",void 0),c([f({json:{write:!0}})],tt.prototype,"outputValues",void 0),c([f({json:{write:!0}})],tt.prototype,"noDataRanges",void 0),c([f({json:{write:!0}})],tt.prototype,"allowUnmatched",void 0),c([f({json:{write:!0}})],tt.prototype,"isLastInputRangeInclusive",void 0),tt=se=c([A("esri.layers.support.rasterFunctions.RemapFunctionArguments")],tt);const vr=tt;let pt=class extends V{constructor(){super(...arguments),this.functionName="Remap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:e}=t;this.outputPixelType=this._getOutputPixelType(e),t.pixelType=this.outputPixelType,t.colormap=null,t.histograms=null,t.bandCount=1,t.attributeTable=null;const{statistics:s}=t,{allowUnmatched:o,outputValues:r,inputRanges:a,noDataRanges:n,isLastInputRangeInclusive:u}=this.functionArguments;if(s!=null&&s.length&&(r!=null&&r.length))if(o){const l=Math.min.apply(null,[...r,s[0].min]),p=Math.max.apply(null,[...r,s[0].max]);t.statistics=[{...s[0],min:l,max:p}]}else{let l=r[0],p=l;for(let h=0;h<r.length;h++)l=l>r[h]?r[h]:l,p=p>r[h]?p:r[h];t.statistics=[{...s[0],min:l,max:p}]}return this.rasterInfo=t,this.lookup=o?null:ps({srcPixelType:e,inputRanges:a,outputValues:r,noDataRanges:n,allowUnmatched:o,isLastInputRangeInclusive:u,outputPixelType:this.outputPixelType}),{success:!0,supportsGPU:(!r||r.length<=Y)&&(!n||n.length<=Y)}}_processPixels(t){var p;const e=(p=t.pixelBlocks)==null?void 0:p[0];if(e==null)return null;const{lookup:s,outputPixelType:o}=this;if(s){const h=ge(e,{lut:[s.lut],offset:s.offset,outputPixelType:o});return h!=null&&s.mask&&(h.mask=hs(e.pixels[0],e.mask,s.mask,s.offset,"u8")),h}const{inputRanges:r,outputValues:a,noDataRanges:n,allowUnmatched:u,isLastInputRangeInclusive:l}=this.functionArguments;return fs(e,{inputRanges:r,outputValues:a,noDataRanges:n,outputPixelType:o,allowUnmatched:u,isLastInputRangeInclusive:l})}_getWebGLParameters(){const{allowUnmatched:t,noDataRanges:e,isLastInputRangeInclusive:s}=this.functionArguments,o=new Float32Array(3*Y),r=1e-5,a=this.functionArguments.inputRanges??[],n=this.functionArguments.outputValues??[],u=n.length;for(let p=0;p<Y;p++)o[3*p]=a[2*p]??$t-1,o[3*p+1]=a[2*p+1]??$t,o[3*p+2]=n[p]??0,p<u&&(p>0&&(o[3*p]-=r),(p<u-1||!s)&&(o[3*p+1]-=r));const l=new Float32Array(2*Y);return l.fill($t),e!=null&&e.length&&l.set(e),{allowUnmatched:t,rangeMaps:o,noDataRanges:l,clampRange:Dt(this.outputPixelType)}}};c([f({json:{write:!0,name:"rasterFunction"}})],pt.prototype,"functionName",void 0),c([f({type:vr,json:{write:!0,name:"rasterFunctionArguments"}})],pt.prototype,"functionArguments",void 0),c([f()],pt.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],pt.prototype,"lookup",void 0),pt=c([A("esri.layers.support.rasterFunctions.RemapFunction")],pt);const Ar=pt;var ne;const Pr=new Mt({1:"degree",2:"percent-rise",3:"adjusted"},{useNumericKeys:!0});let et=ne=class extends U{constructor(){super(...arguments),this.slopeType="degree",this.zFactor=1,this.pixelSizePower=.664,this.pixelSizeFactor=.024,this.removeEdgeEffect=!1}clone(){return new ne({slopeType:this.slopeType,zFactor:this.zFactor,pixelSizePower:this.pixelSizePower,pixelSizeFactor:this.pixelSizeFactor,removeEdgeEffect:this.removeEdgeEffect,raster:this.raster})}};c([Z(Pr)],et.prototype,"slopeType",void 0),c([f({type:Number,json:{write:!0}})],et.prototype,"zFactor",void 0),c([f({type:Number,json:{name:"psPower",write:!0}})],et.prototype,"pixelSizePower",void 0),c([f({type:Number,json:{name:"psZFactor",write:!0}})],et.prototype,"pixelSizeFactor",void 0),c([f({type:Boolean,json:{write:!0}})],et.prototype,"removeEdgeEffect",void 0),et=ne=c([A("esri.layers.support.rasterFunctions.SlopeFunctionArguments")],et);const Tr=et;let ht=class extends V{constructor(){super(...arguments),this.functionName="Slope",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){var e;this.outputPixelType=this._getOutputPixelType("f32");const t=this.sourceRasterInfos[0].clone();return t.pixelType=this.outputPixelType,t.statistics=this.functionArguments.slopeType!=="percent-rise"?[{min:0,max:90,avg:1,stddev:1}]:null,t.histograms=null,t.colormap=null,t.attributeTable=null,t.bandCount=1,this.rasterInfo=t,this.isGCS=((e=t.spatialReference)==null?void 0:e.isGeographic)??!1,{success:!0,supportsGPU:!0}}_processPixels(t){var m;const e=(m=t.pixelBlocks)==null?void 0:m[0];if(e==null)return null;const{zFactor:s,slopeType:o,pixelSizePower:r,pixelSizeFactor:a}=this.functionArguments,{isGCS:n}=this,{extent:u,primaryPixelSizes:l}=t,p=l==null?void 0:l[0],h=p??(u?{x:u.width/e.width,y:u.height/e.height}:{x:1,y:1});return xs(e,{zFactor:s,slopeType:o,pixelSizePower:r,pixelSizeFactor:a,isGCS:n,resolution:h})}_getWebGLParameters(){const{zFactor:t,slopeType:e,pixelSizeFactor:s,pixelSizePower:o}=this.functionArguments;return{zFactor:this.isGCS&&t>=1?t*Vt:t,slopeType:e,pixelSizeFactor:s??0,pixelSizePower:o??0}}};c([f({json:{write:!0,name:"rasterFunction"}})],ht.prototype,"functionName",void 0),c([f({type:Tr,json:{write:!0,name:"rasterFunctionArguments"}})],ht.prototype,"functionArguments",void 0),c([f()],ht.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],ht.prototype,"isGCS",void 0),ht=c([A("esri.layers.support.rasterFunctions.SlopeFunction")],ht);const $r=ht,ze=new Mt({1:"min",2:"max",3:"mean",4:"stddev",5:"median",6:"majority",7:"minority"},{useNumericKeys:!0});function Nr(i,t){const{fillNoDataOnly:e}=t,{band:s,width:o,height:r,mask:a,outBand:n}=i;if(e&&!a)return void n.set(s);const{statisticsType:u,kernelRows:l,kernelCols:p}=t,h=u==="stddev",m=o*r,g=new Float64Array(m),w=new Float64Array(m),y=new Uint32Array(m);for(let T=0;T<r;T++){const $=T*o;let F=0,I=0,C=0;for(let B=0;B<p;B++)a&&!a[$+B]||(F+=s[$+B],h&&(I+=s[$+B]**2),C++);g[$]=F,w[$]=I,y[$]=C;for(let B=1;B<=o-p;B++){const q=$+B-1,Rt=q+p;a?(a[q]&&(C--,F-=s[q],h&&(I-=s[q]**2)),a[Rt]&&(C++,F+=s[Rt],h&&(I+=s[Rt]**2))):(F-=s[q],F+=s[Rt],h&&(I-=s[q]**2,I+=s[Rt]**2)),g[$+B]=F,y[$+B]=C,h&&(w[$+B]=I)}}const d=new Float64Array(m),v=new Float64Array(m),b=new Uint32Array(m),R=l*o;for(let T=0;T<=o-p;T++){let $=0,F=0,I=0;for(let C=0;C<l;C++){const B=C*o+T;$+=g[B],I+=y[B],h&&(F+=w[B])}d[T]=$,v[T]=F,b[T]=I;for(let C=1;C<=r-l;C++){const B=(C-1)*o+T,q=B+R;$-=g[B],$+=g[q],I-=y[B],I+=y[q],h&&(F-=w[B],F+=w[q]),d[C*o+T]=$,v[C*o+T]=F,b[C*o+T]=I}}const k=Math.floor(l/2),G=Math.floor(p/2);for(let T=k;T<r-k;T++){const $=T*o;for(let F=G;F<o-G;F++){const I=(T-k)*o+F-G,C=b[I];if(C===0||e&&(!a||a[$+F]))continue;const B=d[I]/C,q=h?Math.sqrt((v[I]-d[I]*B)/C):B;n[$+F]=q,a&&(a[$+F]=255)}}}function Fr(i,t){const{fillNoDataOnly:e}=t,{band:s,width:o,height:r,mask:a,outBand:n}=i;if(e&&!a)return void n.set(s);const{kernelRows:u,kernelCols:l,statisticsType:p}=t,h=Math.floor(u/2),m=Math.floor(l/2),g=p==="min",w=n.slice(),y=new Uint32Array(o*r);for(let d=h;d<r-h;d++){const v=d*o;for(let b=m;b<o-m;b++){let R=g?Number.MAX_VALUE:-Number.MAX_VALUE,k=0;for(let G=0;G<u;G++)for(let T=0;T<l;T++){const $=v+b+(G-h)*o+T-m;a&&!a[$]||(R=g?Math.min(R,s[$]):Math.max(R,s[$]),k++)}a?(w[v+b]=k===0?0:R,y[v+b]=k):n[v+b]=k===0?0:R}}if(a)for(let d=h;d<r-h;d++){const v=d*o;for(let b=m;b<o-m;b++)if(y[v+b]){if(e&&a[v+b])continue;n[v+b]=w[v+b],a[v+b]=255}}}function Ir(i,t){const{fillNoDataOnly:e}=t,{band:s,width:o,height:r,mask:a,outBand:n}=i;if(e&&!a)return void n.set(s);const{kernelRows:u,kernelCols:l}=t,p=Math.floor(u/2),h=Math.floor(l/2),m=n.slice(),g=new Uint32Array(o*r);for(let w=p;w<r-p;w++){const y=w*o;for(let d=h;d<o-h;d++){if(e&&a&&a[y+d])continue;const v=[];for(let b=0;b<u;b++)for(let R=0;R<l;R++){const k=y+d+(b-p)*o+R-h;a&&!a[k]||v.push(s[k])}v.length&&(v.sort((b,R)=>b-R),a?(m[y+d]=v[Math.floor((v.length-1)/2)],g[y+d]=v.length):n[y+d]=v[Math.floor((v.length-1)/2)])}}if(a)for(let w=p;w<r-p;w++){const y=w*o;for(let d=h;d<o-h;d++)if(g[y+d]){if(e&&a[y+d])continue;n[y+d]=m[y+d],a[y+d]=255}}}function Rr(i,t){const{fillNoDataOnly:e}=t,{band:s,width:o,height:r,mask:a,outBand:n}=i;if(e&&!a)return void n.set(s);const{kernelRows:u,kernelCols:l}=t,p=Math.floor(u/2),h=Math.floor(l/2),m=t.statisticsType==="majority",g=u*l,w=n.slice(),y=new Uint32Array(o*r);for(let d=p;d<r-p;d++){const v=d*o;for(let b=h;b<o-h;b++){if(e&&a&&a[v+b])continue;const R=new Map;for(let $=0;$<u;$++)for(let F=0;F<l;F++){const I=v+b+($-p)*o+F-h;if(a&&!a[I])continue;const C=s[I];R.set(C,R.has(C)?R.get(C)+1:1)}if(R.size===0)continue;let k=0,G=0,T=m?0:g+1;for(const $ of R.keys())G=R.get($),m===G>T&&(T=G,k=$);a?(w[v+b]=k,y[v+b]=R.size):n[v+b]=k}}if(a)for(let d=p;d<r-p;d++){const v=d*o;for(let b=h;b<o-h;b++)if(y[v+b]){if(e&&a[v+b])continue;n[v+b]=w[v+b],a[v+b]=255}}}function kr(i,t){const{mask:e}=i,{fillNoDataOnly:s}=t;if(s&&!e)return i;const{pixels:o,width:r,height:a,bandMasks:n,pixelType:u}=i,l=o.length,p=r*a,h=[],{kernelRows:m,kernelCols:g,statisticsType:w,mirrorEdges:y}=t;if(s&&!e)return i;const d=t.outputPixelType??u,v=[];for(let k=0;k<l;k++){const G=o[k],T=x.createEmptyBand(d,p);s&&T.set(G);const $=(n==null?void 0:n[k])??e,F=($==null?void 0:$.slice())??null,I={band:G,width:r,height:a,mask:F,outBand:T};switch(w){case"min":case"max":Fr(I,t);break;case"mean":case"stddev":Nr(I,t);break;case"median":Ir(I,t);break;case"majority":case"minority":Rr(I,t)}y&&!s&&we(T,r,a,m,g),h.push(T),F&&v.push(F)}let b=v[0]??e;if(v.length!==l&&(v.length=0),l>1&&(n==null?void 0:n.length)){b=new Uint8Array(p),b.set(v[0]);for(let k=1;k<n.length;k++){const G=n[k];for(let T=0;T<G.length;T++)G[T]===0&&(b[T]=0)}}const R=new x({pixelType:d,width:r,height:a,pixels:h,bandMasks:n&&v.length?v:null,mask:b});return R.updateStatistics(),R}var re;let ft=re=class extends U{constructor(){super(...arguments),this.rows=3,this.cols=3,this.fillNoDataOnly=!1,this.statisticsType="min"}clone(){return new re({rows:this.rows,cols:this.cols,fillNoDataOnly:this.fillNoDataOnly,statisticsType:this.statisticsType,raster:W(this.raster)})}};c([f({json:{write:!0,read:{source:["kernelRows","rows"],reader:(i,t)=>Number(i??(t==null?void 0:t.kernelRows)??3)}}})],ft.prototype,"rows",void 0),c([f({json:{write:!0,read:{source:["kernelCols","cols"],reader:(i,t)=>Number(i??(t==null?void 0:t.kernelCols)??3)}}})],ft.prototype,"cols",void 0),c([f({json:{write:!0}})],ft.prototype,"fillNoDataOnly",void 0),c([f({json:{read:{source:["statisticsType","type"],reader:(i,t)=>ze.fromJSON((t==null?void 0:t.statisticsType)??(t==null?void 0:t.type))??"min"},write:{target:"type"}}}),Z(ze)],ft.prototype,"statisticsType",void 0),ft=re=c([A("esri.layers.support.rasterFunctions.StatisticsFunctionArguments")],ft);const Cr=ft,Br=new Set(["min","max","mean","median","majority","minority"]);let Tt=class extends V{constructor(){super(...arguments),this.functionName="Statistics",this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{type:t}=this.functionArguments.toJSON();if(t<1||t>7)return{success:!1,supportsGPU:!1,error:`statistics-function: the given statistics type is not supported ${t}`};const e=this.sourceRasterInfos[0];this.outputPixelType=this._getOutputPixelType(e.pixelType);const s=e.clone();s.pixelType=this.outputPixelType;const{statisticsType:o}=this.functionArguments;return Br.has(o)||(s.statistics=null,s.histograms=null,s.colormap=null,s.attributeTable=null),this.rasterInfo=s,{success:!0,supportsGPU:s.bandCount<=3&&t<5}}_processPixels(t){var n;const e=(n=t.pixelBlocks)==null?void 0:n[0];if(e==null)return e;const{statisticsType:s,rows:o,cols:r,fillNoDataOnly:a}=this.functionArguments;return kr(e,{kernelRows:o,kernelCols:r,fillNoDataOnly:a,outputPixelType:this.outputPixelType,statisticsType:s,mirrorEdges:!0})}_getWebGLParameters(){const{rows:t,cols:e,statisticsType:s,fillNoDataOnly:o}=this.functionArguments;return{fillNoDataOnly:o,kernelRows:t,kernelCols:e,statisticsType:s,clampRange:Dt(this.outputPixelType)}}};c([f({json:{write:!0,name:"rasterFunction"}})],Tt.prototype,"functionName",void 0),c([f({type:Cr,json:{write:!0,name:"rasterFunctionArguments"}})],Tt.prototype,"functionArguments",void 0),c([f()],Tt.prototype,"rasterArgumentNames",void 0),Tt=c([A("esri.layers.support.rasterFunctions.StatisticsFunction")],Tt);const jr=Tt;var oe;let mt=oe=class extends U{constructor(){super(...arguments),this.statistics=null,this.histograms=null}readStatistics(i,t){if(!(i!=null&&i.length))return null;const e=[];return i.forEach(s=>{const o={min:s.min,max:s.max,avg:s.avg??s.mean,stddev:s.stddev??s.standardDeviation};e.push(o)}),e}writeStatistics(i,t,e){if(!(i!=null&&i.length))return;const s=[];i.forEach(o=>{const r={...o,mean:o.avg,standardDeviation:o.stddev};delete r.avg,delete r.stddev,s.push(r)}),t[e]=s}clone(){return new oe({statistics:W(this.statistics),histograms:W(this.histograms)})}};c([f({json:{write:!0}})],mt.prototype,"statistics",void 0),c([Nt("statistics")],mt.prototype,"readStatistics",null),c([Ft("statistics")],mt.prototype,"writeStatistics",null),c([f({json:{write:!0}})],mt.prototype,"histograms",void 0),mt=oe=c([A("esri.layers.support.rasterFunctions.StatisticsHistogramFunctionArguments")],mt);const _r=mt;let st=class extends V{constructor(){super(...arguments),this.functionName="StatisticsHistogram",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isNoopProcess=!0}_bindSourceRasters(){const t=this.sourceRasterInfos[0];this.outputPixelType=this._getOutputPixelType("u8");const e=t.clone(),{statistics:s,histograms:o}=this.functionArguments;return o&&(e.histograms=o),s&&(e.statistics=s),this.rasterInfo=e,{success:!0,supportsGPU:!0}}_processPixels(t){var e;return(e=t.pixelBlocks)==null?void 0:e[0]}};c([f({json:{write:!0,name:"rasterFunction"}})],st.prototype,"functionName",void 0),c([f({type:_r,json:{write:!0,name:"rasterFunctionArguments"}})],st.prototype,"functionArguments",void 0),c([f()],st.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],st.prototype,"indexedColormap",void 0),c([f()],st.prototype,"isNoopProcess",void 0),st=c([A("esri.layers.support.rasterFunctions.StatisticsHistogramFunction")],st);const Sr=st;var ie;const Mr=new Mt({0:"none",3:"standard-deviation",4:"histogram-equalization",5:"min-max",6:"percent-clip",9:"sigmoid"},{useNumericKeys:!0});let z=ie=class extends U{constructor(){super(...arguments),this.computeGamma=!1,this.dynamicRangeAdjustment=!1,this.gamma=[],this.histograms=null,this.statistics=null,this.stretchType="none",this.useGamma=!1}writeStatistics(i,t,e){i!=null&&i.length&&(Array.isArray(i[0])||(i=i.map(s=>[s.min,s.max,s.avg,s.stddev])),t[e]=i)}clone(){return new ie({stretchType:this.stretchType,outputMin:this.outputMin,outputMax:this.outputMax,useGamma:this.useGamma,computeGamma:this.computeGamma,statistics:W(this.statistics),gamma:W(this.gamma),sigmoidStrengthLevel:this.sigmoidStrengthLevel,numberOfStandardDeviations:this.numberOfStandardDeviations,minPercent:this.minPercent,maxPercent:this.maxPercent,histograms:W(this.histograms),dynamicRangeAdjustment:this.dynamicRangeAdjustment,raster:this.raster})}};c([f({type:Boolean,json:{write:!0}})],z.prototype,"computeGamma",void 0),c([f({type:Boolean,json:{name:"dra",write:!0}})],z.prototype,"dynamicRangeAdjustment",void 0),c([f({type:[Number],json:{write:!0}})],z.prototype,"gamma",void 0),c([f()],z.prototype,"histograms",void 0),c([f({type:Number,json:{write:!0}})],z.prototype,"maxPercent",void 0),c([f({type:Number,json:{write:!0}})],z.prototype,"minPercent",void 0),c([f({type:Number,json:{write:!0}})],z.prototype,"numberOfStandardDeviations",void 0),c([f({type:Number,json:{name:"max",write:!0}})],z.prototype,"outputMax",void 0),c([f({type:Number,json:{name:"min",write:!0}})],z.prototype,"outputMin",void 0),c([f({type:Number,json:{write:!0}})],z.prototype,"sigmoidStrengthLevel",void 0),c([f({json:{type:[[Number]],write:!0}})],z.prototype,"statistics",void 0),c([Ft("statistics")],z.prototype,"writeStatistics",null),c([Z(Mr)],z.prototype,"stretchType",void 0),c([f({type:Boolean,json:{write:!0}})],z.prototype,"useGamma",void 0),z=ie=c([A("esri.layers.support.rasterFunctions.StretchFunctionArguments")],z);const Dr=z;let nt=class extends V{constructor(){super(...arguments),this.functionName="Stretch",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null,this.cutOffs=null}_bindSourceRasters(){this.lookup=null,this.cutOffs=null;const t=this.sourceRasterInfos[0],{pixelType:e}=t,{functionArguments:s}=this,{dynamicRangeAdjustment:o,gamma:r,useGamma:a}=s;if(!o&&["u8","u16","s8","s16"].includes(e)){const u=Ut(s.toJSON(),{rasterInfo:t}),l=this._isOutputRoundingNeeded()?"round":"float";this.lookup=vs({pixelType:e,...u,gamma:a?r:null,rounding:l}),this.cutOffs=u}else o||(this.cutOffs=Ut(s.toJSON(),{rasterInfo:t}));this.outputPixelType=this._getOutputPixelType(e);const n=t.clone();return n.pixelType=this.outputPixelType,n.statistics=null,n.histograms=null,n.colormap=null,n.attributeTable=null,this.outputPixelType==="u8"&&(n.keyProperties.DataType="processed"),this.rasterInfo=n,{success:!0,supportsGPU:!o}}_processPixels(t){var n;const e=(n=t.pixelBlocks)==null?void 0:n[0];if(e==null)return e;const{lookup:s}=this;if(s)return ge(e,{...s,outputPixelType:this.rasterInfo.pixelType});const{functionArguments:o}=this,r=this.cutOffs||Ut(o.toJSON(),{rasterInfo:this.sourceRasterInfos[0],pixelBlock:e}),a=o.useGamma?o.gamma:null;return As(e,{...r,gamma:a,outputPixelType:this.outputPixelType})}_getWebGLParameters(){const{outputMin:t=0,outputMax:e=255,gamma:s,useGamma:o}=this.functionArguments,r=this.rasterInfo.bandCount>=2?3:1,a=o&&(s!=null&&s.length)?Ps(r,s):[1,1,1],{minCutOff:n,maxCutOff:u}=this.cutOffs??{minCutOff:[0,0,0],maxCutOff:[255,255,255]};n.length===1&&(n[1]=n[2]=n[0],u[1]=u[2]=u[0]);const l=new Float32Array(r);let p;for(p=0;p<r;p++)l[p]=(e-t)/(u[p]-n[p]);const h=this._isOutputRoundingNeeded();return{bandCount:r,outMin:t,outMax:e,minCutOff:n,maxCutOff:u,factor:l,useGamma:o,gamma:o&&s?s:[1,1,1],gammaCorrection:o&&a?a:[1,1,1],stretchType:this.functionArguments.stretchType,isOutputRounded:h,type:"stretch"}}};c([f({json:{write:!0,name:"rasterFunction"}})],nt.prototype,"functionName",void 0),c([f({type:Dr,json:{write:!0,name:"rasterFunctionArguments"}})],nt.prototype,"functionArguments",void 0),c([f()],nt.prototype,"rasterArgumentNames",void 0),c([f({json:{write:!0}})],nt.prototype,"lookup",void 0),c([f({json:{write:!0}})],nt.prototype,"cutOffs",void 0),nt=c([A("esri.layers.support.rasterFunctions.StretchFunction")],nt);const Or=nt;var ae;let Et=ae=class extends U{constructor(){super(...arguments),this.attributeTableAsRecordSet=null}clone(){return new ae({attributeTableAsRecordSet:W(this.attributeTableAsRecordSet)})}};c([f({json:{write:!0}})],Et.prototype,"attributeTableAsRecordSet",void 0),Et=ae=c([A("esri.layers.support.rasterFunctions.TableFunctionArguments")],Et);const Er=Et;let dt=class extends V{constructor(){super(...arguments),this.functionName="Table",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isNoopProcess=!0}_bindSourceRasters(){const t=this.sourceRasterInfos[0];if(t.bandCount>1||t.pixelType.startsWith("f"))return{success:!1,supportsGPU:!1,error:"table-function: Source data must be single band and integer pixel type."};const{attributeTableAsRecordSet:e}=this.functionArguments;if(!e)return{success:!1,supportsGPU:!1,error:"table-function: Missing attributeTableAsRecordSet argument."};this.outputPixelType=this._getOutputPixelType(t.pixelType);const s=t.clone();return s.pixelType=this.outputPixelType,s.bandCount=1,s.dataType!=="thematic"&&(s.keyProperties=s.keyProperties?{...s.keyProperties,DataType:"thematic"}:{DataType:"thematic"}),this.rasterInfo=s,{success:!0,supportsGPU:!0}}_processPixels(t){var e;return(e=t.pixelBlocks)==null?void 0:e[0]}};c([f({json:{write:!0,name:"rasterFunction"}})],dt.prototype,"functionName",void 0),c([f({type:Er,json:{write:!0,name:"rasterFunctionArguments"}})],dt.prototype,"functionArguments",void 0),c([f()],dt.prototype,"rasterArgumentNames",void 0),c([f()],dt.prototype,"isNoopProcess",void 0),dt=c([A("esri.layers.support.rasterFunctions.TableFunction")],dt);const Gr=dt,D=new Map;function zr(i,t){const{rasterFunctionArguments:e}=i;e&&(e.rasters||[e.raster]).forEach(s=>{s&&typeof s!="number"&&(typeof s=="string"?s.startsWith("http")&&(t.includes(s)||t.push(s)):"rasterFunctionArguments"in s&&zr(s,t))})}function Ao(i,t){if(t=t??{},"function"in(i=W(i))&&"arguments"in i&&i.arguments){const e=es(i,new Map,t);if(ce(e),!e.renderingRule)throw new It("raster-function-helper","Unsupported raster function json.");i=e.renderingRule}if("rasterFunction"in i)return Qe(i=ue(i),t);throw new It("raster-function-helper","unsupported raster function json.")}function Ur(i,t){return t[0]==="rasters"&&Array.isArray(i.rasters)?i.rasters:t.map(e=>i[e])}function Ue(i){return!!(i&&typeof i=="object"&&i.rasterFunction&&i.rasterFunctionArguments)}function ue(i){var o;const{rasterFunction:t,rasterFunctionArguments:e}=i,s={};for(const r in e){let a=e[r];const n=r.toLowerCase();if(n==="rasters"&&Array.isArray(a))s.rasters=a.map(u=>Ue(u)?ue(u):u);else switch(Ue(a)&&(a=ue(a)),n){case"dra":s.dra=a;break;case"pspower":s.psPower=a;break;case"pszfactor":s.psZFactor=a;break;case"bandids":s.bandIds=a;break;default:s[r[0].toLowerCase()+r.slice(1)]=a}}return t!=="Local"||(o=s.rasters)!=null&&o.length||(s.rasters=["$$"]),{...i,rasterFunctionArguments:s}}function Qe(i,t){var m,g;const{rasterFunction:e,rasterFunctionArguments:s}=i,o=(m=i.outputPixelType)==null?void 0:m.toLowerCase();if(e==null||!D.has(e))throw new It("raster-function-helper",`unsupported raster function: ${e}`);const r=D.get(e),a=(typeof r.ctor=="function"?r.ctor:r.ctor.default).fromJSON({...i,outputPixelType:o}),{rasterArgumentNames:n}=a,u=[],l=Ur(s,n),p=n[0]==="rasters",h=[];for(let w=0;w<l.length;w++){const y=l[w];let d;y==null||typeof y=="string"&&y.startsWith("$")?u.push(t==null?void 0:t.raster):typeof y=="string"?t[y]&&u.push(t[y]):typeof y!="number"&&"rasterFunction"in y&&(d=Qe(y,t),p||(a.functionArguments[n[w]]=d),u.push(d)),p&&h.push(d??y)}if(p&&(a.functionArguments.rasters=h),t){a.sourceRasters=u;const w=(g=t.raster)==null?void 0:g.url;w&&(a.mainPrimaryRasterId=w)}return a}function ts(i,t){if(i&&t)for(const e in i){const s=i[e];s&&typeof s=="object"&&"type"in s&&(s.type==="RasterFunctionTemplate"?ts(s.arguments,t):s.type==="RasterFunctionVariable"&&t[s.name]!=null&&(s.value=t[s.name]))}}function le(i,t){var o;if(!i||typeof i!="object")return i;const{value:e}=i;if(!e||typeof e!="object")return i.isDataset?"$$":e;if(Array.isArray(e))return e.length===0?[]:e.map(r=>typeof r=="object"&&r.type==="RasterFunctionVariable"?le(r,t):r);if("value"in e&&["number","string","boolean"].includes(typeof e.value))return e.value;if(i.isDataset&&e.type!=="Scalar")return"$$";if(!("type"in e))return e;let s=e;switch(e.type){case"Scalar":s=e.value;break;case"AlgorithmicColorRamp":s=Ve(e);break;case"MultiPartColorRamp":s={type:"multipart",colorRamps:e.ArrayOfColorRamp.map(Ve)};break;case"ArgumentArray":if((o=e.elements)!=null&&o.length&&e.elements[0].type!=="RasterStatistics"){const r=[];for(let a=0;a<e.elements.length;a++){const n=e.elements[a],{type:u}=n;if(u)if(u==="RasterFunctionTemplate"){const{renderingRule:l}=es(n,t);r.push(l),n._object_id!=null&&t.set(n._object_id,l)}else{if(u!=="RasterFunctionVariable")throw new It("raster-function-helper","unsupported raster function json.");{const l=le(n,t);r.push(l),n._object_id!=null&&t.set(n._object_id,l)}}else r.push(n)}s=r}else s=e.elements}return e._object_id!=null&&t.set(e._object_id,s),s}function Ve(i){const t=i.algorithm??"esriHSVAlgorithm";let{FromColor:e,ToColor:s}=i;if(!Array.isArray(e)){const{r:o,g:r,b:a}=Ae({h:e.Hue,s:e.Saturation,v:e.Value});e=[o,r,a,e.AlphaValue]}if(!Array.isArray(s)){const{r:o,g:r,b:a}=Ae({h:s.Hue,s:s.Saturation,v:s.Value});s=[o,r,a,s.AlphaValue]}return{type:"algorithmic",algorithm:t,fromColor:e,toColor:s}}function es(i,t,e){e&&ts(i,e);const s={renderingRule:{},templates:t};return ss(i,s),s}function ss(i,t){if(!i||!t.renderingRule)return;const{renderingRule:e,templates:s}=t,{function:o,arguments:r,_object_id:a}=i;if(!o||!r)return;a!=null&&s.set(a,e),e.rasterFunction=o.type.replace("Function",""),e.outputPixelType=o.pixelType;const n={};e.rasterFunctionArguments=n;for(const u in r){if(u==="type"||u==="object_id"||u==="_object_ref_id")continue;const l=r[u];l&&typeof l=="object"&&"type"in l&&(l.type==="RasterFunctionTemplate"||l.type==="RasterFunctionVariable")?(l.type==="RasterFunctionVariable"?n[u]=le(l,s):(e.rasterFunctionArguments[u]={},ss(l,{renderingRule:e.rasterFunctionArguments[u],templates:s})),l._object_id!=null&&s.set(l._object_id,n[u])):n[u]=l}switch(n.DEM&&!n.Raster&&(n.Raster=n.DEM,delete n.DEM),e.rasterFunction){case"Stretch":Vr(n);break;case"Colormap":Lr(n);break;case"Convolution":Wr(n);break;case"Mask":qr(n)}}function ce(i){const{renderingRule:t,templates:e}=i;if(typeof t!="object"||!(t!=null&&t.rasterFunctionArguments)||!e.size)return;const{rasterFunctionArguments:s}=t;for(const o in s){const r=s[o],a=o==="_object_ref_id"?r:r&&typeof r=="object"&&"_object_ref_id"in r?r._object_ref_id:null;if(a==null)r&&typeof r=="object"&&(r.rasterFunctionArguments&&ce({renderingRule:r,templates:e}),Array.isArray(r)&&r.forEach((n,u)=>{if(typeof n=="object")if(n._object_ref_id!=null){if(!e.has(n._object_ref_id))throw new It("raster-function-helper",`unsupported raster function json. _object_ref_id: ${r} does not exist`);const l=e.get(a);l&&typeof l=="object"?Object.assign(n,l):r[u]=l}else ce({renderingRule:n,templates:e})}));else{if(!e.has(a))throw new It("raster-function-helper",`unsupported raster function json. _object_ref_id: ${a} does not exist`);const n=e.get(a);o!=="_object_ref_id"?s[o]=n:n&&typeof n=="object"&&Object.assign(s,n)}}}function Vr(i){var t;(t=i.Statistics)!=null&&t.length&&typeof i.Statistics=="object"&&(i.Statistics=i.Statistics.map(e=>[e.min,e.max,e.mean,e.standardDeviation])),i.NumberOfStandardDeviation!=null&&(i.NumberOfStandardDeviations=i.NumberOfStandardDeviation,delete i.NumberOfStandardDeviation)}function Lr(i){var t,e;((e=(t=i.ColorRamp)==null?void 0:t.type)==null?void 0:e.toLowerCase())==="randomcolorramp"&&(delete i.ColorRamp,i.ColormapName="Random"),i.ColorSchemeType===0&&delete i.ColorRamp}function Wr(i){i.ConvolutionType!=null&&(i.Type=i.ConvolutionType,delete i.ConvolutionType)}function qr(i){var t;(t=i.NoDataValues)!=null&&t.length&&typeof i.NoDataValues[0]=="string"&&(i.NoDataValues=i.NoDataValues.filter(e=>e!=="").map(e=>Number(e)))}D.set("Aspect",{desc:"Aspect Function",ctor:Ns,rasterArgumentNames:["raster"]}),D.set("BandArithmetic",{desc:"Band Arithmetic Function",ctor:Qs,rasterArgumentNames:["raster"]}),D.set("Colormap",{desc:"Colormap Function",ctor:cn,rasterArgumentNames:["raster"]}),D.set("CompositeBand",{desc:"CompositeBand Function",ctor:hn,rasterArgumentNames:["rasters"]}),D.set("Convolution",{desc:"Convolution Function",ctor:Pn,rasterArgumentNames:["raster"]}),D.set("ContrastBrightness",{desc:"Contrast Brightness Function",ctor:mn,rasterArgumentNames:["raster"]}),D.set("ExtractBand",{desc:"ExtractBand Function",ctor:Fn,rasterArgumentNames:["raster"]}),D.set("Curvature",{desc:"Curvature Function",ctor:$n,rasterArgumentNames:["raster"]}),D.set("Local",{desc:"Local Function",ctor:gr,rasterArgumentNames:["rasters"]}),D.set("Mask",{desc:"Mask Function",ctor:wr,rasterArgumentNames:["raster"]}),D.set("NDVI",{desc:"NDVI Function",ctor:xr,rasterArgumentNames:["raster"]}),D.set("Remap",{desc:"Remap Function",ctor:Ar,rasterArgumentNames:["raster"]}),D.set("Slope",{desc:"Slope Function",ctor:$r,rasterArgumentNames:["raster"]}),D.set("Statistics",{desc:"Focal Statistics Function",ctor:jr,rasterArgumentNames:["raster"]}),D.set("StatisticsHistogram",{desc:"Statistics Histogram Function",ctor:Sr,rasterArgumentNames:["raster"]}),D.set("Stretch",{desc:"Stretch Function",ctor:Or,rasterArgumentNames:["raster"]}),D.set("Table",{desc:"Attribute Table Function",ctor:Gr,rasterArgumentNames:["raster"]});let jt=class extends de{get affectsPixelSize(){return!1}forwardTransform(i){return i}inverseTransform(i){return i}};c([f()],jt.prototype,"affectsPixelSize",null),c([f({json:{write:!0}})],jt.prototype,"spatialReference",void 0),jt=c([A("esri.layers.support.rasterTransforms.BaseRasterTransform")],jt);const ve=jt;var pe;let _t=pe=class extends ve{constructor(){super(...arguments),this.type="gcs-shift",this.tolerance=1e-8}forwardTransform(i){return(i=i.clone()).type==="point"?(i.x>180+this.tolerance&&(i.x-=360),i):(i.xmin>=180-this.tolerance?(i.xmax-=360,i.xmin-=360):i.xmax>180+this.tolerance&&(i.xmin=-180,i.xmax=180),i)}inverseTransform(i){return(i=i.clone()).type==="point"?(i.x<-this.tolerance&&(i.x+=360),i):(i.xmin<-this.tolerance&&(i.xmin+=360,i.xmax+=360),i)}clone(){return new pe({tolerance:this.tolerance})}};c([Z({GCSShiftXform:"gcs-shift"})],_t.prototype,"type",void 0),c([f()],_t.prototype,"tolerance",void 0),_t=pe=c([A("esri.layers.support.rasterTransforms.GCSShiftTransform")],_t);const Xr=_t;var he;let Gt=he=class extends ve{constructor(){super(...arguments),this.type="identity"}clone(){return new he}};c([Z({IdentityXform:"identity"})],Gt.prototype,"type",void 0),Gt=he=c([A("esri.layers.support.rasterTransforms.IdentityTransform")],Gt);const Hr=Gt;var fe;function me(i,t,e){const{x:s,y:o}=t;if(e<2)return{x:i[0]+s*i[2]+o*i[4],y:i[1]+s*i[3]+o*i[5]};if(e===2){const m=s*s,g=o*o,w=s*o;return{x:i[0]+s*i[2]+o*i[4]+m*i[6]+w*i[8]+g*i[10],y:i[1]+s*i[3]+o*i[5]+m*i[7]+w*i[9]+g*i[11]}}const r=s*s,a=o*o,n=s*o,u=r*s,l=r*o,p=s*a,h=o*a;return{x:i[0]+s*i[2]+o*i[4]+r*i[6]+n*i[8]+a*i[10]+u*i[12]+l*i[14]+p*i[16]+h*i[18],y:i[1]+s*i[3]+o*i[5]+r*i[7]+n*i[9]+a*i[11]+u*i[13]+l*i[15]+p*i[17]+h*i[19]}}function Le(i,t,e){const{xmin:s,ymin:o,xmax:r,ymax:a,spatialReference:n}=t;let u=[];if(e<2)u.push({x:s,y:a}),u.push({x:r,y:a}),u.push({x:s,y:o}),u.push({x:r,y:o});else{let h=10;for(let m=0;m<h;m++)u.push({x:s,y:o+(a-o)*m/(h-1)}),u.push({x:r,y:o+(a-o)*m/(h-1)});h=8;for(let m=1;m<=h;m++)u.push({x:s+(r-s)*m/h,y:o}),u.push({x:s+(r-s)*m/h,y:a})}u=u.map(h=>me(i,h,e));const l=u.map(h=>h.x),p=u.map(h=>h.y);return new is({xmin:Math.min.apply(null,l),xmax:Math.max.apply(null,l),ymin:Math.min.apply(null,p),ymax:Math.max.apply(null,p),spatialReference:n})}function Jr(i){const[t,e,s,o,r,a]=i,n=s*a-r*o,u=r*o-s*a;return[(r*e-t*a)/n,(s*e-t*o)/u,a/n,o/u,-r/n,-s/u]}let X=fe=class extends ve{constructor(){super(...arguments),this.polynomialOrder=1,this.type="polynomial"}readForwardCoefficients(i,t){const{coeffX:e,coeffY:s}=t;if(!(e!=null&&e.length)||!(s!=null&&s.length)||e.length!==s.length)return null;const o=[];for(let r=0;r<e.length;r++)o.push(e[r]),o.push(s[r]);return o}writeForwardCoefficients(i,t,e){const s=[],o=[];for(let r=0;r<(i==null?void 0:i.length);r++)r%2==0?s.push(i[r]):o.push(i[r]);t.coeffX=s,t.coeffY=o}get inverseCoefficients(){let i=this._get("inverseCoefficients");const t=this._get("forwardCoefficients");return!i&&t&&this.polynomialOrder<2&&(i=Jr(t)),i}set inverseCoefficients(i){this._set("inverseCoefficients",i)}readInverseCoefficients(i,t){const{inverseCoeffX:e,inverseCoeffY:s}=t;if(!(e!=null&&e.length)||!(s!=null&&s.length)||e.length!==s.length)return null;const o=[];for(let r=0;r<e.length;r++)o.push(e[r]),o.push(s[r]);return o}writeInverseCoefficients(i,t,e){const s=[],o=[];for(let r=0;r<(i==null?void 0:i.length);r++)r%2==0?s.push(i[r]):o.push(i[r]);t.inverseCoeffX=s,t.inverseCoeffY=o}get affectsPixelSize(){return this.polynomialOrder>0}forwardTransform(i){if(i.type==="point"){const t=me(this.forwardCoefficients,i,this.polynomialOrder);return new Pe({x:t.x,y:t.y,spatialReference:i.spatialReference})}return Le(this.forwardCoefficients,i,this.polynomialOrder)}inverseTransform(i){if(i.type==="point"){const t=me(this.inverseCoefficients,i,this.polynomialOrder);return new Pe({x:t.x,y:t.y,spatialReference:i.spatialReference})}return Le(this.inverseCoefficients,i,this.polynomialOrder)}clone(){return new fe({polynomialOrder:this.polynomialOrder,forwardCoefficients:this.forwardCoefficients?[...this.forwardCoefficients]:null,inverseCoefficients:this.inverseCoefficients?[...this.inverseCoefficients]:null})}};c([f({json:{write:!0}})],X.prototype,"polynomialOrder",void 0),c([f()],X.prototype,"forwardCoefficients",void 0),c([Nt("forwardCoefficients",["coeffX","coeffY"])],X.prototype,"readForwardCoefficients",null),c([Ft("forwardCoefficients")],X.prototype,"writeForwardCoefficients",null),c([f({json:{write:!0}})],X.prototype,"inverseCoefficients",null),c([Nt("inverseCoefficients",["inverseCoeffX","inverseCoeffY"])],X.prototype,"readInverseCoefficients",null),c([Ft("inverseCoefficients")],X.prototype,"writeInverseCoefficients",null),c([f()],X.prototype,"affectsPixelSize",null),c([Z({PolynomialXform:"polynomial"})],X.prototype,"type",void 0),X=fe=c([A("esri.layers.support.rasterTransforms.PolynomialTransform")],X);const Kr=X,ns={GCSShiftXform:Xr,IdentityXform:Hr,PolynomialXform:Kr},Yr=Object.keys(ns);function Po(i){const t=i==null?void 0:i.type;return!i||Yr.includes(t)}function To(i){if(!(i==null?void 0:i.type))return null;const e=ns[i==null?void 0:i.type];if(e){const s=new e;return s.read(i),s}return null}export{zr as C,Ao as R,Po as f,To as i,Xr as n,Kr as y};