/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as t}from"tslib";import{maxMapSizeGpu as o}from"../../../../../../../../../layers/raster/functions/pixelUtils.js";import{uniform as e,define as s,UniformGroup as r}from"../../../../GraphShaderModule.js";import{Vec3 as i,abs as a,sign as l,step as p,FixedArray as n,Float as u}from"../../../../graph/glsl.js";import{BaseRasterProcessorShader as m}from"./BaseRasterProcessorShader.js";class c extends r{}t([e(n.ofType(u,6))],c.prototype,"includedRanges",void 0),t([e(n.ofType(u,o))],c.prototype,"noDataValues",void 0);class y extends m{constructor(){super(...arguments),this.type="MaskShader",this.isMultiband=!0}_process(t){const o=this._getPixel(t),e=this._computeNoDataFactor(o.r),s=this._computeRangeFactor(o.rgb);let r;if(this.isMultiband){const t=this._computeNoDataFactor(o.g),a=this._computeNoDataFactor(o.b),l=new i(e,t,a).multiply(s);r=l.x.multiply(l.y).multiply(l.z)}else r=e.multiply(s.x);return o.multiply(r)}_computeNoDataFactor(t){const{noDataValues:e}=this.maskConfig;let s=new i(1);for(let r=0;r<o/3;r++){const o=3*r,p=new i(e[o+0],e[o+1],e[o+2]),n=a(l(p.subtract(t)));s=s.multiply(n)}return s.x.multiply(s.y).multiply(s.z)}_computeRangeFactor(t){const{includedRanges:o}=this.maskConfig,e=new i(o[0],o[2],o[4]),s=new i(o[1],o[3],o[5]);return p(e,t).multiply(p(t,s))}}t([s],y.prototype,"isMultiband",void 0),t([e(c)],y.prototype,"maskConfig",void 0);export{y as MaskShader};
