/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t,__param as o}from"tslib";import{GraphShaderModule as i,FragmentOutput as e,location as p,uniform as r,define as s,option as l,texture as n,input as a,VertexInput as c,UniformGroup as h,FragmentInput as g}from"../../../GraphShaderModule.js";import{Vec3 as y,Vec4 as u,ifElse as d,texture2D as v,sign as x,mix as P,Vec2 as m,Mat3 as j,Float as b,Sampler2D as f}from"../../../graph/glsl.js";import{getPixelLocation as k,isOutside as M,getPixel as S,ProjectionConfig as T,ProjectionTextures as _}from"./projection.js";class w extends c{}t([p(0,m)],w.prototype,"position",void 0);class z extends g{}class E extends h{}t([r(j)],E.prototype,"dvsMat3",void 0),t([r(m)],E.prototype,"coordScale",void 0),t([r(m)],E.prototype,"srcImageSize",void 0),t([r(b)],E.prototype,"opacity",void 0);class O extends i{constructor(){super(...arguments),this.applyProjection=!0,this.lookupProjection=!1,this.bilinear=!1,this.bicubic=!1,this.nearestOnEdge=!1,this.applyPixelMask=!1,this.applyPixelHighlights=!1}vertex(t){const o=t.position,{dvsMat3:i,coordScale:e}=this.config,p=i.multiply(new y(o.multiply(e),1));return{uv:o,glPosition:new u(p,1)}}fragment(t){const o=new e,i=k(t.uv,this.applyProjection?this.projectionConfig:void 0,this.applyProjection?this.projectionTextures:void 0,this.lookupProjection);let p=this._colorize(i,t.uv);this.applyPixelHighlights&&(p=this._highlightPixels(t.uv,p));const r=d(M(i),new u(0),p);let s=r.a.multiply(this.config.opacity);if(this.applyPixelMask){const o=this._getPixelMask(t.uv);s=s.multiply(o)}return o.fragColor=new u(r.rgb,1).multiply(s),o}_getPixel(t){const{config:o,bicubic:i,bilinear:e,nearestOnEdge:p}=this;return S(t,{texture:this.texture,srcImageSize:o.srcImageSize},{bicubic:i,bilinear:e,nearestOnEdge:p})}_getPixelMask(t){const o=v(this.pixelMaskTexture,t);return x(o.a)}_highlightPixels(t,o){const i=v(this.highlightTexture,t),e=x(i.a);return P(o,i,e)}}t([s],O.prototype,"applyProjection",void 0),t([s],O.prototype,"lookupProjection",void 0),t([s],O.prototype,"bilinear",void 0),t([s],O.prototype,"bicubic",void 0),t([s],O.prototype,"nearestOnEdge",void 0),t([s],O.prototype,"applyPixelMask",void 0),t([s],O.prototype,"applyPixelHighlights",void 0),t([r(E)],O.prototype,"config",void 0),t([l(T)],O.prototype,"projectionConfig",void 0),t([n(f)],O.prototype,"texture",void 0),t([n(_)],O.prototype,"projectionTextures",void 0),t([n(f)],O.prototype,"pixelMaskTexture",void 0),t([n(f)],O.prototype,"highlightTexture",void 0),t([o(0,a(w))],O.prototype,"vertex",null),t([o(0,a(z))],O.prototype,"fragment",null);export{O as BaseRasterColorizerShader,z as RasterColorizerFragmentInput,E as RasterConfig};
