/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as o}from"tslib";import{uniform as t,define as e,UniformGroup as r}from"../../../../GraphShaderModule.js";import{Vec2 as s,Float as i,reduce2D as n,Vec4 as l,clamp as a,FixedArray2D as p,texture2D as c}from"../../../../graph/glsl.js";import{mirror as d}from"../surface.js";import{BaseRasterProcessorShader as m}from"./BaseRasterProcessorShader.js";class u extends r{}o([t(p.ofType(i,5,5,!0))],u.prototype,"kernel",void 0),o([t(s)],u.prototype,"clampRange",void 0);class h extends m{constructor(){super(...arguments),this.type="ConvolutionShader",this.rows=3,this.cols=3}_process(o){const{rows:t,cols:e}=this,r=new s(Math.floor(t/2),Math.floor(e/2)),p=new i(1).divide(this.config.srcImageSize),{kernel:m}=this.convolutionConfig,u=n(m,{initialValue:new l(0,0,0,1),xRange:[0,t],yRange:[0,e],callback:(t,e,n,a)=>{const m=new s(new i(n),new i(a)).subtract(r).multiply(p),u=c(this.texture,d(o.add(m))),h=u.rgb.multiply(e).add(t.rgb),g=u.a.multiply(t.a);return new l(h,g)}}),{clampRange:h}=this.convolutionConfig;return new l(a(u.rgb,h.x,h.y),1).multiply(u.a)}}o([e],h.prototype,"rows",void 0),o([e],h.prototype,"cols",void 0),o([t(u)],h.prototype,"convolutionConfig",void 0);export{h as ConvolutionShader};
