import{Component}from"@theme/component";const INLINE_LAYOUT="inline",STACKED_LAYOUT="stacked",INLINE_LAYOUT_MIN_WIDTH=701,WIDTH_TOLERANCE=1;class DisclosuresSummaryFit extends Component{#animationFrame=0;#abortController=new AbortController;#resizeObserver=new ResizeObserver(()=>this.#scheduleMeasure());#mutationObserver=new MutationObserver(()=>this.#scheduleMeasure());connectedCallback(){super.connectedCallback(),this.#connectObservers(),this.#scheduleMeasure()}disconnectedCallback(){this.#disconnectObservers(),super.disconnectedCallback()}updatedCallback(){super.updatedCallback(),this.#connectObservers(),this.#scheduleMeasure()}get#summaryContent(){const summaryContent=this.querySelector(".disclosures__summary-content");return summaryContent instanceof HTMLElement?summaryContent:null}get#summaryItem(){const summaryItem=this.querySelector(".disclosures__summary-content > .disclosures__summary-item");return summaryItem instanceof HTMLElement?summaryItem:null}#connectObservers(){this.#disconnectObservers(),this.#abortController=new AbortController;const summaryContent=this.#summaryContent,summaryItem=this.#summaryItem;summaryContent&&this.#resizeObserver.observe(summaryContent),summaryItem&&this.#mutationObserver.observe(summaryItem,{attributes:!0,characterData:!0,childList:!0,subtree:!0});for(const image of this.querySelectorAll(".disclosures__summary-content .details__icon"))image.addEventListener("load",this.#scheduleMeasure,{signal:this.#abortController.signal});const fontsReady=document.fonts?.ready;if(fontsReady){const{signal}=this.#abortController;fontsReady.then(()=>{signal.aborted||this.#scheduleMeasure()})}}#disconnectObservers(){this.#abortController.abort(),this.#resizeObserver.disconnect(),this.#mutationObserver.disconnect(),this.#animationFrame&&(window.cancelAnimationFrame(this.#animationFrame),this.#animationFrame=0)}#scheduleMeasure=()=>{this.#animationFrame||(this.#animationFrame=window.requestAnimationFrame(()=>{this.#animationFrame=0,this.#measure()}))};#measure(){const summaryContent=this.#summaryContent,summaryItem=this.#summaryItem;if(!summaryContent||!summaryItem){this.#setLayout(STACKED_LAYOUT);return}const availableWidth=summaryContent.getBoundingClientRect().width;if(availableWidth<INLINE_LAYOUT_MIN_WIDTH){this.#setLayout(STACKED_LAYOUT);return}const nextLayout=this.#measureRequiredWidth(summaryItem)<=availableWidth+WIDTH_TOLERANCE?INLINE_LAYOUT:STACKED_LAYOUT;this.#setLayout(nextLayout)}#measureRequiredWidth(summaryItem){const clone=summaryItem.cloneNode(!0);if(!(clone instanceof HTMLElement))return 0;clone.classList.add("disclosures__summary-item--measure"),clone.setAttribute("aria-hidden","true"),this.append(clone);try{return clone.getBoundingClientRect().width}finally{clone.remove()}}#setLayout(layout){this.dataset.summaryLayout!==layout&&(this.dataset.summaryLayout=layout)}}customElements.get("disclosures-summary-fit")||customElements.define("disclosures-summary-fit",DisclosuresSummaryFit);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/disclosures-summary-fit.js.map?v=1783078800
