/*
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/BidiText","../../../../../../core/screenUtils","../../../../../../symbols/cim/enums","../../alignmentUtils","../../color","../../definitions","../../number","../../materialKey/MaterialKey","./util","./WGLBaseTextTemplate","./WGLMeshTemplate"],(function(e,t,i,n,o,l,a,r,s,c,_,f){"use strict";const m=5;return function(_){function f(e,t,l,c,f,u,h,M,p,x,A,d,z,g,y,S,O,T,I=!1,R,b){var C;(C=_.call(this)||this)._xOffset=i.pt2px(z),C._yOffset=i.pt2px(g),C._decoration=x||"none",C._color=f,C._haloColor=u,C._haloSize=Math.min(Math.floor(m*i.pt2px(i.toPt(l))),127),C._size=Math.min(Math.round(i.pt2px(t)),127);const B=Math.min(Math.round(i.pt2px(c||t)),127);C._referenceSize=Math.round(Math.sqrt(256*B)),C._scale=C._size/a.GLYPH_SIZE,C._angle=d,C._justify=o.getJustification(h||"center"),C._xAlignD=o.getXAnchorDirection(h||"center"),C._yAlignD=o.getYAnchorDirection(M||"baseline"),C._baseline="baseline"===(M||"baseline"),C._bitset=(p===n.Alignment.MAP?1:0)|(A?1:0)<<1;const P=s.MaterialKeyBase.load(e);return P.sdf=!0,C._materialKey=P.data,C._lineWidth=i.pt2px(y)||512,C._lineHeight=S||1,C._textPlacement=O,C._effects=T,C._isCIM=I,C._minMaxZoom=r.i1616to32(Math.round(R*a.MIN_MAX_ZOOM_PRECISION_FACTOR),Math.round(b*a.MIN_MAX_ZOOM_PRECISION_FACTOR)),C}return e._inheritsLoose(f,_),f.fromText=function(e,i){const o=new f(e.materialKey,e.font.size,e.haloSize||0,e.font.size,e.color&&l.premultiplyAlphaRGBAArray(e.color)||0,e.haloColor&&l.premultiplyAlphaRGBAArray(e.haloColor)||0,e.horizontalAlignment,e.verticalAlignment,n.Alignment.SCREEN,e.font.decoration,!1,e.angle||0,e.xoffset,e.yoffset,e.lineWidth,e.lineHeight,null,null,!1,c.DEFAULT_MIN_ZOOM,c.DEFAULT_MAX_ZOOM),[,a]=t.bidiText(e.text);return o.bindTextInfo(i,a),o._vertexBoundsScale=e.maxVVSize?e.maxVVSize/e.font.size:1,o},f.fromCIMText=function(e,i,n){const o=e.scaleFactor||1,a=e.size*e.sizeRatio*o,[r,s]=c.getMinMaxZoom(e.scaleInfo,n),_=new f(e.materialKey,a,e.outlineSize*e.sizeRatio,e.referenceSize,l.premultiplyAlphaRGBA(e.color),l.premultiplyAlphaRGBA(e.outlineColor),e.horizontalAlignment,e.verticalAlignment,e.alignment,e.decoration,e.colorLocked,e.angle,e.offsetX*e.sizeRatio*o,e.offsetY*e.sizeRatio*o,512,1,e.markerPlacement,e.effects,!0,r,s),[,m]=t.bidiText(e.text);return _.bindTextInfo(i,m),_._vertexBoundsScale=e.maxVVSize?e.maxVVSize/a:1,_},f}(_(f))}));
