/*
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 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,texture2D as p,FixedArray2D 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(c.ofType(i,5,5,!0))],u.prototype,"kernel",void 0),o([t(s)],u.prototype,"clampRange",void 0);class g 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)),{texture:c,srcImageSize:m}=this.config,u=new i(1).divide(m),{kernel:g}=this.convolutionConfig,h=n(g,{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(u),g=p(c,d(o.add(m))),h=g.rgb.multiply(e).add(t.rgb),f=g.a.multiply(t.a);return new l(h,f)}}),{clampRange:f}=this.convolutionConfig;return new l(a(h.rgb,f.x,f.y),1).multiply(h.a)}}o([e],g.prototype,"rows",void 0),o([e],g.prototype,"cols",void 0),o([t(u)],g.prototype,"convolutionConfig",void 0);export{g as ConvolutionShader};
