1import{m as i}from"./module.esm-CCyjftVT.js";import{d as n}from"./vendor-react-B6KoJ4Um.js";import{d as r,a as o}from"./timezone-Db1JuaCx.js";import"./vendor-bootstrap-4PcyVVVI.js";const m=()=>({cartArticleContentsStore:i.store("cartArticleContents"),config:{eventsDataUrl:"",templateDataUrl:"",templateId:"",article:{id:"",price:0}},minDate:null,isLoading:!1,selectedDate:null,selectedEventEffectiveEnd:null,selectedEventEffectiveStart:null,selectedEventEnd:null,selectedEventStart:null,selectedGenderOption:"",v10Events:[],v10Store:i.store("v10ReservationStore"),v10TemplateData:{id:"",askForGenderRequirement:!1},initHandler(t){const e=new Date().toISOString().split("T")[0];n.extend(r),n.extend(o),n.tz.setDefault(i.store("shopTimeZone")),this.v10Store.setV10ArticleExists(!0),this.config=t,this.minDate=e,this.selectedDate=e,this.selectedGenderOption="N",this.changeHandler(),this.fetchV10TemplateData().then(s=>{this.v10TemplateData=s}).catch(s=>{console.error(s)}),this.cartArticleContentsStore.items[t.article.id]={price:t.article.price,quantity:0}},isEventSelected(){return this.selectedEventStart!==null&&this.selectedEventEnd!==null},changeHandler(){this.selectedDate!==null&&this.selectedGenderOption!==""&&this.fetchV10Events().then(t=>{this.v10Events=t}).catch(t=>{console.error(t)}).finally(()=>{this.isLoading=!1})},selectEvent(t){this.selectedEventEffectiveEnd=t.effectiveEnd,this.selectedEventEffectiveStart=t.effectiveStart,this.selectedEventEnd=t.end,this.selectedEventStart=t.start,this.v10Store.setPickedEventId(t.id);const e=this.config.article.id;
1this.cartArticleContentsStore.items[e]&&Object.hasOwn(this.cartArticleContentsStore.items[e],"quantity")&&(this.cartArticleContentsStore.items[e].quantity=1,this.cartArticleContentsStore.items[e].id=e,this.cartArticleContentsStore.items[e].name="")},async fetchV10Events(){this.isLoading=!0,this.removeEventSelection();const t=new URL(`${this.config.eventsDataUrl}`,document.URL),e=n();let s=`${this.selectedDate}T00:00:00.000+00:00`;e.format("YYYY-MM-DD")===this.selectedDate&&(s=e.add(1,"minute").format("YYYY-MM-DDTHH:mm:ss.SSS+00:00")),t.searchParams.set("template_id",this.config.templateId),t.searchParams.set("start",s),t.searchParams.set("end",`${this.selectedDate}T23:59:59.999+00:00`),t.searchParams.set("v10_reservation_staff_gender",this.selectedGenderOption);const a=await fetch(t);if(a.ok)return await a.json();throw new Error(`Could not fetch v10 reservation event data (response status ${a.status} )`)},async fetchV10TemplateData(){const t=new URL(`${this.config.templateDataUrl}`,document.URL),e=await fetch(t);if(e.ok)return await e.json();throw new Error(`Could not fetch v10 reservation template data (response status ${e.status} )`)},formatDateToShow(t){const e=n(t),s=i.store("shopTimeZone");return e.tz(s).format("HH:mm")},removeEventSelection(){this.selectedEventStart=null,this.selectedEventEnd=null,this.v10Store.setPickedEventId(null);const t=this.config.article.id;
1this.cartArticleContentsStore.items[t]&&Object.hasOwn(this.cartArticleContentsStore.items[t],"quantity")&&(this.cartArticleContentsStore.items[t].quantity=0)}});export{m as v};
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.