/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t,__param as i}from"tslib";import{location as e,uniform as o,option as l,input as a,UniformGroup as r}from"../../GraphShaderModule.js";import{Vec3 as s,step as n,min as p,length as u,clamp as m,Float as d,max as y,Vec4 as c,Vec2 as f}from"../../graph/glsl.js";import{AFeatureShader as h,BaseHittestVertexInput as v,FeatureVertexInput as w,FeatureFragmentInput as V}from"./AFeatureShader.js";import{thinLineWidthFactor as b,thinLineHalfWidth as S,epsilon as x}from"./constants.js";import{distPointSegment as g}from"./hittestUtils.js";import{VisualVariableColor as j}from"./VisualVariableColor.js";import{VisualVariableOpacity as z}from"./VisualVariableOpacity.js";import{VisualVariableSizeMinMaxValue as M}from"./VisualVariableSizeMinMaxValue.js";import{VisualVariableSizeScaleStops as W}from"./VisualVariableSizeScaleStops.js";import{VisualVariableSizeStops as C}from"./VisualVariableSizeStops.js";import{VisualVariableSizeUnitValue as P}from"./VisualVariableSizeUnitValue.js";import{getVisualVariableColor as R,getVisualVariableOpacity as H,hasVisualVariableSize as O,getVisualVariableSize as U}from"./vvUtils.js";class q extends w{}t([e(3,c)],q.prototype,"color",void 0),t([e(4,f)],q.prototype,"offset",void 0),t([e(5,f)],q.prototype,"normal",void 0),t([e(6,d)],q.prototype,"halfWidth",void 0),t([e(7,d)],q.prototype,"referenceHalfWidth",void 0),t([e(8,f)],q.prototype,"zoomRange",void 0);class A extends V{}class F extends r{}function D(t){return y(new d(b).multiply(n(t,new d(S))),new d(1))}function G(t,i){const{halfWidth:e,normal:o}=t,l=D(e),a=u(o).multiply(e);return m(l.multiply(e.subtract(a)).divide(i.add(l).subtract(new d(1))),new d(0),new d(1))}function L(t,i){const{id:e,halfWidth:o,referenceHalfWidth:l}=i;if(O(t)){const i=new d(2).multiply(l),a=U(t,e,i);return new d(.5).multiply(o.divide(y(l,new d(x)))).multiply(a)}return o}function T(t,i){const{id:e,offset:o,pos:l,normal:a,zoomRange:r}=i,{displayViewScreenMat3:p,displayViewMat3:u}=t.view,m=R(t,e,i.color),f=H(t,e),h=L(t,i),v=new d(.5).multiply(t.antialiasingControls.antialiasing),w=y(h.add(v),new d(.45)).add(new d(.1).multiply(v)),V=D(w).multiply(w).multiply(o),b=u.multiply(new s(V,new d(0))),S=p.multiply(new s(l,new d(1))).add(b),x=new d(2).multiply(n(h,new d(0))).add(t.clip(e,r)),g=new c(S.xy,x,1);return{color:m,opacity:f,halfWidth:w,normal:a,scaledOffset:V,scaledHalfWidth:h,glPosition:new c(g.xy,x,1)}}function k(t,i){const{opacity:e,color:o}=t,l=G(t,i);return e.multiply(o).multiply(l)}t([o(d)],F.prototype,"antialiasing",void 0),t([o(d)],F.prototype,"blur",void 0);class B extends h{constructor(){super(...arguments),this.type="LineShader",this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,i){const e=T(this,t);return{...e,...this.maybeRunHittest(t,i,e.halfWidth)}}fragment(t){const i=k(t,this.antialiasingControls.blur);return this.getFragmentOutput(i,t)}hittest(t,i,e){const{viewMat3:o,tileMat3:l}=this.view,a=o.multiply(l),r=a.multiply(new s(t.pos,1)),u=a.multiply(new s(i.nextPos1,1)),m=a.multiply(new s(i.nextPos2,1)),{distance:d,smallSymbolDistance:y,smallSymbolSizeThreshold:c}=this.hittestRequest,f=n(e,c.multiply(.5)).multiply(d.subtract(y)),h=this.hittestRequest.position;return p(g(h,r.xy,u.xy),g(h,r.xy,m.xy)).subtract(e).add(f)}}t([o(F)],B.prototype,"antialiasingControls",void 0),t([l(j)],B.prototype,"visualVariableColor",void 0),t([l(z)],B.prototype,"visualVariableOpacity",void 0),t([l(M)],B.prototype,"visualVariableSizeMinMaxValue",void 0),t([l(W)],B.prototype,"visualVariableSizeScaleStops",void 0),t([l(C)],B.prototype,"visualVariableSizeStops",void 0),t([l(P)],B.prototype,"visualVariableSizeUnitValue",void 0),t([i(0,a(q)),i(1,a(v))],B.prototype,"vertex",null),t([i(0,a(A))],B.prototype,"fragment",null);export{F as AntialiasingControls,A as LineFragmentInput,B as LineShader,q as LineVertexInput,G as getLineAntialiasing,k as getLineFragmentColor,D as getLineThinFactor,T as getLineVertexData};
