import{Component}from"@theme/component";class ProductTitle extends Component{constructor(){super()}connectedCallback(){super.connectedCallback(),this.#initializeTruncation()}#initializeTruncation(){"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver(()=>{this.#calculateTruncation()}),this.resizeObserver.observe(this),this.#calculateTruncation()):(window.addEventListener("resize",this.#handleResize.bind(this)),this.#calculateTruncation())}#calculateTruncation(){const textElement=this.refs.text||this.querySelector(".title-text")||this;if(!textElement.textContent)return;const containerHeight=this.clientHeight,computedStyle=window.getComputedStyle(this),lineHeight=parseFloat(computedStyle.lineHeight),paddingTop=parseFloat(computedStyle.paddingTop),paddingBottom=parseFloat(computedStyle.paddingBottom),availableHeight=containerHeight-paddingTop-paddingBottom,maxLines=Math.max(1,Math.floor(availableHeight/lineHeight));textElement.style.display="-webkit-box",textElement.style.webkitBoxOrient="vertical",textElement.style.overflow="hidden",textElement.style.textOverflow="ellipsis",textElement.style.webkitLineClamp=String(maxLines)}#handleResize(){this.#calculateTruncation()}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver&&this.resizeObserver.disconnect(),window.removeEventListener("resize",this.#handleResize)}}customElements.get("product-title")||customElements.define("product-title",ProductTitle);export default ProductTitle;
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/product-title-truncation.js.map?v=1783128609
