async function getCartDrawerContent(){const t=await fetch(`${Joomla.getOptions("easystore.base")}/index.php?option=com_easystore&task=display.createDrawer`);const e=await t.json();document.body.insertAdjacentHTML("beforeend",e.data)}window.addEventListener("alpine:init",async()=>{getCartDrawerContent();Alpine.data("cartDrawer",()=>{return{init(){this.$watch("open",async t=>{this.isLoading=true;if(t){this.updateDrawerContent()}else{this.$refs.drawerContent.innerHTML=null}this.isLoading=false});window.addEventListener("keyup",t=>{if(t.key==="Escape"&&document.body.classList.contains("easystore-drawer-active")){this.closeDrawer()}})},open:false,isLoading:false,checkout_url:"",openDrawer(){this.open=true;document.body.classList.add("easystore-drawer-active")},closeDrawer(){this.$refs.drawerContainer.classList.add("easystore-drawer-closing");setTimeout(()=>{this.open=false;document.body.classList.remove("easystore-drawer-active");document.body.classList.remove("easystore-modal-open");this.$refs.drawerContainer.classList.remove("easystore-drawer-closing");const t=document.body.classList.contains("view-cart");const e=document.body.classList.contains("view-checkout");if(t||e){window.location.reload()}},300)},async fetchData(){const t=await fetch(`${Joomla.getOptions("easystore.base")}/index.php?option=com_easystore&task=cart.getCartDrawerContent`);const e=await t.json();return e},async clearCart(){const t=await fetch(`${Joomla.getOptions("easystore.base")}/index.php?option=com_easystore&task=cart.clearCart`);const e=await t.json();if(e.data.status===200){this.updateDrawerContent()}return false},async updateDrawerContent(){const t=await this.fetchData();this.$refs.drawerContent.innerHTML=t.data.content;this.checkout_url=t.data.checkout_url}}})});