1import{Component}from"@theme/component";import{debounce,isClickedOutside,onAnimationEnd}from"@theme/utilities";export class DialogComponent extends Component{requiredRefs=["dialog"];connectedCallback(){super.connectedCallback(),(this.minWidth||this.maxWidth)&&window.addEventListener("resize",this.#handleResize)}disconnectedCallback(){super.disconnectedCallback(),(this.minWidth||this.maxWidth)&&window.removeEventListener("resize",this.#handleResize)}#handleResize=debounce(()=>{const{minWidth,maxWidth}=this;if(!minWidth&&!maxWidth)return;const windowWidth=window.innerWidth;(windowWidth<minWidth||windowWidth>maxWidth)&&this.closeDialog()},50);#previousScrollY=0;#scrollLocked=!1;showDialog(){const{dialog}=this.refs;if(dialog.open)return;const scrollY=window.scrollY;this.#previousScrollY=scrollY,requestAnimationFrame(()=>{this.nonModal||(document.body.style.width="100%",document.body.style.position="fixed",document.body.style.top=`-${scrollY}px`,this.#scrollLocked=!0),this.nonModal?dialog.show():dialog.showModal(),this.dispatchEvent(new DialogOpenEvent),this.addEventListener("click",this.#handleClick),this.addEventListener("keydown",this.#handleKeyDown),this.nonModal&&document.addEventListener("click",this.#handleDocumentClick)})}closeDialog=async()=>{const{dialog}=this.refs;dialog.open&&(this.removeEventListener("click",this.#handleClick),this.removeEventListener("keydown",this.#handleKeyDown),document.removeEventListener("click",this.#handleDocumentClick),dialog.style.animation="none",dialog.offsetWidth,dialog.classList.add("dialog-closing"),dialog.style.animation="",await onAnimationEnd(dialog,void 0,{subtree:!1}),this.#scrollLocked&&(document.body.style.width="",document.body.style.position="",document.body.style.top="",window.scrollTo({top:this.#previousScrollY,behavior:"instant"}),this.#scrollLocked=!1),dialog.close(),dialog.classList.remove("dialog-closing"),this.dispatchEvent(new DialogCloseEvent))};toggleDialog=()=>{this.refs.dialog.open?this.closeDialog():this.showDialog()};#handleClick(event){const{dialog}=this.refs;isClickedOutside(event,dialog)&&this.closeDialog()}#handleDocumentClick=event=>{if(!this.nonModal)return;const{dialog}=this.refs,target=event.target;target instanceof Element&&target.closest('.aa-DetachedOverlay, .aa-DetachedContainer, .aa-Panel, [class^="ais-"], [class*=" ais-"]')||target instanceof Node&&!dialog.contains(target)&&this.closeDialog()};#handleKeyDown(event){event.key==="Escape"&&(event.preventDefault(),this.closeDialog())}get minWidth(){return Number(this.getAttribute("dialog-active-min-width"))}get maxWidth(){return Number(this.getAttribute("dialog-active-max-width"))}get nonModal(){return this.hasAttribute("non-modal")}}customElements.get("dialog-component")||customElements.define("dialog-component",DialogComponent);export class DialogOpenEvent extends CustomEvent{constructor(){super(DialogOpenEvent.eventName)}static eventName="dialog:open"}export class DialogCloseEvent extends CustomEvent{constructor(){super(DialogCloseEvent.eventName)}static eventName="dialog:close"}document.addEventListener("toggle",event=>{if(event.target instanceof HTMLDetailsElement&&event.target.hasAttribute("scroll-lock")){const{open}=event.target;open?document.documentElement.setAttribute("scroll-lock",""):document.documentElement.removeAttribute("scroll-lock")}},{capture:!0}); 2//# sourceMappingURL=/cdn/shop/t/1/assets/dialog.js.map?v=146611567174897408381779920164
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.