// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["../../core/screenUtils","../support/textUtils"],function(p,u){function t(c){return`rgba(${c.slice(0,3).toString()},${c[3]})`}function r(c,a){var d=a.font;d=`${d.style} ${d.weight} ${p.pt2px(Math.max(a.size,.5)*a.pixelRatio).toFixed(1)}px ${d.family}, sans-serif`;c.font=d;c.textBaseline="top";switch(a.horizontalAlignment){case "left":a="left";break;case "right":a="right";break;case "center":a="center";break;default:a="left"}c.textAlign=a}class v{constructor(c){c&&(this._textRasterizationCanvas= c)}rasterizeText(c,a){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const d=this._textRasterizationCanvas;var b=d.getContext("2d",{willReadFrequently:!0});r(b,a);this._parameters=a;this._textLines=c.split(/\r?\n/);this._lineHeight=this._computeLineHeight();const {decoration:l,weight:m}=a.font;this._lineThroughWidthOffset=l&&"line-through"===l?.1*this._lineHeight:0;var e=(c=null!=a.backgroundColor||null!=a.borderLine)?u.backgroundPadding:0,f=this._computeTextWidth(b, a)+2*e,h=this._lineHeight*this._textLines.length+2*e;d.width=f+2*this._lineThroughWidthOffset;d.height=h;if(0===d.width||0===d.height)return d.width=d.height=1,{size:[0,0],image:new Uint32Array(0),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,canvas:d};this._renderedLineHeight=Math.round(this._lineHeight*a.pixelRatio);this._renderedHaloSize=p.pt2px(a.halo.size)*a.pixelRatio;this._renderedWidth=f*a.pixelRatio;this._renderedHeight=h*a.pixelRatio;this._lineThroughWidthOffset*=a.pixelRatio;f=a.halo&&a.halo.color? a.halo.color:[0,0,0,0];this._fillStyle=t(a.color??[0,0,0,0]);this._haloStyle=`rgb(${f.slice(0,3).toString()})`;f=this._renderedLineHeight;var g=this._renderedHaloSize;b.save();b.clearRect(0,0,d.width,d.height);r(b,a);h=e*a.pixelRatio;e=b.textAlign;var k=this._renderedWidth-2*h;e=("center"===e?.5*k:"right"===e?k:0)+g+h;h=g+h;g=0g;g++){const k=(.6+.1*g)*h;c.lineWidth=k;c.strokeText(f,a,d);b&&"none"!==b&&this._renderDecoration(c,a,d,b,l,k)}d+=m}}computeTextSize(c,a){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const d=this._textRasterizationCanvas;var b=d.getContext("2d");r(b,a);this._parameters=a;this._textLines= c.split(/\r?\n/);this._lineHeight=this._computeLineHeight();c=this._computeTextWidth(b,a);b=this._lineHeight*this._textLines.length;d.width=c;d.height=b;return[c*a.pixelRatio,b*a.pixelRatio]}_computeTextWidth(c,a){let d=0;for(const b of this._textLines)d=Math.max(d,c.measureText(b).width);a=a.font;if("italic"===a.style||"oblique"===a.style||"string"===typeof a.weight&&("bold"===a.weight||"bolder"===a.weight)||"number"===typeof a.weight&&600