/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t,__param as e}from"tslib";import{location as i,define as o,uniform as s,input as r,VertexInput as n,GraphShaderModule as a,FragmentOutput as l,FragmentInput as p}from"../../../GraphShaderModule.js";import{Vec4 as y,Float as d,mod as c,clamp as h,mix as u,normalize as v,equal as w,or as f,ifElse as g,lessThan as m,and as x,notEqual as z,greaterThan as T,cond as b,Vec2 as L,exp as F,length as I}from"../../../graph/glsl.js";import{FlowAnimationState as S,FlowLineConfig as O,FlowColorValue as C,FlowFloatValue as j,getFadeOpacity as R,getFlowSize as V,getFlowExtrudedPosition as Z,getFlowPremultipliedColor as P,getFragmentColor as G}from"./FlowUtils.js";class M extends n{}t([i(0,y)],M.prototype,"xyts0",void 0),t([i(1,y)],M.prototype,"xyts1",void 0),t([i(2,y)],M.prototype,"typeIdFirstTimeLastTime",void 0),t([i(3,y)],M.prototype,"extrudeInfo",void 0);class U extends p{}class k extends a{constructor(){super(...arguments),this.type="FlowParticlesShader",this.vvColor=null,this.vvOpacity=null,this.vvSize=null}vertex(t){const e=t.typeIdFirstTimeLastTime.z,i=t.typeIdFirstTimeLastTime.w.subtract(e),o=t.xyts0.xy,s=t.xyts0.z.subtract(e),r=t.xyts0.w,n=t.xyts1.xy,a=t.xyts1.z.subtract(e),l=t.xyts1.w,p=t.typeIdFirstTimeLastTime.x,I=t.typeIdFirstTimeLastTime.y,S=new d(2),O=new d(1),C=new d(2),j=new d(3),G=t.extrudeInfo.xy,M=t.extrudeInfo.zw,U=i.add(this.config.trailLength),k=c(this.state.time.multiply(this.config.flowSpeed),U),q=k.subtract(s).divide(a.subtract(s)),A=h(q,new d(0),new d(1)),B=u(s,a,A),D=u(r,l,A),E=u(G,M,A),H=v(n.subtract(o)).multiply(new d(.5)),J=w(p,S),K=f(w(I,O),w(I,C)),N=g(J,f(m(q,new d(0)),x(T(q,new d(1)),z(a,i))),m(q,new d(0))),Q=g(J,b([w(I,O),E],[w(I,C),E.multiply(new d(-1))],[w(I,j),E.add(H)],[!0,E.multiply(new d(-1)).add(H)]),b([w(I,O),G],[w(I,C),G.multiply(new d(-1))],[w(I,j),E],[!0,E.multiply(new d(-1))])),W=g(J,b([w(I,O),new L(.5,0)],[w(I,C),new L(.5,1)],[w(I,j),new L(1,0)],[!0,new L(1,1)]),b([w(I,O),new L(.5,0)],[w(I,C),new L(.5,1)],[w(I,j),new L(.5,0)],[!0,new L(.5,1)])),X=g(J,B,g(K,s,B)),Y=g(J,D,g(K,r,D)),$=g(J,R(k.subtract(B).divide(this.config.trailLength),this.config.decayRate,this.config.fadeToZero),g(K,R(k.subtract(s).divide(this.config.trailLength),this.config.decayRate,this.config.fadeToZero),R(k.subtract(B).divide(this.config.trailLength),this.config.decayRate,this.config.fadeToZero))),_=new d(1).subtract(F(X.multiply(new d(-1)))),tt=V(this.size.getValue(Y,this.vvSize),this.config.featheringSize,this.config.featheringOffset),et=this.color.getValue(Y,this.vvColor),it=et.a.multiply(this.opacity.getValue(Y,this.vvOpacity)).multiply($).multiply(u(new d(1),_,this.config.introFade)).multiply(this.state.displayOpacity),ot=g(J,u(o,n,A),g(K,o,u(o,n,A))),st=Z(this.state,ot,Q,tt);return{glPosition:g(N,new y(0,0,-2,1),new y(st,0,1)),color:P(et,it),texcoord:W,size:tt}}fragment(t){const e=new l;return e.fragColor=G(t.color,I(t.texcoord.subtract(new L(.5))),t.size,this.config.featheringSize),e}}t([o],k.prototype,"vvColor",void 0),t([o],k.prototype,"vvOpacity",void 0),t([o],k.prototype,"vvSize",void 0),t([s(S)],k.prototype,"state",void 0),t([s(O)],k.prototype,"config",void 0),t([s(C)],k.prototype,"color",void 0),t([s(j)],k.prototype,"opacity",void 0),t([s(j)],k.prototype,"size",void 0),t([e(0,r(M))],k.prototype,"vertex",null),t([e(0,r(U))],k.prototype,"fragment",null);export{k as FlowParticlesShader};
