import{n as e}from"./pinia-D94NEbtV.js";var t=`kn-checkout-v1`,n=[`guest`,`signin`,`register`];function r(){return{name:``,company:``,street:``,postalCode:``,city:``,country:`AT`,phone:``}}function i(){return{accountMode:`guest`,email:``,acceptsMarketing:!1,password:``,passwordConfirm:``,firstName:``,lastName:``,billingSame:!0,shippingAddress:r(),billingAddress:r()}}function a(){if(typeof sessionStorage>`u`)return i();try{let e=sessionStorage.getItem(t);if(!e)return i();let n=JSON.parse(e);return{...i(),...n}}catch{return i()}}function o(e){if(!(typeof sessionStorage>`u`))try{let{password:n,passwordConfirm:r,...i}=e;sessionStorage.setItem(t,JSON.stringify(i))}catch{}}function s(e){return e?[`name`,`street`,`postalCode`,`city`,`country`].every(t=>String(e[t]||``).trim().length>0):!1}var c=e(`checkout`,{state:()=>a(),getters:{accountComplete(e){return!e.email||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email.trim())?!1:e.accountMode===`signin`?e.password.length>=8:e.accountMode===`register`?e.password.length>=8&&e.password===e.passwordConfirm:!0},shippingComplete(e){return s(e.shippingAddress)?e.billingSame?!0:s(e.billingAddress):!1}},actions:{setAccountMode(e){n.includes(e)&&(this.accountMode=e,this.persist())},update(e){Object.assign(this,e),this.persist()},updateShipping(e){this.shippingAddress={...this.shippingAddress,...e},this.persist()},updateBilling(e){this.billingAddress={...this.billingAddress,...e},this.persist()},persist(){o(this.$state)},reset(){Object.assign(this,i()),typeof sessionStorage<`u`&&sessionStorage.removeItem(t)}}});export{c as t};