@innosolutions/inno-calendar 1.0.55 → 1.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";const e=require("react/jsx-runtime"),Ce=require("./use-calendar-BEuelmSu.cjs"),c=require("react"),h=require("./index-D2U2F80P.cjs"),w=require("./week-view-DfavofVM.cjs"),ye=require("./slot-selection-context-CHSaOPWP.cjs"),Y=require("./utils.cjs");function Ze({view:t,className:n=""}){return e.jsx("div",{className:n,style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"400px",backgroundColor:"#f9fafb",borderRadius:"0.5rem",border:"1px dashed #d1d5db"},children:e.jsxs("div",{style:{textAlign:"center",color:"#6b7280"},children:[e.jsxs("p",{style:{fontSize:"1.125rem",fontWeight:500},children:[t.charAt(0).toUpperCase()+t.slice(1)," View"]}),e.jsx("p",{style:{fontSize:"0.875rem"},children:"Implementation pending"})]})})}function ze({view:t,className:n}){return e.jsx(Ze,{view:t,className:n})}function et(t){const{events:n,resources:r,scheduleTypes:s,initialView:o="week",initialDate:a,initialFilters:m,preferences:x,locale:d,slots:j,renderEvent:k,onViewChange:b,onDateChange:I,onEventClick:W,onSlotSelect:F,onFiltersChange:R,className:S,children:y}=t,A=Ce.useOptionalCalendarContext();if(A)return e.jsx("div",{className:S,style:{position:"relative"},children:y??e.jsx(ze,{view:A.view,className:S})});const O=Ce.useCalendar({events:n,resources:r,scheduleTypes:s,initialView:o,initialDate:a,initialFilters:m,preferences:x,locale:d,onViewChange:b,onDateChange:I,onEventClick:W,onSlotSelect:F,onFiltersChange:R});return e.jsx(Ce.CalendarProvider,{value:O,children:e.jsx("div",{className:S,style:{position:"relative"},children:y??e.jsx(ze,{view:O.view,className:S})})})}function tt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),e.jsx("path",{d:"m15 5 4 4"})]})}function Ge({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),e.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function De({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}function nt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m4.9 4.9 14.2 14.2"})]})}function we({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}function rt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]})}function st({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function ot({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function at({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}function it({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"})]})}function lt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),e.jsx("path",{d:"M10 9H8"}),e.jsx("path",{d:"M16 13H8"}),e.jsx("path",{d:"M16 17H8"})]})}function me({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:h.cn("animate-spin",t),children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}const ct={edit:"Edit",delete:"Delete",cancel:"Cancel Event",close:"Close",going:"Going",notGoing:"Not Going",confirmMeeting:"Confirm meeting took place",completed:"Completed",canceled:"Canceled",participants:"Participants",guest:"guest",guests:"guests",confirmed:"confirmed",organizer:"Organizer",client:"Client",more:"more",noDateProvided:"No date provided",eventNotFound:"Event not found",cancellationNote:"Cancellation Note",canceledOn:"Canceled on",acceptThisEvent:"Accept this event only",acceptAllEvents:"Accept all events",deleteConfirmTitle:"Delete Event",deleteConfirmDescription:"Are you sure you want to delete this event? This action cannot be undone."},be=c.forwardRef(({onClick:t,label:n,children:r,className:s,variant:o="ghost",...a},m)=>e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button",ref:m,onClick:t,className:h.cn("h-8 w-8 rounded-full flex items-center justify-center transition-colors",o==="ghost"&&"hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400",o==="destructive"&&"hover:bg-red-50 dark:hover:bg-red-950/30 text-zinc-600 dark:text-zinc-400 hover:text-red-600",s),"aria-label":n,...a,children:r})}),e.jsx(w.TooltipContent,{side:"bottom",className:"text-xs",children:n})]}));be.displayName="IconButton";function dt({src:t,alt:n,initials:r,className:s,isClient:o}){const[a,m]=c.useState(!1);return e.jsx("div",{className:h.cn("relative h-7 w-7 rounded-full overflow-hidden shrink-0",s),children:t&&!a?e.jsx("img",{src:t,alt:n,className:"h-full w-full object-cover",onError:()=>m(!0)}):e.jsx("div",{className:h.cn("h-full w-full flex items-center justify-center text-[10px] font-medium",o?"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300":"bg-zinc-200 dark:bg-zinc-700 text-zinc-700 dark:text-zinc-300"),children:r})})}function Pe({participant:t,isEventCanceled:n=!1,labels:r}){const s=t.name||"Unknown",o=s.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),a=t.isOrganizer??!1,m=t.isConfirmed,x=m===!0,d=m===!1,j=t.isClient??!1,k=t.profilePicture||t.avatar,b=n;return e.jsxs("div",{className:h.cn("flex items-center gap-3 py-0",b&&"opacity-60"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(dt,{src:k,alt:s,initials:o,isClient:j,className:h.cn(b&&"grayscale")}),b||d?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-100 dark:bg-red-900/50 flex items-center justify-center",children:e.jsx(De,{className:"h-2 w-2 text-red-600 dark:text-red-400 stroke-[3]"})})}):x?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-100 dark:bg-green-900/50 flex items-center justify-center",children:e.jsx(we,{className:"h-2 w-2 text-green-600 dark:text-green-400 stroke-[3]"})})}):null]}),e.jsxs("div",{className:"!h-fit min-w-0 gap-0",children:[e.jsx("div",{className:"gap-0",children:e.jsx("span",{className:h.cn("text-sm text-zinc-900 dark:text-zinc-100 truncate",b&&"line-through text-zinc-500 dark:text-zinc-500"),children:s})}),j&&e.jsx("div",{className:"text-[10px] px-1.5 w-fit py-0.5 rounded bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-medium",children:r.client}),a&&!b&&e.jsx("div",{className:"text-xs text-zinc-500",children:r.organizer})]})]})}function ut({open:t,onOpenChange:n,title:r,children:s}){return c.useEffect(()=>{if(!t)return;const o=a=>{a.key==="Escape"&&n(!1)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t,n]),c.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),t?e.jsxs("div",{className:"fixed inset-0 z-50",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>n(!1),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&n(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-xl overflow-hidden",children:[r&&e.jsx("div",{className:"sr-only",children:r}),s]})})]}):null}function xt({open:t,onOpenChange:n,title:r,description:s,cancelLabel:o,confirmLabel:a,onConfirm:m,isLoading:x}){return t?e.jsxs("div",{className:"fixed inset-0 z-[60]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>n(!1),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&n(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-xl p-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-zinc-100",children:r}),e.jsx("p",{className:"mt-2 text-sm text-zinc-600 dark:text-zinc-400",children:s}),e.jsxs("div",{className:"mt-4 flex justify-end gap-3",children:[e.jsx(w.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:o}),e.jsxs(w.Button,{variant:"destructive",size:"sm",onClick:m,disabled:x,children:[x&&e.jsx(me,{className:"h-4 w-4 mr-2"}),e.jsx(Ge,{className:"h-4 w-4 mr-2"}),a]})]})]})})]}):null}function ht(t,n){return t.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}function mt(t,n){const r={hour:"2-digit",minute:"2-digit",hour12:!1};return`${t.toLocaleTimeString(void 0,r)} – ${n.toLocaleTimeString(void 0,r)}`}function ft(t){return t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function gt(t){const[n,r]=c.useState(()=>typeof window<"u"?window.matchMedia(t).matches:!1);return c.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia(t),o=a=>r(a.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[t]),n}function Ae({event:t,labels:n,isLoading:r,onClose:s,onEdit:o,onDelete:a,onCancel:m,onAccept:x,onDecline:d,onConfirmMeeting:j,canEdit:k=!0,canDelete:b=!1,canCancel:I=!0,isCurrentUserParticipant:W=!1,isCurrentUserClient:F=!1,currentUserAcceptStatus:R,isAcceptLoading:S=!1,isDeclineLoading:y=!1,isConfirmLoading:A=!1,isDeleteLoading:O=!1,renderParticipant:B,renderHeaderActions:D,renderCancelReason:_,renderDeleteConfirmation:z,formatDate:P=ht,formatTimeRange:V=mt}){const[q,K]=c.useState(!1),p=!(t.isCanceled||t.meetingTookPlace),l=t.isRecurring??!1,f=t.participantDetails,E=t.participantsNames||[],$=f&&f.length>0,T=R===!0,re=R===!1,G=W&&!F&&p,ge=$?f.filter(M=>M.isConfirmed).length:t.isAccepted?E.length:0,ee=$?f.length:E.length,Q=t.scheduleTypeColor||t.hexColor||"#039BE5",xe=c.useCallback(()=>t.startDate?P(t.startDate):n.noDateProvided,[t.startDate,P,n.noDateProvided]),se=c.useCallback(()=>t.startDate&&t.endDate?V(t.startDate,t.endDate):null,[t.startDate,t.endDate,V]),oe=()=>{s(),o?.(t)},pe=()=>{s(),m?.(t)},le=()=>{K(!0)},g=()=>{a?.(t),K(!1)};return r?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx(me,{className:"h-6 w-6 text-zinc-400"})}):e.jsxs(w.TooltipProvider,{delayDuration:300,children:[e.jsxs("div",{className:"flex flex-col gap-0.5 p-3",children:[e.jsx("div",{className:"flex items-start justify-end gap-0.5",children:D?D({onClose:s}):e.jsxs(e.Fragment,{children:[p&&k&&o&&e.jsx(be,{onClick:oe,label:n.edit,children:e.jsx(tt,{className:"h-[18px] w-[18px]"})}),p&&I&&m&&e.jsx(be,{onClick:pe,label:n.cancel,children:e.jsx(nt,{className:"h-[18px] w-[18px]"})}),b&&a&&e.jsx(be,{onClick:le,label:n.delete,variant:"destructive",children:e.jsx(Ge,{className:"h-[18px] w-[18px]"})}),e.jsx(be,{onClick:s,label:n.close,children:e.jsx(De,{className:"h-[18px] w-[18px]"})})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded mt-1 shrink-0",style:{backgroundColor:Q}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:h.cn("text-[22px] font-normal text-zinc-900 dark:text-zinc-100 leading-tight",t.isCanceled&&"line-through opacity-60"),children:t.title}),t.meetingTookPlace&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 text-xs font-medium",children:[e.jsx(rt,{className:"h-3 w-3"}),n.completed]}),t.isCanceled&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 text-xs font-medium",children:[e.jsx(De,{className:"h-3 w-3"}),n.canceled]})]}),e.jsxs("div",{className:"mt-1 text-sm text-zinc-600 dark:text-zinc-400",children:[e.jsx("span",{children:xe()}),se()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1.5",children:"·"}),e.jsx("span",{children:se()})]})]}),l&&t.recurrenceSummary&&e.jsx("div",{className:"text-sm text-zinc-500 dark:text-zinc-500",children:t.recurrenceSummary})]})]})}),t.isCanceled&&e.jsx("div",{className:"mx-4 p-3 rounded-lg bg-red-50 dark:bg-red-950/30",children:_?_(t):e.jsx("div",{className:"flex items-start gap-0",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:n.cancellationNote}),t.cancelReason&&e.jsxs("div",{className:"mt-1 text-sm text-red-600/80 dark:text-red-400/80 italic",children:['"',t.cancelReason,'"']}),t.canceledDate&&e.jsxs("div",{className:"mt-1.5 text-xs text-red-500/70 dark:text-red-400/60",children:[n.canceledOn," ",ft(t.canceledDate)]})]})})}),e.jsxs("div",{className:"space-y-0.5",children:[t.address&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(at,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:t.address})]}),($||E.length>0)&&e.jsxs("div",{className:"flex items-start gap-2 py-0",children:[e.jsx(ot,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsxs("span",{className:"text-sm text-zinc-900 dark:text-zinc-100 font-medium",children:[ee," ",ee!==1?n.guests:n.guest]}),ee>0&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["(",ge," ",n.confirmed,")"]})]}),e.jsxs("div",{className:"mt-2 space-y-2",children:[$?f.slice(0,6).map((M,U)=>B?B(M,U):e.jsx(Pe,{participant:M,isEventCanceled:t.isCanceled,labels:n},M.id)):E.slice(0,6).map((M,U)=>{const te={id:String(U),name:M,email:"",isConfirmed:t.isAccepted,isOrganizer:U===0,isClient:!1};return B?B(te,U):e.jsx(Pe,{participant:te,isEventCanceled:t.isCanceled,labels:n},M)}),ee>6&&e.jsxs("div",{className:"text-xs text-zinc-500 py-1.5 pl-10",children:["+",ee-6," ",n.more]})]})]})]}),t.description&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lt,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap",children:t.description})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(it,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:$&&f.find(M=>M.isOrganizer)?.name||E[0]||"Calendar"})]})]}),G&&x&&d&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 mt-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsxs(w.DropdownMenu,{children:[e.jsx(w.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex",children:[e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("rounded-r-none gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:M=>{M.stopPropagation(),T||x(t)},disabled:S,children:S?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[T&&e.jsx(we,{className:"h-3.5 w-3.5"}),n.going]})}),e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("rounded-l-none px-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),children:e.jsx(st,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(w.DropdownMenuContent,{align:"start",children:[e.jsxs(w.DropdownMenuItem,{className:h.cn("gap-1.5 h-8 !border-none !bg-green-50 text-green-800 hover:!bg-green-100",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>x(t),children:[e.jsx(we,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),n.acceptThisEvent]}),e.jsxs(w.DropdownMenuItem,{onClick:()=>x(t),children:[e.jsx(we,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),n.acceptAllEvents]})]})]}):e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>{T||x(t)},disabled:S,children:S?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[T&&e.jsx(we,{className:"h-3.5 w-3.5"}),n.going]})}),e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("gap-1.5 h-8 !border-none !bg-rose-100 text-rose-800 hover:!bg-rose-200",re&&"!bg-rose-700 !text-white hover:!bg-rose-700"),onClick:()=>{re||d(t)},disabled:y,children:y?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[re&&e.jsx(De,{className:"h-3.5 w-3.5"}),n.notGoing]})})]})}),W&&T&&!t.meetingTookPlace&&!t.isCanceled&&j&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 py-3",children:e.jsxs(w.Button,{size:"sm",variant:"outline",className:"w-full h-9 hover:!bg-green-100 hover:text-green-700 text-green-700 !bg-green-100 !border-none dark:text-green-400 dark:hover:bg-green-950/30",onClick:()=>j(t),disabled:A,children:[A&&e.jsx(me,{className:"h-4 w-4 mr-2"}),n.confirmMeeting]})})]}),z?q&&z({onConfirm:g,onCancel:()=>K(!1),isLoading:O}):e.jsx(xt,{open:q,onOpenChange:K,title:n.deleteConfirmTitle,description:n.deleteConfirmDescription,cancelLabel:n.cancel,confirmLabel:n.delete,onConfirm:g,isLoading:O})]})}function pt({event:t,children:n,open:r,onOpenChange:s,isLoading:o,labels:a,onEdit:m,onDelete:x,onCancel:d,onAccept:j,onDecline:k,onConfirmMeeting:b,canEdit:I=!0,canDelete:W=!1,canCancel:F=!0,isCurrentUserParticipant:R,isCurrentUserClient:S,currentUserAcceptStatus:y,isAcceptLoading:A,isDeclineLoading:O,isConfirmLoading:B,isDeleteLoading:D,renderParticipant:_,renderHeaderActions:z,renderCancelReason:P,renderDeleteConfirmation:V,formatDate:q,formatTimeRange:K,className:p,width:l=360}){const f=gt("(min-width: 768px)"),E={...ct,...a},$=c.useCallback(()=>{s?.(!1)},[s]),T={event:t,labels:E,isLoading:o,onClose:$,onEdit:m,onDelete:x,onCancel:d,onAccept:j,onDecline:k,onConfirmMeeting:b,canEdit:I,canDelete:W,canCancel:F,isCurrentUserParticipant:R,isCurrentUserClient:S,currentUserAcceptStatus:y,isAcceptLoading:A,isDeclineLoading:O,isConfirmLoading:B,isDeleteLoading:D,renderParticipant:_,renderHeaderActions:z,renderCancelReason:P,renderDeleteConfirmation:V,formatDate:q,formatTimeRange:K};return f?e.jsxs(w.Popover,{open:r??!1,onOpenChange:s??(()=>{}),children:[e.jsx(w.PopoverTrigger,{asChild:!0,children:n}),e.jsx(w.PopoverContent,{className:h.cn("p-0 shadow-lg !rounded-2xl bg-white dark:bg-zinc-900 overflow-hidden border z-50",p),style:{width:l},align:"center",side:"bottom",sideOffset:4,children:e.jsx(Ae,{...T})})]}):e.jsxs(e.Fragment,{children:[n,e.jsx(ut,{open:r??!1,onOpenChange:s??(()=>{}),title:t.title,children:e.jsx(Ae,{...T})})]})}const Me=44,Fe=4,vt=56,Re=8,ke=80,je=140,We=100,Oe=2,jt=8,wt=18;function bt(t){return t.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function yt(t,n){const r=[];for(let s=0;s<n;s++){const o=new Date(t);o.setDate(o.getDate()+s),r.push(o)}return r}function kt(t,n,r){const s=[];return t.forEach((o,a)=>{for(let m=n;m<r;m++)s.push({hour:m,dayIndex:a,date:o})}),s}function Te(t){return`${t.toString().padStart(2,"0")}:00`}function Nt(t){return t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function _e(t){const n=[...t].sort((o,a)=>o.startCol!==a.startCol?o.startCol-a.startCol:a.spanCols-o.spanCols),r=[],s=[];for(const o of n){let a=0;for(;s[a]!==void 0&&s[a]>o.startCol;)a++;s[a]=o.startCol+o.spanCols,r.push({...o,stackIndex:a})}return r}function Ct({src:t,alt:n,fallback:r,className:s}){return e.jsx("div",{className:h.cn("relative flex shrink-0 overflow-hidden rounded-sm border bg-muted",s),children:t?e.jsx("img",{src:t,alt:n,className:"aspect-square h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-muted text-muted-foreground",children:r})})}const Dt=7;function fe({daysToShow:t=Dt,events:n,users:r=[],selectedDate:s,onDateChange:o,onEventClick:a,onSlotClick:m,onSlotSelect:x,visibleHours:d,className:j,getEventUserId:k,renderPopover:b,slots:I,classNames:W,enableDrag:F=!0}){const R=c.useRef(null),S=ye.useOptionalDragDrop(),[y,A]=c.useState(null),O=c.useRef(!1),[B,D]=c.useState(null),_=s??new Date,z=!0,P=d?.from??jt,V=d?.to??wt,q=V-P,K=c.useMemo(()=>{const i=new Date(_);if(t===1||t===3)return i.setHours(0,0,0,0),i;const u=i.getDay(),v=u===0?-6:1-u;return i.setDate(i.getDate()+v),i.setHours(0,0,0,0),i},[_,t]),p=c.useMemo(()=>yt(K,t),[K,t]),l=c.useMemo(()=>kt(p,P,V),[z,p,P,V]),E=k??(i=>{if(i.resourceId)return i.resourceId;const u=i.data;if(u?.userId)return String(u.userId);if(u?.user&&typeof u.user=="object"&&u.user.id)return String(u.user.id);if(i.user?.id)return i.user.id;if(i.participants?.[0]?.id)return i.participants[0].id}),$=c.useMemo(()=>{const i=new Map;for(const u of r)i.set(u.id,{id:u.id,name:u.name,avatar:u.avatar??void 0,email:u.email});for(const u of n){const N=u.data?.user;N?.id&&!i.has(N.id)&&i.set(N.id,{id:N.id,name:N.name??"",avatar:N.avatar??void 0,email:N.email}),u.user?.id&&!i.has(u.user.id)&&i.set(u.user.id,{id:u.user.id,name:u.user.name,avatar:u.user.avatar??void 0,email:u.user.email});for(const C of u.participants||[])C.id&&!i.has(C.id)&&i.set(C.id,{id:C.id,name:C.name,avatar:C.avatar??void 0,email:C.email})}return Array.from(i.values())},[r,n]),T=c.useMemo(()=>{const i=[],u=new Map;for(const C of $)u.set(C.id,[]);u.set("unassigned",[]);for(const C of n){const L=E(C)??"unassigned";(u.get(L)??u.get("unassigned")).push(C)}const v=C=>{const L=[];for(const H of C){const J=H.startDate.getHours()+H.startDate.getMinutes()/60,Z=H.endDate.getHours()+H.endDate.getMinutes()/60;for(let X=0;X<p.length;X++){const ne=p[X],ce=Y.startOfDay(ne),de=Y.endOfDay(ne);if(H.startDate<=de&&H.endDate>=ce){let ue=P,ve=V;if(H.startDate>=ce&&(ue=Math.max(P,J)),H.endDate<=de&&(ve=Math.min(V,Z)),ue=Math.max(P,Math.min(V,ue)),ve=Math.max(P,Math.min(V,ve)),ve>ue){const Ie=X*q+Math.floor(ue-P),Qe=X*q+Math.ceil(ve-P);L.push({event:H,startCol:Ie,spanCols:Math.max(1,Qe-Ie)})}}}}return L};for(const C of $){const L=u.get(C.id)??[],H=v(L),J=_e(H),Z=J.reduce((X,ne)=>Math.max(X,ne.stackIndex+1),0);i.push({user:C,events:J,maxStack:Math.max(Z,1)})}const N=u.get("unassigned")??[];if(N.length>0){const C=v(N),L=_e(C),H=L.reduce((J,Z)=>Math.max(J,Z.stackIndex+1),0);i.push({user:{id:"unassigned",name:"Unassigned",avatar:void 0,email:void 0},events:L,maxStack:Math.max(H,1)})}return i.filter(C=>C.events.length>0)},[$,n,p,z,q,P,V,E]),re=c.useMemo(()=>{const i=new Map;for(const u of T)for(const v of u.events)if(v.spanCols===1){const N=i.get(v.startCol)??0;i.set(v.startCol,N+1)}return i},[T]),G=c.useMemo(()=>{const i=l.length,u=ke,v=[];for(let N=0;N<i;N++){const C=re.get(N)??0;C>Oe?v.push(We+(C-Oe)*20):C>0?v.push(Math.max(u,We)):v.push(u)}return v},[z,l.length,p.length,re]),ge=i=>Math.max(vt,i*(Me+Fe)+Re*2),ee=je+G.reduce((i,u)=>i+u,0),Q=c.useMemo(()=>{const i=[0];for(let u=0;u<G.length;u++)i.push(i[u]+G[u]);return i},[G]);c.useLayoutEffect(()=>{const i=R.current;if(!i)return;const u=()=>{let v=-1;const C=new Date().getHours();{for(let L=0;L<l.length;L++){const H=l[L];if(H&&Y.isToday(H.date)&&H.hour<=C&&H.hour+1>C){v=L;break}}if(v===-1)for(let L=0;L<l.length;L++){const H=l[L];if(H&&Y.isToday(H.date)){v=L;break}}}if(v!==-1){const L=(Q[v]??0)+je,H=i.clientWidth,J=Math.max(0,L-H/3);i.scrollTo({left:J,behavior:"instant"})}};requestAnimationFrame(()=>{requestAnimationFrame(u)})},[_,l,p,Q,z]);const xe=c.useCallback((i,u)=>{const v=u.getBoundingClientRect(),N=i-v.left+u.scrollLeft;for(let C=0;C<Q.length-1;C++){const L=Q[C],H=Q[C+1];if(N>=L&&N<H){const J=(N-L)/(H-L),Z=Math.floor(J*60),X=Math.round(Z/15)*15;return{colIndex:C,minute:Math.min(X,45)}}}return null},[Q]),se=c.useCallback((i,u)=>{if(l[i]){const v=l[i],N=new Date(v.date);return N.setHours(v.hour,u??0,0,0),{date:N,hour:v.hour}}return{date:new Date}},[z,l,p]),oe=c.useCallback((i,u)=>{if(i.preventDefault(),i.dataTransfer.dropEffect="move",!S?.isDragging||!S.dragState)return;const v=i.currentTarget,N=xe(i.clientX,v);if(!N)return;const{colIndex:C,minute:L}=N,{date:H,hour:J}=se(C,L);S.updateDragPreview(H,J,L,u);const{originalStartDate:Z,originalEndDate:X}=S.dragState,ne=X.getTime()-Z.getTime(),ce=l.length;let de;{const ue=ne/36e5;de=Math.max(1,Math.ceil(ue))}de=Math.min(de,ce-C),D({resourceId:u,colIndex:C,spanCols:de})},[S,xe,se,z,l.length,p.length]),pe=c.useCallback(i=>{const u=i.relatedTarget;i.currentTarget.contains(u)||D(null)},[]),le=c.useCallback((i,u)=>{i.preventDefault(),D(null),S?.isDragging&&S.endDrag()},[S]),g=c.useCallback((i,u)=>{if(!y||y.resourceId!==i)return!1;const v=Math.min(y.startCol,y.endCol),N=Math.max(y.startCol,y.endCol);return u>=v&&u<=N},[y]),M=c.useCallback((i,u)=>!B||B.resourceId!==i?!1:u>=B.colIndex&&u<B.colIndex+B.spanCols,[B]),U=c.useCallback((i,u,v)=>{v.button!==0&&v.pointerType==="mouse"||(x||m)&&(v.preventDefault(),O.current=!0,A({resourceId:i,startCol:u,endCol:u,isSelecting:!0}))},[x,m]),te=c.useCallback((i,u,v)=>{if(O.current&&!(!y||y.resourceId!==i)){if(v.buttons===0){O.current=!1;return}A(N=>N?{...N,endCol:u}:null)}},[y]),he=c.useCallback(()=>{if(!O.current||!y)return;O.current=!1;const i=Math.min(y.startCol,y.endCol),u=Math.max(y.startCol,y.endCol),v=se(i),N=se(u),C=new Date(v.date),L=new Date(N.date);N.hour!==void 0&&L.setHours(N.hour+1,0,0,0);const H={startDate:C,endDate:L,resourceId:y.resourceId};i===u&&m&&m(v.date,v.hour,y.resourceId),x?.(H),A(J=>J?{...J,isSelecting:!1}:null),setTimeout(()=>A(null),150)},[y,se,z,m,x]);return c.useEffect(()=>{const i=()=>{O.current&&he()};return window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[he]),c.useEffect(()=>{S?.isDragging||D(null)},[S?.isDragging]),e.jsx("div",{className:h.cn("flex h-full flex-col",j),children:e.jsx("div",{className:"ic-timeline-scroll-container flex-1",ref:R,children:e.jsxs("div",{className:"relative",style:{minWidth:ee},children:[e.jsx("div",{className:"ic-timeline-header sticky top-0 z-20 border-b bg-background",children:t>1?e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex shrink-0 items-center justify-center border-r bg-background px-2 sticky left-0 z-10",style:{width:je},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("div",{className:"flex border-b",children:p.map((i,u)=>{const v=Y.isToday(i),N=u*q,C=G.slice(N,N+q).reduce((L,H)=>L+H,0);return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center border-r py-1.5 font-medium",v?"bg-primary/10 text-primary":"bg-muted/30"),style:{width:C},children:e.jsx("span",{className:"text-xs",children:Nt(i)})},`day-${i.toISOString()}`)})}),e.jsx("div",{className:"flex",children:l.map((i,u)=>{const v=i.hour===P,N=Y.isToday(i.date),C=G[u]??ke;return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center py-1.5 text-[10px] text-muted-foreground",v&&u>0?"border-l-2 border-l-border":"border-r border-r-border/50",N&&"bg-primary/5"),style:{width:C},children:Te(i.hour)},`hour-${i.dayIndex}-${i.hour}`)})})]})]}):e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex shrink-0 items-center border-r bg-background px-2 py-2",style:{width:je},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),l.map((i,u)=>{const v=i.hour===P,N=Y.isToday(i.date),C=G[u]??ke;return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center py-1.5 text-[10px] text-muted-foreground",v&&u>0?"border-l-2 border-l-border":"border-r border-r-border/50",N&&"bg-primary/5"),style:{width:C},children:Te(i.hour)},`hour-${i.dayIndex}-${i.hour}`)})]})}),T.map(i=>{const u=ge(i.maxStack);return e.jsxs("div",{className:h.cn("relative flex border-b",W?.resourceRow),style:{height:u},children:[e.jsx("div",{className:"sticky left-0 z-10",style:{width:je},children:e.jsxs("div",{className:h.cn("flex h-full items-center gap-2 sm:gap-3 border-r bg-background px-2 sm:px-4",W?.resourceHeader),children:[e.jsx(Ct,{className:"size-7",src:i.user.avatar,alt:i.user.name,fallback:bt(i.user.name)}),e.jsx("span",{className:"truncate text-xs sm:text-sm font-medium",children:i.user.name})]})}),e.jsxs("div",{className:"ic-timeline-grid relative flex",onDragOver:v=>oe(v,i.user.id),onDragLeave:pe,onDrop:v=>le(v,i.user.id),children:[l.map((v,N)=>{const C=v.hour===P&&N>0,L=G[N]??ke,H=g(i.user.id,N),J=M(i.user.id,N),Z=!!(x||m);return e.jsx("div",{role:Z?"button":void 0,tabIndex:Z?0:void 0,"aria-label":Z?`Select ${Te(v.hour)} on ${v.date.toLocaleDateString()} for ${i.user.name}`:void 0,onPointerDown:X=>U(i.user.id,N,X),onPointerEnter:X=>te(i.user.id,N,X),onPointerUp:he,onKeyDown:X=>{if(Z&&(X.key==="Enter"||X.key===" ")){X.preventDefault();const ne=se(N);m?.(ne.date,ne.hour,i.user.id),x?.({startDate:ne.date,endDate:(()=>{const ce=new Date(ne.date);return ne.hour!==void 0&&ce.setHours(ne.hour+1,0,0,0),ce})(),resourceId:i.user.id})}},className:h.cn("shrink-0 select-none touch-none transition-colors",Z&&"cursor-pointer",C?"border-l-2 border-l-border":"border-r border-r-border/50",Y.isToday(v.date)&&"bg-primary/5",Z&&!y?.isSelecting&&!S?.isDragging&&"hover:bg-blue-50/60",H&&"bg-blue-100/70",J&&"bg-primary/20 ring-2 ring-primary ring-inset"),style:{width:L}},`cell-${v.dayIndex}-${v.hour}`)}),i.events.map(v=>{const N=(Q[v.startCol]??0)+2,C=Q[v.startCol+v.spanCols]??Q[Q.length-1]??0,L=Q[v.startCol]??0,H=C-L-4,J=Re+v.stackIndex*(Me+Fe);return e.jsx("div",{className:"absolute",style:{left:N,width:Math.max(H,0),top:J,height:Me},children:e.jsx(w.EventCard,{event:v.event,variant:"compact",enableDrag:F,onClick:a,renderPopover:b,className:h.cn("h-full w-full",W?.eventCardCompact)})},v.event.id)})]})]},i.user.id)}),T.length===0&&e.jsx("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:"No users or events to display"})]})})})}const Mt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Tt=["January","February","March","April","May","June","July","August","September","October","November","December"];function $e(t){const n=t.hexColor;return n?{backgroundColor:n}:{}}function St({day:t,date:n,events:r,isCurrentMonth:s,onDayClick:o}){const a=Y.isToday(n),m=3,x=r.length;return e.jsxs("button",{type:"button",onClick:()=>o?.(n),className:h.cn("flex h-9 sm:h-11 flex-1 flex-col items-center justify-start gap-0.5 rounded-md pt-0.5 sm:pt-1","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors",!s&&"opacity-40"),children:[e.jsx("div",{className:h.cn("flex size-5 sm:size-6 items-center justify-center rounded-full text-[10px] sm:text-xs font-medium",a&&"bg-primary font-semibold text-primary-foreground"),children:t}),x>0&&e.jsx("div",{className:"mt-0.5 flex items-center gap-0.5",children:x<=m?r.map(d=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:$e(d)},d.id)):e.jsxs(e.Fragment,{children:[r.slice(0,m).map(d=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:$e(d)},d.id)),e.jsxs("span",{className:"text-[6px] sm:text-[7px] font-medium text-muted-foreground",children:["+",x-m]})]})})]})}function Et({date:t,events:n,onMonthClick:r,onDayClick:s}){const o=c.useMemo(()=>Y.generateMonthGrid(t,0),[t]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{type:"button",onClick:()=>r?.(t),className:h.cn("w-full rounded-t-lg border px-2 sm:px-3 py-1.5 sm:py-2 text-xs sm:text-sm font-semibold","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors"),children:Tt[t.getMonth()]}),e.jsxs("div",{className:"flex-1 space-y-1.5 sm:space-y-2 rounded-b-lg border border-t-0 p-2 sm:p-3",children:[e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 text-center",children:Mt.map((a,m)=>e.jsxs("div",{className:"text-[9px] sm:text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"sm:hidden",children:a[0]}),e.jsx("span",{className:"hidden sm:inline",children:a})]},m))}),e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 gap-y-1",children:o.map((a,m)=>{const x=Y.getEventsForDay(n,a.date);return e.jsx(St,{day:a.date.getDate(),date:a.date,events:x,isCurrentMonth:a.isCurrentMonth,onDayClick:s},`${m+1}-${a.date.toISOString()}`)})})]})]})}function Je({events:t,year:n,onMonthClick:r,onDayClick:s,className:o,slots:a,classNames:m}){const x=c.useMemo(()=>Y.getYearMonths(n),[n]);return e.jsxs("div",{className:h.cn("flex flex-col h-full",o),children:[e.jsx("div",{className:"flex items-center justify-center border-b px-4 py-3",children:e.jsx("h2",{className:"text-lg font-semibold",children:n})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(d=>e.jsx(Et,{date:d,events:t,onMonthClick:r,onDayClick:s},d.getMonth()))})})]})}const Ne=200,Lt=60,Ht=300,It=7,Be=2,Se=40,zt=18;function Pt(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m18 15-6-6-6 6"})})}function At(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ft(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}function Rt(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function Wt({containerRef:t,className:n}){const[r,s]=c.useState({canUp:!1,canDown:!1,canLeft:!1,canRight:!1}),[o,a]=c.useState({x:0,y:0}),[m,x]=c.useState(!1),d=r.canUp||r.canDown||r.canLeft||r.canRight,j=c.useRef(null),k=c.useRef(null),b=c.useRef(null),I=c.useRef(!1),W=c.useRef({x:0,y:0}),F=c.useRef({x:0,y:0}),R=c.useRef(0),S=c.useCallback(()=>{const p=t.current;if(!p)return;const l=4;s({canUp:p.scrollTop>l,canDown:p.scrollTop+p.clientHeight<p.scrollHeight-l,canLeft:p.scrollLeft>l,canRight:p.scrollLeft+p.clientWidth<p.scrollWidth-l})},[t]);c.useEffect(()=>{const p=t.current;if(!p)return;S(),p.addEventListener("scroll",S,{passive:!0});const l=new ResizeObserver(S);l.observe(p);const f=new MutationObserver(S);return f.observe(p,{childList:!0,subtree:!0}),()=>{p.removeEventListener("scroll",S),l.disconnect(),f.disconnect()}},[t,S]);const y=c.useCallback((p,l)=>{t.current?.scrollBy({left:p,top:l,behavior:"smooth"})},[t]),A=c.useCallback(()=>y(0,-Ne),[y]),O=c.useCallback(()=>y(0,Ne),[y]),B=c.useCallback(()=>y(-Ne,0),[y]),D=c.useCallback(()=>y(Ne,0),[y]),_=c.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),k.current&&(clearInterval(k.current),k.current=null)},[]),z=c.useCallback(p=>{p(),j.current=setTimeout(()=>{k.current=setInterval(p,Lt)},Ht)},[]);c.useEffect(()=>_,[_]),c.useEffect(()=>{const p=t.current;if(!p)return;const l=f=>{if(f.ctrlKey||f.metaKey||f.altKey)return;const E=f.target.tagName;if(!(E==="INPUT"||E==="TEXTAREA"||f.target.isContentEditable))switch(f.key){case"ArrowUp":f.preventDefault(),A();break;case"ArrowDown":f.preventDefault(),O();break;case"ArrowLeft":f.preventDefault(),B();break;case"ArrowRight":f.preventDefault(),D();break}};return p.addEventListener("keydown",l),()=>p.removeEventListener("keydown",l)},[t,A,O,B,D]);const P=c.useCallback(()=>{I.current=!1,x(!1),a({x:0,y:0}),F.current={x:0,y:0},R.current&&cancelAnimationFrame(R.current)},[]),V=c.useCallback(p=>{p.preventDefault(),I.current=!0,x(!0),W.current={x:p.clientX,y:p.clientY},F.current={x:0,y:0},p.target.setPointerCapture(p.pointerId);const l=()=>{if(!I.current)return;const f=t.current;if(f){const{x:E,y:$}=F.current,T=Math.sqrt(E*E+$*$);if(T>Be){const G=Math.min(T/Se,1)*zt;f.scrollLeft+=E/T*G,f.scrollTop+=$/T*G}}R.current=requestAnimationFrame(l)};R.current=requestAnimationFrame(l)},[t]),q=c.useCallback(p=>{if(!I.current)return;const l=p.clientX-W.current.x,f=p.clientY-W.current.y;F.current={x:l,y:f};const E=Math.sqrt(l*l+f*f);if(E<Be)a({x:0,y:0});else{const T=Math.min(E,Se)/Se*It;a({x:l/E*T,y:f/E*T})}},[]),K=c.useCallback(p=>{switch(p.key){case"ArrowUp":p.preventDefault(),A();break;case"ArrowDown":p.preventDefault(),O();break;case"ArrowLeft":p.preventDefault(),B();break;case"ArrowRight":p.preventDefault(),D();break}},[A,O,B,D]);return d?e.jsxs("div",{className:`inno-scroll-nav ${n??""}`,role:"toolbar","aria-label":"Scroll navigation",onKeyDown:K,children:[e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-up ${r.canUp?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll up",disabled:!r.canUp,onPointerDown:()=>z(A),onPointerUp:_,onPointerLeave:_,tabIndex:r.canUp?0:-1,children:e.jsx(Pt,{})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-left ${r.canLeft?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll left",disabled:!r.canLeft,onPointerDown:()=>z(B),onPointerUp:_,onPointerLeave:_,tabIndex:r.canLeft?0:-1,children:e.jsx(Ft,{})}),e.jsx("button",{ref:b,type:"button",className:`inno-scroll-nav-joystick ${m?"inno-scroll-nav-joystick-active":""}`,"aria-label":"Drag to scroll freely",onPointerDown:V,onPointerMove:q,onPointerUp:P,onPointerCancel:P,tabIndex:0,children:e.jsx("span",{className:"inno-scroll-nav-joystick-dot",style:{transform:`translate(${o.x}px, ${o.y}px)`}})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-right ${r.canRight?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll right",disabled:!r.canRight,onPointerDown:()=>z(D),onPointerUp:_,onPointerLeave:_,tabIndex:r.canRight?0:-1,children:e.jsx(Rt,{})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-down ${r.canDown?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll down",disabled:!r.canDown,onPointerDown:()=>z(O),onPointerUp:_,onPointerLeave:_,tabIndex:r.canDown?0:-1,children:e.jsx(At,{})})]}):null}function Ot(t){switch(t){case"day":case"week":return"time";default:return"day"}}function _t({onEventClick:t,onSlotClick:n,onSlotSelect:r,onAddEvent:s,className:o,showHeader:a=!0,minSelectionMinutes:m=30,showMoreMode:x,showMoreEventsInPopover:d=!1,isLoading:j=!1,slots:k,classNames:b,settingsContent:I,filterContent:W,headerActions:F,renderPopover:R,calendarRef:S,headerConfig:y,eventDetailMode:A,renderEventDetail:O}){const B=x??(d?"popover":"expand"),{view:D,setView:_,selectedDate:z,setSelectedDate:P,slotDuration:V,filteredEvents:q,users:K,visibleHours:p,workingHours:l,badgeVariant:f,showWorkingHoursOnly:E,clearFocusEventId:$}=ye.useInnoCalendar(),T=c.useMemo(()=>{if(!E||!l)return{startHour:p.start,endHour:p.end};let g=24,M=0;for(const U of Object.keys(l)){const te=l[Number(U)];!te||te.enabled===!1||(te.from<g&&(g=te.from),te.to>M&&(M=te.to))}return g>=M?{startHour:p.start,endHour:p.end}:{startHour:g,endHour:M}},[E,l,p]),re=T,G=c.useRef(null);c.useImperativeHandle(S,()=>({scrollToToday:()=>{const g=new Date;P(g,D),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const M=G.current?.querySelector(".ic-timeline-scroll-container, [class*='overflow-auto']");if(!M)return;const he=(g.getHours()-T.startHour)*96;he>0&&M.scrollTo({top:Math.max(0,he-100),behavior:"smooth"})})})},scrollToWorkingHours:()=>{let g=8;if(l)for(const M of Object.keys(l)){const U=l[Number(M)];U?.enabled&&U.from<g&&(g=Math.max(U.from-1,0))}requestAnimationFrame(()=>{requestAnimationFrame(()=>{const M=G.current?.querySelector(".ic-timeline-scroll-container, [class*='overflow-auto']");if(!M)return;const te=(g-T.startHour)*96;M.scrollTo({top:Math.max(0,te),behavior:"smooth"})})})},getViewRect:()=>G.current?.getBoundingClientRect()??null,focusEvent:g=>{$(),requestAnimationFrame(()=>{$()});const M=G.current?.querySelector(`[data-event-id="${g}"]`);M&&setTimeout(()=>M.click(),150)}}),[P,D,T,l,$]);const ge=c.useMemo(()=>Ot(D),[D]),ee=c.useCallback(g=>{if(r){r(g);return}if(n){const M=g.startDate.getHours();n(g.startDate,M)}},[r,n]),Q=c.useCallback(g=>{_("day"),P(g,"day")},[P,_]),xe=c.useCallback(g=>{_("month"),P(g,"month")},[P,_]),se=c.useCallback(g=>{t?.(g)},[t]),oe=c.useCallback((g,M,U)=>{n?.(g,M)},[n]),pe=()=>{const g=q,M=se,U=R;switch(D){case"day":return e.jsx(w.DayView,{events:g,date:z,visibleHours:re,workingHours:l,slotDuration:V,badgeVariant:f,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"week":return e.jsx(w.WeekView,{events:g,date:z,visibleHours:re,workingHours:l,slotDuration:V,badgeVariant:f,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"month":return e.jsx(w.MonthView,{events:g,date:z,badgeVariant:f,onEventClick:M,onDayClick:Q,renderPopover:U,showMoreMode:B,...k&&{slots:k},...b&&{classNames:b}});case"year":return e.jsx(Je,{events:g,year:z.getFullYear(),onMonthClick:xe,onDayClick:Q,...k&&{slots:k},...b&&{classNames:b}});case"agenda":return e.jsx(w.AgendaView,{events:g,date:z,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"resource-day":return e.jsx(fe,{daysToShow:1,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"resource-week":return e.jsx(fe,{daysToShow:7,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-day":return e.jsx(fe,{daysToShow:1,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-3day":return e.jsx(fe,{daysToShow:3,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-week":return e.jsx(fe,{daysToShow:7,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});default:return e.jsx(w.MonthView,{events:g,date:z,badgeVariant:f,onEventClick:M,onDayClick:Q,...k&&{slots:k},...b&&{classNames:b}})}},le=c.useRef(null);return c.useEffect(()=>{G.current=le.current}),e.jsx(ye.SlotSelectionProvider,{mode:ge,onSelect:ee,minDurationMinutes:m,slotDurationMinutes:V,enabled:!!(r||n),children:e.jsxs("div",{className:h.cn("inno-calendar-root flex flex-col h-full p-4",b?.root,o),children:[a&&e.jsx(w.CalendarHeader,{currentDate:z,view:D,events:q,onViewChange:_,onNavigateToday:()=>P(new Date,D),onNavigatePrev:()=>{const g=new Date(z);D==="day"||D==="timeline-day"||D==="resource-day"?g.setDate(g.getDate()-1):D==="timeline-3day"?g.setDate(g.getDate()-3):D==="week"||D==="timeline-week"||D==="resource-week"?g.setDate(g.getDate()-7):D==="month"?g.setMonth(g.getMonth()-1):D==="year"?g.setFullYear(g.getFullYear()-1):g.setDate(g.getDate()-7),P(g,D)},onNavigateNext:()=>{const g=new Date(z);D==="day"||D==="timeline-day"||D==="resource-day"?g.setDate(g.getDate()+1):D==="timeline-3day"?g.setDate(g.getDate()+3):D==="week"||D==="timeline-week"||D==="resource-week"?g.setDate(g.getDate()+7):D==="month"?g.setMonth(g.getMonth()+1):D==="year"?g.setFullYear(g.getFullYear()+1):g.setDate(g.getDate()+7),P(g,D)},availableViews:["day","week","month","agenda"],showTimelineViews:!0,showSettings:!!I,...!F&&s&&{onAddEvent:s},actions:F,settingsContent:I,filterContent:W,...y&&{headerConfig:y}}),e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:le,className:h.cn("h-full border rounded-lg bg-white overflow-x-auto",b?.viewContainer),children:pe()}),j&&e.jsx("div",{className:"inno-calendar-loading-overlay",children:e.jsx("div",{className:"inno-calendar-spinner"})}),e.jsx(Wt,{containerRef:le})]})]})})}function $t({events:t,users:n=[],scheduleTypes:r=[],initialView:s="week",initialDate:o,initialSelectedUserId:a,initialScheduleTypeIds:m,initialParticipantIds:x,initialWorkingHoursView:d,initialSearchQuery:j,preferencesConfig:k,onEventClick:b,onSlotClick:I,onSlotSelect:W,onAddEvent:F,onEventDrop:R,onDateChange:S,onViewChange:y,className:A,showHeader:O=!0,minSelectionMinutes:B=30,showMoreMode:D,showMoreEventsInPopover:_=!1,isLoading:z=!1,renderPopover:P,slots:V,classNames:q,settingsContent:K,filterContent:p,headerActions:l,focusEventId:f,headerConfig:E,eventDetailMode:$,renderEventDetail:T},re){return e.jsx(ye.DragDropProvider,{...R&&{onEventDrop:R},children:e.jsx(ye.InnoCalendarProvider,{initialEvents:t,initialUsers:n,initialScheduleTypes:r,initialView:s,...o&&{initialDate:o},...a&&{initialSelectedUserId:a},...m&&{initialScheduleTypeIds:m},...x&&{initialParticipantIds:x},...d&&{initialWorkingHoursView:d},...j&&{initialSearchQuery:j},...k&&{preferencesConfig:k},...S&&{onDateChange:S},...y&&{onViewChange:y},...f&&{initialFocusEventId:f},children:e.jsx(_t,{...b&&{onEventClick:b},...I&&{onSlotClick:I},...W&&{onSlotSelect:W},...F&&{onAddEvent:F},...P&&{renderPopover:P},className:A,showHeader:O,minSelectionMinutes:B,...D&&{showMoreMode:D},showMoreEventsInPopover:_,isLoading:z,...V&&{slots:V},...q&&{classNames:q},settingsContent:K,filterContent:p,headerActions:l,calendarRef:re,...E&&{headerConfig:E},...$&&{eventDetailMode:$},...T&&{renderEventDetail:T}})})})}const Bt=c.forwardRef($t),ie=c.forwardRef(({className:t,children:n,...r},s)=>e.jsx("select",{ref:s,className:h.cn("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm","ring-offset-background","focus:outline-none focus:ring-1 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50","[&>option]:bg-background",t),...r,children:n}));ie.displayName="Select";const ae=c.forwardRef(({className:t,...n},r)=>e.jsx("label",{ref:r,className:h.cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...n}));ae.displayName="Label";function Ut({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Vt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const Yt=[{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}];function Kt({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Slot duration",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the time slot duration for day and week calendar views.",...o},m=x=>{r||n(Number(x.target.value))};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Vt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Ut,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx(ie,{value:t.toString(),onChange:m,disabled:r,className:"h-9 w-[128px] text-sm",children:Yt.map(x=>e.jsx("option",{value:x.value.toString(),children:x.label},x.value))})]})}function qt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Gt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const Jt=[{value:"dot",label:"Dot indicator"},{value:"colored",label:"Full color"},{value:"mixed",label:"Mixed"}];function Xt({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Event display",lockedMessage:"This setting is locked by the administrator",infoMessage:"Choose how events are displayed. Dot shows a small indicator, colored fills the entire event, mixed uses both.",options:{dot:"Dot indicator",colored:"Full color",mixed:"Mixed"},...o},m=d=>a.options?.[d]??d,x=d=>{r||n(d.target.value)};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Gt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(qt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx(ie,{value:t,onChange:x,disabled:r,className:"h-9 w-[128px] text-sm",children:Jt.map(d=>e.jsx("option",{value:d.value,children:m(d.value)},d.value))})]})}function Qt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Zt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function en(){return Array.from({length:25},(t,n)=>({value:n,label:`${String(n).padStart(2,"0")}:00`}))}function tn({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Visible hours",from:"From",to:"To",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the visible hour range for day and week views. Hours outside this range will be hidden.",...o},m=en(),x=j=>{if(r)return;const k=Number(j.target.value);k<t.endHour&&n({...t,startHour:k})},d=j=>{if(r)return;const k=Number(j.target.value);k>t.startHour&&n({...t,endHour:k})};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Zt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Qt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ae,{className:"text-xs text-muted-foreground",children:a.from}),e.jsx(ie,{value:t.startHour.toString(),onChange:x,disabled:r,className:"h-9 w-[88px] text-sm",children:m.map(j=>e.jsx("option",{value:j.value.toString(),disabled:j.value>=t.endHour,children:j.label},j.value))})]}),e.jsx("span",{className:"mt-5 text-muted-foreground",children:"—"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ae,{className:"text-xs text-muted-foreground",children:a.to}),e.jsx(ie,{value:t.endHour.toString(),onChange:d,disabled:r,className:"h-9 w-[88px] text-sm",children:m.map(j=>e.jsx("option",{value:j.value.toString(),disabled:j.value<=t.startHour,children:j.label},j.value))})]})]})]})}function nn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function rn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function sn({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}const on=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function an(){return Array.from({length:25},(t,n)=>({value:n,label:`${String(n).padStart(2,"0")}:00`}))}const Ue={sunday:"Sun",monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat"};function ln({dayLabel:t,config:n,onChange:r,disabled:s,hourOptions:o}){const a=()=>{s||r({...n,enabled:!n.enabled})},m=d=>{if(s)return;const j=Number(d.target.value);j<n.to&&r({...n,from:j})},x=d=>{if(s)return;const j=Number(d.target.value);j>n.from&&r({...n,to:j})};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",role:"checkbox","aria-checked":n.enabled,"aria-label":`Enable ${t}`,onClick:a,disabled:s,className:h.cn("flex size-5 shrink-0 items-center justify-center rounded border transition-colors",n.enabled?"border-primary bg-primary text-primary-foreground":"border-input bg-background",s&&"cursor-not-allowed opacity-50"),children:n.enabled&&e.jsx(sn,{className:"size-3"})}),e.jsx("span",{className:h.cn("w-10 text-sm",!n.enabled&&"text-muted-foreground"),children:t}),e.jsx(ie,{value:n.from.toString(),onChange:m,disabled:s||!n.enabled,className:"h-8 w-[76px] text-xs",children:o.map(d=>e.jsx("option",{value:d.value.toString(),disabled:d.value>=n.to,children:d.label},d.value))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}),e.jsx(ie,{value:n.to.toString(),onChange:x,disabled:s||!n.enabled,className:"h-8 w-[76px] text-xs",children:o.map(d=>e.jsx("option",{value:d.value.toString(),disabled:d.value<=n.from,children:d.label},d.value))})]})}function cn({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Working hours",lockedMessage:"This setting is locked by the administrator",infoMessage:"Configure working hours for each day of the week. Non-working hours will be grayed out in day and week views.",days:Ue,...o},m=an(),x=(d,j)=>{r||n({...t,[d]:j})};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(rn,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(nn,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx("div",{className:"flex flex-col gap-2",children:on.map(d=>e.jsx(ln,{dayLabel:a.days?.[d]??Ue[d],config:t[d],onChange:j=>x(d,j),disabled:r,hourOptions:m},d))})]})}const dn={sunday:{enabled:!1,from:8,to:18},monday:{enabled:!0,from:8,to:18},tuesday:{enabled:!0,from:8,to:18},wednesday:{enabled:!0,from:8,to:18},thursday:{enabled:!0,from:8,to:18},friday:{enabled:!0,from:8,to:18},saturday:{enabled:!1,from:8,to:18}};function Ee({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function un({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function xn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Le({checked:t,onCheckedChange:n,className:r,children:s}){return e.jsx("button",{type:"button",role:"checkbox","aria-checked":t,onClick:()=>n(!t),className:r,children:s})}function hn({src:t,alt:n,fallback:r,className:s}){const[o,a]=c.useState(!1);return!t||o?e.jsx("div",{className:h.cn("flex items-center justify-center bg-zinc-200 text-zinc-600 font-medium text-sm",s),children:r||"?"}):e.jsx("img",{src:t,alt:n||"",className:h.cn("object-cover",s),onError:()=>a(!0)})}function Ve({value:t,onChange:n,placeholder:r,className:s}){return e.jsxs("div",{className:h.cn("relative",s),children:[e.jsx(un,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),placeholder:r,className:"h-9 w-full rounded-lg border border-border bg-white pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary"})]})}function Ye(t,n,r,s=.3){if(!n.trim())return t;const o=n.toLowerCase();return t.filter(a=>r(a).some(x=>x?x.toLowerCase().includes(o):!1))}const mn={title:"Filters",subtitle:"Filter calendar events",scheduleTypes:"Event Types",participants:"Participants",clearAll:"Clear all",selectAll:"Select all",unselectAll:"Unselect all",searchScheduleTypes:"Search event types...",searchParticipants:"Search participants...",noScheduleTypes:"No event types found",noParticipants:"No participants found"};function fn({scheduleTypes:t,users:n,selectedScheduleTypeIds:r,onScheduleTypeChange:s,selectedUserIds:o,onUserChange:a,onClearAll:m,className:x,scheduleTypesLoading:d=!1,usersLoading:j=!1,labels:k,getScheduleTypeName:b}){const I={...mn,...k},[W,F]=c.useState(""),[R,S]=c.useState(""),y=c.useMemo(()=>W.trim()?Ye(t,W,l=>[l.name,b?.(l)||l.name]):t,[t,W,b]),A=c.useMemo(()=>R.trim()?Ye(n,R,l=>[l.name,l.email||""]):n,[n,R]),O=y.length>0&&y.every(l=>r.includes(l.id)),B=A.length>0&&A.every(l=>o.includes(l.id)),D=r.length+o.length,_=(l,f)=>{const E=f?[...r,l]:r.filter($=>$!==l);s(E)},z=()=>{if(O){const l=new Set(y.map(f=>f.id));s(r.filter(f=>!l.has(f)))}else{const l=new Set([...r,...y.map(f=>f.id)]);s(Array.from(l))}},P=(l,f)=>{const E=f?[...o,l]:o.filter($=>$!==l);a(E)},V=()=>{if(B){const l=new Set(A.map(f=>f.id));a(o.filter(f=>!l.has(f)))}else{const l=new Set([...o,...A.map(f=>f.id)]);a(Array.from(l))}},q=()=>{s([]),a([]),m?.()},K=l=>b?b(l):l.name,p=l=>l.colorHex||l.color||"#069AD7";return e.jsxs("div",{className:h.cn("flex min-w-72 max-w-72 flex-col rounded-lg border bg-white shadow-sm",x),children:[e.jsxs("header",{className:"flex items-start justify-between gap-2 px-4 pb-2 pt-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.subtitle})]}),D>0&&e.jsxs("button",{type:"button",onClick:q,className:"flex h-auto items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(xn,{className:"h-3.5 w-3.5"}),I.clearAll]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:I.scheduleTypes}),e.jsx("button",{type:"button",onClick:z,className:"text-xs font-medium text-primary transition-colors hover:text-primary/80",children:O?I.unselectAll:I.selectAll})]}),t.length>6&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx(Ve,{value:W,onChange:F,placeholder:I.searchScheduleTypes})}),e.jsxs("div",{className:"flex max-h-[220px] flex-col gap-2 overflow-y-auto px-4 pb-2 scrollbar-thin",children:[d?Array.from({length:4}).map((l,f)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-2 rounded-md border border-border/60 bg-muted/40 p-2",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"})]},`skeleton-${f}`)):y.map(l=>{const f=r.includes(l.id),E=p(l);return e.jsxs(Le,{checked:f,onCheckedChange:$=>_(l.id,$),className:h.cn("relative flex w-full cursor-pointer items-center justify-between gap-3 rounded-md border border-border bg-white px-3 py-2 transition-colors hover:border-primary/50",f&&"border-primary bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:h.cn("flex h-4 w-4 items-center justify-center rounded border border-border text-xs transition-colors",f&&"border-primary bg-primary text-primary-foreground"),children:f&&e.jsx(Ee,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:K(l)})]}),e.jsx("div",{className:"h-4 w-4 rounded-full border",style:{backgroundColor:E,borderColor:E}})]},l.id)}),!d&&y.length===0&&e.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:I.noScheduleTypes})]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:I.participants}),e.jsx(Le,{checked:B,onCheckedChange:()=>V(),className:h.cn("flex h-5 w-5 items-center justify-center rounded border border-border bg-white transition-colors hover:border-primary/50",B&&"border-primary bg-primary text-primary-foreground"),children:B&&e.jsx(Ee,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(Ve,{value:R,onChange:S,placeholder:I.searchParticipants})}),e.jsxs("div",{className:"flex max-h-[400px] flex-col gap-2 overflow-y-auto px-4 pb-4 scrollbar-thin",children:[j?Array.from({length:4}).map((l,f)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-3 rounded-md border border-border/60 bg-muted/40 p-3",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-2 w-32 rounded bg-muted-foreground/10"})]})]},`p-skeleton-${f}`)):A.map(l=>{const f=o.includes(l.id);return e.jsxs(Le,{checked:f,onCheckedChange:E=>P(l.id,E),className:h.cn("relative flex w-full cursor-pointer items-start gap-2 rounded-lg border border-border bg-white p-2 transition-colors hover:border-primary/50",f&&"border-primary bg-zinc-50"),children:[e.jsx("span",{className:h.cn("flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border border-border transition-colors",f&&"border-primary bg-primary text-primary-foreground"),children:f&&e.jsx(Ee,{className:"h-2.5 w-2.5"})}),e.jsxs("div",{className:"flex flex-1 items-start gap-2",children:[e.jsx(hn,{src:l.avatar??null,alt:l.name,fallback:l.name?.[0]?.toUpperCase()??"?",className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex max-w-[140px] flex-col gap-0.5 overflow-hidden",children:[e.jsx("span",{className:"line-clamp-1 text-sm font-medium text-foreground",children:l.name}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",title:l.email,children:l.email})]})]})]},l.id)}),!j&&A.length===0&&e.jsx("p",{className:"px-4 text-xs text-muted-foreground",children:I.noParticipants})]})]})]})}function gn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}),e.jsx("circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"})]})}function pn({scheduleTypes:t,value:n,onChange:r,allLabel:s="All types",className:o,label:a}){const m=d=>{r(d.target.value)},x=t.find(d=>String(d.id)===n);return e.jsxs("div",{className:h.cn("flex flex-col gap-1",o),children:[a&&e.jsx(ae,{className:"text-xs text-muted-foreground",children:a}),e.jsxs("div",{className:"relative",children:[x?e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 size-3 -translate-y-1/2 rounded-full",style:{backgroundColor:x.color}}):e.jsx(gn,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(ie,{value:n,onChange:m,className:"h-9 w-full min-w-[140px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:s}),t.map(d=>e.jsx("option",{value:String(d.id),children:d.label},d.id))]})]})]})}function vn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function jn({users:t,value:n,onChange:r,allLabel:s="All users",className:o,label:a}){const m=x=>{r(x.target.value)};return e.jsxs("div",{className:h.cn("flex flex-col gap-1",o),children:[a&&e.jsx(ae,{className:"text-xs text-muted-foreground",children:a}),e.jsxs("div",{className:"relative",children:[e.jsx(vn,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(ie,{value:n,onChange:m,className:"h-9 w-full min-w-[120px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:s}),t.map(x=>e.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})}function wn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"}),e.jsx("path",{d:"M8 14h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 18h.01"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M16 18h.01"})]})}function bn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.3V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function yn({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function kn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 3h6v6"}),e.jsx("path",{d:"M10 14 21 3"}),e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function Nn(t){const n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${s}`}function Ke(t){const n=t.getHours(),r=t.getMinutes(),s=n>=12?"PM":"AM",o=n%12||12,a=String(r).padStart(2,"0");return`${o}:${a} ${s}`}function Cn(t){const n=Ke(t.startDate),r=Ke(t.endDate);return`${n} - ${r}`}function Dn(t){const n=Y.addDays(new Date,1);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function Mn(t){if(Y.isToday(t))return"Today";if(Dn(t))return"Tomorrow";const n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=n[t.getDay()],o=r[t.getMonth()],a=t.getDate();return`${s}, ${o} ${a}`}function Tn(t,n){const r=new Map;for(const s of t){const o=Nn(s.startDate),a=r.get(o)??[];a.push(s),r.set(o,a)}return Array.from(r.entries()).map(([s,o])=>{const a=[...o].sort((x,d)=>x.startDate.getTime()-d.startDate.getTime()),m=n>0?a.slice(0,n):a;return{date:new Date(s),dateKey:s,events:m,hasMore:n>0&&a.length>n}}).sort((s,o)=>s.date.getTime()-o.date.getTime())}function Sn(t){const n=Y.startOfDay(new Date),r=Y.endOfDay(new Date);return t.filter(s=>s.startDate>=n&&s.startDate<=r).length}function He({className:t}){return e.jsx("div",{className:h.cn("animate-pulse rounded-md bg-muted",t)})}function En({event:t,onClick:n}){return e.jsxs("button",{type:"button",onClick:()=>n?.(t),className:h.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3 p-2"),children:[e.jsx("div",{className:"shrink-0 rounded-full mt-1.5 size-2",style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Cn(t)})]}),n&&e.jsx(yn,{className:"shrink-0 size-4 text-muted-foreground/50 mt-1"})]})}function Ln({group:t,onEventClick:n}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5",children:[e.jsx("h3",{className:h.cn("text-xs font-semibold",Y.isToday(t.date)&&"text-primary"),children:Mn(t.date)}),t.hasMore&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.events.length," more"]})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(r=>e.jsx(En,{event:r,onClick:n},r.id))})]})}function Hn({events:t,isLoading:n=!1,className:r,daysAhead:s=7,maxEventsPerDay:o=3,onEventClick:a,onNavigateToAgenda:m}){const[x,d]=c.useState(!1),j=c.useMemo(()=>{const F=Y.startOfDay(new Date),R=Y.addDays(F,s);return t.filter(S=>S.endDate>=F&&S.startDate<R)},[t,s]),k=c.useMemo(()=>Tn(j,o),[j,o]),b=c.useMemo(()=>Sn(t),[t]),I=F=>{d(!1),a?.(F)},W=()=>{d(!1),m?.()};return e.jsxs(w.Popover,{open:x,onOpenChange:d,children:[e.jsxs(w.PopoverTrigger,{className:h.cn("relative rounded-xl hover:text-zinc-700 hover:!bg-zinc-300 !bg-zinc-200 text-zinc-600 shadow-none !px-2.5 p-2 max-h-10",r),children:[e.jsx(wn,{className:"h-4 w-4"}),b>0&&e.jsx(w.Badge,{variant:"destructive",className:"absolute -right-4 -top-4 m-3 flex h-5 w-5 items-center justify-center rounded-full bg-primary p-0 text-[10px] font-medium hover:bg-primary",children:b>99?"99+":b})]}),e.jsxs(w.PopoverContent,{className:"w-80 rounded-xl p-0",align:"end",side:"bottom",sideOffset:8,children:[e.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Upcoming"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b>0?`${b} event${b>1?"s":""} today`:"No events today"})]}),m&&e.jsxs("button",{type:"button",onClick:W,className:"text-xs text-primary hover:underline flex items-center gap-1",children:["View all",e.jsx(kn,{className:"size-3"})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto p-2",children:n?e.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:3}).map((F,R)=>e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(He,{className:"h-2 w-2 rounded-full mt-2"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(He,{className:"h-4 w-full"}),e.jsx(He,{className:"h-3 w-3/4"})]})]},R))}):k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(bn,{className:"mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"}),e.jsxs("p",{className:"text-xs text-muted-foreground/70",children:["Your schedule is clear for the next ",s," days"]})]}):e.jsx("div",{className:"space-y-3 divide-y",children:k.map(F=>e.jsx(Ln,{group:F,onEventClick:I},F.dateKey))})})]})]})}function In({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.25V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function Xe({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function zn(t){const n=new Date;return n.setDate(n.getDate()+1),t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function qe(t){const n=t.getHours(),r=t.getMinutes(),s=n>=12?"PM":"AM";return`${n%12||12}:${r.toString().padStart(2,"0")} ${s}`}function Pn(t){return new Intl.DateTimeFormat("en-US",{weekday:"long",month:"short",day:"numeric"}).format(t)}function An(t){const n=qe(t.startDate),r=qe(t.endDate);return`${n} - ${r}`}function Fn(t){return Y.isToday(t)?"Today":zn(t)?"Tomorrow":Pn(t)}function Rn(t,n){const r=new Map;for(const s of t){const o=Y.formatDateISO(s.startDate),a=r.get(o)??[];a.push(s),r.set(o,a)}return Array.from(r.entries()).map(([s,o])=>{const a=[...o].sort((x,d)=>x.startDate.getTime()-d.startDate.getTime()),m=n>0?a.slice(0,n):a;return{date:new Date(s),dateKey:s,events:m,hasMore:n>0&&a.length>n}}).sort((s,o)=>s.date.getTime()-o.date.getTime())}function Wn({event:t,onClick:n,compact:r}){return e.jsxs("button",{type:"button",onClick:()=>n?.(t),className:h.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3",r?"p-2":"p-3"),children:[e.jsx("div",{className:h.cn("shrink-0 rounded-full mt-1",r?"size-2":"size-2.5"),style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:h.cn("font-medium truncate",r?"text-xs":"text-sm"),children:t.title}),e.jsx("p",{className:h.cn("text-muted-foreground truncate",r?"text-[10px]":"text-xs"),children:An(t)})]}),n&&e.jsx(Xe,{className:h.cn("shrink-0 text-muted-foreground/50",r?"size-3":"size-4")})]})}function On({group:t,onEventClick:n,onViewMore:r,compact:s}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:h.cn("flex items-center justify-between px-2",s?"py-1":"py-1.5"),children:[e.jsx("h3",{className:h.cn("font-semibold",s?"text-xs":"text-sm",Y.isToday(t.date)&&"text-primary"),children:Fn(t.date)}),t.hasMore&&r&&e.jsx("button",{type:"button",onClick:()=>r(t.date),className:h.cn("text-primary hover:underline",s?"text-[10px]":"text-xs"),children:"+more"})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(o=>e.jsx(Wn,{event:o,onClick:n,compact:s},o.id))})]})}function _n({events:t,daysAhead:n=7,maxEventsPerDay:r=3,onEventClick:s,onViewAll:o,className:a,emptyState:m,title:x="Upcoming",showHeader:d=!0,compact:j=!1}){const k=Ce.useOptionalCalendarContext(),b=k?.filteredEvents,I=k?.currentDate??new Date,W=t??b??[],F=c.useMemo(()=>{const y=Y.startOfDay(I),A=new Date(y);return A.setDate(A.getDate()+n),W.filter(O=>O.endDate>=y&&O.startDate<A)},[W,n,I]),R=c.useMemo(()=>Rn(F,r),[F,r]),S=F.length;return R.length===0?e.jsxs("div",{className:h.cn("rounded-lg border bg-card",a),children:[d&&e.jsx("div",{className:h.cn("border-b px-4 flex items-center justify-between",j?"py-2":"py-3"),children:e.jsx("h2",{className:h.cn("font-semibold",j?"text-sm":"text-base"),children:x})}),e.jsx("div",{className:h.cn("flex flex-col items-center justify-center text-center",j?"py-6 px-4":"py-10 px-6"),children:m??e.jsxs(e.Fragment,{children:[e.jsx(In,{className:h.cn("text-muted-foreground/50 mb-2",j?"size-8":"size-10")}),e.jsx("p",{className:h.cn("text-muted-foreground",j?"text-xs":"text-sm"),children:"No upcoming events"})]})})]}):e.jsxs("div",{className:h.cn("rounded-lg border bg-card overflow-hidden",a),children:[d&&e.jsxs("div",{className:h.cn("border-b px-4 flex items-center justify-between",j?"py-2":"py-3"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:h.cn("font-semibold",j?"text-sm":"text-base"),children:x}),e.jsx("span",{className:h.cn("text-muted-foreground bg-muted rounded-full px-2",j?"text-[10px] py-0":"text-xs py-0.5"),children:S})]}),o&&e.jsxs("button",{type:"button",onClick:()=>o(),className:h.cn("text-primary hover:underline flex items-center gap-0.5",j?"text-xs":"text-sm"),children:["View all",e.jsx(Xe,{className:"size-3"})]})]}),e.jsx("div",{className:h.cn("divide-y overflow-auto",j?"p-2 max-h-[280px]":"p-3 max-h-[400px]"),children:R.map(y=>e.jsx(On,{group:y,onEventClick:s,onViewMore:o?A=>o(A):void 0,compact:j},y.dateKey))})]})}exports.AgendaDropdown=Hn;exports.AgendaWidget=_n;exports.BadgeVariantSetting=Xt;exports.Calendar=et;exports.CalendarFilterSidebar=fn;exports.DEFAULT_WEEK_WORKING_HOURS=dn;exports.EventPopover=pt;exports.InnoCalendar=Bt;exports.ScheduleTypeFilter=pn;exports.SlotDurationSetting=Kt;exports.TimelineView=fe;exports.UserFilter=jn;exports.VisibleHoursSetting=tn;exports.WorkingHoursSetting=cn;exports.YearView=Je;
2
- //# sourceMappingURL=agenda-widget-YH495m1F.cjs.map
1
+ "use strict";const e=require("react/jsx-runtime"),Ce=require("./use-calendar-BEuelmSu.cjs"),c=require("react"),h=require("./index-D2U2F80P.cjs"),w=require("./week-view-TztP9f-j.cjs"),ye=require("./slot-selection-context-CHSaOPWP.cjs"),Y=require("./utils.cjs");function Ze({view:t,className:n=""}){return e.jsx("div",{className:n,style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"400px",backgroundColor:"#f9fafb",borderRadius:"0.5rem",border:"1px dashed #d1d5db"},children:e.jsxs("div",{style:{textAlign:"center",color:"#6b7280"},children:[e.jsxs("p",{style:{fontSize:"1.125rem",fontWeight:500},children:[t.charAt(0).toUpperCase()+t.slice(1)," View"]}),e.jsx("p",{style:{fontSize:"0.875rem"},children:"Implementation pending"})]})})}function ze({view:t,className:n}){return e.jsx(Ze,{view:t,className:n})}function et(t){const{events:n,resources:r,scheduleTypes:s,initialView:o="week",initialDate:a,initialFilters:m,preferences:x,locale:d,slots:j,renderEvent:k,onViewChange:b,onDateChange:I,onEventClick:W,onSlotSelect:F,onFiltersChange:R,className:S,children:y}=t,A=Ce.useOptionalCalendarContext();if(A)return e.jsx("div",{className:S,style:{position:"relative"},children:y??e.jsx(ze,{view:A.view,className:S})});const O=Ce.useCalendar({events:n,resources:r,scheduleTypes:s,initialView:o,initialDate:a,initialFilters:m,preferences:x,locale:d,onViewChange:b,onDateChange:I,onEventClick:W,onSlotSelect:F,onFiltersChange:R});return e.jsx(Ce.CalendarProvider,{value:O,children:e.jsx("div",{className:S,style:{position:"relative"},children:y??e.jsx(ze,{view:O.view,className:S})})})}function tt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),e.jsx("path",{d:"m15 5 4 4"})]})}function Ge({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),e.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function De({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}function nt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m4.9 4.9 14.2 14.2"})]})}function we({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}function rt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]})}function st({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function ot({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function at({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}function it({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"})]})}function lt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),e.jsx("path",{d:"M10 9H8"}),e.jsx("path",{d:"M16 13H8"}),e.jsx("path",{d:"M16 17H8"})]})}function me({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:h.cn("animate-spin",t),children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}const ct={edit:"Edit",delete:"Delete",cancel:"Cancel Event",close:"Close",going:"Going",notGoing:"Not Going",confirmMeeting:"Confirm meeting took place",completed:"Completed",canceled:"Canceled",participants:"Participants",guest:"guest",guests:"guests",confirmed:"confirmed",organizer:"Organizer",client:"Client",more:"more",noDateProvided:"No date provided",eventNotFound:"Event not found",cancellationNote:"Cancellation Note",canceledOn:"Canceled on",acceptThisEvent:"Accept this event only",acceptAllEvents:"Accept all events",deleteConfirmTitle:"Delete Event",deleteConfirmDescription:"Are you sure you want to delete this event? This action cannot be undone."},be=c.forwardRef(({onClick:t,label:n,children:r,className:s,variant:o="ghost",...a},m)=>e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button",ref:m,onClick:t,className:h.cn("h-8 w-8 rounded-full flex items-center justify-center transition-colors",o==="ghost"&&"hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400",o==="destructive"&&"hover:bg-red-50 dark:hover:bg-red-950/30 text-zinc-600 dark:text-zinc-400 hover:text-red-600",s),"aria-label":n,...a,children:r})}),e.jsx(w.TooltipContent,{side:"bottom",className:"text-xs",children:n})]}));be.displayName="IconButton";function dt({src:t,alt:n,initials:r,className:s,isClient:o}){const[a,m]=c.useState(!1);return e.jsx("div",{className:h.cn("relative h-7 w-7 rounded-full overflow-hidden shrink-0",s),children:t&&!a?e.jsx("img",{src:t,alt:n,className:"h-full w-full object-cover",onError:()=>m(!0)}):e.jsx("div",{className:h.cn("h-full w-full flex items-center justify-center text-[10px] font-medium",o?"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300":"bg-zinc-200 dark:bg-zinc-700 text-zinc-700 dark:text-zinc-300"),children:r})})}function Pe({participant:t,isEventCanceled:n=!1,labels:r}){const s=t.name||"Unknown",o=s.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),a=t.isOrganizer??!1,m=t.isConfirmed,x=m===!0,d=m===!1,j=t.isClient??!1,k=t.profilePicture||t.avatar,b=n;return e.jsxs("div",{className:h.cn("flex items-center gap-3 py-0",b&&"opacity-60"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(dt,{src:k,alt:s,initials:o,isClient:j,className:h.cn(b&&"grayscale")}),b||d?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-100 dark:bg-red-900/50 flex items-center justify-center",children:e.jsx(De,{className:"h-2 w-2 text-red-600 dark:text-red-400 stroke-[3]"})})}):x?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-100 dark:bg-green-900/50 flex items-center justify-center",children:e.jsx(we,{className:"h-2 w-2 text-green-600 dark:text-green-400 stroke-[3]"})})}):null]}),e.jsxs("div",{className:"!h-fit min-w-0 gap-0",children:[e.jsx("div",{className:"gap-0",children:e.jsx("span",{className:h.cn("text-sm text-zinc-900 dark:text-zinc-100 truncate",b&&"line-through text-zinc-500 dark:text-zinc-500"),children:s})}),j&&e.jsx("div",{className:"text-[10px] px-1.5 w-fit py-0.5 rounded bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-medium",children:r.client}),a&&!b&&e.jsx("div",{className:"text-xs text-zinc-500",children:r.organizer})]})]})}function ut({open:t,onOpenChange:n,title:r,children:s}){return c.useEffect(()=>{if(!t)return;const o=a=>{a.key==="Escape"&&n(!1)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t,n]),c.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),t?e.jsxs("div",{className:"fixed inset-0 z-50",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>n(!1),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&n(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-xl overflow-hidden",children:[r&&e.jsx("div",{className:"sr-only",children:r}),s]})})]}):null}function xt({open:t,onOpenChange:n,title:r,description:s,cancelLabel:o,confirmLabel:a,onConfirm:m,isLoading:x}){return t?e.jsxs("div",{className:"fixed inset-0 z-[60]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>n(!1),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&n(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-xl p-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-zinc-100",children:r}),e.jsx("p",{className:"mt-2 text-sm text-zinc-600 dark:text-zinc-400",children:s}),e.jsxs("div",{className:"mt-4 flex justify-end gap-3",children:[e.jsx(w.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:o}),e.jsxs(w.Button,{variant:"destructive",size:"sm",onClick:m,disabled:x,children:[x&&e.jsx(me,{className:"h-4 w-4 mr-2"}),e.jsx(Ge,{className:"h-4 w-4 mr-2"}),a]})]})]})})]}):null}function ht(t,n){return t.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}function mt(t,n){const r={hour:"2-digit",minute:"2-digit",hour12:!1};return`${t.toLocaleTimeString(void 0,r)} – ${n.toLocaleTimeString(void 0,r)}`}function ft(t){return t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function gt(t){const[n,r]=c.useState(()=>typeof window<"u"?window.matchMedia(t).matches:!1);return c.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia(t),o=a=>r(a.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[t]),n}function Ae({event:t,labels:n,isLoading:r,onClose:s,onEdit:o,onDelete:a,onCancel:m,onAccept:x,onDecline:d,onConfirmMeeting:j,canEdit:k=!0,canDelete:b=!1,canCancel:I=!0,isCurrentUserParticipant:W=!1,isCurrentUserClient:F=!1,currentUserAcceptStatus:R,isAcceptLoading:S=!1,isDeclineLoading:y=!1,isConfirmLoading:A=!1,isDeleteLoading:O=!1,renderParticipant:B,renderHeaderActions:D,renderCancelReason:_,renderDeleteConfirmation:z,formatDate:P=ht,formatTimeRange:V=mt}){const[q,K]=c.useState(!1),p=!(t.isCanceled||t.meetingTookPlace),l=t.isRecurring??!1,f=t.participantDetails,E=t.participantsNames||[],$=f&&f.length>0,T=R===!0,re=R===!1,G=W&&!F&&p,ge=$?f.filter(M=>M.isConfirmed).length:t.isAccepted?E.length:0,ee=$?f.length:E.length,Q=t.scheduleTypeColor||t.hexColor||"#039BE5",xe=c.useCallback(()=>t.startDate?P(t.startDate):n.noDateProvided,[t.startDate,P,n.noDateProvided]),se=c.useCallback(()=>t.startDate&&t.endDate?V(t.startDate,t.endDate):null,[t.startDate,t.endDate,V]),oe=()=>{s(),o?.(t)},pe=()=>{s(),m?.(t)},le=()=>{K(!0)},g=()=>{a?.(t),K(!1)};return r?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx(me,{className:"h-6 w-6 text-zinc-400"})}):e.jsxs(w.TooltipProvider,{delayDuration:300,children:[e.jsxs("div",{className:"flex flex-col gap-0.5 p-3",children:[e.jsx("div",{className:"flex items-start justify-end gap-0.5",children:D?D({onClose:s}):e.jsxs(e.Fragment,{children:[p&&k&&o&&e.jsx(be,{onClick:oe,label:n.edit,children:e.jsx(tt,{className:"h-[18px] w-[18px]"})}),p&&I&&m&&e.jsx(be,{onClick:pe,label:n.cancel,children:e.jsx(nt,{className:"h-[18px] w-[18px]"})}),b&&a&&e.jsx(be,{onClick:le,label:n.delete,variant:"destructive",children:e.jsx(Ge,{className:"h-[18px] w-[18px]"})}),e.jsx(be,{onClick:s,label:n.close,children:e.jsx(De,{className:"h-[18px] w-[18px]"})})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded mt-1 shrink-0",style:{backgroundColor:Q}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:h.cn("text-[22px] font-normal text-zinc-900 dark:text-zinc-100 leading-tight",t.isCanceled&&"line-through opacity-60"),children:t.title}),t.meetingTookPlace&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 text-xs font-medium",children:[e.jsx(rt,{className:"h-3 w-3"}),n.completed]}),t.isCanceled&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 text-xs font-medium",children:[e.jsx(De,{className:"h-3 w-3"}),n.canceled]})]}),e.jsxs("div",{className:"mt-1 text-sm text-zinc-600 dark:text-zinc-400",children:[e.jsx("span",{children:xe()}),se()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1.5",children:"·"}),e.jsx("span",{children:se()})]})]}),l&&t.recurrenceSummary&&e.jsx("div",{className:"text-sm text-zinc-500 dark:text-zinc-500",children:t.recurrenceSummary})]})]})}),t.isCanceled&&e.jsx("div",{className:"mx-4 p-3 rounded-lg bg-red-50 dark:bg-red-950/30",children:_?_(t):e.jsx("div",{className:"flex items-start gap-0",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:n.cancellationNote}),t.cancelReason&&e.jsxs("div",{className:"mt-1 text-sm text-red-600/80 dark:text-red-400/80 italic",children:['"',t.cancelReason,'"']}),t.canceledDate&&e.jsxs("div",{className:"mt-1.5 text-xs text-red-500/70 dark:text-red-400/60",children:[n.canceledOn," ",ft(t.canceledDate)]})]})})}),e.jsxs("div",{className:"space-y-0.5",children:[t.address&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(at,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:t.address})]}),($||E.length>0)&&e.jsxs("div",{className:"flex items-start gap-2 py-0",children:[e.jsx(ot,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsxs("span",{className:"text-sm text-zinc-900 dark:text-zinc-100 font-medium",children:[ee," ",ee!==1?n.guests:n.guest]}),ee>0&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["(",ge," ",n.confirmed,")"]})]}),e.jsxs("div",{className:"mt-2 space-y-2",children:[$?f.slice(0,6).map((M,U)=>B?B(M,U):e.jsx(Pe,{participant:M,isEventCanceled:t.isCanceled,labels:n},M.id)):E.slice(0,6).map((M,U)=>{const te={id:String(U),name:M,email:"",isConfirmed:t.isAccepted,isOrganizer:U===0,isClient:!1};return B?B(te,U):e.jsx(Pe,{participant:te,isEventCanceled:t.isCanceled,labels:n},M)}),ee>6&&e.jsxs("div",{className:"text-xs text-zinc-500 py-1.5 pl-10",children:["+",ee-6," ",n.more]})]})]})]}),t.description&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lt,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap",children:t.description})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(it,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:$&&f.find(M=>M.isOrganizer)?.name||E[0]||"Calendar"})]})]}),G&&x&&d&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 mt-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsxs(w.DropdownMenu,{children:[e.jsx(w.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex",children:[e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("rounded-r-none gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:M=>{M.stopPropagation(),T||x(t)},disabled:S,children:S?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[T&&e.jsx(we,{className:"h-3.5 w-3.5"}),n.going]})}),e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("rounded-l-none px-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),children:e.jsx(st,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(w.DropdownMenuContent,{align:"start",children:[e.jsxs(w.DropdownMenuItem,{className:h.cn("gap-1.5 h-8 !border-none !bg-green-50 text-green-800 hover:!bg-green-100",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>x(t),children:[e.jsx(we,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),n.acceptThisEvent]}),e.jsxs(w.DropdownMenuItem,{onClick:()=>x(t),children:[e.jsx(we,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),n.acceptAllEvents]})]})]}):e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",T&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>{T||x(t)},disabled:S,children:S?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[T&&e.jsx(we,{className:"h-3.5 w-3.5"}),n.going]})}),e.jsx(w.Button,{size:"sm",variant:"outline",className:h.cn("gap-1.5 h-8 !border-none !bg-rose-100 text-rose-800 hover:!bg-rose-200",re&&"!bg-rose-700 !text-white hover:!bg-rose-700"),onClick:()=>{re||d(t)},disabled:y,children:y?e.jsx(me,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[re&&e.jsx(De,{className:"h-3.5 w-3.5"}),n.notGoing]})})]})}),W&&T&&!t.meetingTookPlace&&!t.isCanceled&&j&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 py-3",children:e.jsxs(w.Button,{size:"sm",variant:"outline",className:"w-full h-9 hover:!bg-green-100 hover:text-green-700 text-green-700 !bg-green-100 !border-none dark:text-green-400 dark:hover:bg-green-950/30",onClick:()=>j(t),disabled:A,children:[A&&e.jsx(me,{className:"h-4 w-4 mr-2"}),n.confirmMeeting]})})]}),z?q&&z({onConfirm:g,onCancel:()=>K(!1),isLoading:O}):e.jsx(xt,{open:q,onOpenChange:K,title:n.deleteConfirmTitle,description:n.deleteConfirmDescription,cancelLabel:n.cancel,confirmLabel:n.delete,onConfirm:g,isLoading:O})]})}function pt({event:t,children:n,open:r,onOpenChange:s,isLoading:o,labels:a,onEdit:m,onDelete:x,onCancel:d,onAccept:j,onDecline:k,onConfirmMeeting:b,canEdit:I=!0,canDelete:W=!1,canCancel:F=!0,isCurrentUserParticipant:R,isCurrentUserClient:S,currentUserAcceptStatus:y,isAcceptLoading:A,isDeclineLoading:O,isConfirmLoading:B,isDeleteLoading:D,renderParticipant:_,renderHeaderActions:z,renderCancelReason:P,renderDeleteConfirmation:V,formatDate:q,formatTimeRange:K,className:p,width:l=360}){const f=gt("(min-width: 768px)"),E={...ct,...a},$=c.useCallback(()=>{s?.(!1)},[s]),T={event:t,labels:E,isLoading:o,onClose:$,onEdit:m,onDelete:x,onCancel:d,onAccept:j,onDecline:k,onConfirmMeeting:b,canEdit:I,canDelete:W,canCancel:F,isCurrentUserParticipant:R,isCurrentUserClient:S,currentUserAcceptStatus:y,isAcceptLoading:A,isDeclineLoading:O,isConfirmLoading:B,isDeleteLoading:D,renderParticipant:_,renderHeaderActions:z,renderCancelReason:P,renderDeleteConfirmation:V,formatDate:q,formatTimeRange:K};return f?e.jsxs(w.Popover,{open:r??!1,onOpenChange:s??(()=>{}),children:[e.jsx(w.PopoverTrigger,{asChild:!0,children:n}),e.jsx(w.PopoverContent,{className:h.cn("p-0 shadow-lg !rounded-2xl bg-white dark:bg-zinc-900 overflow-hidden border z-50",p),style:{width:l},align:"center",side:"bottom",sideOffset:4,children:e.jsx(Ae,{...T})})]}):e.jsxs(e.Fragment,{children:[n,e.jsx(ut,{open:r??!1,onOpenChange:s??(()=>{}),title:t.title,children:e.jsx(Ae,{...T})})]})}const Me=44,Fe=4,vt=56,Re=8,ke=80,je=140,We=100,Oe=2,jt=8,wt=18;function bt(t){return t.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function yt(t,n){const r=[];for(let s=0;s<n;s++){const o=new Date(t);o.setDate(o.getDate()+s),r.push(o)}return r}function kt(t,n,r){const s=[];return t.forEach((o,a)=>{for(let m=n;m<r;m++)s.push({hour:m,dayIndex:a,date:o})}),s}function Te(t){return`${t.toString().padStart(2,"0")}:00`}function Nt(t){return t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function _e(t){const n=[...t].sort((o,a)=>o.startCol!==a.startCol?o.startCol-a.startCol:a.spanCols-o.spanCols),r=[],s=[];for(const o of n){let a=0;for(;s[a]!==void 0&&s[a]>o.startCol;)a++;s[a]=o.startCol+o.spanCols,r.push({...o,stackIndex:a})}return r}function Ct({src:t,alt:n,fallback:r,className:s}){return e.jsx("div",{className:h.cn("relative flex shrink-0 overflow-hidden rounded-sm border bg-muted",s),children:t?e.jsx("img",{src:t,alt:n,className:"aspect-square h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-muted text-muted-foreground",children:r})})}const Dt=7;function fe({daysToShow:t=Dt,events:n,users:r=[],selectedDate:s,onDateChange:o,onEventClick:a,onSlotClick:m,onSlotSelect:x,visibleHours:d,className:j,getEventUserId:k,renderPopover:b,slots:I,classNames:W,enableDrag:F=!0}){const R=c.useRef(null),S=ye.useOptionalDragDrop(),[y,A]=c.useState(null),O=c.useRef(!1),[B,D]=c.useState(null),_=s??new Date,z=!0,P=d?.from??jt,V=d?.to??wt,q=V-P,K=c.useMemo(()=>{const i=new Date(_);if(t===1||t===3)return i.setHours(0,0,0,0),i;const u=i.getDay(),v=u===0?-6:1-u;return i.setDate(i.getDate()+v),i.setHours(0,0,0,0),i},[_,t]),p=c.useMemo(()=>yt(K,t),[K,t]),l=c.useMemo(()=>kt(p,P,V),[z,p,P,V]),E=k??(i=>{if(i.resourceId)return i.resourceId;const u=i.data;if(u?.userId)return String(u.userId);if(u?.user&&typeof u.user=="object"&&u.user.id)return String(u.user.id);if(i.user?.id)return i.user.id;if(i.participants?.[0]?.id)return i.participants[0].id}),$=c.useMemo(()=>{const i=new Map;for(const u of r)i.set(u.id,{id:u.id,name:u.name,avatar:u.avatar??void 0,email:u.email});for(const u of n){const N=u.data?.user;N?.id&&!i.has(N.id)&&i.set(N.id,{id:N.id,name:N.name??"",avatar:N.avatar??void 0,email:N.email}),u.user?.id&&!i.has(u.user.id)&&i.set(u.user.id,{id:u.user.id,name:u.user.name,avatar:u.user.avatar??void 0,email:u.user.email});for(const C of u.participants||[])C.id&&!i.has(C.id)&&i.set(C.id,{id:C.id,name:C.name,avatar:C.avatar??void 0,email:C.email})}return Array.from(i.values())},[r,n]),T=c.useMemo(()=>{const i=[],u=new Map;for(const C of $)u.set(C.id,[]);u.set("unassigned",[]);for(const C of n){const L=E(C)??"unassigned";(u.get(L)??u.get("unassigned")).push(C)}const v=C=>{const L=[];for(const H of C){const J=H.startDate.getHours()+H.startDate.getMinutes()/60,Z=H.endDate.getHours()+H.endDate.getMinutes()/60;for(let X=0;X<p.length;X++){const ne=p[X],ce=Y.startOfDay(ne),de=Y.endOfDay(ne);if(H.startDate<=de&&H.endDate>=ce){let ue=P,ve=V;if(H.startDate>=ce&&(ue=Math.max(P,J)),H.endDate<=de&&(ve=Math.min(V,Z)),ue=Math.max(P,Math.min(V,ue)),ve=Math.max(P,Math.min(V,ve)),ve>ue){const Ie=X*q+Math.floor(ue-P),Qe=X*q+Math.ceil(ve-P);L.push({event:H,startCol:Ie,spanCols:Math.max(1,Qe-Ie)})}}}}return L};for(const C of $){const L=u.get(C.id)??[],H=v(L),J=_e(H),Z=J.reduce((X,ne)=>Math.max(X,ne.stackIndex+1),0);i.push({user:C,events:J,maxStack:Math.max(Z,1)})}const N=u.get("unassigned")??[];if(N.length>0){const C=v(N),L=_e(C),H=L.reduce((J,Z)=>Math.max(J,Z.stackIndex+1),0);i.push({user:{id:"unassigned",name:"Unassigned",avatar:void 0,email:void 0},events:L,maxStack:Math.max(H,1)})}return i.filter(C=>C.events.length>0)},[$,n,p,z,q,P,V,E]),re=c.useMemo(()=>{const i=new Map;for(const u of T)for(const v of u.events)if(v.spanCols===1){const N=i.get(v.startCol)??0;i.set(v.startCol,N+1)}return i},[T]),G=c.useMemo(()=>{const i=l.length,u=ke,v=[];for(let N=0;N<i;N++){const C=re.get(N)??0;C>Oe?v.push(We+(C-Oe)*20):C>0?v.push(Math.max(u,We)):v.push(u)}return v},[z,l.length,p.length,re]),ge=i=>Math.max(vt,i*(Me+Fe)+Re*2),ee=je+G.reduce((i,u)=>i+u,0),Q=c.useMemo(()=>{const i=[0];for(let u=0;u<G.length;u++)i.push(i[u]+G[u]);return i},[G]);c.useLayoutEffect(()=>{const i=R.current;if(!i)return;const u=()=>{let v=-1;const C=new Date().getHours();{for(let L=0;L<l.length;L++){const H=l[L];if(H&&Y.isToday(H.date)&&H.hour<=C&&H.hour+1>C){v=L;break}}if(v===-1)for(let L=0;L<l.length;L++){const H=l[L];if(H&&Y.isToday(H.date)){v=L;break}}}if(v!==-1){const L=(Q[v]??0)+je,H=i.clientWidth,J=Math.max(0,L-H/3);i.scrollTo({left:J,behavior:"instant"})}};requestAnimationFrame(()=>{requestAnimationFrame(u)})},[_,l,p,Q,z]);const xe=c.useCallback((i,u)=>{const v=u.getBoundingClientRect(),N=i-v.left+u.scrollLeft;for(let C=0;C<Q.length-1;C++){const L=Q[C],H=Q[C+1];if(N>=L&&N<H){const J=(N-L)/(H-L),Z=Math.floor(J*60),X=Math.round(Z/15)*15;return{colIndex:C,minute:Math.min(X,45)}}}return null},[Q]),se=c.useCallback((i,u)=>{if(l[i]){const v=l[i],N=new Date(v.date);return N.setHours(v.hour,u??0,0,0),{date:N,hour:v.hour}}return{date:new Date}},[z,l,p]),oe=c.useCallback((i,u)=>{if(i.preventDefault(),i.dataTransfer.dropEffect="move",!S?.isDragging||!S.dragState)return;const v=i.currentTarget,N=xe(i.clientX,v);if(!N)return;const{colIndex:C,minute:L}=N,{date:H,hour:J}=se(C,L);S.updateDragPreview(H,J,L,u);const{originalStartDate:Z,originalEndDate:X}=S.dragState,ne=X.getTime()-Z.getTime(),ce=l.length;let de;{const ue=ne/36e5;de=Math.max(1,Math.ceil(ue))}de=Math.min(de,ce-C),D({resourceId:u,colIndex:C,spanCols:de})},[S,xe,se,z,l.length,p.length]),pe=c.useCallback(i=>{const u=i.relatedTarget;i.currentTarget.contains(u)||D(null)},[]),le=c.useCallback((i,u)=>{i.preventDefault(),D(null),S?.isDragging&&S.endDrag()},[S]),g=c.useCallback((i,u)=>{if(!y||y.resourceId!==i)return!1;const v=Math.min(y.startCol,y.endCol),N=Math.max(y.startCol,y.endCol);return u>=v&&u<=N},[y]),M=c.useCallback((i,u)=>!B||B.resourceId!==i?!1:u>=B.colIndex&&u<B.colIndex+B.spanCols,[B]),U=c.useCallback((i,u,v)=>{v.button!==0&&v.pointerType==="mouse"||(x||m)&&(v.preventDefault(),O.current=!0,A({resourceId:i,startCol:u,endCol:u,isSelecting:!0}))},[x,m]),te=c.useCallback((i,u,v)=>{if(O.current&&!(!y||y.resourceId!==i)){if(v.buttons===0){O.current=!1;return}A(N=>N?{...N,endCol:u}:null)}},[y]),he=c.useCallback(()=>{if(!O.current||!y)return;O.current=!1;const i=Math.min(y.startCol,y.endCol),u=Math.max(y.startCol,y.endCol),v=se(i),N=se(u),C=new Date(v.date),L=new Date(N.date);N.hour!==void 0&&L.setHours(N.hour+1,0,0,0);const H={startDate:C,endDate:L,resourceId:y.resourceId};i===u&&m&&m(v.date,v.hour,y.resourceId),x?.(H),A(J=>J?{...J,isSelecting:!1}:null),setTimeout(()=>A(null),150)},[y,se,z,m,x]);return c.useEffect(()=>{const i=()=>{O.current&&he()};return window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[he]),c.useEffect(()=>{S?.isDragging||D(null)},[S?.isDragging]),e.jsx("div",{className:h.cn("flex h-full flex-col",j),children:e.jsx("div",{className:"ic-timeline-scroll-container flex-1",ref:R,children:e.jsxs("div",{className:"relative",style:{minWidth:ee},children:[e.jsx("div",{className:"ic-timeline-header sticky top-0 z-20 border-b bg-background",children:t>1?e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex shrink-0 items-center justify-center border-r bg-background px-2 sticky left-0 z-10",style:{width:je},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("div",{className:"flex border-b",children:p.map((i,u)=>{const v=Y.isToday(i),N=u*q,C=G.slice(N,N+q).reduce((L,H)=>L+H,0);return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center border-r py-1.5 font-medium",v?"bg-primary/10 text-primary":"bg-muted/30"),style:{width:C},children:e.jsx("span",{className:"text-xs",children:Nt(i)})},`day-${i.toISOString()}`)})}),e.jsx("div",{className:"flex",children:l.map((i,u)=>{const v=i.hour===P,N=Y.isToday(i.date),C=G[u]??ke;return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center py-1.5 text-[10px] text-muted-foreground",v&&u>0?"border-l-2 border-l-border":"border-r border-r-border/50",N&&"bg-primary/5"),style:{width:C},children:Te(i.hour)},`hour-${i.dayIndex}-${i.hour}`)})})]})]}):e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex shrink-0 items-center border-r bg-background px-2 py-2",style:{width:je},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),l.map((i,u)=>{const v=i.hour===P,N=Y.isToday(i.date),C=G[u]??ke;return e.jsx("div",{className:h.cn("flex shrink-0 items-center justify-center py-1.5 text-[10px] text-muted-foreground",v&&u>0?"border-l-2 border-l-border":"border-r border-r-border/50",N&&"bg-primary/5"),style:{width:C},children:Te(i.hour)},`hour-${i.dayIndex}-${i.hour}`)})]})}),T.map(i=>{const u=ge(i.maxStack);return e.jsxs("div",{className:h.cn("relative flex border-b",W?.resourceRow),style:{height:u},children:[e.jsx("div",{className:"sticky left-0 z-10",style:{width:je},children:e.jsxs("div",{className:h.cn("flex h-full items-center gap-2 sm:gap-3 border-r bg-background px-2 sm:px-4",W?.resourceHeader),children:[e.jsx(Ct,{className:"size-7",src:i.user.avatar,alt:i.user.name,fallback:bt(i.user.name)}),e.jsx("span",{className:"truncate text-xs sm:text-sm font-medium",children:i.user.name})]})}),e.jsxs("div",{className:"ic-timeline-grid relative flex",onDragOver:v=>oe(v,i.user.id),onDragLeave:pe,onDrop:v=>le(v,i.user.id),children:[l.map((v,N)=>{const C=v.hour===P&&N>0,L=G[N]??ke,H=g(i.user.id,N),J=M(i.user.id,N),Z=!!(x||m);return e.jsx("div",{role:Z?"button":void 0,tabIndex:Z?0:void 0,"aria-label":Z?`Select ${Te(v.hour)} on ${v.date.toLocaleDateString()} for ${i.user.name}`:void 0,onPointerDown:X=>U(i.user.id,N,X),onPointerEnter:X=>te(i.user.id,N,X),onPointerUp:he,onKeyDown:X=>{if(Z&&(X.key==="Enter"||X.key===" ")){X.preventDefault();const ne=se(N);m?.(ne.date,ne.hour,i.user.id),x?.({startDate:ne.date,endDate:(()=>{const ce=new Date(ne.date);return ne.hour!==void 0&&ce.setHours(ne.hour+1,0,0,0),ce})(),resourceId:i.user.id})}},className:h.cn("shrink-0 select-none touch-none transition-colors",Z&&"cursor-pointer",C?"border-l-2 border-l-border":"border-r border-r-border/50",Y.isToday(v.date)&&"bg-primary/5",Z&&!y?.isSelecting&&!S?.isDragging&&"hover:bg-blue-50/60",H&&"bg-blue-100/70",J&&"bg-primary/20 ring-2 ring-primary ring-inset"),style:{width:L}},`cell-${v.dayIndex}-${v.hour}`)}),i.events.map(v=>{const N=(Q[v.startCol]??0)+2,C=Q[v.startCol+v.spanCols]??Q[Q.length-1]??0,L=Q[v.startCol]??0,H=C-L-4,J=Re+v.stackIndex*(Me+Fe);return e.jsx("div",{className:"absolute",style:{left:N,width:Math.max(H,0),top:J,height:Me},children:e.jsx(w.EventCard,{event:v.event,variant:"compact",enableDrag:F,onClick:a,renderPopover:b,className:h.cn("h-full w-full",W?.eventCardCompact)})},v.event.id)})]})]},i.user.id)}),T.length===0&&e.jsx("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:"No users or events to display"})]})})})}const Mt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Tt=["January","February","March","April","May","June","July","August","September","October","November","December"];function $e(t){const n=t.hexColor;return n?{backgroundColor:n}:{}}function St({day:t,date:n,events:r,isCurrentMonth:s,onDayClick:o}){const a=Y.isToday(n),m=3,x=r.length;return e.jsxs("button",{type:"button",onClick:()=>o?.(n),className:h.cn("flex h-9 sm:h-11 flex-1 flex-col items-center justify-start gap-0.5 rounded-md pt-0.5 sm:pt-1","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors",!s&&"opacity-40"),children:[e.jsx("div",{className:h.cn("flex size-5 sm:size-6 items-center justify-center rounded-full text-[10px] sm:text-xs font-medium",a&&"bg-primary font-semibold text-primary-foreground"),children:t}),x>0&&e.jsx("div",{className:"mt-0.5 flex items-center gap-0.5",children:x<=m?r.map(d=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:$e(d)},d.id)):e.jsxs(e.Fragment,{children:[r.slice(0,m).map(d=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:$e(d)},d.id)),e.jsxs("span",{className:"text-[6px] sm:text-[7px] font-medium text-muted-foreground",children:["+",x-m]})]})})]})}function Et({date:t,events:n,onMonthClick:r,onDayClick:s}){const o=c.useMemo(()=>Y.generateMonthGrid(t,0),[t]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{type:"button",onClick:()=>r?.(t),className:h.cn("w-full rounded-t-lg border px-2 sm:px-3 py-1.5 sm:py-2 text-xs sm:text-sm font-semibold","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors"),children:Tt[t.getMonth()]}),e.jsxs("div",{className:"flex-1 space-y-1.5 sm:space-y-2 rounded-b-lg border border-t-0 p-2 sm:p-3",children:[e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 text-center",children:Mt.map((a,m)=>e.jsxs("div",{className:"text-[9px] sm:text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"sm:hidden",children:a[0]}),e.jsx("span",{className:"hidden sm:inline",children:a})]},m))}),e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 gap-y-1",children:o.map((a,m)=>{const x=Y.getEventsForDay(n,a.date);return e.jsx(St,{day:a.date.getDate(),date:a.date,events:x,isCurrentMonth:a.isCurrentMonth,onDayClick:s},`${m+1}-${a.date.toISOString()}`)})})]})]})}function Je({events:t,year:n,onMonthClick:r,onDayClick:s,className:o,slots:a,classNames:m}){const x=c.useMemo(()=>Y.getYearMonths(n),[n]);return e.jsxs("div",{className:h.cn("flex flex-col h-full",o),children:[e.jsx("div",{className:"flex items-center justify-center border-b px-4 py-3",children:e.jsx("h2",{className:"text-lg font-semibold",children:n})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:x.map(d=>e.jsx(Et,{date:d,events:t,onMonthClick:r,onDayClick:s},d.getMonth()))})})]})}const Ne=200,Lt=60,Ht=300,It=7,Be=2,Se=40,zt=18;function Pt(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m18 15-6-6-6 6"})})}function At(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function Ft(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}function Rt(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function Wt({containerRef:t,className:n}){const[r,s]=c.useState({canUp:!1,canDown:!1,canLeft:!1,canRight:!1}),[o,a]=c.useState({x:0,y:0}),[m,x]=c.useState(!1),d=r.canUp||r.canDown||r.canLeft||r.canRight,j=c.useRef(null),k=c.useRef(null),b=c.useRef(null),I=c.useRef(!1),W=c.useRef({x:0,y:0}),F=c.useRef({x:0,y:0}),R=c.useRef(0),S=c.useCallback(()=>{const p=t.current;if(!p)return;const l=4;s({canUp:p.scrollTop>l,canDown:p.scrollTop+p.clientHeight<p.scrollHeight-l,canLeft:p.scrollLeft>l,canRight:p.scrollLeft+p.clientWidth<p.scrollWidth-l})},[t]);c.useEffect(()=>{const p=t.current;if(!p)return;S(),p.addEventListener("scroll",S,{passive:!0});const l=new ResizeObserver(S);l.observe(p);const f=new MutationObserver(S);return f.observe(p,{childList:!0,subtree:!0}),()=>{p.removeEventListener("scroll",S),l.disconnect(),f.disconnect()}},[t,S]);const y=c.useCallback((p,l)=>{t.current?.scrollBy({left:p,top:l,behavior:"smooth"})},[t]),A=c.useCallback(()=>y(0,-Ne),[y]),O=c.useCallback(()=>y(0,Ne),[y]),B=c.useCallback(()=>y(-Ne,0),[y]),D=c.useCallback(()=>y(Ne,0),[y]),_=c.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=null),k.current&&(clearInterval(k.current),k.current=null)},[]),z=c.useCallback(p=>{p(),j.current=setTimeout(()=>{k.current=setInterval(p,Lt)},Ht)},[]);c.useEffect(()=>_,[_]),c.useEffect(()=>{const p=t.current;if(!p)return;const l=f=>{if(f.ctrlKey||f.metaKey||f.altKey)return;const E=f.target.tagName;if(!(E==="INPUT"||E==="TEXTAREA"||f.target.isContentEditable))switch(f.key){case"ArrowUp":f.preventDefault(),A();break;case"ArrowDown":f.preventDefault(),O();break;case"ArrowLeft":f.preventDefault(),B();break;case"ArrowRight":f.preventDefault(),D();break}};return p.addEventListener("keydown",l),()=>p.removeEventListener("keydown",l)},[t,A,O,B,D]);const P=c.useCallback(()=>{I.current=!1,x(!1),a({x:0,y:0}),F.current={x:0,y:0},R.current&&cancelAnimationFrame(R.current)},[]),V=c.useCallback(p=>{p.preventDefault(),I.current=!0,x(!0),W.current={x:p.clientX,y:p.clientY},F.current={x:0,y:0},p.target.setPointerCapture(p.pointerId);const l=()=>{if(!I.current)return;const f=t.current;if(f){const{x:E,y:$}=F.current,T=Math.sqrt(E*E+$*$);if(T>Be){const G=Math.min(T/Se,1)*zt;f.scrollLeft+=E/T*G,f.scrollTop+=$/T*G}}R.current=requestAnimationFrame(l)};R.current=requestAnimationFrame(l)},[t]),q=c.useCallback(p=>{if(!I.current)return;const l=p.clientX-W.current.x,f=p.clientY-W.current.y;F.current={x:l,y:f};const E=Math.sqrt(l*l+f*f);if(E<Be)a({x:0,y:0});else{const T=Math.min(E,Se)/Se*It;a({x:l/E*T,y:f/E*T})}},[]),K=c.useCallback(p=>{switch(p.key){case"ArrowUp":p.preventDefault(),A();break;case"ArrowDown":p.preventDefault(),O();break;case"ArrowLeft":p.preventDefault(),B();break;case"ArrowRight":p.preventDefault(),D();break}},[A,O,B,D]);return d?e.jsxs("div",{className:`inno-scroll-nav ${n??""}`,role:"toolbar","aria-label":"Scroll navigation",onKeyDown:K,children:[e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-up ${r.canUp?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll up",disabled:!r.canUp,onPointerDown:()=>z(A),onPointerUp:_,onPointerLeave:_,tabIndex:r.canUp?0:-1,children:e.jsx(Pt,{})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-left ${r.canLeft?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll left",disabled:!r.canLeft,onPointerDown:()=>z(B),onPointerUp:_,onPointerLeave:_,tabIndex:r.canLeft?0:-1,children:e.jsx(Ft,{})}),e.jsx("button",{ref:b,type:"button",className:`inno-scroll-nav-joystick ${m?"inno-scroll-nav-joystick-active":""}`,"aria-label":"Drag to scroll freely",onPointerDown:V,onPointerMove:q,onPointerUp:P,onPointerCancel:P,tabIndex:0,children:e.jsx("span",{className:"inno-scroll-nav-joystick-dot",style:{transform:`translate(${o.x}px, ${o.y}px)`}})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-right ${r.canRight?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll right",disabled:!r.canRight,onPointerDown:()=>z(D),onPointerUp:_,onPointerLeave:_,tabIndex:r.canRight?0:-1,children:e.jsx(Rt,{})}),e.jsx("button",{type:"button",className:`inno-scroll-nav-btn inno-scroll-nav-down ${r.canDown?"":"inno-scroll-nav-btn-disabled"}`,"aria-label":"Scroll down",disabled:!r.canDown,onPointerDown:()=>z(O),onPointerUp:_,onPointerLeave:_,tabIndex:r.canDown?0:-1,children:e.jsx(At,{})})]}):null}function Ot(t){switch(t){case"day":case"week":return"time";default:return"day"}}function _t({onEventClick:t,onSlotClick:n,onSlotSelect:r,onAddEvent:s,className:o,showHeader:a=!0,minSelectionMinutes:m=30,showMoreMode:x,showMoreEventsInPopover:d=!1,isLoading:j=!1,slots:k,classNames:b,settingsContent:I,filterContent:W,headerActions:F,renderPopover:R,calendarRef:S,headerConfig:y,eventDetailMode:A,renderEventDetail:O}){const B=x??(d?"popover":"expand"),{view:D,setView:_,selectedDate:z,setSelectedDate:P,slotDuration:V,filteredEvents:q,users:K,visibleHours:p,workingHours:l,badgeVariant:f,showWorkingHoursOnly:E,clearFocusEventId:$}=ye.useInnoCalendar(),T=c.useMemo(()=>{if(!E||!l)return{startHour:p.start,endHour:p.end};let g=24,M=0;for(const U of Object.keys(l)){const te=l[Number(U)];!te||te.enabled===!1||(te.from<g&&(g=te.from),te.to>M&&(M=te.to))}return g>=M?{startHour:p.start,endHour:p.end}:{startHour:g,endHour:M}},[E,l,p]),re=T,G=c.useRef(null);c.useImperativeHandle(S,()=>({scrollToToday:()=>{const g=new Date;P(g,D),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const M=G.current?.querySelector(".ic-timeline-scroll-container, [class*='overflow-auto']");if(!M)return;const he=(g.getHours()-T.startHour)*96;he>0&&M.scrollTo({top:Math.max(0,he-100),behavior:"smooth"})})})},scrollToWorkingHours:()=>{let g=8;if(l)for(const M of Object.keys(l)){const U=l[Number(M)];U?.enabled&&U.from<g&&(g=Math.max(U.from-1,0))}requestAnimationFrame(()=>{requestAnimationFrame(()=>{const M=G.current?.querySelector(".ic-timeline-scroll-container, [class*='overflow-auto']");if(!M)return;const te=(g-T.startHour)*96;M.scrollTo({top:Math.max(0,te),behavior:"smooth"})})})},getViewRect:()=>G.current?.getBoundingClientRect()??null,focusEvent:g=>{$(),requestAnimationFrame(()=>{$()});const M=G.current?.querySelector(`[data-event-id="${g}"]`);M&&setTimeout(()=>M.click(),150)}}),[P,D,T,l,$]);const ge=c.useMemo(()=>Ot(D),[D]),ee=c.useCallback(g=>{if(r){r(g);return}if(n){const M=g.startDate.getHours();n(g.startDate,M)}},[r,n]),Q=c.useCallback(g=>{_("day"),P(g,"day")},[P,_]),xe=c.useCallback(g=>{_("month"),P(g,"month")},[P,_]),se=c.useCallback(g=>{t?.(g)},[t]),oe=c.useCallback((g,M,U)=>{n?.(g,M)},[n]),pe=()=>{const g=q,M=se,U=R;switch(D){case"day":return e.jsx(w.DayView,{events:g,date:z,visibleHours:re,workingHours:l,slotDuration:V,badgeVariant:f,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"week":return e.jsx(w.WeekView,{events:g,date:z,visibleHours:re,workingHours:l,slotDuration:V,badgeVariant:f,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"month":return e.jsx(w.MonthView,{events:g,date:z,badgeVariant:f,onEventClick:M,onDayClick:Q,renderPopover:U,showMoreMode:B,...k&&{slots:k},...b&&{classNames:b}});case"year":return e.jsx(Je,{events:g,year:z.getFullYear(),onMonthClick:xe,onDayClick:Q,...k&&{slots:k},...b&&{classNames:b}});case"agenda":return e.jsx(w.AgendaView,{events:g,date:z,onEventClick:M,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"resource-day":return e.jsx(fe,{daysToShow:1,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"resource-week":return e.jsx(fe,{daysToShow:7,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-day":return e.jsx(fe,{daysToShow:1,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-3day":return e.jsx(fe,{daysToShow:3,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});case"timeline-week":return e.jsx(fe,{daysToShow:7,events:g,users:K,selectedDate:z,visibleHours:{from:T.startHour,to:T.endHour},onEventClick:M,onSlotSelect:ee,onSlotClick:oe,renderPopover:U,...k&&{slots:k},...b&&{classNames:b}});default:return e.jsx(w.MonthView,{events:g,date:z,badgeVariant:f,onEventClick:M,onDayClick:Q,...k&&{slots:k},...b&&{classNames:b}})}},le=c.useRef(null);return c.useEffect(()=>{G.current=le.current}),e.jsx(ye.SlotSelectionProvider,{mode:ge,onSelect:ee,minDurationMinutes:m,slotDurationMinutes:V,enabled:!!(r||n),children:e.jsxs("div",{className:h.cn("inno-calendar-root flex flex-col h-full p-4",b?.root,o),children:[a&&e.jsx(w.CalendarHeader,{currentDate:z,view:D,events:q,onViewChange:_,onNavigateToday:()=>P(new Date,D),onNavigatePrev:()=>{const g=new Date(z);D==="day"||D==="timeline-day"||D==="resource-day"?g.setDate(g.getDate()-1):D==="timeline-3day"?g.setDate(g.getDate()-3):D==="week"||D==="timeline-week"||D==="resource-week"?g.setDate(g.getDate()-7):D==="month"?g.setMonth(g.getMonth()-1):D==="year"?g.setFullYear(g.getFullYear()-1):g.setDate(g.getDate()-7),P(g,D)},onNavigateNext:()=>{const g=new Date(z);D==="day"||D==="timeline-day"||D==="resource-day"?g.setDate(g.getDate()+1):D==="timeline-3day"?g.setDate(g.getDate()+3):D==="week"||D==="timeline-week"||D==="resource-week"?g.setDate(g.getDate()+7):D==="month"?g.setMonth(g.getMonth()+1):D==="year"?g.setFullYear(g.getFullYear()+1):g.setDate(g.getDate()+7),P(g,D)},availableViews:["day","week","month","agenda"],showTimelineViews:!0,showSettings:!!I,...!F&&s&&{onAddEvent:s},actions:F,settingsContent:I,filterContent:W,...y&&{headerConfig:y}}),e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:le,className:h.cn("h-full border rounded-lg bg-white overflow-x-auto",b?.viewContainer),children:pe()}),j&&e.jsx("div",{className:"inno-calendar-loading-overlay",children:e.jsx("div",{className:"inno-calendar-spinner"})}),e.jsx(Wt,{containerRef:le})]})]})})}function $t({events:t,users:n=[],scheduleTypes:r=[],initialView:s="week",initialDate:o,initialSelectedUserId:a,initialScheduleTypeIds:m,initialParticipantIds:x,initialWorkingHoursView:d,initialSearchQuery:j,preferencesConfig:k,onEventClick:b,onSlotClick:I,onSlotSelect:W,onAddEvent:F,onEventDrop:R,onDateChange:S,onViewChange:y,className:A,showHeader:O=!0,minSelectionMinutes:B=30,showMoreMode:D,showMoreEventsInPopover:_=!1,isLoading:z=!1,renderPopover:P,slots:V,classNames:q,settingsContent:K,filterContent:p,headerActions:l,focusEventId:f,headerConfig:E,eventDetailMode:$,renderEventDetail:T},re){return e.jsx(ye.DragDropProvider,{...R&&{onEventDrop:R},children:e.jsx(ye.InnoCalendarProvider,{initialEvents:t,initialUsers:n,initialScheduleTypes:r,initialView:s,...o&&{initialDate:o},...a&&{initialSelectedUserId:a},...m&&{initialScheduleTypeIds:m},...x&&{initialParticipantIds:x},...d&&{initialWorkingHoursView:d},...j&&{initialSearchQuery:j},...k&&{preferencesConfig:k},...S&&{onDateChange:S},...y&&{onViewChange:y},...f&&{initialFocusEventId:f},children:e.jsx(_t,{...b&&{onEventClick:b},...I&&{onSlotClick:I},...W&&{onSlotSelect:W},...F&&{onAddEvent:F},...P&&{renderPopover:P},className:A,showHeader:O,minSelectionMinutes:B,...D&&{showMoreMode:D},showMoreEventsInPopover:_,isLoading:z,...V&&{slots:V},...q&&{classNames:q},settingsContent:K,filterContent:p,headerActions:l,calendarRef:re,...E&&{headerConfig:E},...$&&{eventDetailMode:$},...T&&{renderEventDetail:T}})})})}const Bt=c.forwardRef($t),ie=c.forwardRef(({className:t,children:n,...r},s)=>e.jsx("select",{ref:s,className:h.cn("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm","ring-offset-background","focus:outline-none focus:ring-1 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50","[&>option]:bg-background",t),...r,children:n}));ie.displayName="Select";const ae=c.forwardRef(({className:t,...n},r)=>e.jsx("label",{ref:r,className:h.cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...n}));ae.displayName="Label";function Ut({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Vt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const Yt=[{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}];function Kt({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Slot duration",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the time slot duration for day and week calendar views.",...o},m=x=>{r||n(Number(x.target.value))};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Vt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Ut,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx(ie,{value:t.toString(),onChange:m,disabled:r,className:"h-9 w-[128px] text-sm",children:Yt.map(x=>e.jsx("option",{value:x.value.toString(),children:x.label},x.value))})]})}function qt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Gt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const Jt=[{value:"dot",label:"Dot indicator"},{value:"colored",label:"Full color"},{value:"mixed",label:"Mixed"}];function Xt({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Event display",lockedMessage:"This setting is locked by the administrator",infoMessage:"Choose how events are displayed. Dot shows a small indicator, colored fills the entire event, mixed uses both.",options:{dot:"Dot indicator",colored:"Full color",mixed:"Mixed"},...o},m=d=>a.options?.[d]??d,x=d=>{r||n(d.target.value)};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Gt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(qt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx(ie,{value:t,onChange:x,disabled:r,className:"h-9 w-[128px] text-sm",children:Jt.map(d=>e.jsx("option",{value:d.value,children:m(d.value)},d.value))})]})}function Qt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Zt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function en(){return Array.from({length:25},(t,n)=>({value:n,label:`${String(n).padStart(2,"0")}:00`}))}function tn({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Visible hours",from:"From",to:"To",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the visible hour range for day and week views. Hours outside this range will be hidden.",...o},m=en(),x=j=>{if(r)return;const k=Number(j.target.value);k<t.endHour&&n({...t,startHour:k})},d=j=>{if(r)return;const k=Number(j.target.value);k>t.startHour&&n({...t,endHour:k})};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Zt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(Qt,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ae,{className:"text-xs text-muted-foreground",children:a.from}),e.jsx(ie,{value:t.startHour.toString(),onChange:x,disabled:r,className:"h-9 w-[88px] text-sm",children:m.map(j=>e.jsx("option",{value:j.value.toString(),disabled:j.value>=t.endHour,children:j.label},j.value))})]}),e.jsx("span",{className:"mt-5 text-muted-foreground",children:"—"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(ae,{className:"text-xs text-muted-foreground",children:a.to}),e.jsx(ie,{value:t.endHour.toString(),onChange:d,disabled:r,className:"h-9 w-[88px] text-sm",children:m.map(j=>e.jsx("option",{value:j.value.toString(),disabled:j.value<=t.startHour,children:j.label},j.value))})]})]})]})}function nn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function rn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function sn({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}const on=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function an(){return Array.from({length:25},(t,n)=>({value:n,label:`${String(n).padStart(2,"0")}:00`}))}const Ue={sunday:"Sun",monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat"};function ln({dayLabel:t,config:n,onChange:r,disabled:s,hourOptions:o}){const a=()=>{s||r({...n,enabled:!n.enabled})},m=d=>{if(s)return;const j=Number(d.target.value);j<n.to&&r({...n,from:j})},x=d=>{if(s)return;const j=Number(d.target.value);j>n.from&&r({...n,to:j})};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",role:"checkbox","aria-checked":n.enabled,"aria-label":`Enable ${t}`,onClick:a,disabled:s,className:h.cn("flex size-5 shrink-0 items-center justify-center rounded border transition-colors",n.enabled?"border-primary bg-primary text-primary-foreground":"border-input bg-background",s&&"cursor-not-allowed opacity-50"),children:n.enabled&&e.jsx(sn,{className:"size-3"})}),e.jsx("span",{className:h.cn("w-10 text-sm",!n.enabled&&"text-muted-foreground"),children:t}),e.jsx(ie,{value:n.from.toString(),onChange:m,disabled:s||!n.enabled,className:"h-8 w-[76px] text-xs",children:o.map(d=>e.jsx("option",{value:d.value.toString(),disabled:d.value>=n.to,children:d.label},d.value))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}),e.jsx(ie,{value:n.to.toString(),onChange:x,disabled:s||!n.enabled,className:"h-8 w-[76px] text-xs",children:o.map(d=>e.jsx("option",{value:d.value.toString(),disabled:d.value<=n.from,children:d.label},d.value))})]})}function cn({value:t,onChange:n,isLocked:r=!1,className:s,labels:o={}}){const a={title:"Working hours",lockedMessage:"This setting is locked by the administrator",infoMessage:"Configure working hours for each day of the week. Non-working hours will be grayed out in day and week views.",days:Ue,...o},m=an(),x=(d,j)=>{r||n({...t,[d]:j})};return e.jsxs("div",{className:h.cn("flex flex-col gap-3",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"text-sm font-semibold",children:a.title}),r?e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(rn,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{children:e.jsx("p",{children:a.lockedMessage})})]})}):e.jsx(w.TooltipProvider,{delayDuration:100,children:e.jsxs(w.Tooltip,{children:[e.jsx(w.TooltipTrigger,{children:e.jsx(nn,{className:"size-3 text-muted-foreground"})}),e.jsx(w.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:a.infoMessage})})]})})]}),e.jsx("div",{className:"flex flex-col gap-2",children:on.map(d=>e.jsx(ln,{dayLabel:a.days?.[d]??Ue[d],config:t[d],onChange:j=>x(d,j),disabled:r,hourOptions:m},d))})]})}const dn={sunday:{enabled:!1,from:8,to:18},monday:{enabled:!0,from:8,to:18},tuesday:{enabled:!0,from:8,to:18},wednesday:{enabled:!0,from:8,to:18},thursday:{enabled:!0,from:8,to:18},friday:{enabled:!0,from:8,to:18},saturday:{enabled:!1,from:8,to:18}};function Ee({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function un({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function xn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Le({checked:t,onCheckedChange:n,className:r,children:s}){return e.jsx("button",{type:"button",role:"checkbox","aria-checked":t,onClick:()=>n(!t),className:r,children:s})}function hn({src:t,alt:n,fallback:r,className:s}){const[o,a]=c.useState(!1);return!t||o?e.jsx("div",{className:h.cn("flex items-center justify-center bg-zinc-200 text-zinc-600 font-medium text-sm",s),children:r||"?"}):e.jsx("img",{src:t,alt:n||"",className:h.cn("object-cover",s),onError:()=>a(!0)})}function Ve({value:t,onChange:n,placeholder:r,className:s}){return e.jsxs("div",{className:h.cn("relative",s),children:[e.jsx(un,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),placeholder:r,className:"h-9 w-full rounded-lg border border-border bg-white pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary"})]})}function Ye(t,n,r,s=.3){if(!n.trim())return t;const o=n.toLowerCase();return t.filter(a=>r(a).some(x=>x?x.toLowerCase().includes(o):!1))}const mn={title:"Filters",subtitle:"Filter calendar events",scheduleTypes:"Event Types",participants:"Participants",clearAll:"Clear all",selectAll:"Select all",unselectAll:"Unselect all",searchScheduleTypes:"Search event types...",searchParticipants:"Search participants...",noScheduleTypes:"No event types found",noParticipants:"No participants found"};function fn({scheduleTypes:t,users:n,selectedScheduleTypeIds:r,onScheduleTypeChange:s,selectedUserIds:o,onUserChange:a,onClearAll:m,className:x,scheduleTypesLoading:d=!1,usersLoading:j=!1,labels:k,getScheduleTypeName:b}){const I={...mn,...k},[W,F]=c.useState(""),[R,S]=c.useState(""),y=c.useMemo(()=>W.trim()?Ye(t,W,l=>[l.name,b?.(l)||l.name]):t,[t,W,b]),A=c.useMemo(()=>R.trim()?Ye(n,R,l=>[l.name,l.email||""]):n,[n,R]),O=y.length>0&&y.every(l=>r.includes(l.id)),B=A.length>0&&A.every(l=>o.includes(l.id)),D=r.length+o.length,_=(l,f)=>{const E=f?[...r,l]:r.filter($=>$!==l);s(E)},z=()=>{if(O){const l=new Set(y.map(f=>f.id));s(r.filter(f=>!l.has(f)))}else{const l=new Set([...r,...y.map(f=>f.id)]);s(Array.from(l))}},P=(l,f)=>{const E=f?[...o,l]:o.filter($=>$!==l);a(E)},V=()=>{if(B){const l=new Set(A.map(f=>f.id));a(o.filter(f=>!l.has(f)))}else{const l=new Set([...o,...A.map(f=>f.id)]);a(Array.from(l))}},q=()=>{s([]),a([]),m?.()},K=l=>b?b(l):l.name,p=l=>l.colorHex||l.color||"#069AD7";return e.jsxs("div",{className:h.cn("flex min-w-72 max-w-72 flex-col rounded-lg border bg-white shadow-sm",x),children:[e.jsxs("header",{className:"flex items-start justify-between gap-2 px-4 pb-2 pt-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.subtitle})]}),D>0&&e.jsxs("button",{type:"button",onClick:q,className:"flex h-auto items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(xn,{className:"h-3.5 w-3.5"}),I.clearAll]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:I.scheduleTypes}),e.jsx("button",{type:"button",onClick:z,className:"text-xs font-medium text-primary transition-colors hover:text-primary/80",children:O?I.unselectAll:I.selectAll})]}),t.length>6&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx(Ve,{value:W,onChange:F,placeholder:I.searchScheduleTypes})}),e.jsxs("div",{className:"flex max-h-[220px] flex-col gap-2 overflow-y-auto px-4 pb-2 scrollbar-thin",children:[d?Array.from({length:4}).map((l,f)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-2 rounded-md border border-border/60 bg-muted/40 p-2",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"})]},`skeleton-${f}`)):y.map(l=>{const f=r.includes(l.id),E=p(l);return e.jsxs(Le,{checked:f,onCheckedChange:$=>_(l.id,$),className:h.cn("relative flex w-full cursor-pointer items-center justify-between gap-3 rounded-md border border-border bg-white px-3 py-2 transition-colors hover:border-primary/50",f&&"border-primary bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:h.cn("flex h-4 w-4 items-center justify-center rounded border border-border text-xs transition-colors",f&&"border-primary bg-primary text-primary-foreground"),children:f&&e.jsx(Ee,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:K(l)})]}),e.jsx("div",{className:"h-4 w-4 rounded-full border",style:{backgroundColor:E,borderColor:E}})]},l.id)}),!d&&y.length===0&&e.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:I.noScheduleTypes})]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:I.participants}),e.jsx(Le,{checked:B,onCheckedChange:()=>V(),className:h.cn("flex h-5 w-5 items-center justify-center rounded border border-border bg-white transition-colors hover:border-primary/50",B&&"border-primary bg-primary text-primary-foreground"),children:B&&e.jsx(Ee,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(Ve,{value:R,onChange:S,placeholder:I.searchParticipants})}),e.jsxs("div",{className:"flex max-h-[400px] flex-col gap-2 overflow-y-auto px-4 pb-4 scrollbar-thin",children:[j?Array.from({length:4}).map((l,f)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-3 rounded-md border border-border/60 bg-muted/40 p-3",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-2 w-32 rounded bg-muted-foreground/10"})]})]},`p-skeleton-${f}`)):A.map(l=>{const f=o.includes(l.id);return e.jsxs(Le,{checked:f,onCheckedChange:E=>P(l.id,E),className:h.cn("relative flex w-full cursor-pointer items-start gap-2 rounded-lg border border-border bg-white p-2 transition-colors hover:border-primary/50",f&&"border-primary bg-zinc-50"),children:[e.jsx("span",{className:h.cn("flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border border-border transition-colors",f&&"border-primary bg-primary text-primary-foreground"),children:f&&e.jsx(Ee,{className:"h-2.5 w-2.5"})}),e.jsxs("div",{className:"flex flex-1 items-start gap-2",children:[e.jsx(hn,{src:l.avatar??null,alt:l.name,fallback:l.name?.[0]?.toUpperCase()??"?",className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex max-w-[140px] flex-col gap-0.5 overflow-hidden",children:[e.jsx("span",{className:"line-clamp-1 text-sm font-medium text-foreground",children:l.name}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",title:l.email,children:l.email})]})]})]},l.id)}),!j&&A.length===0&&e.jsx("p",{className:"px-4 text-xs text-muted-foreground",children:I.noParticipants})]})]})]})}function gn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}),e.jsx("circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"})]})}function pn({scheduleTypes:t,value:n,onChange:r,allLabel:s="All types",className:o,label:a}){const m=d=>{r(d.target.value)},x=t.find(d=>String(d.id)===n);return e.jsxs("div",{className:h.cn("flex flex-col gap-1",o),children:[a&&e.jsx(ae,{className:"text-xs text-muted-foreground",children:a}),e.jsxs("div",{className:"relative",children:[x?e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 size-3 -translate-y-1/2 rounded-full",style:{backgroundColor:x.color}}):e.jsx(gn,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(ie,{value:n,onChange:m,className:"h-9 w-full min-w-[140px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:s}),t.map(d=>e.jsx("option",{value:String(d.id),children:d.label},d.id))]})]})]})}function vn({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function jn({users:t,value:n,onChange:r,allLabel:s="All users",className:o,label:a}){const m=x=>{r(x.target.value)};return e.jsxs("div",{className:h.cn("flex flex-col gap-1",o),children:[a&&e.jsx(ae,{className:"text-xs text-muted-foreground",children:a}),e.jsxs("div",{className:"relative",children:[e.jsx(vn,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(ie,{value:n,onChange:m,className:"h-9 w-full min-w-[120px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:s}),t.map(x=>e.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})}function wn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"}),e.jsx("path",{d:"M8 14h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 18h.01"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M16 18h.01"})]})}function bn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.3V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function yn({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function kn({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 3h6v6"}),e.jsx("path",{d:"M10 14 21 3"}),e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function Nn(t){const n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${s}`}function Ke(t){const n=t.getHours(),r=t.getMinutes(),s=n>=12?"PM":"AM",o=n%12||12,a=String(r).padStart(2,"0");return`${o}:${a} ${s}`}function Cn(t){const n=Ke(t.startDate),r=Ke(t.endDate);return`${n} - ${r}`}function Dn(t){const n=Y.addDays(new Date,1);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function Mn(t){if(Y.isToday(t))return"Today";if(Dn(t))return"Tomorrow";const n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=n[t.getDay()],o=r[t.getMonth()],a=t.getDate();return`${s}, ${o} ${a}`}function Tn(t,n){const r=new Map;for(const s of t){const o=Nn(s.startDate),a=r.get(o)??[];a.push(s),r.set(o,a)}return Array.from(r.entries()).map(([s,o])=>{const a=[...o].sort((x,d)=>x.startDate.getTime()-d.startDate.getTime()),m=n>0?a.slice(0,n):a;return{date:new Date(s),dateKey:s,events:m,hasMore:n>0&&a.length>n}}).sort((s,o)=>s.date.getTime()-o.date.getTime())}function Sn(t){const n=Y.startOfDay(new Date),r=Y.endOfDay(new Date);return t.filter(s=>s.startDate>=n&&s.startDate<=r).length}function He({className:t}){return e.jsx("div",{className:h.cn("animate-pulse rounded-md bg-muted",t)})}function En({event:t,onClick:n}){return e.jsxs("button",{type:"button",onClick:()=>n?.(t),className:h.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3 p-2"),children:[e.jsx("div",{className:"shrink-0 rounded-full mt-1.5 size-2",style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Cn(t)})]}),n&&e.jsx(yn,{className:"shrink-0 size-4 text-muted-foreground/50 mt-1"})]})}function Ln({group:t,onEventClick:n}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5",children:[e.jsx("h3",{className:h.cn("text-xs font-semibold",Y.isToday(t.date)&&"text-primary"),children:Mn(t.date)}),t.hasMore&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.events.length," more"]})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(r=>e.jsx(En,{event:r,onClick:n},r.id))})]})}function Hn({events:t,isLoading:n=!1,className:r,daysAhead:s=7,maxEventsPerDay:o=3,onEventClick:a,onNavigateToAgenda:m}){const[x,d]=c.useState(!1),j=c.useMemo(()=>{const F=Y.startOfDay(new Date),R=Y.addDays(F,s);return t.filter(S=>S.endDate>=F&&S.startDate<R)},[t,s]),k=c.useMemo(()=>Tn(j,o),[j,o]),b=c.useMemo(()=>Sn(t),[t]),I=F=>{d(!1),a?.(F)},W=()=>{d(!1),m?.()};return e.jsxs(w.Popover,{open:x,onOpenChange:d,children:[e.jsxs(w.PopoverTrigger,{className:h.cn("relative rounded-xl hover:text-zinc-700 hover:!bg-zinc-300 !bg-zinc-200 text-zinc-600 shadow-none !px-2.5 p-2 max-h-10",r),children:[e.jsx(wn,{className:"h-4 w-4"}),b>0&&e.jsx(w.Badge,{variant:"destructive",className:"absolute -right-4 -top-4 m-3 flex h-5 w-5 items-center justify-center rounded-full bg-primary p-0 text-[10px] font-medium hover:bg-primary",children:b>99?"99+":b})]}),e.jsxs(w.PopoverContent,{className:"w-80 rounded-xl p-0",align:"end",side:"bottom",sideOffset:8,children:[e.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Upcoming"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b>0?`${b} event${b>1?"s":""} today`:"No events today"})]}),m&&e.jsxs("button",{type:"button",onClick:W,className:"text-xs text-primary hover:underline flex items-center gap-1",children:["View all",e.jsx(kn,{className:"size-3"})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto p-2",children:n?e.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:3}).map((F,R)=>e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(He,{className:"h-2 w-2 rounded-full mt-2"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(He,{className:"h-4 w-full"}),e.jsx(He,{className:"h-3 w-3/4"})]})]},R))}):k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(bn,{className:"mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"}),e.jsxs("p",{className:"text-xs text-muted-foreground/70",children:["Your schedule is clear for the next ",s," days"]})]}):e.jsx("div",{className:"space-y-3 divide-y",children:k.map(F=>e.jsx(Ln,{group:F,onEventClick:I},F.dateKey))})})]})]})}function In({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.25V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function Xe({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function zn(t){const n=new Date;return n.setDate(n.getDate()+1),t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function qe(t){const n=t.getHours(),r=t.getMinutes(),s=n>=12?"PM":"AM";return`${n%12||12}:${r.toString().padStart(2,"0")} ${s}`}function Pn(t){return new Intl.DateTimeFormat("en-US",{weekday:"long",month:"short",day:"numeric"}).format(t)}function An(t){const n=qe(t.startDate),r=qe(t.endDate);return`${n} - ${r}`}function Fn(t){return Y.isToday(t)?"Today":zn(t)?"Tomorrow":Pn(t)}function Rn(t,n){const r=new Map;for(const s of t){const o=Y.formatDateISO(s.startDate),a=r.get(o)??[];a.push(s),r.set(o,a)}return Array.from(r.entries()).map(([s,o])=>{const a=[...o].sort((x,d)=>x.startDate.getTime()-d.startDate.getTime()),m=n>0?a.slice(0,n):a;return{date:new Date(s),dateKey:s,events:m,hasMore:n>0&&a.length>n}}).sort((s,o)=>s.date.getTime()-o.date.getTime())}function Wn({event:t,onClick:n,compact:r}){return e.jsxs("button",{type:"button",onClick:()=>n?.(t),className:h.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3",r?"p-2":"p-3"),children:[e.jsx("div",{className:h.cn("shrink-0 rounded-full mt-1",r?"size-2":"size-2.5"),style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:h.cn("font-medium truncate",r?"text-xs":"text-sm"),children:t.title}),e.jsx("p",{className:h.cn("text-muted-foreground truncate",r?"text-[10px]":"text-xs"),children:An(t)})]}),n&&e.jsx(Xe,{className:h.cn("shrink-0 text-muted-foreground/50",r?"size-3":"size-4")})]})}function On({group:t,onEventClick:n,onViewMore:r,compact:s}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:h.cn("flex items-center justify-between px-2",s?"py-1":"py-1.5"),children:[e.jsx("h3",{className:h.cn("font-semibold",s?"text-xs":"text-sm",Y.isToday(t.date)&&"text-primary"),children:Fn(t.date)}),t.hasMore&&r&&e.jsx("button",{type:"button",onClick:()=>r(t.date),className:h.cn("text-primary hover:underline",s?"text-[10px]":"text-xs"),children:"+more"})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(o=>e.jsx(Wn,{event:o,onClick:n,compact:s},o.id))})]})}function _n({events:t,daysAhead:n=7,maxEventsPerDay:r=3,onEventClick:s,onViewAll:o,className:a,emptyState:m,title:x="Upcoming",showHeader:d=!0,compact:j=!1}){const k=Ce.useOptionalCalendarContext(),b=k?.filteredEvents,I=k?.currentDate??new Date,W=t??b??[],F=c.useMemo(()=>{const y=Y.startOfDay(I),A=new Date(y);return A.setDate(A.getDate()+n),W.filter(O=>O.endDate>=y&&O.startDate<A)},[W,n,I]),R=c.useMemo(()=>Rn(F,r),[F,r]),S=F.length;return R.length===0?e.jsxs("div",{className:h.cn("rounded-lg border bg-card",a),children:[d&&e.jsx("div",{className:h.cn("border-b px-4 flex items-center justify-between",j?"py-2":"py-3"),children:e.jsx("h2",{className:h.cn("font-semibold",j?"text-sm":"text-base"),children:x})}),e.jsx("div",{className:h.cn("flex flex-col items-center justify-center text-center",j?"py-6 px-4":"py-10 px-6"),children:m??e.jsxs(e.Fragment,{children:[e.jsx(In,{className:h.cn("text-muted-foreground/50 mb-2",j?"size-8":"size-10")}),e.jsx("p",{className:h.cn("text-muted-foreground",j?"text-xs":"text-sm"),children:"No upcoming events"})]})})]}):e.jsxs("div",{className:h.cn("rounded-lg border bg-card overflow-hidden",a),children:[d&&e.jsxs("div",{className:h.cn("border-b px-4 flex items-center justify-between",j?"py-2":"py-3"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:h.cn("font-semibold",j?"text-sm":"text-base"),children:x}),e.jsx("span",{className:h.cn("text-muted-foreground bg-muted rounded-full px-2",j?"text-[10px] py-0":"text-xs py-0.5"),children:S})]}),o&&e.jsxs("button",{type:"button",onClick:()=>o(),className:h.cn("text-primary hover:underline flex items-center gap-0.5",j?"text-xs":"text-sm"),children:["View all",e.jsx(Xe,{className:"size-3"})]})]}),e.jsx("div",{className:h.cn("divide-y overflow-auto",j?"p-2 max-h-[280px]":"p-3 max-h-[400px]"),children:R.map(y=>e.jsx(On,{group:y,onEventClick:s,onViewMore:o?A=>o(A):void 0,compact:j},y.dateKey))})]})}exports.AgendaDropdown=Hn;exports.AgendaWidget=_n;exports.BadgeVariantSetting=Xt;exports.Calendar=et;exports.CalendarFilterSidebar=fn;exports.DEFAULT_WEEK_WORKING_HOURS=dn;exports.EventPopover=pt;exports.InnoCalendar=Bt;exports.ScheduleTypeFilter=pn;exports.SlotDurationSetting=Kt;exports.TimelineView=fe;exports.UserFilter=jn;exports.VisibleHoursSetting=tn;exports.WorkingHoursSetting=cn;exports.YearView=Je;
2
+ //# sourceMappingURL=agenda-widget-Bt38QZqV.cjs.map