"use strict";(globalThis.webpackChunksugar_calendar_bookings_scheduling_appointments=globalThis.webpackChunksugar_calendar_bookings_scheduling_appointments||[]).push([[8596],{8596(e,t,n){n.d(t,{default:()=>h});var a=n(6087),s=n(9173);const o=e=>{const t=e.split("-");if(3!==t.length)throw new Error(`Invalid date format: ${e}. Expected Y-m-d format.`);const n=parseInt(t[0],10),a=parseInt(t[1],10),s=parseInt(t[2],10);if(isNaN(n)||isNaN(a)||isNaN(s))throw new Error(`Invalid date values in: ${e}. All parts must be numeric.`);const o=new Date(Date.UTC(n,a-1,s));if(o.getUTCFullYear()!==n||o.getUTCMonth()!==a-1||o.getUTCDate()!==s)throw new Error(`Invalid date: ${e}`);return o};var r=n(2763);const l="XR6vOfAz8fXAyxFTTIf4";var i=n(790);const c=(0,a.memo)((function({day:e,appointments:t,displayTimeZone:n,...s}){const o=(0,a.useMemo)((()=>{const n=(0,r.BR)(e.date);return t[n]||[]}),[e.date,t]),c=o.length>0;return(0,i.jsxs)("button",{...s,className:`${s.className} fhSJ86Wdxex2hResnm6p`,children:[(0,i.jsx)("span",{className:"fBCRfektXhl1ZVgyInXa",children:e.date.getDate()}),c&&(0,i.jsx)("div",{className:"V4eiRGRSmOVPWM00_PL3",children:o.map(((e,t)=>{const n=4===t&&e.isOverflow?l+" v4HnYJ_ni5eO4t6Z7HGk":l;return(0,i.jsx)("span",{className:n,style:{backgroundColor:e.color}},t)}))})]})}));c.displayName="CustomDayButton";const u=c,d=e=>{const{children:t,className:n}=e,a=t?.charAt(0)||"";return(0,i.jsx)("th",{"aria-label":e["aria-label"],className:n,scope:"col",children:a})},h=(0,a.memo)((function({currentMonth:e,selectedDate:t,appointments:n,displayTimeZone:r="UTC",showNavigation:l=!1,onDateSelect:c,startOfWeek:h=0}){const{month:m,setMonth:g,selected:p,setSelected:f}=((e,t)=>{const[n,s]=(0,a.useState)((()=>o(e))),[r,l]=(0,a.useState)((()=>o(t)));return{month:n,setMonth:s,selected:r,setSelected:l}})(e,t),{handleDateSelect:N,handleMonthChange:S}=((e,t,n)=>({handleDateSelect:(0,a.useCallback)((t=>{t&&(e(t),n&&n(t))}),[e,n]),handleMonthChange:(0,a.useCallback)((e=>{t(e)}),[t])}))(f,g,c),v=((e,t)=>{const n=(0,a.useCallback)((n=>(0,i.jsx)(u,{...n,appointments:e,displayTimeZone:t})),[e,t]);return(0,a.useMemo)((()=>({DayButton:n,Weekday:d})),[n])})(n,r);return(0,i.jsx)("div",{className:"XqcYyab1w3sOTqj2yk1y",children:(0,i.jsx)(s.h,{mode:"single",selected:p,onSelect:N,month:m,onMonthChange:S,navLayout:"around",showOutsideDays:!0,hideNavigation:!l,weekStartsOn:h,components:v})})}))},2763(e,t,n){n.d(t,{BR:()=>r,Zv:()=>l,fU:()=>o,pe:()=>i});var a=n(8141),s=n(8443);function o(e,t="g:i a"){const n=Math.floor(e/60),a=e%60,o=`2000-01-01T${String(n).padStart(2,"0")}:${String(a).padStart(2,"0")}:00Z`;return(0,s.dateI18n)(t,o,"UTC")}function r(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function l(e){return/[gh]/.test(e)}function i(e,t){if(!e)return null;const n=new a.BB(e,t);return isNaN(n.getTime())?null:{hours:n.getHours(),minutes:n.getMinutes()}}n(7723)}}]);