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;showDialog(options={}){const{dialog}=this.refs;if(dialog.open)return;const scrollY=window.scrollY;this.#previousScrollY=scrollY;const isCoarsePointer=window.matchMedia("(hover: none) and (pointer: coarse)").matches,immediate=options.immediate??(this.id==="search-modal"&&isCoarsePointer),openDialog=()=>{document.body.style.width="100%",document.body.style.position="fixed",document.body.style.top=`-${scrollY}px`,dialog.showModal(),this.dispatchEvent(new DialogOpenEvent),options.onOpen?.(),this.addEventListener("click",this.#handleClick),this.addEventListener("keydown",this.#handleKeyDown)};immediate?openDialog():requestAnimationFrame(openDialog)}closeDialog=async()=>{const{dialog}=this.refs;dialog.open&&(this.removeEventListener("click",this.#handleClick),this.removeEventListener("keydown",this.#handleKeyDown),dialog.classList.add("dialog-closing"),await onAnimationEnd(dialog,void 0,{subtree:!1}),document.body.style.width="",document.body.style.position="",document.body.style.top="",window.scrollTo({top:this.#previousScrollY,behavior:"instant"}),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,stickyBar=document.getElementById("mobile-sticky-filter-sort-bar"),target=event.target;if(stickyBar&&target instanceof Element&&stickyBar.contains(target)){const clickedButton=target.closest(".mobile-sticky-filter-sort-bar__button");if(clickedButton instanceof HTMLElement){const isFilterButton=clickedButton.classList.contains("mobile-sticky-filter-sort-bar__button--filter"),isSortButton=clickedButton.classList.contains("mobile-sticky-filter-sort-bar__button--sort"),filterDrawer=document.getElementById("filters-drawer"),sortPopup=document.getElementById("mobile-sort-popup");if(isFilterButton&&sortPopup&&this.id==="mobile-sort-popup"){event.preventDefault(),event.stopPropagation(),this.closeDialog(),setTimeout(()=>{filterDrawer&&"showDialog"in filterDrawer&&typeof filterDrawer.showDialog=="function"&&filterDrawer.showDialog()},50);return}if(isSortButton&&filterDrawer&&this.id==="filters-drawer"){event.preventDefault(),event.stopPropagation(),this.closeDialog(),setTimeout(()=>{sortPopup&&"showDialog"in sortPopup&&typeof sortPopup.showDialog=="function"&&sortPopup.showDialog()},50);return}}}const windowHeight=window.innerHeight;event.clientY>windowHeight-58||isClickedOutside(event,dialog)&&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"))}}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/571/assets/dialog.js.map?v=78684071807082385361782290355
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.