class DetailsModal extends HTMLElement{constructor(){super(),this.hideDelay=205,this.detailsContainer=this.querySelector("details"),this.summaryToggle=this.querySelector("summary"),this.detailsContainer.addEventListener("keyup",event=>event.code.toUpperCase()==="ESCAPE"&&this.close()),this.summaryToggle.addEventListener("click",this.onSummaryClick.bind(this)),this.querySelector('button[type="button"]').addEventListener("click",this.close.bind(this)),this.summaryToggle.setAttribute("role","button")}isOpen(){return this.detailsContainer.hasAttribute("open")}onSummaryClick(event){event.preventDefault(),event.target.closest("details").hasAttribute("open")?this.close():this.open(event)}onBodyClick(event){(!this.contains(event.target)||event.target.classList.contains("modal-overlay"))&&this.close(!1)}open(){this.onBodyClickEvent=this.onBodyClickEvent||this.onBodyClick.bind(this),this.detailsContainer.classList.add("closed"),this.detailsContainer.setAttribute("open",!0),setTimeout(()=>{this.detailsContainer.classList.remove("closed")}),this.addEventListener("click",this.onBodyClickEvent),window.isIOS?this.lockScrollIOS():document.body.classList.add("overflow-hidden"),trapFocus(this.detailsContainer.querySelector('[tabindex="-1"]'),this.detailsContainer.querySelector('input:not([type="hidden"])'))}close(focusToggle=!0){this.detailsContainer.classList.add("closed"),setTimeout(()=>{removeTrapFocus(focusToggle?this.summaryToggle:null),this.detailsContainer.removeAttribute("open"),this.removeEventListener("click",this.onBodyClickEvent),window.isIOS?this.unlockScrollIOS():document.body.classList.remove("overflow-hidden"),this.detailsContainer.classList.remove("closed")},this.hideDelay)}lockScrollIOS(){this.scrollPosition=window.scrollY,document.body.style.position="fixed",document.body.style.top=`-${this.scrollPosition}px`,document.body.style.width="100%",document.body.classList.add("overflow-hidden")}unlockScrollIOS(){document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.classList.remove("overflow-hidden")}}customElements.define("details-modal",DetailsModal);
//# sourceMappingURL=/cdn/shop/t/365/assets/details-modal.js.map?v=81051398097110120041753250040