1import{U as ge,d as we,D as $e,at as ne,V as Ce,u as De,r as u,j as d,o as Se,W as ie,c as s,b as a,y as f,q as _,t as l,e as $,Y as Me,v as w,au as re,F as v,g as y,f as I,ag as ue,x as L,a0 as Ve,A as E,S as ce,N as de,Q as Te,a5 as ze,h as n}from"./index-Bm4GpDNS.js";var Ie=ge("outline","device-mobile","DeviceMobile",[["path",{d:"M6 5a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M11 4h2",key:"svg-1"}],["path",{d:"M12 17v.01",key:"svg-2"}]]);const Le={class:"min-h-screen bg-gray-100 flex flex-col items-center py-6 px-4"},Ne={class:"w-full max-w-lg"},Fe={class:"mb-4 px-4 py-3 bg-primary/10 text-primary rounded-xl text-sm"},je={class:"flex items-start gap-2"},Ue=["innerHTML"],Ae={class:"flex items-center justify-between gap-3 mt-5 pl-7"},Be=["href"],He={class:"bg-white text-black rounded-2xl shadow-sm overflow-hidden"},Ke={class:"p-4 border-b border-black/5 flex items-center gap-2"},Re={class:"font-bold text-lg"},qe={class:"ml-auto flex items-center gap-0.5 bg-black/5 rounded-lg p-0.5 text-xs font-semibold"},Pe={class:"p-4 flex flex-col gap-4"},Ye={key:0,class:"text-center py-12 text-black/40 text-sm"},Ee={key:1,class:"text-center py-12"},Oe={class:"text-black/50 text-sm"},Qe={class:"text-sm text-black/60 flex items-center gap-1 font-medium"},We={key:0,class:"mt-2 text-xs bg-[var(--ochre-100)] text-[var(--ochre-900)] rounded-xl px-3 py-2.5 leading-relaxed"},Ge={key:0,class:"flex gap-2 bg-black/5 rounded-xl p-1"},Je={key:1,class:"flex flex-wrap gap-2"},Xe=["onClick"],Ze={class:"block text-xs font-medium text-black/50 mb-1.5"},et={class:"flex flex-wrap gap-2"},tt=["onClick"],ot={class:"flex gap-2 overflow-x-auto pb-1 -mx-1 px-1 items-stretch"},at=["onClick"],lt=["aria-label"],st={class:"text-xs font-semibold"},nt=["min","max"],it={key:2,class:"text-xs text-amber-600"},rt={key:0,class:"text-center py-8 text-black/40 text-sm"},ut={key:1,class:"text-center py-8 text-black/40 text-sm"},ct={key:2,class:"grid grid-cols-3 gap-2"},dt=["onClick","disabled"],pt={key:0,class:"text-center py-8 text-black/40 text-sm"},bt={key:1,class:"text-center py-8 text-black/40 text-sm"},vt={key:2,class:"grid grid-cols-3 gap-2"},mt=["onClick"],kt={class:"text-sm font-semibold"},ft={class:"text-[10px] text-black/40"},_t={class:"bg-black/[0.03] rounded-xl p-4 flex flex-col gap-1.5 text-sm"},yt={class:"font-semibold text-black/70"},xt={class:"text-black/60 flex items-center gap-1"},ht={class:"text-black/60 flex items-center gap-1"},gt=["placeholder"],wt=["placeholder"],$t=["placeholder"],Ct={class:"text-xs text-black/40 mt-1"},Dt={key:0,class:"flex items-center justify-between px-3 py-2.5 bg-primary/5 border border-primary/20 rounded-xl text-sm"},St={class:"text-black/60"},Mt={class:"font-bold text-black"},Vt={key:1,class:"flex items-center gap-2 px-3 py-2.5 bg-amber-50 border border-amber-200 rounded-xl text-sm text-amber-700"},Tt={class:"flex items-start gap-2 text-xs text-black/65 cursor-pointer"},zt={class:"flex items-start gap-2 text-xs text-black/50 cursor-pointer"},It={key:2,class:"text-xs text-danger"},Lt=["disabled"],Nt=["disabled"],Ft=["disabled"],jt=["disabled"],Ut={key:3,class:"text-center py-8"},At={class:"w-16 h-16 bg-success/10 rounded-full flex items-center justify-center mx-auto mb-4"},Bt={class:"font-bold text-lg mb-1"},Ht={class:"text-sm text-black/50"},pe=5,qt=we({__name:"BookVenueView",setup(Kt){const{t:S,locale:O}=$e();if(!localStorage.getItem("access_token")){const e=localStorage.getItem("10use.public_locale");ne(e==="en"||e==="sk"?e:"sk")}function Q(e){ne(e),localStorage.setItem("10use.public_locale",e)}const W=De(),M=Ce(),G=W.params.venueId,m=u("pick"),J=u(!0),X=u(!1),B=u(""),be=d(()=>/\(demo\)|ukážkov/i.test(B.value)),C=u([]),c=u(null),x=u(null),V=u([]),H=u(!1),p=u(null),r=u({name:"",email:"",phone:"",acceptTerms:!1,acceptMarketing:!1}),h=u(!1),g=u(""),Z=d(()=>{const e=c.value?.allowed_durations;return e&&e.length?e:[60]}),k=u("specific"),T=u([]),K=u(!1),ve=d(()=>{const e=new Set;for(const i of C.value)for(const t of i.allowed_durations||[])e.add(t);const o=[...e].sort((i,t)=>i-t);return o.length?o:[60]}),R=d(()=>k.value==="any"?ve.value:Z.value);function q(e){return`${e.getFullYear()}
1-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}const N=d(()=>{const e=[],o=new Date;o.setHours(0,0,0,0);for(let i=0;i<pe;i++){const t=new Date(o);t.setDate(o.getDate()+i),e.push({iso:q(t),label:i===0?S("public_book.today"):t.toLocaleDateString("sk-SK",{weekday:"short",day:"numeric",month:"numeric"})})}return e}),b=u(N.value[0]?.iso??""),me=d(()=>{const e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()+pe),q(e)}),ke=d(()=>{const e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()+365),q(e)}),ee=d(()=>!N.value.some(e=>e.iso===b.value));function fe(e){const o=e.target.value;o&&(b.value=o)}const P=u(W.query.paid==="1");Se(async()=>{P.value&&(m.value="done");try{const e=await M.fetchPublicVenue(G);B.value=e.venue.display_name,C.value=e.resources,te(e.resources[0]??null),c.value&&await F()}catch{X.value=!0}finally{J.value=!1}});function te(e){c.value=e,x.value=Z.value[0]??60}ie([c,b,x],()=>{k.value==="specific"&&c.value&&F()}),ie([k,b,x],()=>{k.value==="any"&&oe()});async function F(){if(c.value){H.value=!0,V.value=[];try{V.value=await M.fetchPublicAvailability(c.value.id,b.value,b.value,x.value??void 0)}catch{V.value=[]}finally{H.value=!1}}}async function oe(){K.value=!0,T.value=[];try{T.value=await M.fetchVenueFreeSlots(G,b.value,x.value??60)}catch{T.value=[]}finally{K.value=!1}}function ae(e){k.value!==e&&(k.value=e,R.value.includes(x.value??-1)||(x.value=R.value[0]??60),e==="any"?oe():c.value&&F())}function _e(e){const o=e.free_courts[0];if(!o)return;const i=C.value.find(t=>t.id===o.resource_id);i&&(c.value=i),p.value={starts_at:e.starts_at,ends_at:e.ends_at,is_free:!0},g.value="",m.value="form"}function j(e){return new Date(e).toLocaleTimeString("sk-SK",{hour:"2-digit",minute:"2-digit"})}const le=d(()=>{if(b.value===N.value[0]?.iso)return S("public_book.today");const e=new Date(b.value+"T00:00:00");return isNaN(e.getTime())?b.value:e.toLocaleDateString("sk-SK",{weekday:"long",day:"numeric",month:"long",year:"numeric"})});function ye(e){e.is_free&&(p.value=e,g.value="",m.value="form")}const z=d(()=>r.value.name.trim().length>=2&&/.+@.+\..+/.test(r.value.email)&&r.value.phone.trim().length>=6&&r.value.acceptTerms),Y=d(()=>{const e=c.value;return!!e?.payments_active&&(e?.payment_mode==="online"||e?.payment_mode==="both"||e?.payment_mode==null)}),se=d(()=>{const e=c.value;return e?.payments_active?e?.payment_mode==="cash"||e?.payment_mode==="both":!0}),D=d(()=>{const e=c.value?.price_per_hour;if(!e||!p.value)return null;const o=(new Date(p.value.ends_at).getTime()-new Date(p.value.starts_at).getTime())/36e5;return Math.round(parseFloat(e)*o*100)/100});async function U(e="cash"){if(!c.value||!p.value||!z.value)return;h.value=!0,g.value="";const o={resource:c.value.id,starts_at:p.value.starts_at,ends_at:p.value.ends_at,name:r.value.name.trim(),email:r.value.email.trim(),phone:r.value.phone.trim(),accepted_terms:r.value.acceptTerms,accepted_marketing:r.value.acceptMarketing};try{if(e==="online"){const{checkout_url:i}=await M.guestCheckout(o);window.location.href=i;return}await M.guestBook(o),m.value="done"}catch(i){i?.status===409||i?.status===400?(g.value=S("public_book.slot_taken"),m.value="pick",p.value=null,await F()):g.value=i?.message||S("public_book.error")}finally{h.value=!1}}const xe=d(()=>window.location.origin+"/register"),he=d(()=>S("public_book.app_cta").replace("tenuse",'<span style="font-family:var(--wordmark);font-weight:600">tenuse<span style="color:var(--ochre)">.</span></span>'));return(e,o)=>{const i=Te("router-link");return n(),s("div",Le,[a("div",Ne,[a("div",Fe,[a("div",je,[f(_(Ie),{size:18,class:"mt-0.5 shrink-0"}),a("span",{class:"flex-1 font-medium",innerHTML:he.value},null,8,Ue)]),a("div",Ae,[o[15]||(o[15]=a("a",{href:"https://www.tenuse.sk",target:"_blank",rel:"noopener",class:"underline opacity-70 hover:opacity-100"},"www.tenuse.sk",-1)),a("a",{href:xe.value,style:{color:"#fff"},class:"inline-flex items-center px-4 py-2 bg-primary rounded-lg font-semibold hover:opacity-90 transition"},l(e.$t("public_book.app_cta_btn")),9,Be)])]),a("div",He,[a("div",Ke,[m.value==="form"?(n(),s("button",{key:0,onClick:o[0]||(o[0]=t=>{m.value="pick",p.value=null}),class:"p-1 rounded hover:bg-black/5"},[f(_(Me),{size:18,class:"text-black/50"})])):$("",!0),a("h1",Re,l(e.$t("public_book.title")),1),a("div",qe,[a("button",{onClick:o[1]||(o[1]=t=>Q("sk")),class:w(["px-2 py-1 rounded-md transition",_(O)==="sk"?"bg-white text-primary shadow-sm":"text-black/40"])}," SK ",2),a("button",{onClick:o[2]||(o[2]=t=>Q("en")),class:w(["px-2 py-1 rounded-md transition",_(O)==="en"?"bg-white text-primary shadow-sm":"text-black/40"])}," EN ",2)])]),a("div",Pe,[J.value?(n(),s("div",Ye,l(e.$t("public_book.loading")),1)):X.value?(n(),s("div",Ee,[f(_(re),{size:40,"stroke-width":1.5,class:"text-black/20 mx-auto mb-3"}),a("p",Oe,l(e.$t("public_book.not_found")),1)])):(n(),s(v,{key:2},[a("p",Qe,[f(_(re),{size:15,class:"text-primary"}),y(" "+l(B.value),1)]),be.value?(n(),s("p",We,[...o[16]||(o[16]=[y(" Toto je ",-1),a("b",null,"ukážkové Å¡portovisko (demo)",-1),y(" â vyskúšaj si rezerváciu nezáväzne. Nie je to platba, len si pozri ako to funguje. ",-1)])])):$("",!0),m.value==="pick"?(n(),s(v,{key:1},[C.value.length>1?(n(),s("div",Ge,[a("button",{onClick:o[3]||(o[3]=t=>ae("specific")),class:w(["flex-1 px-3 py-1.5 rounded-lg text-xs font-semibold transition",k.value==="specific"?"bg-white text-primary shadow-sm":"text-black/50"])},l(e.$t("public_book.specific_court")),3),a("button",{onClick:o[4]||(o[4]=t=>ae("any")),class:w(["flex-1 px-3 py-1.5 rounded-lg text-xs font-semibold transition",k.value==="any"?"bg-white text-primary shadow-sm":"text-black/50"])},l(e.$t("public_book.any_court")),3)])):$("",!0),k.value==="specific"&&C.value.length>1?(n(),s("div",Je,[(n(!0),s(v,null,I(C.value,t=>(n(),s("button",{key:t.id,onClick:A=>te(t),class:w(["px-3 py-1.5 rounded-full text-xs font-medium border transition",c.value?.id===t.id?"bg-primary/10 text-primary border-primary/30":"bg-black/5 text-black/50 border-transparent"])},l(t.name),11,Xe))),128))])):$("",!0),a("div",null,[a("label",Ze,l(e.$t("public_book.duration")),1),a("div",et,[(n(!0),s(v,null,I(R.value,t=>(n(),s("button",{key:t,onClick:A=>x.value=t,class:w(["px-3 py-1.5 rounded-full text-xs font-semibold border transition",x.value===t?"bg-primary text-white border-primary":"bg-white text-black/60 border-black/15"])},l(t)+"â² ",11,tt))),128))])]),a("div",ot,[(n(!0),s(v,null,I(N.value,t=>(n(),s("button",{key:t.iso,onClick:A=>b.value=t.iso,class:w(["flex-shrink-0 px-3 py-2 rounded-xl text-xs font-medium border transition whitespace-nowrap",b.value===t.iso?"bg-primary text-white border-primary":"bg-white text-black/60 border-black/10"])},l(t.label),11,at))),128)),a("label",{onClick:o[5]||(o[5]=t=>
1t.currentTarget?.querySelector("input")?.showPicker?.()),"aria-label":e.$t("booking.pick_date"),class:w(["relative flex-shrink-0 px-3 py-2 rounded-xl border transition inline-flex items-center gap-1 whitespace-nowrap cursor-pointer",ee.value?"bg-primary text-white border-primary":"bg-white text-primary border-primary/30 hover:bg-primary/5"])},[f(_(ue),{size:16}),a("span",st,l(ee.value?le.value:e.$t("booking.more_dates")),1),a("input",{type:"date",min:me.value,max:ke.value,onChange:fe,class:"absolute inset-0 opacity-0 w-full h-full pointer-events-none"},null,40,nt)],10,lt)]),g.value?(n(),s("p",it,l(g.value),1)):$("",!0),k.value==="specific"?(n(),s(v,{key:3},[H.value?(n(),s("div",rt,l(e.$t("public_book.loading")),1)):V.value.length?(n(),s("div",ct,[(n(!0),s(v,null,I(V.value,t=>(n(),s("button",{key:t.starts_at,onClick:A=>ye(t),disabled:!t.is_free,class:w(["py-2.5 rounded-xl text-sm font-semibold border transition",t.is_free?"border-primary/30 text-primary hover:bg-primary/5":"border-black/5 bg-black/5 text-black/30 line-through cursor-not-allowed"])},l(j(t.starts_at)),11,dt))),128))])):(n(),s("div",ut,l(e.$t("public_book.no_slots")),1))],64)):(n(),s(v,{key:4},[K.value?(n(),s("div",pt,l(e.$t("public_book.loading")),1)):T.value.length?(n(),s("div",vt,[(n(!0),s(v,null,I(T.value,t=>(n(),s("button",{key:t.starts_at,onClick:A=>_e(t),class:"py-2 rounded-xl border border-primary/30 text-primary hover:bg-primary/5 transition flex flex-col items-center"},[a("span",kt,l(j(t.starts_at)),1),a("span",ft,l(e.$t("public_book.n_courts_free",{n:t.free_courts.length})),1)],8,mt))),128))])):(n(),s("div",bt,l(e.$t("public_book.no_slots")),1))],64))],64)):m.value==="form"&&p.value?(n(),s(v,{key:2},[a("div",_t,[a("p",yt,l(c.value?.name),1),a("p",xt,[f(_(ue),{size:14}),y(" "+l(le.value),1)]),a("p",ht,[f(_(Ve),{size:14}),y(" "+l(j(p.value.starts_at))+"â"+l(j(p.value.ends_at)),1)])]),L(a("input",{"onUpdate:modelValue":o[6]||(o[6]=t=>r.value.name=t),type:"text",placeholder:e.$t("public_book.name"),class:"w-full px-3 py-2.5 border border-black/15 rounded-xl text-sm text-black focus:outline-none focus:border-primary"},null,8,gt),[[E,r.value.name]]),L(a("input",{"onUpdate:modelValue":o[7]||(o[7]=t=>r.value.email=t),type:"email",placeholder:e.$t("public_book.email"),class:"w-full px-3 py-2.5 border border-black/15 rounded-xl text-sm text-black focus:outline-none focus:border-primary"},null,8,wt),[[E,r.value.email]]),a("div",null,[L(a("input",{"onUpdate:modelValue":o[8]||(o[8]=t=>r.value.phone=t),type:"tel",required:"",placeholder:e.$t("public_book.phone"),class:"w-full px-3 py-2.5 border border-black/15 rounded-xl text-sm text-black focus:outline-none focus:border-primary"},null,8,$t),[[E,r.value.phone]]),a("p",Ct,l(e.$t("public_book.phone_hint")),1)]),Y.value&&D.value!=null?(n(),s("div",Dt,[a("span",St,l(e.$t("booking.to_pay")),1),a("span",Mt,l(D.value.toFixed(2))+" â¬",1)])):se.value?(n(),s("div",Vt,l(e.$t("public_book.pay_on_site")),1)):$("",!0),a("label",Tt,[L(a("input",{"onUpdate:modelValue":o[9]||(o[9]=t=>r.value.acceptTerms=t),type:"checkbox",class:"mt-0.5 h-4 w-4 rounded border-black/20 text-primary cursor-pointer"},null,512),[[ce,r.value.acceptTerms]]),a("span",null,[y(l(e.$t("public_book.terms_intro"))+" ",1),f(i,{to:"/terms",target:"_blank",class:"text-primary font-medium hover:underline"},{default:de(()=>[y(l(e.$t("public_book.terms_link")),1)]),_:1}),y(" "+l(e.$t("public_book.terms_and"))+" ",1),f(i,{to:"/privacy",target:"_blank",class:"text-primary font-medium hover:underline"},{default:de(()=>[y(l(e.$t("public_book.privacy_link")),1)]),_:1}),o[17]||(o[17]=y(". ",-1))])]),a("label",zt,[L(a("input",{"onUpdate:modelValue":o[10]||(o[10]=t=>r.value.acceptMarketing=t),type:"checkbox",class:"mt-0.5 h-4 w-4 rounded border-black/20 text-primary cursor-pointer"},null,512),[[ce,r.value.acceptMarketing]]),a("span",null,l(e.$t("public_book.marketing_consent")),1)]),g.value?(n(),s("p",It,l(g.value),1)):$("",!0),Y.value&&se.value?(n(),s(v,{key:3},[a("button",{onClick:o[11]||(o[11]=t=>U("online")),disabled:h.value||!z.value,class:"w-full py-3 bg-primary text-white rounded-xl font-semibold text-sm hover:bg-primary/90 transition disabled:opacity-50"},l(h.value?e.$t("public_book.booking"):e.$t("booking.pay_and_book",{amount:D.value!=null?D.value.toFixed(2)+" â¬":""})),9,Lt),a("button",{onClick:o[12]||(o[12]=t=>U("cash")),disabled:h.value||!z.value,class:"w-full py-3 border border-primary/30 text-primary rounded-xl font-semibold text-sm hover:bg-primary/5 transition disabled:opacity-50"},l(e.$t("public_book.book_pay_on_site")),9,Nt)],64)):Y.value?(n(),s("button",{key:4,onClick:o[13]||(o[13]=t=>U("online")),disabled:h.value||!z.value,class:"w-full py-3 bg-primary text-white rounded-xl font-semibold text-sm hover:bg-primary/90 transition disabled:opacity-50"},l(h.value?e.$t("public_book.booking"):e.$t("booking.pay_and_book",{amount:D.value!=null?D.value.toFixed(2)+" â¬":""})),9,Ft)):(n(),s("button",{key:5,onClick:o[14]||(o[14]=t=>U("cash")),disabled:h.value||!z.value,class:"w-full py-3 bg-primary text-white rounded-xl font-semibold text-sm hover:bg-primary/90 transition disabled:opacity-50"},l(h.value?e.$t("public_book.booking"):e.$t("public_book.confirm")),9,jt))],64)):m.value==="done"?(n(),s("div",Ut,[a("div",At,[f(_(ze),{size:32,class:"text-success"})]),a("h2",Bt,l(P.value?e.$t("public_book.paid_title"):e.$t("public_book.done_title")),1),a("p",Ht,l(P.value?e.$t("public_book.paid_hint"):e.$t("public_book.done_hint")),1)])):$("",!0)],64))])])])])}}});
1export{qt as default};
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.