import{aD as t,aE as i,bv as s,bO as e,bP as o,a$ as h,b0 as a,b1 as l,b2 as n,b3 as r}from"./p-BTBbFFOR.js";import{I as c,V as d}from"./p-ULeawcYN.js";var p=function(t,i,s,e){var o,h=arguments.length,a=h<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,i,s,e);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(a=(h<3?o(a):h>3?o(i,s,a):o(i,s))||a);return h>3&&a&&Object.defineProperty(i,s,a),a};class v extends s{componentDidLoad(){this.initTextContent()}constructor(){super({target:()=>[this.host,document.body],callback:()=>{"ellipsis"===this.overflow&&(this.tooltipRef&&(this.tooltipRef.innerText=this.content),this.handleTooltip())},isDeferred:!0}),this.handleTooltip=async()=>{0!==this.host.clientWidth&&(e(this.host)?this.createTooltip().componentOnReady().then((()=>{this.updateTooltipDisplayText()})):(this.tooltipRef&&this.tooltipRef.classList.contains("hydrated")&&(this.host.innerText=this.content,this.tooltipRef.remove(),this.tooltipRef=null),this.host.style.minWidth="auto"))},this.createTooltip=()=>{var t,i,s;return this.tooltipRef=this.host.querySelector("vega-tooltip"),this.tooltipRef||(this.tooltipRef=document.createElement("vega-tooltip"),this.tooltipRef.text=this.content,this.tooltipRef.innerText=this.content,this.tooltipRef.placement=null===(t=this.tooltip)||void 0===t?void 0:t.placement,this.tooltipRef.maxWidth=null===(i=this.tooltip)||void 0===i?void 0:i.maxWidth,this.tooltipRef.minWidth=null===(s=this.tooltip)||void 0===s?void 0:s.minWidth,"function"==typeof this.host.replaceChildren&&this.host.replaceChildren(this.tooltipRef)),this.tooltipRef},this.updateTooltipDisplayText=async()=>{let t=parseFloat(o(this.host,"font-size"));t=isNaN(t)?v.DEFAULT_FONT_SIZE:t;const i=Math.floor(this.host.getBoundingClientRect().width/Math.floor(t/2));if(e(this.tooltipRef))for(let t=i;t>=1&&(this.tooltipRef.textContent=this.truncateStringWithEllipsis(t),e(this.tooltipRef));t--)if(t<=1){this.insertMinWidthStyle();break}},this.truncateStringWithEllipsis=t=>this.content.substring(0,t)+"...",this.initTextContent=()=>{this.content=this.host.textContent}}watchTooltip(){var t,i,s;this.tooltipRef&&(this.tooltipRef.placement=null===(t=this.tooltip)||void 0===t?void 0:t.placement,this.tooltipRef.maxWidth=null===(i=this.tooltip)||void 0===i?void 0:i.maxWidth,this.tooltipRef.minWidth=null===(s=this.tooltip)||void 0===s?void 0:s.minWidth)}insertMinWidthStyle(){let t=this.host.shadowRoot.querySelector("#min-width-placeholder");t||(t=document.createElement("span"),t.id="min-width-placeholder",t.style.cssText="position:absolute; visibility:hidden; word-break:keep-all;",this.host.shadowRoot.appendChild(t)),t.textContent=this.truncateStringWithEllipsis(1),this.host.style.minWidth=t.getBoundingClientRect().width+"px"}}v.DEFAULT_FONT_SIZE=16,p([t()],v.prototype,"host",void 0),p([t()],v.prototype,"tooltip",void 0),p([t()],v.prototype,"overflow",void 0),p([i("componentDidLoad")],v.prototype,"componentDidLoad",null),p([i("watchTooltip")],v.prototype,"watchTooltip",null);var f=function(t,i,s,e){var o,h=arguments.length,a=h<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,i,s,e);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(a=(h<3?o(a):h>3?o(i,s,a):o(i,s))||a);return h>3&&a&&Object.defineProperty(i,s,a),a};const u=class{constructor(t){a(this,t),this.globalSlimmers={},this.tooltipRenderer=new v,this.vegaComponentUsageRuntimeMetricsSlimmer=new d,this.overflow="newline"}watchTooltip(){}componentDidLoad(){}render(){return l(n,{key:"a13c92346e9097027783f95fb74bba9523623eca",class:{"vega-container-text-ellipsis":"ellipsis"===this.overflow,"vega-container-text-newline":"newline"===this.overflow}},l("slot",{key:"8ef72be1c1b216620fea1ea6c0a0d0b82dff4035"}))}get host(){return r(this)}static get watchers(){return{tooltip:[{watchTooltip:0}]}}};f([c()],u.prototype,"globalSlimmers",void 0),f([h()],u.prototype,"tooltipRenderer",void 0),f([h()],u.prototype,"vegaComponentUsageRuntimeMetricsSlimmer",void 0),u.style=":host{display:block}:host(.vega-container-text-newline){overflow-wrap:break-word}:host(.vega-container-text-ellipsis){word-break:break-all}";export{u as vega_text}