import{N as p}from"./index-DXdAv5n3.js";function k(e){if(!e||!e.includes(":"))return e;const[t,r]=e.split(":"),n=Number(t),s=Number(r);if(Number.isNaN(n)||Number.isNaN(s))return e;const a=n>=12?"PM":"AM";return`${n%12||12}:${s.toString().padStart(2,"0")} ${a}`}function w(){var e;try{const t=Intl.DateTimeFormat().resolvedOptions().timeZone,n=(e=new Intl.DateTimeFormat(void 0,{timeZoneName:"short"}).formatToParts(new Date).find(s=>s.type==="timeZoneName"))==null?void 0:e.value;return!t&&!n?"Local time":t?!n||n===t?t:`${n} (${t})`:n??"Local time"}catch{return"Local time"}}const M=1,A=.25;function T(e){const t=e.getDay();return["sunday","monday","tuesday","wednesday","thursday","friday","saturday"][t]}function x(e,t){const r=T(e),n=t.find(s=>s.day===r);return!n||n.enabled!==!0?!1:S(n).length>0}function $(e,t){const r=t.find(s=>s.day===e);if(!r||r.enabled!==!0)return null;const n=S(r);return n.length===0?null:{enabled:!0,windows:n}}function B(e,t){const r=$(e,t);if(!r)return null;const n=r.windows.map(i=>h(i.from)),s=r.windows.map(i=>h(i.to)),a=Math.min(...n),o=Math.max(...s);return{enabled:!0,from:N(a),to:N(o)}}function h(e){const[t,r]=e.split(":").map(Number);return t*60+r}function N(e){const t=(e%1440+1440)%1440,r=Math.floor(t/60),n=t%60;return`${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}function R(e,t,r,n){const s=u=>{if(!u)return"";if(/^\d{1,2}:\d{2}$/.test(u))return u;const l=u.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(l){let f=parseInt(l[1],10);const y=parseInt(l[2],10),g=l[3].toUpperCase();return g==="PM"&&f!==12&&(f+=12),g==="AM"&&f===12&&(f=0),`${f.toString().padStart(2,"0")}:${y.toString().padStart(2,"0")}`}return u},a=s(e),o=s(t);if(!a||!o)return"Please select both start and end times";const i=u=>{const[l,f]=u.split(":").map(Number),y=l>=12?"PM":"AM";return`${l%12||12}:${f.toString().padStart(2,"0")} ${y}`},c=w(),d=new Date(`${p(r,"yyyy-MM-dd")}T${a}:00`),m=new Date(`${p(r,"yyyy-MM-dd")}T${o}:00`);if(Number.isNaN(d.getTime())||Number.isNaN(m.getTime()))return"Please select a valid time range.";m<=d&&m.setDate(m.getDate()+1);const D=P(d,m);for(const u of D){const l=$(u.dayOfWeek,n);if(!l)return`This venue is not available on ${u.dayLabel}. Please select a different time range.`;if(!H(l.windows).some(g=>u.startMinutes>=g.start&&u.endMinutes<=g.end)){const g=l.windows.map(b=>`${i(b.from)} - ${i(b.to)}`).join(", ");return`Selected time is outside availability hours for ${u.dayLabel} (${g}). All times are shown in ${c}.`}}return null}function S(e){return Array.isArray(e.windows)&&e.windows.length>0?e.windows.filter(t=>typeof(t==null?void 0:t.from)=="string"&&typeof(t==null?void 0:t.to)=="string").map(t=>({from:t.from,to:t.to})):typeof e.from=="string"&&typeof e.to=="string"?[{from:e.from,to:e.to}]:[]}function H(e){const t=e.map(n=>{const s=h(n.from),a=h(n.to);return s===a?null:a<s?{start:s,end:1440}:{start:s,end:a}}).filter(n=>n!=null).sort((n,s)=>n.start-s.start),r=[];for(const n of t){const s=r[r.length-1];if(!s){r.push({...n});continue}n.start<=s.end?s.end=Math.max(s.end,n.end):r.push({...n})}return r}function P(e,t){const r=[];let n=new Date(e);for(;n<t;){const s=new Date(n);s.setHours(0,0,0,0);const a=new Date(s);a.setDate(a.getDate()+1);const o=new Date(Math.max(n.getTime(),e.getTime())),i=new Date(Math.min(a.getTime(),t.getTime())),c=o.getHours()*60+o.getMinutes(),d=i.getTime()===a.getTime()?24*60:i.getHours()*60+i.getMinutes(),m=T(s),D=m.charAt(0).toUpperCase()+m.slice(1);r.push({dayOfWeek:m,dayLabel:D,startMinutes:c,endMinutes:d}),n=a}return r}function I(e){const t=A;return Math.round(e/t)*t}function L(e){if(!Number.isFinite(e)||e<=0)return"0";const t=I(e);return Math.abs(t-Math.round(t))<1e-9?String(Math.round(t)):String(Number(t.toFixed(2)))}function W(e){const t=L(e),r=Number(t);return`${t} hr${r===1?"":"s"}`}function z(e){return!Number.isFinite(e)||e<0?"Please select a valid start and end time.":e<M?`Minimum booking duration is ${M} hour. Please extend your end time.`:null}function v(e,t){const r=new Date;r.setHours(0,0,0,0);const n=new Date(r);if(typeof t=="number"&&t>0){const o=Math.ceil(t/24);n.setDate(n.getDate()+o)}const s=new Date(r),a=typeof e=="number"&&e>0?e:365;return s.setDate(s.getDate()+a),s.setHours(23,59,59,999),{minDate:n,maxDate:s}}function E(e,t,r){try{const[n,s,a]=e.split("-").map(Number),o=new Date(n,s-1,a);if(o.setHours(0,0,0,0),Number.isNaN(o.getTime()))return!1;const{minDate:i,maxDate:c}=v(t,r);return o>=i&&o<=c}catch{return!1}}function F(e){const{bookingWindowDays:t,minimumLeadTimeHours:r,schedule:n,blockedDates:s=[]}=e,{minDate:a,maxDate:o}=v(t,r);return{minDate:a,maxDate:o,disabledDates:c=>{const d=new Date(c.getFullYear(),c.getMonth(),c.getDate()).getTime();if(d<a.getTime()||d>o.getTime())return!0;const m=p(c,"yyyy-MM-dd");return s.includes(m)?!0:!x(c,n)}}}export{M,F as a,x as b,z as c,T as d,$ as e,W as f,w as g,k as h,E as i,B as j,N as m,I as r,h as t,R as v};