/*
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","../../../../Color","../../../../core/Logger","../../../../core/maybe","../../../../core/screenUtils","../../../../chunks/vec4f64"],(function(o,e,t,r,n,i,l){"use strict";const a=r.getLogger("esri.views.3d.webgl-engine.lib.TextRenderParameters");let s=function(){function o(o){this.definition=o,this.key=JSON.stringify(o),this.haloSize=Math.round(o.halo.size),this.textStyle=this._colorToRGBA(o.color),this.haloStyle=this._colorToRGB(o.halo.color),this.backgroundStyle=0!==o.background.color[3]?this._colorToRGBA(o.background.color):null}var r=o.prototype;return r.fontString=function(o){const e=this.definition.font;return`${e.style} ${e.weight} ${o}px ${e.family}, sans-serif`},r._colorToRGB=function(o){return`rgb(${o.slice(0,3).map((o=>Math.floor(255*o))).toString()})`},r._colorToRGBA=function(o){return`rgba(${o.slice(0,3).map((o=>Math.floor(255*o))).toString()},${o[3]})`},o.fromSymbol=function(){var r=e._asyncToGenerator((function*(e,r=1){const s=n.get(e,"material","color"),c=n.mapOr(s,l.ZEROS,t.toUnitRGBA),u=n.mapOr(e.size,12,i.pt2px),f=e.lineHeight,g=n.isSome(e.background)?t.toUnitRGBA(e.background.color):l.ZEROS,d={family:n.mapOr(e.font,"sans-serif",(o=>o.family)),decoration:n.mapOr(e.font,"none",(o=>o.decoration)),weight:n.mapOr(e.font,"normal",(o=>o.weight)),style:n.mapOr(e.font,"normal",(o=>o.style))},m=e.halo,h=n.isSome(m)&&n.isSome(m.color)&&m.size>0?{size:i.pt2px(m.size),color:t.toUnitRGBA(m.color)}:{size:0,color:l.ZEROS},p=new o({color:c,size:u,background:{color:g,padding:n.isSome(e.background)?[.65*u,.5*u]:[0,0],borderRadius:n.isSome(e.background)?u*(6/16):0},lineSpacingFactor:f,font:d,halo:h,pixelRatio:r}),y=p.fontString(u);try{yield document.fonts.load(y)}catch(S){a.warnOnce(`Failed to preload font '${y}'. Some text symbology may be rendered using the default browser font.`)}return p}));function s(o){return r.apply(this,arguments)}return s}(),o}();o.TextRenderParameters=s,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
