/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/maybe","../../vectorTiles/style/StyleDefinition","../enums","../number","./WGLBrush","../../../../webgl/enums"],(function(e,t,r,i,n,a,o,s){"use strict";let l=function(e){function o(){var t;return(t=e.apply(this,arguments)||this)._programOptions={id:!1},t}t._inheritsLoose(o,e);var l=o.prototype;return l.dispose=function(){},l.drawMany=function(e,t){const{context:o,displayLevel:l,requiredLevel:c,state:u,drawPhase:d,painter:f,spriteMosaic:p,styleLayerUID:y,requestRender:m}=e;if(!t.some((e=>{var t,r;return null!=(t=null==(r=e.layerData.get(y))?void 0:r.circleIndexCount)&&t})))return;const v=e.styleLayer,g=v.circleMaterial,T=f.vectorTilesMaterialManager,M=1.2,_=v.getPaintValue("circle-translate",l),h=v.getPaintValue("circle-translate-anchor",l),E=d===n.WGLDrawPhase.HITTEST,L=this._programOptions;L.id=E;const I=T.getMaterialProgram(o,g,L);if(!E&&r.isSome(m)&&!I.isCompiled)return void m();o.useProgram(I),I.setUniformMatrix3fv("u_displayMat3",h===i.TranslateAnchor.VIEWPORT?u.displayMat3:u.displayViewMat3),I.setUniform2fv("u_circleTranslation",_),I.setUniform1f("u_depth",v.z),I.setUniform1f("u_antialiasingWidth",M);let P=-1;if(E){const e=a.u32to4Xu8(y+1);I.setUniform4fv("u_id",e)}for(const i of t){if(!i.layerData.has(y))continue;i.key.level!==P&&(P=i.key.level,g.setDataUniforms(I,l,v,P,p));const e=i.layerData.get(y);if(!e.circleIndexCount)continue;e.prepareForRendering(o);const t=e.circleVertexArrayObject;r.isNone(t)||(o.bindVAO(t),I.setUniformMatrix3fv("u_dvsMat3",i.transforms.dvs),c!==i.key.level?o.setStencilFunction(s.CompareFunction.EQUAL,i.stencilRef,255):o.setStencilFunction(s.CompareFunction.GREATER,255,255),o.drawElements(s.PrimitiveType.TRIANGLES,e.circleIndexCount,s.DataType.UNSIGNED_INT,Uint32Array.BYTES_PER_ELEMENT*e.circleIndexStart),i.triangleCount+=e.circleIndexCount/3)}},o}(o);e.WGLBrushVTLCircle=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
