/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/maybe","../core/shaderLibrary/ShaderOutputOptions","../core/shaderTechnique/ReloadableShaderModule","../core/shaderTechnique/ShaderTechnique","../lib/DefaultVertexAttributeLocations","../lib/Program","../lib/StencilUtils","../../../../chunks/NativeLine.glsl","../../../webgl/enums","../../../webgl/renderState"],(function(e,t,i,r,l,s,n,a,p,o,u,h,c){"use strict";let d=function(e){function t(t,i,r){var l;return(l=e.call(this,t,i,r)||this).stipplePattern=null,l.stippleTextureBind=null,l.stippleTextureRepository=t.stippleTextureRepository,l}i._inheritsLoose(t,e);var s=t.prototype;return s.initializeProgram=function(e){const i=t.shader.get().build(this.configuration);return new p.Program(e.rctx,i,a.Default3D)},s.destroy=function(){e.prototype.destroy.call(this),this.stippleTextureRepository.release(this.stipplePattern),this.stipplePattern=null,this.stippleTextureBind=null},s.bindPass=function(e,t){if(this.program.bindPass(e,t),this.stipplePattern!==e.stipplePattern){const t=e.stipplePattern;this.stippleTextureBind=this.stippleTextureRepository.swap(this.stipplePattern,t),this.stipplePattern=t}if(this.stippleEnabled){const{pixelSize:e,sdfNormalizer:t,pixels:i}=r.isSome(this.stippleTextureBind)?this.stippleTextureBind(this.program):{pixelSize:1,sdfNormalizer:1,pixels:1};this.program.setUniform1f("stipplePatternSDFNormalizer",t),this.program.setUniform1f("stipplePatternTextureSize",i),this.program.setUniform1f("stipplePatternPixelSize",e),this.program.setUniform1f("stipplePatternPixelSizeInv",1/e)}},s.initializePipeline=function(){const e=this.configuration,t=c.separateBlendingParams(h.BlendFactor.SRC_ALPHA,h.BlendFactor.ONE,h.BlendFactor.ONE_MINUS_SRC_ALPHA,h.BlendFactor.ONE_MINUS_SRC_ALPHA),i=(t,i=null,r=null)=>c.makePipelineState({blending:i,depthTest:o.depthCompareLess,depthWrite:r,colorWrite:c.defaultColorWriteParams,stencilWrite:e.hasOccludees?o.stencilWriteMaskOn:null,stencilTest:e.hasOccludees?t?o.stencilToolMaskBaseParams:o.stencilBaseAllZerosParams:null});return e.output===l.ShaderOutput.Color?(this._occludeePipelineState=i(!0,e.transparent||this.stippleEnabled?t:null,c.defaultDepthWriteParams),i(!1,e.transparent||this.stippleEnabled?t:null,c.defaultDepthWriteParams)):i(!1)},s.getPipelineState=function(t,i){return i?this._occludeePipelineState:e.prototype.getPipelineState.call(this,t,i)},i._createClass(t,[{key:"stippleEnabled",get:function(){return this.configuration.stippleEnabled&&this.configuration.output!==l.ShaderOutput.Highlight}},{key:"primitiveType",get:function(){return h.PrimitiveType.LINES}}]),t}(n.ShaderTechnique);d.shader=new s.ReloadableShaderModule(u.NativeLine,(()=>new Promise(((t,i)=>e(["./NativeLine.glsl"],t,i))))),t.NativeLineTechnique=d,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
