/*
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","../../../../../../core/screenUtils","../../../../../../chunks/mat2df32","../../../../../../chunks/vec2f32","../../../../../../symbols/cim/enums","../../color","../../definitions","../../enums","../../number","../../materialKey/MaterialKey","./util","./WGLBaseMarkerTemplate","./WGLMeshTemplate"],(function(t,e,o,r,i,n,a,l,s,c,m,h,p,_){"use strict";return function(p){function _(t,e,o,a,h,_,u,f,M,x,d,y,A,S,E,R,g,O,L,T,B,I,P){var V;(V=p.call(this)||this).angle=a,V.height=u,V.width=_,V.xOffset=e*L,V.yOffset=o*L,V._markerPlacement=T,V._effects=B,V._anchorX=.5-(.5+R)*E.width/E.width,V._anchorY=.5-(.5+g)*E.height/E.height,V._minMaxZoom=c.i1616to32(Math.round(I*l.MIN_MAX_ZOOM_PRECISION_FACTOR),Math.round(P*l.MIN_MAX_ZOOM_PRECISION_FACTOR));const C=(S===n.Alignment.MAP?l.BITSET_MARKER_ALIGNMENT_MAP:l.BITSET_MARKER_ALIGNMENT_SCREEN)|(d?l.BITSET_GENERIC_LOCK_COLOR:0)|(A?l.BITSET_MARKER_OUTLINE_ALLOW_COLOR_OVERRIDE:0)|(y?l.BITSET_MARKER_SCALE_SYMBOLS_PROPORTIONALLY:0),N=E&&E.sdf,z=m.MarkerMaterialKey.load(t);z.sdf=N,z.pattern=!0,z.textureBinding=E.textureBinding,V._materialKey=z.data,V._fillColor=h,V._outlineColor=M,V._sizeOutlineWidth=c.i8888to32(Math.round(Math.min(Math.sqrt(128*_),255)),Math.round(Math.min(Math.sqrt(128*u),255)),Math.round(Math.min(Math.sqrt(128*x),255)),Math.round(Math.min(Math.sqrt(128*f),255)));const b=E.rect.x+l.SPRITE_PADDING,k=E.rect.y+l.SPRITE_PADDING,U=b+E.width,w=k+E.height;V._offsets.xUpperLeft=b,V._offsets.yUpperLeft=k,V._offsets.xUpperRight=U,V._offsets.yUpperRight=k,V._offsets.xBottomLeft=b,V._offsets.yBottomLeft=w,V._offsets.xBottomRight=U,V._offsets.yBottomRight=w,z.symbologyType===s.WGLSymbologyType.PIE_CHART?(V._texUpperLeft=c.i1616to32(0,1),V._texUpperRight=c.i1616to32(1,1),V._texBottomLeft=c.i1616to32(0,0),V._texBottomRight=c.i1616to32(1,0)):(V._texUpperLeft=c.i1616to32(b,k),V._texUpperRight=c.i1616to32(U,k),V._texBottomLeft=c.i1616to32(b,w),V._texBottomRight=c.i1616to32(U,w)),_*=O,u*=O,_*=L,u*=L;const G=Math.round(64*O);V._bitestAndDistRatio=c.i1616to32(C,G),V._computedWidth=_,V._computedHeight=u;const K=i.create(),D=r.create();return V._applyTransformation(D,K),V}return t._inheritsLoose(_,p),_.fromCIMMarker=function(t,r,i){const l=r&&r.width||1,s=r&&r.height||1,c=t.size,m=l/s*t.scaleX,p=t.scaleSymbolsProportionally&&t.frameHeight?c/t.frameHeight:1;let u=a.premultiplyAlphaRGBA(t.color);const f=a.premultiplyAlphaRGBA(t.outlineColor),M=o.pt2px(c),x=M*m,d=o.pt2px(t.offsetX||0),y=o.pt2px(t.offsetY||0),A=o.pt2px(t.outlineWidth||0)*p,S=t.alignment||n.Alignment.SCREEN,E=o.pt2px(t.referenceSize),[R,g]=h.getMinMaxZoom(t.scaleInfo,i);r.sdf||0!==u||(u=-1);let O=t.rotation||0;t.rotateClockwise||(O=-O);let L=0,T=0;const B=t.anchorPoint;B&&(t.isAbsoluteAnchorPoint?c&&(L=-B.x/(c*m),T=B.y/c):(L=B.x,T=B.y));const I=new _(t.materialKey,d,y,O,u,x,M,E,f,A,t.colorLocked,t.scaleSymbolsProportionally,!1,S,r,L,T,t.sizeRatio,e.unwrapOr(t.scaleFactor,1),t.markerPlacement,t.effects,R,g);return I._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/x:1,I._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/M:1,I},_.fromPictureMarker=function(t,e){const r=Math.round(o.pt2px(t.width)),i=Math.round(o.pt2px(t.height)),a=l.PICTURE_FILL_COLOR,s=Math.round(o.pt2px(t.xoffset||0)),c=Math.round(o.pt2px(t.yoffset||0)),m=new _(t.materialKey,s,c,t.angle,a,r,i,i,0,0,!1,!1,!1,n.Alignment.SCREEN,e,0,0,1,1,null,null,h.DEFAULT_MIN_ZOOM,h.DEFAULT_MAX_ZOOM);return m._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/t.width:1,m._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/t.height:1,m},_.fromSimpleMarker=function(t,e){const r=a.premultiplyAlphaRGBAArray(t.color),i=Math.round(o.pt2px(t.size)),l=i,s=Math.round(o.pt2px(t.xoffset||0)),c=Math.round(o.pt2px(t.yoffset||0)),m=t.style,p=t.outline,u=0|(p&&p.color&&a.premultiplyAlphaRGBAArray(p.color)),f=0|(p&&p.width&&Math.round(o.pt2px(p.width))),M=new _(t.materialKey,s,c,t.angle,r,i,l,l,u,f,!1,!1,"esriSMSCross"===m||"esriSMSX"===m,n.Alignment.SCREEN,e,0,0,126/64,1,null,null,h.DEFAULT_MIN_ZOOM,h.DEFAULT_MAX_ZOOM);return M.boundsType="esriSMSCircle"===m?"circle":"square",M._vertexBoundsScaleX=t.maxVVSize?t.maxVVSize/t.size:1,M._vertexBoundsScaleY=t.maxVVSize?t.maxVVSize/t.size:1,M},_.fromLineSymbolMarker=function(t,e){const r=a.premultiplyAlphaRGBAArray(t.color),i=6,l=Math.round(o.pt2px(i*t.lineWidth)),s=l,c="cross"===t.style||"x"===t.style;let m;switch(t.placement){case"begin-end":m=n.ExtremityPlacement.Both;break;case"begin":m=n.ExtremityPlacement.JustBegin;break;case"end":m=n.ExtremityPlacement.JustEnd;break;default:m=n.ExtremityPlacement.None}const p={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:m,offsetAlongLine:0},u=new _(t.materialKey,0,0,0,r,l,s,s/i,r,c?Math.round(o.pt2px(t.lineWidth)):0,!1,!1,c,n.Alignment.MAP,e,0,0,126/64,1,p,null,h.DEFAULT_MIN_ZOOM,h.DEFAULT_MAX_ZOOM);return u.boundsType="circle"===t.style?"circle":"square",u},_}(p(_))}));
