/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as n}from"tslib";import{uniform as t,UniformGroup as e}from"../../../GraphShaderModule.js";import{Float as i,texture2D as o,Vec2 as s,Vec4 as r,FixedArray as d,sqrt as l,dot as p,Vec3 as w,abs as c,step as u}from"../../../graph/glsl.js";class a extends e{}function y(n){const t=c(n),e=u(t,new s(1,1)).multiply(t),o=new i(2).subtract(t),r=u(new i(1),t).multiply(o);return e.add(r)}function m(n,t,e){const l=new i(1).divide(e),p=o(n,y(l.multiply(new s(-1,-1)).add(t))),w=o(n,y(l.multiply(new s(0,-1)).add(t))),c=o(n,y(l.multiply(new s(1,-1)).add(t))),u=o(n,y(l.multiply(new s(-1,0)).add(t))),a=o(n,y(t)),m=o(n,y(l.multiply(new s(1,0)).add(t))),f=o(n,y(l.multiply(new s(-1,1)).add(t))),Z=o(n,y(l.multiply(new s(0,1)).add(t))),x=o(n,y(l.multiply(new s(1,1)).add(t))),z=new r(p.a,w.a,c.a,u.a),A=new r(m.a,f.a,Z.a,x.a),g=z.multiply(A),h=g.xy.multiply(g.zw),v=h.x.multiply(h.y).multiply(a.a),b=new d(new i(0),10);return b[0]=p.r,b[1]=w.r,b[2]=c.r,b[3]=u.r,b[4]=a.r,b[5]=m.r,b[6]=f.r,b[7]=Z.r,b[8]=x.r,b[9]=v,b}function f(n,t){const e=new r(n[5],n[3],n[7],n[1]).multiply(2),i=new w(n[2],e[0],n[8]),o=new w(n[0],e[1],n[6]),d=p(i.subtract(o),new w(1)),l=new w(n[6],e[2],n[8]),c=new w(n[0],e[3],n[2]),u=p(l.subtract(c),new w(1));return new s(d,u).multiply(t)}function Z(n,t,e){const{factor:o}=t,s=f(n,o),d=l(p(s,s).add(1)),c=n[9],{sinZsinAs:u,sinZcosAs:a,cosZs:y,weights:m}=t;if(!e){const n=x({sinZsinA:u[0],sinZcosA:a[0],cosZ:y[0],weights:new i(1),dzxy:s,dzd:d});return new r(n,n,n,c)}const Z=x({sinZsinA:new w(u[0],u[1],u[2]),sinZcosA:new w(a[0],a[1],a[2]),cosZ:new w(y[0],y[1],y[2]),weights:new w(m[0],m[1],m[2]),dzxy:s,dzd:d}),z=x({sinZsinA:new w(u[3],u[4],u[5]),sinZcosA:new w(a[3],a[5],a[5]),cosZ:new w(y[3],y[4],y[5]),weights:new w(m[3],m[4],m[5]),dzxy:s,dzd:d}),A=p(Z.add(z),new w(1));return new r(A,A,A,c)}function x(n){const t=n.sinZsinA.multiply(n.dzxy.y),e=n.sinZcosA.multiply(n.dzxy.x),o=t.subtract(e),s=n.cosZ.add(o).divide(n.dzd);return s.multiply(u(new i(0),s)).multiply(n.weights)}function z(n,t){const{pixelSizeFactor:e}=n,i=[n.factor[0]/t[0],n.factor[1]/t[1]];if(e>0){const{zFactor:o,pixelSizePower:s,gcsFactor:r}=n,d=t[0]*r,l=t[1]*r;i[0]=(o+d**s*e)/(8*d),i[1]=(o+l**s*e)/(8*l)}return i}n([t(d.ofType(i,6))],a.prototype,"sinZcosAs",void 0),n([t(d.ofType(i,6))],a.prototype,"sinZsinAs",void 0),n([t(d.ofType(i,6))],a.prototype,"cosZs",void 0),n([t(d.ofType(i,6))],a.prototype,"weights",void 0),n([t(i)],a.prototype,"minValue",void 0),n([t(i)],a.prototype,"maxValue",void 0),n([t(s)],a.prototype,"factor",void 0);export{a as HillshadeConfig,f as computeDeltaZ,z as computeZFactor,m as getSurfaceValues,Z as hillshade,y as mirror};
