import{prefersReducedMotion}from"@theme/utilities";class JumboText extends HTMLElement{connectedCallback(){requestAnimationFrame(this.#handleResize),this.dataset.textEffect&&this.dataset.textEffect!=="none"&&!prefersReducedMotion()&&this.#setIntersectionObserver()}disconnectedCallback(){this.#resizeObserver.disconnect(),this.dataset.textEffect&&this.dataset.textEffect!=="none"&&!prefersReducedMotion()&&this.intersectionObserver?.disconnect()}#setIntersectionObserver(){this.intersectionObserver=new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting?(this.classList.add("jumbo-text-visible"),this.dataset.animationRepeat==="false"&&this.intersectionObserver.unobserve(entry.target)):this.classList.remove("jumbo-text-visible")})},{threshold:.3}),this.intersectionObserver.observe(this)}#calculateOptimalFontSize=()=>{if(!this.textContent?.trim()||(this.classList.remove("ready"),this.offsetWidth<=0))return;this.#resizeObserver.disconnect(),this.style.fontSize="1px";const fontSize=findOptimalFontSize(this,this.offsetWidth);this.style.fontSize=`${fontSize}px`,this.#resizeObserver.observe(this),this.classList.add("ready")};#handleResize=()=>{this.#calculateOptimalFontSize();const bottom=this.getBoundingClientRect().bottom+window.scrollY,distanceFromBottom=document.documentElement.offsetHeight-bottom;this.dataset.capText=(distanceFromBottom<=100).toString()};#resizeObserver=new ResizeNotifier(this.#handleResize)}function checkTextOverflow(element,containerWidth,size){return element.style.fontSize=`${size}px`,element.scrollWidth>containerWidth}function findOptimalFontSize(element,containerWidth){let minSize=1,maxSize=500;const precision=.5,textLength=element.textContent?.length||0;let fontSize=Math.min(maxSize,Math.sqrt(containerWidth)*(15/Math.sqrt(Math.max(1,textLength))));checkTextOverflow(element,containerWidth,fontSize)?maxSize=fontSize:minSize=fontSize;let iterations=0;const MAX_ITERATIONS=30;for(;maxSize-minSize>precision&&iterations<MAX_ITERATIONS;)fontSize=(minSize+maxSize)/2,checkTextOverflow(element,containerWidth,fontSize)?maxSize=fontSize:minSize=fontSize,iterations++;return minSize*.99}customElements.get("jumbo-text")||customElements.define("jumbo-text",JumboText);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/jumbo-text.js.map?v=1783128568
