import{r as t,h as i,H as s,g as e}from"./p-6b2342e0.js";import{c as o,M as h,I as l}from"./p-6e1ab235.js";import{V as a,I as n}from"./p-8ce9e214.js";import{j as r,k as c}from"./p-ec2a1d4c.js";import{P as d}from"./p-81dd00d0.js";import"./p-49a2e141.js";import"./p-d4ea8e22.js";import"./p-ed45b3b6.js";import"./p-b75ee3ba.js";var p=function(t,i,s,e){var o,h=arguments.length,l=h<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,i,s,e);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(l=(h<3?o(l):h>3?o(i,s,l):o(i,s))||l);return h>3&&l&&Object.defineProperty(i,s,l),l};class v extends d{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&&(this.host.style.minWidth="auto",r(this.host)?(this.createTooltip().componentOnReady().then((()=>{this.updateTooltipDisplayText()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.host&&this.host.isConnected&&(this.host.style.minWidth="auto",this.tooltipRef&&(this.tooltipRef.innerText=this.content),r(this.host)?this.tooltipRef&&this.updateTooltipDisplayText():this.tooltipRef&&this.tooltipRef.classList.contains("hydrated")&&(this.host.innerText=this.content,this.tooltipRef.remove(),this.tooltipRef=null))}))}))):this.tooltipRef&&this.tooltipRef.classList.contains("hydrated")&&(this.host.innerText=this.content,this.tooltipRef.remove(),this.tooltipRef=null))},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,this.host.replaceChildren(this.tooltipRef)),this.tooltipRef},this.updateTooltipDisplayText=async()=>{let t=parseFloat(c(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(r(this.tooltipRef))for(let t=i;t>=1&&(this.tooltipRef.textContent=this.truncateStringWithEllipsis(t),r(this.tooltipRef));t--)if(t<=1){this.insertMinWidthStyle();break}},this.truncateStringWithEllipsis=t=>this.content.substring(0,t)+"...",this.initTextContent=()=>{this.content=this.host.textContent}}componentDidLoad(){this.initTextContent()}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([o()],v.prototype,"host",void 0),p([o()],v.prototype,"tooltip",void 0),p([o()],v.prototype,"overflow",void 0),p([h("componentDidLoad")],v.prototype,"componentDidLoad",null),p([h("watchTooltip")],v.prototype,"watchTooltip",null);var u=function(t,i,s,e){var o,h=arguments.length,l=h<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,i,s,e);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(l=(h<3?o(l):h>3?o(i,s,l):o(i,s))||l);return h>3&&l&&Object.defineProperty(i,s,l),l};const m=class{constructor(i){t(this,i),this.globalSlimmers={},this.tooltipRenderer=new v,this.vegaComponentUsageRuntimeMetricsSlimmer=new a,this.overflow="newline"}watchTooltip(){}componentDidLoad(){}render(){return i(s,{class:{"vega-container-text-ellipsis":"ellipsis"===this.overflow,"vega-container-text-newline":"newline"===this.overflow}},i("slot",null))}get host(){return e(this)}static get watchers(){return{tooltip:["watchTooltip"]}}};u([n()],m.prototype,"globalSlimmers",void 0),u([l()],m.prototype,"tooltipRenderer",void 0),u([l()],m.prototype,"vegaComponentUsageRuntimeMetricsSlimmer",void 0),m.style=":host{display:block}:host(.vega-container-text-newline){overflow-wrap:break-word}:host(.vega-container-text-ellipsis){word-break:break-all}";export{m as vega_text}