/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{addProjViewLocalOrigin as e}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float4PassUniform as t}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as o}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as r}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{outputColorHighlightOLID as i}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js";import{ShaderBuilder as n}from"../views/webgl/ShaderBuilder.js";function l(l){const s=new n,{vertex:d,fragment:a}=s;s.include(i,l),e(d,l),d.uniforms.add(new o("width",e=>e.width)),s.attributes.add("position","vec3"),s.attributes.add("normal","vec3"),s.attributes.add("uv0","vec2"),s.attributes.add("length","float"),s.varyings.add("vtc","vec2"),s.varyings.add("vlength","float"),s.varyings.add("vradius","float"),d.main.add(r`vec3 bitangent = normal;
vtc = uv0;
vlength = length;
vradius = 0.5 * width;
vec4 pos = view * vec4(position + vradius * bitangent * uv0.y, 1.0);
gl_Position = proj * pos;`),a.uniforms.add(new o("outlineSize",e=>e.outlineSize),new t("outlineColor",e=>e.outlineColor),new o("stripeLength",e=>e.stripeLength),new t("stripeEvenColor",e=>e.stripeEvenColor),new t("stripeOddColor",e=>e.stripeOddColor));const v=1/Math.sqrt(2);return a.code.add(r`
    const float INV_SQRT2 = ${r.float(v)};

    vec4 arrowColor(vec2 tc, float len) {
      float d = INV_SQRT2 * (tc.x - abs(tc.y));
      d = min(d, INV_SQRT2 * (len - tc.x - abs(tc.y)));
      d = min(d, 1.0 - abs(tc.y));

      if (d < 0.0) {
        return vec4(0.0);
      }
      if (d < outlineSize) {
        return outlineColor;
      }
      return fract(0.5 / stripeLength * tc.x * vradius) >= 0.5 ? stripeOddColor : stripeEvenColor;
    }`),a.main.add(r`vec2 ntc = vec2(vtc.x / vradius, vtc.y);
vec4 color = arrowColor(ntc, vlength / vradius);
outputColorHighlightOLID(color, color.rgb);`),s}const s=Object.freeze(Object.defineProperty({__proto__:null,build:l},Symbol.toStringTag,{value:"Module"}));export{s as M,l as b};
