import{debounce,requestIdleCallback,viewTransition}from"@theme/utilities";const OFFSET=40;export class FloatingPanelComponent extends HTMLElement{#updatePosition=async()=>{viewTransition.current&&await viewTransition.current;const rect=this.getBoundingClientRect(),viewportWidth=window.innerWidth;if(this.style.top=OFFSET+"px",rect.right>viewportWidth){const overflowAmount=rect.right-viewportWidth+OFFSET;this.style.left=`-${overflowAmount}px`}if(rect.left<0){const overflowAmount=Math.abs(rect.left)+OFFSET;this.style.left=`${overflowAmount}px`}this.#mutationObserver.takeRecords()};#mutationObserver=new MutationObserver(this.#updatePosition);#resizeListener=debounce(()=>{const parent=this.closest("details"),closeOnResize=this.dataset.closeOnResize==="true";parent instanceof HTMLDetailsElement&&closeOnResize&&(parent.open=!1,parent.removeAttribute("open"),this.#updatePosition())},100);connectedCallback(){window.addEventListener("resize",this.#resizeListener),requestIdleCallback(()=>{this.#updatePosition(),this.#mutationObserver.observe(this,{attributes:!0})})}disconnectedCallback(){window.removeEventListener("resize",this.#resizeListener),this.#mutationObserver.disconnect()}}customElements.get("floating-panel-component")||customElements.define("floating-panel-component",FloatingPanelComponent);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/floating-panel.js.map?v=1783128494
