/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/maybe","../definitions","./WGLBrush","../materialKey/MaterialKey","../../../../webgl/enums"],(function(t,e,i,o,s,a){"use strict";let n=function(o){function n(){var t;return(t=o.apply(this,arguments)||this)._computeDesc=new Map,t}t._inheritsLoose(n,o);var r=n.prototype;return r.prepareState=function({context:t},e,i){i&&i.includes("hittest")?t.setBlendFunctionSeparate(a.BlendFactor.ONE,a.BlendFactor.ONE,a.BlendFactor.ONE,a.BlendFactor.ONE):t.setBlendFunctionSeparate(a.BlendFactor.ONE,a.BlendFactor.ONE_MINUS_SRC_ALPHA,a.BlendFactor.ONE,a.BlendFactor.ONE_MINUS_SRC_ALPHA),t.setBlendingEnabled(!0),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!0),t.setStencilFunction(a.CompareFunction.EQUAL,e.stencilRef,255)},r.draw=function(t,i,o){const a=this.getGeometryType();i.commit(t);const n=i.getGeometry(a);e.isNone(n)||(t.timeline.begin(this.name),t.attributeView.bindTextures(t.context),n.forEachCommand((e=>{const a=s.MaterialKeyBase.load(e.materialKey).symbologyType;this.supportsSymbology(a)&&this.drawGeometry(t,i,e,o)})))},r._setSharedUniforms=function(t,o,s){const{displayLevel:a,pixelRatio:n,state:r,passOptions:u}=o;e.isSome(u)&&"hittest"===u.type&&(t.setUniform2fv("u_hittestPos",u.position),t.setUniform1f("u_hittestDist",u.distance)),t.setUniform1f("u_pixelRatio",n),t.setUniformMatrix3fv("u_tileMat3",s.transforms.tileMat3),t.setUniformMatrix3fv("u_viewMat3",r.viewMat3),t.setUniformMatrix3fv("u_dvsMat3",s.transforms.dvs),t.setUniformMatrix3fv("u_displayViewMat3",r.displayViewMat3),t.setUniform1f("u_currentZoom",Math.round(a*i.MIN_MAX_ZOOM_PRECISION_FACTOR)),t.setUniform1i("u_attributeTextureSize",o.attributeView.size),t.setUniform1i("u_attributeData0",i.TEXTURE_BINDING_ATTRIBUTE_DATA_0),t.setUniform1i("u_attributeData1",i.TEXTURE_BINDING_ATTRIBUTE_DATA_1),t.setUniform1i("u_attributeData2",i.TEXTURE_BINDING_ATTRIBUTE_DATA_2),t.setUniform1i("u_attributeData3",i.TEXTURE_BINDING_ATTRIBUTE_DATA_3),t.setUniform1i("u_attributeData4",i.TEXTURE_BINDING_ATTRIBUTE_DATA_4),t.setUniform1i("u_attributeData5",i.TEXTURE_BINDING_ATTRIBUTE_DATA_5)},r._setSizeVVUniforms=function(t,e,i,o){if(t.vvSizeMinMaxValue&&e.setUniform4fv("u_vvSizeMinMaxValue",i.vvSizeMinMaxValue),t.vvSizeScaleStops&&e.setUniform1f("u_vvSizeScaleStopsValue",i.vvSizeScaleStopsValue),t.vvSizeFieldStops){const t=i.getSizeVVFieldStops(o.key.level);e.setUniform1fv("u_vvSizeFieldStopsValues",t.values),e.setUniform1fv("u_vvSizeFieldStopsSizes",t.sizes)}t.vvSizeUnitValue&&e.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",i.vvSizeUnitValueToPixelsRatio)},r._setColorAndOpacityVVUniforms=function(t,e,i){t.vvColor&&(e.setUniform1fv("u_vvColorValues",i.vvColorValues),e.setUniform4fv("u_vvColors",i.vvColors)),t.vvOpacity&&(e.setUniform1fv("u_vvOpacityValues",i.vvOpacityValues),e.setUniform1fv("u_vvOpacities",i.vvOpacities))},r._setRotationVVUniforms=function(t,e,i){t.vvRotation&&e.setUniform1f("u_vvRotationType","geographic"===i.vvMaterialParameters.vvRotationType?0:1)},r._getTriangleDesc=function(t,e,i=["a_pos"]){const o=e.bufferLayouts.geometry,s=i.map((t=>o.findIndex((e=>e.name===t)))),a=`${t}-${s.join("-")}`;let n=this._computeDesc.get(a);if(!n){const t=e.strides,i=e.strides.geometry,r=new Map(e.attributes),u=o.map((t=>({...t}))),l=Math.max(...e.attributes.values()),f={geometry:u};let v=0;for(const e of s){const t=o[e];f.geometry.push({count:t.count,name:t.name+"1",divisor:t.divisor,normalized:t.normalized,offset:i+t.offset,stride:i,type:t.type}),f.geometry.push({count:t.count,name:t.name+"2",divisor:t.divisor,normalized:t.normalized,offset:2*i+t.offset,stride:i,type:t.type}),r.set(t.name+"1",l+ ++v),r.set(t.name+"2",l+ ++v)}n={bufferLayouts:f,attributes:r,strides:t},this._computeDesc.set(a,n)}return n},n}(o);return n}));
