@ilamy/calendar 2.0.3 → 3.0.1

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.
package/dist/index.d.ts CHANGED
@@ -354,14 +354,15 @@ type DayjsStatics = { [K in keyof typeof dayjs] : (typeof dayjs)[K] };
354
354
  /**
355
355
  * The configured dayjs: a one-argument constructor plus every dayjs static.
356
356
  *
357
- * The constructor forwards its arguments to `dayjs.tz()`, whose second
358
- * parameter is a TIMEZONE and not a parse format, so `dayjs(input, 'YYYY-MM-DD')`
359
- * threw `RangeError: invalid time zone` at runtime while type-checking cleanly
360
- * (see the recurrence date-picker bug). Format parsing would additionally need
361
- * the CustomParseFormat plugin, which this module deliberately does not extend
362
- * (https://day.js.org/docs/en/parse/string-format). Offering only the
363
- * one-argument form turns that mistake into a compile error. To parse in an
364
- * explicit zone, call `dayjs.tz(input, timezone)`.
357
+ * The constructor takes the input and nothing else. It used to forward every
358
+ * argument to `dayjs.tz()`, whose second parameter is a TIMEZONE and not a parse
359
+ * format, so `dayjs(input, 'YYYY-MM-DD')` threw `RangeError: invalid time zone`
360
+ * at runtime while type-checking cleanly (see the recurrence date-picker bug).
361
+ * A second argument is now ignored rather than misread, and the one-argument type
362
+ * keeps it a compile error either way. Format parsing would additionally need the
363
+ * CustomParseFormat plugin, which this module deliberately does not extend
364
+ * (https://day.js.org/docs/en/parse/string-format). To read a bare wall-clock
365
+ * string as a time in a given zone, call `dayjs.tz(input, timezone)`.
365
366
  */
366
367
  type ConfiguredDayjs = ((date?: dayjs.ConfigType) => dayjs.Dayjs3) & DayjsStatics;
367
368
  declare const _default: ConfiguredDayjs;
@@ -492,6 +493,26 @@ type TimeFormat = "12-hour" | "24-hour";
492
493
  */
493
494
  type SlotDuration = 15 | 30 | 60;
494
495
  /**
496
+ * Which slice of an event a `renderEvent` call is drawing.
497
+ *
498
+ * An event too long for the row it starts in is cut at the boundary and drawn
499
+ * as one bar per row, each through its own `renderEvent` call. Without knowing
500
+ * which slice it has, a custom renderer cannot tell a real end from a break —
501
+ * so it rounds both, marks neither, and two halves of one booking read as two
502
+ * bookings that happen to sit either side of a Sunday. The built-in renderer
503
+ * has always had this; a custom one had no way to ask.
504
+ *
505
+ * Named to match FullCalendar's event render hook, which gives its renderers
506
+ * the same two facts under the same names, so a renderer ported from there
507
+ * behaves the same here.
508
+ */
509
+ interface EventSegment {
510
+ /** This bar holds the event's real start, rather than resuming a cut one. */
511
+ isStart: boolean;
512
+ /** This bar holds the event's real end, rather than running past it. */
513
+ isEnd: boolean;
514
+ }
515
+ /**
495
516
  * Custom class names for calendar styling.
496
517
  * Allows users to override default styles for various calendar elements.
497
518
  */
@@ -600,7 +621,7 @@ interface IlamyCalendarProps {
600
621
  * Custom render function for calendar events.
601
622
  * If provided, it will override the default event rendering.
602
623
  */
603
- renderEvent?: (event: CalendarEvent) => React3.ReactNode;
624
+ renderEvent?: (event: CalendarEvent, segment: EventSegment) => React3.ReactNode;
604
625
  /**
605
626
  * Callback when an event is clicked.
606
627
  * Provides the clicked event object.
@@ -686,9 +707,10 @@ interface IlamyCalendarProps {
686
707
  */
687
708
  disableDragAndDrop?: boolean;
688
709
  /**
689
- * Maximum number of events to display per day in month view.
710
+ * Maximum number of events to display in one grid cell: a day in month
711
+ * view, an hour in the resource day view.
690
712
  * Additional events will be hidden and can be viewed via a "more" link.
691
- * Defaults to 3 if not specified.
713
+ * Defaults to 4 if not specified.
692
714
  */
693
715
  dayMaxEvents?: number;
694
716
  /**
@@ -972,4 +994,4 @@ interface IlamyCalendarApi {
972
994
  * Returns a limited set of commonly used properties and methods.
973
995
  */
974
996
  declare function useIlamyCalendarContext(): IlamyCalendarApi;
975
- export { useIlamyCalendarContext, defaultTranslations, _default as dayjs, WeekDays, ViewHeaderContext, ViewConfig, VerticalColumnSpec, TranslatorFunction, Translations, TranslationKey, TimeFormat, SlotDuration, SLOT_EVENT_MUTATION_SCOPE, SLOT_EVENT_FORM, Resource, RenderCurrentTimeIndicatorProps, PluginView, PluginMutationResult, PluginMutationArgs, PluginDateRange, OpenEventFormInput, ManipulateType3 as ManipulateType, IlamyResourceCalendarProps, IlamyResourceCalendar, IlamyPlugin, IlamyCalendarProps, IlamyCalendarApi, IlamyCalendar, HorizontalRowSpec, HorizontalCellSpec, EventMutationScopeSlotContext, EventFormSlotContext, EventFormProps, Dayjs3 as Dayjs, ColumnSpec, CellInfo, CalendarView, CalendarEvent, CalendarClassesOverride, BusinessHours };
997
+ export { BusinessHours, CalendarClassesOverride, CalendarEvent, CalendarView, CellInfo, ColumnSpec, Dayjs3 as Dayjs, EventFormProps, EventFormSlotContext, EventMutationScopeSlotContext, EventSegment, HorizontalCellSpec, HorizontalRowSpec, IlamyCalendar, IlamyCalendarApi, IlamyCalendarProps, IlamyPlugin, IlamyResourceCalendar, IlamyResourceCalendarProps, ManipulateType3 as ManipulateType, OpenEventFormInput, PluginDateRange, PluginMutationArgs, PluginMutationResult, PluginView, RenderCurrentTimeIndicatorProps, Resource, SLOT_EVENT_FORM, SLOT_EVENT_MUTATION_SCOPE, SlotDuration, TimeFormat, TranslationKey, Translations, TranslatorFunction, VerticalColumnSpec, ViewConfig, ViewHeaderContext, WeekDays, _default as dayjs, defaultTranslations, useIlamyCalendarContext };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{A as v2,B as w2,C as H2,D as pP,E as c2,F as d2,G as I4,H as e2,a as _,b as G,c as O4,d as q,e as a2,f as P2,g as p2,h as $2,i as rP,j as f2,k as z2,l as d,m as b0,n as yP,o as N0,p as hP,q as k,r as nP,s as t2,t as s2,u as T0,v as u2,w as lP,x as uP,y as g2,z as E2}from"./shared/chunk-b53nxddz.js";import"./shared/chunk-7vqv0k0j.js";var NP="event-form",KP="event-mutation-scope",LP=({event:P,onChange:p})=>{return G((f)=>f.renderSlot)(NP,{event:P,onChange:p})},M0=({dialog:P,onResolve:p,onCancel:$})=>{let f=G((Y)=>Y.getEventManager);if(!(P.isOpen&&P.event))return null;let z=f(P.event),b={event:P.event,operation:P.operation,resolve:p,cancel:$};return z?.renderSlot?.(KP,b)};import{useEffect as F4,useMemo as M4}from"react";import{DndContext as T5,MouseSensor as S5,pointerWithin as g5,TouchSensor as D5,useSensor as MP,useSensors as E5}from"@dnd-kit/core";import{useRef as AP}from"react";import{useCallback as A0,useEffect as B5,useRef as O5,useState as I5}from"react";var h0={isOpen:!1,operation:"edit",event:null};function V0(P){let{applyScopedEdit:p,applyScopedDelete:$}=G((Q)=>({applyScopedEdit:Q.applyScopedEdit,applyScopedDelete:Q.applyScopedDelete})),[f,z]=I5(h0),b=O5(f);B5(()=>{b.current=f},[f]);let Y=A0((Q,X)=>{z({isOpen:!0,operation:"edit",event:Q,updates:X})},[]),Z=A0((Q)=>{z({isOpen:!0,operation:"delete",event:Q})},[]),J=A0(()=>z(h0),[]),U=A0((Q)=>{let X=b.current;if(!X.event)return;if(X.operation==="edit")p(X.event,X.updates??{},Q);else $(X.event,Q);z(h0),P?.()},[p,$,P]);return{dialogState:f,openEditDialog:Y,openDeleteDialog:Z,closeDialog:J,handleConfirm:U}}var _P=(P,p)=>{let{active:$,over:f}=P;if(!$||!f||!p)return null;let z=f.data.current||{},b=z.type==="time-cell",{resourceId:Y,allDay:Z}=z,J;if(b){let{date:N,hour:F=0,minute:M=0}=z;J=_(N).hour(F).minute(M)}else{let{date:N}=z;J=_(N)}let U=p.end.diff(p.start,"second"),Q=J.add(U,"second");if(Q.isSame(Q.startOf("day")))Q=Q.subtract(1,"day").endOf("day");let X={start:J,end:Q,resourceId:Y,allDay:b?!1:Z??p.allDay};return{activeEvent:p,updates:X}};import{DragOverlay as R5}from"@dnd-kit/core";import{snapCenterToCursor as H5}from"@dnd-kit/modifiers";import{useImperativeHandle as k5,useState as m5}from"react";import{jsx as GP}from"react/jsx-runtime";var FP=({ref:P})=>{let[p,$]=m5(null);return k5(P,()=>({setActiveEvent:$})),GP(R5,{modifiers:[H5],children:p&&GP("div",{className:q("cursor-grab truncate rounded bg-amber-200 p-2 text-[10px] shadow-lg sm:text-xs w-20",p.backgroundColor||"bg-blue-500",p.color||"text-white"),children:p?.title})})};import{jsx as VP,jsxs as WP,Fragment as w5}from"react/jsx-runtime";function BP({children:P}){let p=AP(null),$=AP(null),{updateEvent:f,getEventManager:z,disableDragAndDrop:b}=G((A)=>({updateEvent:A.updateEvent,getEventManager:A.getEventManager,disableDragAndDrop:A.disableDragAndDrop})),{dialogState:Y,openEditDialog:Z,closeDialog:J,handleConfirm:U}=V0(),Q=MP(S5,{activationConstraint:{distance:2}}),X=MP(D5,{activationConstraint:{delay:100,tolerance:5}}),N=E5(Q,X),F=(A,V)=>{let m=!V||Object.keys(V).length===0;if(!A?.id||m)return;if(z(A)?.applyEdit)Z(A,V);else f(A.id,V)},M=(A)=>{let{active:V}=A;if(V.data.current?.type==="calendar-event")$.current?.setActiveEvent(V.data.current.event),p.current=V.data.current.event},W=(A)=>{let V=_P(A,p.current);if(V){let{activeEvent:m,updates:B}=V;F(m,B)}p.current=null,$.current?.setActiveEvent(null)},K=(A)=>{p.current=null};if(b)return P;return WP(w5,{children:[WP(T5,{collisionDetection:g5,onDragCancel:K,onDragEnd:W,onDragStart:M,sensors:N,children:[P,VP(FP,{ref:$})]}),VP(M0,{dialog:Y,onCancel:J,onResolve:U})]})}import{Slot as C5}from"@radix-ui/react-slot";import{cva as v5}from"class-variance-authority";import{jsx as h5}from"react/jsx-runtime";var y5=v5("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function R({className:P,variant:p,size:$,asChild:f=!1,...z}){return h5(f?C5:"button",{className:q(y5({variant:p,size:$,className:P})),"data-slot":"button",...z})}import*as W0 from"@radix-ui/react-checkbox";import{CheckIcon as j5}from"lucide-react";import{jsx as j0}from"react/jsx-runtime";function OP({className:P,...p}){return j0(W0.Root,{className:q("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",P),"data-slot":"checkbox",...p,children:j0(W0.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:j0(j5,{className:"size-3.5"})})})}import{ChevronDownIcon as i5}from"lucide-react";import{useEffect as x5,useState as u5}from"react";import{jsx as o5}from"react/jsx-runtime";function P0({className:P,type:p,...$}){return o5("input",{className:q("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",P),"data-slot":"input",type:p,...$})}import*as y from"@radix-ui/react-popover";import{jsx as B0}from"react/jsx-runtime";function o({...P}){return B0(y.Root,{"data-slot":"popover",...P})}function i({...P}){return B0(y.Trigger,{"data-slot":"popover-trigger",...P})}function x({className:P,align:p="center",sideOffset:$=4,...f}){return B0(y.Portal,{children:B0(y.Content,{align:p,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",P),"data-slot":"popover-content",sideOffset:$,...f})})}import{jsx as u,jsxs as q0}from"react/jsx-runtime";var IP=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,o0=(P)=>Boolean(P&&IP.test(P)),c5=(P)=>{let p=P.match(/bg-([a-z]+)-\d+/)?.at(1);if(!p)return"Custom";return p.charAt(0).toUpperCase()+p.slice(1)};function RP({value:P,onChange:p,swatches:$=[],className:f,"aria-label":z="Select color"}){let[b,Y]=u5(o0(P)?P:"");x5(()=>{Y(o0(P)?P:"")},[P]);let Z=(X)=>{let N=X.target.value;if(Y(N),IP.test(N))p(N)},J=o0(P),U=$.find((X)=>X.value===P),Q;if(U)Q=U.label;else if(J)Q=P;else if(P)Q=c5(P);else Q="Pick a color";return q0(o,{children:[q0(i,{"aria-label":z,className:q("border-input focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 text-sm shadow-xs outline-none focus-visible:ring-[3px]",f),"data-slot":"color-picker-trigger",type:"button",children:[q0("span",{className:"flex items-center gap-2",children:[u("span",{className:q("size-5 shrink-0 rounded-full border",!J&&P),style:J?{backgroundColor:P}:void 0}),u("span",{className:q(J&&"font-mono text-xs"),children:Q})]}),u(i5,{className:"size-4 shrink-0 opacity-50"})]}),q0(x,{className:"w-56","data-slot":"color-picker-content",children:[$.length>0&&u("div",{className:"grid grid-cols-7 gap-1.5",children:$.map((X)=>{let N=P===X.value;return u("button",{"aria-label":X.label,"aria-pressed":N,className:q("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",X.value,N&&"ring-ring ring-2 ring-offset-1"),onClick:()=>p(X.value),type:"button"},X.value)})}),u("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),q0("div",{className:"flex items-center gap-2",children:[u("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(X)=>p(X.target.value),type:"color",value:J?P:"#000000"}),u(P0,{"aria-label":"Hex color",className:"font-mono",onChange:Z,placeholder:"#000000",value:b})]})]})]})}import*as HP from"@radix-ui/react-label";import{jsx as d5}from"react/jsx-runtime";function l({className:P,...p}){return d5(HP.Root,{className:q("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",P),"data-slot":"label",...p})}import*as O from"@radix-ui/react-select";import{CheckIcon as r5,ChevronDownIcon as kP,ChevronUpIcon as n5}from"lucide-react";import{jsx as H,jsxs as i0}from"react/jsx-runtime";function mP({...P}){return H(O.Root,{"data-slot":"select",...P})}function TP({...P}){return H(O.Value,{"data-slot":"select-value",...P})}function SP({className:P,size:p="default",children:$,...f}){return i0(O.Trigger,{className:q("cursor-pointer border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",P),"data-size":p,"data-slot":"select-trigger",...f,children:[$,H(O.Icon,{asChild:!0,children:H(kP,{className:"size-4 opacity-50"})})]})}function gP({className:P,children:p,position:$="popper",align:f="center",...z}){return H(O.Portal,{children:i0(O.Content,{align:f,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",$==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",P),"data-slot":"select-content",position:$,...z,children:[H(l5,{}),H(O.Viewport,{className:q("p-1",$==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1"),children:p}),H(a5,{})]})})}function DP({className:P,children:p,...$}){return i0(O.Item,{className:q("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",P),"data-slot":"select-item",...$,children:[H("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:H(O.ItemIndicator,{children:H(r5,{className:"size-4"})})}),H(O.ItemText,{children:p})]})}function l5({className:P,...p}){return H(O.ScrollUpButton,{className:q("flex cursor-default items-center justify-center py-1",P),"data-slot":"select-scroll-up-button",...p,children:H(n5,{className:"size-4"})})}function a5({className:P,...p}){return H(O.ScrollDownButton,{className:q("flex cursor-default items-center justify-center py-1",P),"data-slot":"select-scroll-down-button",...p,children:H(kP,{className:"size-4"})})}import{jsx as t5}from"react/jsx-runtime";function EP({className:P,...p}){return t5("textarea",{className:q("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",P),"data-slot":"textarea",...p})}function wP(P){if(P===void 0)return;if(_.isDayjs(P))return P;let p=_(P);return p.isValid()?p:void 0}function CP(P){let p=P.replace("#",""),$=p.length===3?p.split("").map((Z)=>Z+Z).join(""):p;if(!/^[0-9a-fA-F]{6}$/.test($))return"#000000";let f=Number.parseInt($.slice(0,2),16),z=Number.parseInt($.slice(2,4),16),b=Number.parseInt($.slice(4,6),16);return(f*299+z*587+b*114)/1000>=128?"#000000":"#ffffff"}import{useEffect as Kp,useState as w}from"react";import{PopoverClose as bp}from"@radix-ui/react-popover";import{Calendar as Zp}from"lucide-react";import{useEffect as Yp,useRef as Qp,useState as Jp}from"react";import{useState as pp}from"react";import{ChevronLeftIcon as s5,ChevronRightIcon as e5}from"lucide-react";import{jsx as U0,jsxs as Pp}from"react/jsx-runtime";function p0({label:P,onPrev:p,onNext:$,prevLabel:f,nextLabel:z}){return Pp("div",{className:"mb-2 flex items-center justify-between",children:[U0(R,{"aria-label":f,onClick:p,size:"icon",variant:"ghost",children:U0(s5,{className:"size-4"})}),U0("div",{className:"text-sm font-medium select-none",children:P}),U0(R,{"aria-label":z,onClick:$,size:"icon",variant:"ghost",children:U0(e5,{className:"size-4"})})]})}import{jsx as h,jsxs as vP}from"react/jsx-runtime";function $p(P){let p=P.weekHover&&!P.isCurrentWeek;return q("p-0 text-center",P.weekHover&&"first:rounded-l-md last:rounded-r-md",p&&"group-hover/week:bg-accent",P.isCurrentWeek&&"bg-primary")}function fp(P){return q("w-full aspect-square text-sm select-none",!P.isDisabled&&"cursor-pointer",!(P.weekHover||P.isDisabled)&&"hover:bg-accent rounded-md",P.isOutside&&"text-muted-foreground/50",P.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",P.isCurrentWeek&&"text-primary-foreground font-medium",P.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",P.isDisabled&&"opacity-50 cursor-not-allowed")}function zp({day:P,state:p,onSelect:$}){return h("td",{className:$p(p),"data-disabled":p.isDisabled,"data-outside":p.isOutside,"data-selected":p.isSelected,role:"gridcell",tabIndex:-1,children:h("button",{"aria-disabled":p.isDisabled,"aria-hidden":p.isOutside,className:fp(p),"data-disabled":p.isDisabled,"data-selected":p.isSelected,disabled:p.isDisabled||p.isOutside,onClick:()=>$?.(P.toDate()),tabIndex:p.isOutside?-1:0,type:"button",children:P.format("D")})})}function K0({selected:P,defaultMonth:p,onSelect:$,disabled:f,firstDayOfWeek:z=0,className:b,weekHover:Y=!1,highlightedWeekOf:Z}){let[J,U]=pp(()=>_(p??P??new Date).startOf("month")),Q=hP(J,z),X=P?_(P).format("YYYY-MM-DD"):void 0,N=N0(_(),z).map((K)=>K.format("dd")),F,M;if(Z){let K=N0(Z,z);F=K.at(0),M=K.at(-1)}let W=(K)=>{let A=K.format("YYYY-MM-DD")===X,V=!1;if(F&&M){let m=!K.isBefore(F,"day"),B=!K.isAfter(M,"day");V=m&&B}return{isOutside:!K.isSame(J,"month"),isSelected:A,isDisabled:f?.(K.toDate())??!1,isCurrent:yP(K)&&!A,isCurrentWeek:V,weekHover:Y}};return vP("div",{className:q("bg-background p-3 w-72",b),"data-slot":"calendar",children:[h(p0,{label:J.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>U((K)=>K.add(1,"month")),onPrev:()=>U((K)=>K.subtract(1,"month")),prevLabel:"Previous month"}),vP("table",{className:"w-full border-collapse",role:"grid",children:[h("thead",{children:h("tr",{children:N.map((K,A)=>h("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:K},A))})}),h("tbody",{children:Q.map((K,A)=>h("tr",{className:q(Y&&"group/week"),children:K.map((V)=>h(zp,{day:V,onSelect:$,state:W(V)},V.toISOString()))},A))})]})]})}import{jsx as $0,jsxs as x0}from"react/jsx-runtime";function jP({date:P,closeOnSelect:p,onChange:$,label:f="Pick a date",className:z,disabled:b}){let Y=G((X)=>X.firstDayOfWeek),Z=Qp(null),[J,U]=Jp(P);Yp(()=>{U(P)},[P]);let Q=(X)=>{if(U(X),p)Z.current?.click();$?.(X)};return $0("div",{className:z,children:x0(o,{children:[$0(i,{asChild:!0,children:x0(R,{className:q("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!P,variant:"outline",children:[$0(Zp,{}),J?_(J).format("ll"):$0("span",{children:f})]})}),x0(x,{align:"start",className:"w-auto p-0",children:[$0(bp,{ref:Z,style:{display:"none"}}),$0(K0,{defaultMonth:J,disabled:b,firstDayOfWeek:Y,onSelect:Q,selected:J})]})]})})}import{Clock as qp}from"lucide-react";import{useEffect as Up,useRef as iP,useState as u0}from"react";import{useMemo as Xp}from"react";function oP({timeFormat:P="12-hour",minTime:p="00:00",maxTime:$="23:45"}){return{timeOptions:Xp(()=>{let b=[],[Y,Z]=p.split(":").map(Number),[J,U]=$.split(":").map(Number),Q=Y*60+Z,X=J*60+U;for(let N=Q;N<=X;N+=15){let F=Math.floor(N/60),M=N%60,W=`${F.toString().padStart(2,"0")}:${M.toString().padStart(2,"0")}`;b.push(W)}return b},[p,$]),formatTime:(b)=>{let[Y,Z]=b.split(":").map(Number);if(P==="24-hour")return`${Y.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`;let J=Y>=12?"PM":"AM",U=Y;if(Y===0)U=12;else if(Y>12)U=Y-12;return`${U}:${Z.toString().padStart(2,"0")} ${J}`}}}import{jsx as c,jsxs as c0}from"react/jsx-runtime";var Np=(P)=>{P.stopPropagation()};function xP({value:P,onChange:p,minTime:$="00:00",maxTime:f="23:45",timeFormat:z="12-hour",placeholder:b="Select time...",className:Y,disabled:Z=!1,name:J}){let[U,Q]=u0(!1),[X,N]=u0(""),F=iP(null),M=iP(null),[W,K]=u0(0),{timeOptions:A,formatTime:V}=oP({timeFormat:z,minTime:$,maxTime:f}),m=A.filter((S)=>{return V(S).toLowerCase().includes(X.toLowerCase())}),B=(S)=>{p(S),Q(!1),N("")};Up(()=>{if(U){if(M.current)K(M.current.offsetWidth);setTimeout(()=>{F.current?.focus()},0)}},[U]);let Q0=P?V(P):b;return c0(o,{onOpenChange:Q,open:U,children:[c(i,{asChild:!0,children:c0(R,{"aria-controls":"time-picker-listbox","aria-expanded":U,className:q("w-full justify-start",Y),"data-testid":k.timePicker(J),disabled:Z,ref:M,role:"combobox",variant:"outline",children:[c(qp,{className:"mr-2 h-4 w-4"}),Q0]})}),c0(x,{align:"start",className:"p-0",style:{width:W},children:[c("div",{className:"p-2 border-b",children:c(P0,{className:"h-8",onChange:(S)=>N(S.target.value),placeholder:"Search time...",ref:F,value:X})}),c(d,{className:"h-[200px]",onWheel:Np,children:c("div",{className:"p-1",children:m.length===0?c("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):m.map((S)=>{let G0=V(S);return c("button",{className:q("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",S===P&&"bg-accent text-accent-foreground"),onClick:()=>B(S),type:"button",children:G0},S)})})})]})]})}var cP=(P,p,$)=>{let[f,z]=p.split(":").map(Number),b=_(P).hour(f).minute(z);return $?b.hour(0).minute(0):b},dP=(P,p,$)=>{let[f,z]=p.split(":").map(Number),b=_(P).hour(f).minute(z);return $?b.hour(23).minute(59):b},d0=(P,p)=>{if(!p)return{min:"00:00",max:"23:59"};let $=_(P),{minStart:f,maxEnd:z,hasBusinessHours:b}=uP({allDates:[$],businessHours:p,hideNonBusinessHours:!1});if(!b)return{min:"00:00",max:"23:59"};return{min:`${f.toString().padStart(2,"0")}:00`,max:`${(z-1).toString().padStart(2,"0")}:45`}};import{jsx as I,jsxs as g,Fragment as Mp}from"react/jsx-runtime";var aP="bg-blue-100 text-blue-800",Lp=[{value:aP,label:"Blue"},{value:"bg-green-100 text-green-800",label:"Green"},{value:"bg-purple-100 text-purple-800",label:"Purple"},{value:"bg-red-100 text-red-800",label:"Red"},{value:"bg-yellow-100 text-yellow-800",label:"Yellow"},{value:"bg-pink-100 text-pink-800",label:"Pink"},{value:"bg-indigo-100 text-indigo-800",label:"Indigo"},{value:"bg-amber-100 text-amber-800",label:"Amber"},{value:"bg-emerald-100 text-emerald-800",label:"Emerald"},{value:"bg-sky-100 text-sky-800",label:"Sky"},{value:"bg-violet-100 text-violet-800",label:"Violet"},{value:"bg-rose-100 text-rose-800",label:"Rose"},{value:"bg-teal-100 text-teal-800",label:"Teal"},{value:"bg-orange-100 text-orange-800",label:"Orange"}],tP=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,_p=(P,p)=>{if(P&&tP.test(P))return P;return p??aP},Gp=(P)=>{if(tP.test(P))return{backgroundColor:P,color:CP(P)};return{backgroundColor:void 0,color:P}},Fp=({colorChanged:P,hadInitialColor:p,selectedColor:$,initialBackgroundColor:f,initialColor:z})=>{if(P||!p)return Gp($);return{backgroundColor:f,color:z}},r0=({name:P,label:p,placeholder:$,value:f,required:z=!1,multiline:b=!1,onChange:Y})=>g("div",{className:"grid gap-1 sm:gap-2",children:[I(l,{className:"text-xs sm:text-sm",htmlFor:P,children:p}),b?I(EP,{className:"min-h-16 text-sm",id:P,name:P,onChange:Y,placeholder:$,required:z,value:f}):I(P0,{className:"h-8 text-sm sm:h-9",id:P,name:P,onChange:Y,placeholder:$,required:z,value:f})]}),sP=({selectedEvent:P,onClose:p,onUpdate:$,onDelete:f,onAdd:z})=>{let{dialogState:b,openEditDialog:Y,openDeleteDialog:Z,closeDialog:J,handleConfirm:U}=V0(p),{t:Q,timeFormat:X,getEventManager:N,resources:F}=G((L)=>({t:L.t,timeFormat:L.timeFormat,getEventManager:L.getEventManager,resources:L.resources??[]})),{id:M,resourceId:W,resourceIds:K,start:A=_(),end:V=_().add(1,"hour"),allDay:m=!1,color:B,backgroundColor:Q0,title:S="",description:G0="",location:fP=""}=P??{},zP=F.length>0,bP=W??K?.at(0),ZP=zP&&bP===void 0,[S0,P5]=w(bP),g0=zP?S0:W,F0=nP(g0),YP=Boolean(P&&N(P)),[s,QP]=w(A.toDate()),[e,JP]=w(V.toDate()),[j,p5]=w(m),[D0,$5]=w(_p(Q0,B)),[f5,z5]=w(!1),b5=Boolean(B||Q0),Z5=(L)=>{$5(L),z5(!0)},[E0,XP]=w(A.format("HH:mm")),[w0,C0]=w(V.format("HH:mm")),[v,Y5]=w({title:S,description:G0,location:fP}),[v0,Q5]=w({}),J5={...P,...v0},X5=(L)=>Q5((D)=>({...D,...L})),q5=(L)=>{if(!L)return;if(QP(L),_(L).isAfter(_(e)))JP(L)},U5=(L)=>{if(!L)return;if(JP(L),L&&_(L).isBefore(_(s)))QP(L)},N5=(L)=>{if(XP(L),_(s).isSame(_(e),"day")&&L>w0)C0(L)},K5=(L)=>{if(C0(L),_(s).isSame(_(e),"day")&&L<E0)XP(L)},y0=(L)=>{let{name:D,value:E}=L.target;Y5((J0)=>({...J0,[D]:E}))};Kp(()=>{if(j)C0("23:59")},[j]);let L5=(L)=>{return F.find((E)=>String(E.id)===L)?.id??L},qP=ZP&&S0===void 0,_5=(L)=>{if(L.preventDefault(),qP)return;let D=cP(s,E0,j),E=dP(e,w0,j),J0=Fp({colorChanged:f5,hadInitialColor:b5,selectedColor:D0,initialBackgroundColor:Q0,initialColor:B}),X0={id:M||_().format("YYYYMMDDHHmmss"),title:v.title,start:D,end:E,resourceId:g0,description:v.description,location:v.location,allDay:j,...J0,...v0};if(P?.id&&YP){Y(P,{title:v.title,start:D,end:E,resourceId:g0,description:v.description,location:v.location,allDay:j,color:D0,...v0});return}if(M)$?.(X0);else z?.(X0);p()},G5=()=>{if(!P?.id)return;if(YP){Z(P);return}f?.(P),p()},UP;if(F0)UP=(L)=>!lP(_(L),F0);let F5=d0(s,F0),M5=d0(e,F0),A5=[["startDate",s,q5],["endDate",e,U5]],V5=[["startTime","start-time",E0,N5,F5],["endTime","end-time",w0,K5,M5]],W5=S0?.toString();return g(Mp,{children:[g("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:_5,children:[I(d,{className:"flex-1 min-h-0",children:g("div",{className:"grid gap-3 sm:gap-4 p-1",children:[I(r0,{label:Q("title"),name:"title",onChange:y0,placeholder:Q("eventTitlePlaceholder"),required:!0,value:v.title}),I(r0,{label:Q("description"),multiline:!0,name:"description",onChange:y0,placeholder:Q("eventDescriptionPlaceholder"),value:v.description}),ZP&&g("div",{className:"grid gap-1 sm:gap-2",children:[I(l,{className:"text-xs sm:text-sm",htmlFor:"resource",children:Q("resource")}),g(mP,{onValueChange:(L)=>P5(L5(L)),value:W5,children:[I(SP,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:I(TP,{placeholder:Q("selectResource")})}),I(gP,{children:F.map((L)=>I(DP,{value:String(L.id),children:L.title},String(L.id)))})]})]}),g("div",{className:"flex items-center space-x-2",children:[I(OP,{checked:j,id:"allDay",onCheckedChange:(L)=>p5(L===!0)}),I(l,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:Q("allDay")})]}),I("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:A5.map(([L,D,E])=>g("div",{children:[I(l,{className:"text-xs sm:text-sm",children:Q(L)}),I(jP,{className:"mt-1",closeOnSelect:!0,date:D,disabled:UP,onChange:E})]},L))}),!j&&I("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:V5.map(([L,D,E,J0,X0])=>g("div",{children:[I(l,{className:"text-xs sm:text-sm",children:Q(L)}),I(xP,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:X0.max,minTime:X0.min,name:D,onChange:J0,placeholder:Q("searchTime"),timeFormat:X,value:E})]},L))}),g("div",{className:"grid gap-1 sm:gap-2",children:[I(l,{className:"text-xs sm:text-sm",children:Q("color")}),I(RP,{"aria-label":Q("color"),onChange:Z5,swatches:Lp,value:D0})]}),I(r0,{label:Q("location"),name:"location",onChange:y0,placeholder:Q("eventLocationPlaceholder"),value:v.location}),I(LP,{event:J5,onChange:X5})]})}),g(rP,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[M&&I(R,{className:"w-full sm:mr-auto sm:w-auto",onClick:G5,size:"sm",type:"button",variant:"destructive",children:Q("delete")}),g("div",{className:"flex w-full gap-2 sm:w-auto",children:[I(R,{className:"flex-1 sm:flex-none",onClick:p,size:"sm",type:"button",variant:"outline",children:Q("cancel")}),I(R,{className:"flex-1 sm:flex-none",disabled:qP,size:"sm",type:"submit",children:M?Q("update"):Q("create")})]})]})]}),I(M0,{dialog:b,onCancel:J,onResolve:U})]})};import{jsx as O0,jsxs as eP}from"react/jsx-runtime";var b2=()=>{let{t:P,selectedEvent:p,isEventFormOpen:$,closeEventForm:f,addEvent:z,updateEvent:b,deleteEvent:Y,renderEventForm:Z}=G((X)=>({t:X.t,selectedEvent:X.selectedEvent,isEventFormOpen:X.isEventFormOpen,closeEventForm:X.closeEventForm,addEvent:X.addEvent,updateEvent:X.updateEvent,deleteEvent:X.deleteEvent,renderEventForm:X.renderEventForm})),Q={open:$,onClose:f,selectedEvent:p,onAdd:z,onUpdate:(X)=>{b(X.id,X)},onDelete:(X)=>{Y(X.id)}};if(Z)return Z(Q);return O0(P2,{onOpenChange:f,open:$,children:eP(p2,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[eP($2,{className:"mb-2 sm:mb-4 shrink-0",children:[O0(f2,{className:"text-base sm:text-lg",children:p?.id?P("editEvent"):P("createEvent")}),O0(z2,{className:"text-xs sm:text-sm",children:p?.id?P("editEventDetails"):P("addNewEvent")})]}),O0(sP,{...Q})]})})};import{ChevronLeft as hp,ChevronRight as jp,Download as op,Plus as ip}from"lucide-react";import{ChevronDown as Ip}from"lucide-react";import{useState as Rp}from"react";function Z2(){let{currentLocale:P,timezone:p}=G((f)=>({currentLocale:f.currentLocale,timezone:f.timezone}));return{formatDateRange:(f,z)=>{let b=new Intl.DateTimeFormat(P,{timeZone:p,month:"short",day:"numeric"});if(f.year()===z.year())return b.formatRange(f.toDate(),z.toDate());return`${b.format(f.toDate())} – ${b.format(z.toDate())}`}}}import{useState as Vp}from"react";import{jsx as Ap}from"react/jsx-runtime";function I0({label:P,isSelected:p,isCurrent:$,onSelect:f}){return Ap("button",{"aria-pressed":p,className:q("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",$&&"ring-1 ring-inset ring-foreground/40",p&&"bg-primary text-primary-foreground"),onClick:f,type:"button",children:P})}import{jsx as n0,jsxs as Wp}from"react/jsx-runtime";function Y2({selected:P,onSelect:p}){let[$,f]=Vp(()=>P.year()),z=_(),b=Array.from({length:12},(Y,Z)=>({index:Z,label:P.month(Z).format("MMM")}));return Wp("div",{className:"w-72 p-3","data-slot":"month-grid",children:[n0(p0,{label:$,nextLabel:"Next year",onNext:()=>f((Y)=>Y+1),onPrev:()=>f((Y)=>Y-1),prevLabel:"Previous year"}),n0("div",{className:"grid grid-cols-3 gap-1",children:b.map((Y)=>{let Z=$===P.year()&&Y.index===P.month(),J=$===z.year()&&Y.index===z.month()&&!Z;return n0(I0,{isCurrent:J,isSelected:Z,label:Y.label,onSelect:()=>p(P.year($).month(Y.index).date(1))},Y.index)})})]})}import{useState as Bp}from"react";import{jsx as l0,jsxs as Op}from"react/jsx-runtime";var L0=12;function Q2({selected:P,onSelect:p}){let[$,f]=Bp(()=>P.year()-P.year()%L0),z=_(),b=Array.from({length:L0},(Y,Z)=>$+Z);return Op("div",{className:"w-72 p-3","data-slot":"year-grid",children:[l0(p0,{label:`${$} – ${$+L0-1}`,nextLabel:"Next years",onNext:()=>f((Y)=>Y+L0),onPrev:()=>f((Y)=>Y-L0),prevLabel:"Previous years"}),l0("div",{className:"grid grid-cols-3 gap-1",children:b.map((Y)=>{let Z=Y===P.year(),J=Y===z.year()&&!Z;return l0(I0,{isCurrent:J,isSelected:Z,label:Y,onSelect:()=>p(P.year(Y))},Y)})})]})}import{jsx as a,jsxs as J2}from"react/jsx-runtime";var Hp={day:"day",week:"week",month:"month",year:"year"};function kp(P){let p=P?.navigationStep??{amount:1,unit:P?.navigationUnit??"day"};if(p.amount!==1)return"range";return Hp[p.unit]??"range"}function X2({className:P}){let{currentDate:p,currentRange:$,view:f,selectDate:z,firstDayOfWeek:b,getViews:Y}=G((B)=>({currentDate:B.currentDate,currentRange:B.currentRange,view:B.view,selectDate:B.selectDate,firstDayOfWeek:B.firstDayOfWeek,getViews:B.getViews})),{formatDateRange:Z}=Z2(),[J,U]=Rp(!1),Q=N0(p,b),X=Q.at(0)??p,N=Q.at(-1)??p,F=(B)=>{z(B),U(!1)},M=kp(Y().find((B)=>B.name===f)),K={year:p.format("YYYY"),month:p.format("MMM YYYY"),week:Z(X,N),day:p.format("ddd, MMM D, YYYY"),range:Z($.start,$.end)}[M],A=a(K0,{defaultMonth:p.toDate(),firstDayOfWeek:b,onSelect:(B)=>B&&F(_(B)),selected:p.toDate()}),m={year:a(Q2,{onSelect:F,selected:p}),month:a(Y2,{onSelect:F,selected:p}),week:a(K0,{defaultMonth:p.toDate(),firstDayOfWeek:b,highlightedWeekOf:p,onSelect:(B)=>B&&F(_(B)),weekHover:!0}),day:A,range:A}[M];return J2(o,{onOpenChange:U,open:J,children:[a(i,{asChild:!0,children:J2(R,{className:q("font-semibold",P),"data-testid":"calendar-title",variant:"outline",children:[K,a(Ip,{className:"size-4 shrink-0 opacity-50"})]})}),a(x,{align:"start",className:"w-auto p-0",children:m})]})}var a0=`\r
2
- `,mp=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(a0),R0=(P)=>{return P.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
- `,"\\n").replaceAll("\r","")},q2=(P,p=!1)=>{if(p)return P.format("YYYYMMDD");return P.utc().format("YYYYMMDD[T]HHmmss[Z]")},Tp=(P)=>{return P.uid||`${P.id}@ilamy.calendar`},Sp=(P,p)=>{let $=_().utc().format("YYYYMMDD[T]HHmmss[Z]"),f=P.allDay?";VALUE=DATE":"",z=["BEGIN:VEVENT",`UID:${Tp(P)}`,`DTSTART${f}:${q2(P.start,P.allDay)}`,`DTEND${f}:${q2(P.end,P.allDay)}`,`SUMMARY:${R0(P.title)}`,P.description&&`DESCRIPTION:${R0(P.description)}`,P.location&&`LOCATION:${R0(P.location)}`].filter(Boolean),b=p("ical:vevent-properties",P).filter((Z)=>typeof Z==="string"),Y=[`DTSTAMP:${$}`,`CREATED:${$}`,`LAST-MODIFIED:${$}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...z,...b,...Y].join(a0)},gp=(P,p,$="ilamy Calendar")=>{let f=R0($),z=P.map((b)=>Sp(b,p));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${f}`,`X-WR-CALDESC:Exported from ${f}`,mp,...z,"END:VCALENDAR"].join(a0)},U2=(P,p,$="calendar.ics",f="ilamy Calendar")=>{let z=new Blob([gp(P,p,f)],{type:"text/calendar;charset=utf-8"}),b=URL.createObjectURL(z),Y=$;if(!$.endsWith(".ics"))Y=`${$}.ics`;let Z=document.createElement("a");Z.href=b,Z.download=Y,document.body.append(Z),Z.click(),Z.remove(),URL.revokeObjectURL(b)};function N2(){let{rawEvents:P,collect:p}=G(($)=>({rawEvents:$.rawEvents,collect:$.collect}));return()=>{let $=`ilamy-calendar-${_().format("YYYY-MM-DD")}.ics`;U2(P,p,$,"ilamy Calendar")}}import*as C from"@radix-ui/react-dropdown-menu";import{jsx as _0}from"react/jsx-runtime";function K2({...P}){return _0(C.Root,{"data-slot":"dropdown-menu",...P})}function L2({...P}){return _0(C.Trigger,{"data-slot":"dropdown-menu-trigger",...P})}function _2({className:P,sideOffset:p=4,align:$="end",...f}){return _0(C.Portal,{children:_0(C.Content,{align:$,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",P),"data-slot":"dropdown-menu-content",sideOffset:p,...f})})}function G2({className:P,...p}){return _0(C.Item,{className:q("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",P),"data-slot":"dropdown-menu-item",...p})}import{Check as Dp,ChevronDown as Ep}from"lucide-react";function H0(){let{getViews:P,resources:p}=G((f)=>({getViews:f.getViews,resources:f.resources})),$=Boolean(p?.length);return P().filter((f)=>!$||f.supportsResources)}import{jsx as r,jsxs as t0}from"react/jsx-runtime";function F2({className:P}){let{view:p,setView:$,t:f}=G((J)=>({view:J.view,setView:J.setView,t:J.t})),z=H0(),b=z.find((J)=>J.name===p),Y=b?f(b.label??b.name):"",Z=b?.icon;return t0(K2,{children:[r(L2,{asChild:!0,className:P,children:t0(R,{size:"default",variant:"outline",children:[Z&&r(Z,{className:"size-4"}),r("span",{children:Y}),r(Ep,{className:"size-4 opacity-50"})]})}),r(_2,{align:"end",className:"min-w-40",children:z.map((J)=>{let U=J.icon;return t0(G2,{onSelect:()=>$(J.name),children:[r(U,{className:"size-4"}),r("span",{className:"flex-1",children:f(J.label??J.name)}),J.name===p&&r(Dp,{className:"size-4"})]},J.name)})})]})}import*as k0 from"@radix-ui/react-toggle-group";import{cva as wp}from"class-variance-authority";import{createContext as Cp,useContext as vp}from"react";import{jsx as s0}from"react/jsx-runtime";var yp=wp("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer select-none",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-2.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),M2=Cp({size:"default",variant:"default"});function A2({className:P,variant:p,size:$,children:f,...z}){return s0(k0.Root,{className:q("flex items-center justify-center gap-1",P),"data-slot":"toggle-group",...z,children:s0(M2.Provider,{value:{variant:p,size:$},children:f})})}function V2({className:P,children:p,variant:$,size:f,...z}){let b=vp(M2);return s0(k0.Item,{className:q(yp({variant:b.variant||$,size:b.size||f}),P),"data-slot":"toggle-group-item",...z,children:p})}import{jsx as W2}from"react/jsx-runtime";function B2({className:P}){let{view:p,setView:$,t:f}=G((b)=>({view:b.view,setView:b.setView,t:b.t})),z=H0();return W2(A2,{className:q("bg-muted gap-0 rounded-lg p-0.75",P),onValueChange:(b)=>b&&$(b),size:"sm",type:"single",value:p,children:z.map((b)=>W2(V2,{className:"text-muted-foreground data-[state=on]:bg-background data-[state=on]:text-foreground rounded-md px-3 font-medium data-[state=on]:shadow-sm",value:b.name,children:f(b.label??b.name)},b.name))})}import{jsx as T,jsxs as f0}from"react/jsx-runtime";var O2=({className:P=""})=>{let{nextPeriod:p,prevPeriod:$,today:f,openEventForm:z,headerComponent:b,headerClassName:Y,t:Z,hideExportButton:J}=G((Q)=>({nextPeriod:Q.nextPeriod,prevPeriod:Q.prevPeriod,today:Q.today,openEventForm:Q.openEventForm,headerComponent:Q.headerComponent,headerClassName:Q.headerClassName,t:Q.t,hideExportButton:Q.hideExportButton})),U=N2();if(b)return b;return T("div",{className:q("@container/base-header w-full",Y),"data-testid":"calendar-header",children:f0("div",{className:q("flex flex-col items-center gap-2 @lg/base-header:flex-row @lg/base-header:justify-between",P),children:[f0("div",{className:"flex min-w-0 items-center gap-2",children:[f0("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[T(R,{"aria-label":Z("previous"),className:"h-full",onClick:$,size:"icon",variant:"ghost",children:T(hp,{className:"size-4"})}),T(R,{"aria-label":Z("next"),className:"h-full",onClick:p,size:"icon",variant:"ghost",children:T(jp,{className:"size-4"})})]}),T(R,{onClick:f,size:"default",variant:"outline",children:Z("today")}),T(X2,{})]}),f0("div",{className:"flex items-center gap-2",children:[T(B2,{className:"hidden @3xl/base-header:flex"}),T(F2,{className:"@3xl/base-header:hidden"}),!J&&f0(R,{"aria-label":Z("export"),onClick:U,size:"default",variant:"outline",children:[T(op,{className:"size-4"}),T("span",{className:"hidden @2xl/base-header:inline",children:Z("export")})]}),f0(R,{"aria-label":Z("new"),onClick:()=>z(),size:"default",children:[T(ip,{className:"size-4"}),T("span",{className:"hidden @2xl/base-header:inline",children:Z("new")})]})]})]})})};import{useMemo as x2}from"react";import{useRef as ep}from"react";import{useEffect as xp,useRef as up}from"react";var cp=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,dp="[data-hour]",rp=(P)=>{let $=cp.exec(P)?.at(1);if(!$)return null;let f=Number.parseInt($,10);return f>=0&&f<=23?f:null},e0=(P)=>Number.parseInt(P.getAttribute("data-hour")??"",10),np=(P,p)=>{let $=P.at(0),f=P.at(-1);if(!$||!f)return null;if(p<=e0($))return $;if(p>=e0(f))return f;return P.find((z)=>e0(z)===p)??null},lp=(P,p,$,f)=>{let z=p.getBoundingClientRect(),b=$.getBoundingClientRect();if(f==="horizontal"){P.scrollTo({left:z.left-b.left,behavior:"auto"});return}P.scrollTo({top:z.top-b.top,behavior:"auto"})},m0=({viewportRef:P,scrollTime:p,enabled:$,scrollKey:f,axis:z="vertical"})=>{let b=up(null);xp(()=>{if(!$||!p)return;if(b.current===f)return;let Y=rp(p);if(Y===null)return;let Z=P.current;if(!Z)return;let J=Array.from(Z.querySelectorAll(dp)),U=J.at(0),Q=np(J,Y);if(!U||!Q)return;lp(Z,Q,U,z),b.current=f},[$,p,f,P,z])};import{memo as ap}from"react";import{jsx as sp}from"react/jsx-runtime";var tp=({children:P,className:p})=>{let{stickyViewHeader:$,viewHeaderClassName:f}=G((z)=>({stickyViewHeader:z.stickyViewHeader,viewHeaderClassName:z.viewHeaderClassName}));return sp("div",{className:q("flex h-12 w-fit",$&&"sticky top-0 z-21 bg-background",p,f),"data-testid":"horizontal-grid-header",children:P})},I2=ap(tp);import{jsx as z0,jsxs as R2}from"react/jsx-runtime";var k2=({rows:P,children:p,classes:$,allDay:f,gridType:z,variant:b="resource",dayNumberHeight:Y})=>{let{currentDate:Z,view:J,scrollTime:U}=G(),Q=ep(null),X=b==="resource",N=!X;m0({viewportRef:Q,scrollTime:U,enabled:z==="hour"&&X,scrollKey:`${J}-${Z.format("YYYY-MM-DD")}`,axis:"horizontal"});let M=p&&z0(I2,{className:$?.header,children:p});return R2("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",children:[N&&M,R2(d,{className:q("h-full",N&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Q},children:[X&&M,z0("div",{className:q("flex flex-1 w-fit",$?.body),"data-testid":"horizontal-grid-body",children:z0("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:P.map((W)=>z0(H2,{allDay:W.allDay??f,dayNumberHeight:Y,gridType:z,variant:b,...W},W.id))},Z.format("YYYY-MM"))}),z0(b0,{className:"z-30"}),z0(b0,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as K4}from"react";import{memo as Q4}from"react";import{memo as b4}from"react";import{useMemo as S2}from"react";var P4=(P)=>{let p=[],$=[],f=null;for(let z of P){if(f&&z.start.isSameOrAfter(f)){if($.length>0)p.push($);$=[]}$.push(z),f=f?_.max(f,z.end):z.end}if($.length>0)p.push($);return p},m2=(P,{gridStart:p,totalUnits:$,gridType:f,isDiscrete:z})=>{let b=P.start.diff(p,f,!0),Y=P.end.diff(p,f,!0);if(z){if(b=Math.floor(b),Y=Math.ceil(Y),Y<=b)Y=b+1}if(b<0)b=0;if(Y>$)Y=$;let Z=Math.max(0,Y-b);if(Z===0)return null;return{top:b/$*100,height:Z/$*100}},p4={2:25,3:50,4:60},$4=70,f4=(P)=>p4[P]??$4,z4=(P,p)=>{let $=P.length===1?P.at(0):void 0;if($){let Z=m2($,p);if(!Z)return[];return[{kind:"vertical",event:$,left:0,width:100,...Z}]}let f=[...P].sort((Z,J)=>{let U=J.end.diff(J.start,"minute")-Z.end.diff(Z.start,"minute");return U!==0?U:Z.start.diff(J.start)}),z=f.length,b=z>1?f4(z)/(z-1):0,Y=[];for(let Z=0;Z<z;Z++){let J=f.at(Z);if(!J)continue;let U=m2(J,p);if(!U)continue;let Q=Z===0?0:b*Z;Y.push({kind:"vertical",event:J,...U,left:Q,width:100-Q,zIndex:Z+1})}return Y},T2=({days:P,gridType:p="hour",events:$})=>{let f=$.filter((b)=>!b.allDay).toSorted((b,Y)=>b.start.diff(Y.start));if(f.length===0)return[];let z={gridStart:P.at(0)||_(),totalUnits:P.length,gridType:p,isDiscrete:p==="day"};return P4(f).flatMap((b)=>z4(b,z))};var D2=({days:P,gridType:p,resourceId:$})=>{let{getEventsForDateRange:f}=G(),z=P.at(0),b=P.at(-1),Y=z?.startOf("day"),Z=b?.endOf("day"),J=S2(()=>{if(!Y||!Z)return[];let Q=f(Y,Z);if($)Q=g2(Q,$);return Q.filter((X)=>!X.allDay)},[Y,Z,f,$]);return S2(()=>{return T2({days:P,events:J,gridType:p})},[P,p,J])};import{jsx as PP,jsxs as Y4}from"react/jsx-runtime";var Z4=({days:P,gridType:p="hour",resourceId:$,resource:f,"data-testid":z})=>{let{resources:b}=G((X)=>({resources:X.resources})),Y=D2({days:P,gridType:p,resourceId:$}),Z=P.at(0),J=P.at(-1)?.add(1,p),U=!$||b?.at(0)?.id===$,Q=p==="hour"&&Boolean(Z&&J);return Y4("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":z,children:[Q&&Z&&J&&PP(w2,{rangeEnd:J,rangeStart:Z,resource:f,withDot:U}),Y.map((X,N)=>{let{event:F}=X,M=`event-${F.id}-${N}-${P.at(0)?.toISOString()}-${$??"no-resource"}`,W=F.end.diff(F.start,"minute")<=15;return PP("div",{className:"absolute",style:{left:`${X.left}%`,width:`calc(${X.width}% - var(--spacing) * 2)`,top:`${X.top}%`,height:`${X.height}%`},children:PP(E2,{className:q("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":W}),elementId:M,event:F})},k.listKey(M,"wrapper"))})]})},C2=b4(Z4);import{jsx as Z0,jsxs as X4}from"react/jsx-runtime";var J4=({id:P,days:p,resource:$,"data-testid":f,gridType:z,className:b,renderCell:Y,noEvents:Z,slotDurationMinutes:J=60})=>{let U=$?.id,Q=Math.floor(60/J),X=Array.from({length:Q},(F,M)=>M*J),N=X.length>1;return Z0("div",{className:q("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",b),"data-testid":f||k.container.vertical.col(P),children:X4("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${p.length}, minmax(0, 1fr))`},children:[p.map((F,M)=>{let W=F.format("HH");if(Y){let K=P===k.col.time,A=K?k.cell.verticalTime(W):k.cell.vertical(F,W,"00",U);return Z0("div",{className:"min-h-[60px] bg-background","data-hour":K?W:void 0,"data-testid":A,children:Y(F)},k.listKey(P,M,W))}return Z0("div",{className:"flex flex-col min-h-[60px]",children:X.map((K,A)=>{let V=String(K).padStart(2,"0"),m=k.cell.vertical(F,W,V,U),B=N&&A<X.length-1;return Z0(v2,{className:q("hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",B&&"border-b border-dashed"),"data-testid":m,day:N?F.minute(K):F,gridType:z,hour:z==="hour"?F.hour():void 0,minute:N?K:void 0,resourceId:U,shouldRenderEvents:!1,slotDurationMinutes:J},k.listKey(P,M,V))})},k.listKey(P,M,W))}),!Z&&Z0("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Z0(C2,{"data-testid":k.container.eventsLayer("vertical",P),days:p,gridType:z,resource:$,resourceId:U})})]})})},y2=Q4(J4);import{memo as q4}from"react";import{jsx as h2,jsxs as N4}from"react/jsx-runtime";var U4=({children:P,classes:p,allDayRow:$,expandAllDayRow:f=!1})=>{let{stickyViewHeader:z,viewHeaderClassName:b}=G((Z)=>({stickyViewHeader:Z.stickyViewHeader,viewHeaderClassName:Z.viewHeaderClassName})),Y="min-w-full w-fit";return N4("div",{className:q(f&&"flex h-full flex-col",z&&"sticky top-0 z-21 bg-background",b),children:[h2("div",{className:q("min-h-12 border-b","min-w-full w-fit",p?.header),"data-testid":"vertical-grid-header",children:P}),$&&h2("div",{className:q("flex min-h-12 border-b","min-w-full w-fit",f&&"flex-1 overflow-hidden",p?.allDay),"data-testid":"vertical-grid-all-day",children:$})]})},j2=q4(U4);import{jsx as Y0,jsxs as o2}from"react/jsx-runtime";var i2=({columns:P,children:p,gridType:$="day",variant:f="resource",classes:z,allDayRow:b,slotDurationMinutes:Y,style:Z})=>{let J=f==="resource",U=!J,Q=P.every((A)=>!A.days?.length),{currentDate:X,view:N,scrollTime:F}=G(),M=K4(null);m0({viewportRef:M,scrollTime:F,enabled:$==="hour"&&!Q,scrollKey:`${N}-${X.format("YYYY-MM-DD")}`});let K=p&&Y0(j2,{allDayRow:b,classes:{header:z?.header,allDay:z?.allDay},expandAllDayRow:Q,children:p});if(Q&&K)return Y0("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:Z,children:K});return o2("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:Z,children:[U&&K,o2(d,{className:q("h-full",U&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:M},children:[J&&K,Y0("div",{className:q("relative flex flex-1 min-w-full w-fit gap-px bg-border",z?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:P.map((A,V)=>Y0(y2,{...A,gridType:$,slotDurationMinutes:Y},k.listKey(A.id,V)))}),Y0(b0,{className:"z-30"})," ",Y0(b0,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as t}from"react/jsx-runtime";var L4=(P,p)=>p==="vertical",_4=({specs:P,header:p,composesResourceAxis:$,variant:f})=>{let{slotDuration:z}=G((N)=>({slotDuration:N.slotDuration})),b=P.some((N)=>N.gridType==="hour")?"hour":"day",Y=P.filter((N)=>!N.noEvents).map((N)=>N.day).filter((N)=>Boolean(N)),Z=P.find((N)=>N.noEvents),U=Boolean(Z?.className?.includes(pP))?{cell:"flex-1 min-w-0",spacer:pP}:void 0,Q;if(b==="hour")Q=$?t(d2,{columns:P}):t(c2,{classes:U,days:Y});return t(i2,{allDayRow:Q,classes:$?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:P,gridType:b,slotDurationMinutes:z,variant:f,children:p})},G4=({specs:P,header:p,composesResourceAxis:$,variant:f})=>{let z=P.some((Z)=>Z.columns?.some((J)=>J.gridType==="hour"))?"hour":"day",b=P.some((Z)=>Z.columns?.some((J)=>J.days)),Y=$?{header:q(b&&u2,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return t(k2,{classes:Y,dayNumberHeight:$?0:void 0,gridType:z,rows:P,variant:f,children:p})},r2=({view:P})=>{let{currentDate:p,firstDayOfWeek:$,hiddenDays:f,businessHours:z,hideNonBusinessHours:b,resources:Y,orientation:Z,weekViewGranularity:J}=G((K)=>({currentDate:K.currentDate,firstDayOfWeek:K.firstDayOfWeek,hiddenDays:K.hiddenDays,businessHours:K.businessHours,hideNonBusinessHours:K.hideNonBusinessHours,resources:K.resources,orientation:K.orientation,weekViewGranularity:K.weekViewGranularity})),U=x2(()=>({firstDayOfWeek:$,hiddenDays:f,businessHours:z,hideNonBusinessHours:b,resources:Y,orientation:Z,weekViewGranularity:J}),[$,f,z,b,Y,Z,J]),Q=x2(()=>P.columns?.(p,U),[P,p,U]);if(!Q||!P.layout){let K=P.component;if(K)return t(K,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${P.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let N=Boolean(Y?.length)&&Boolean(P.supportsResources),F=N?Z??"horizontal":P.layout,M=N?"resource":"regular",W=P.renderHeader?.({date:p,config:U});if(L4(Q,F))return t(_4,{composesResourceAxis:N,header:W,specs:Q,variant:M});return t(G4,{composesResourceAxis:N,header:W,specs:Q,variant:M})};var n2=(P)=>{if(!P||P.length===0)return;return new Set(P.map((p)=>T0[p]))};function l2(P){if(!P||!P.length)return[];return P.map((p)=>{return{...p,start:_.isDayjs(p.start)?p.start:_(p.start),end:_.isDayjs(p.end)?p.end:_(p.end)}})}import{jsx as n,jsxs as V4}from"react/jsx-runtime";var A4=()=>{let{view:P,getViews:p}=G((z)=>({view:z.view,getViews:z.getViews})),$=p().find((z)=>z.name===P);return V4("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[n(O2,{className:"p-1 shrink-0 mb-1"}),n(BP,{children:n(a2,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:P,children:n("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:$?n(r2,{view:$},P):null})})}),n(b2,{})]})},$P=({events:P,firstDayOfWeek:p="sunday",initialView:$="month",initialDate:f,eventSpacing:z=t2,eventHeight:b=s2,stickyViewHeader:Y=!0,viewHeaderClassName:Z="",timeFormat:J="12-hour",hideNonBusinessHours:U=!1,hiddenDays:Q,resources:X,orientation:N,...F})=>{let M=Boolean(X?.length),W=M4(()=>l2(P),[P]);return F4(()=>{if(typeof process<"u"&&!1)console.warn("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[N,M]),n(e2,{eventHeight:b,eventSpacing:z,events:W,firstDayOfWeek:T0[p],hiddenDays:n2(Q),hideNonBusinessHours:U,initialDate:wP(f),initialView:$,orientation:N,resources:X,stickyViewHeader:Y,timeFormat:J,viewHeaderClassName:Z,...F,children:n(A4,{})})};import{jsx as B4}from"react/jsx-runtime";var W4=(P)=>B4($P,{...P});export{O4 as useIlamyCalendarContext,I4 as defaultTranslations,_ as dayjs,KP as SLOT_EVENT_MUTATION_SCOPE,NP as SLOT_EVENT_FORM,W4 as IlamyResourceCalendar,$P as IlamyCalendar};
1
+ import{t}from"./shared/chunk-4jynmg6d.js";import{r,Q,i,l,s,O,o,L,z,B,P,q,I,_,E,k,H,G,W,T,U,X,Y,M}from"./shared/chunk-79d4xe20.js";import{e,Z}from"./shared/chunk-d7599sry.js";import{b,R,x,A,w,V}from"./shared/chunk-n7xt0j3a.js";import{n,y,m,a,g,v,C,D,p}from"./shared/chunk-4yfcvykw.js";import{c,f}from"./shared/chunk-w4nsrq2y.js";var Lt="event-form",Yt="event-mutation-scope",_t=({event:d,onChange:u})=>r((S)=>S.renderSlot)(Lt,{event:d,onChange:u}),Je=({dialog:d,onResolve:u,onCancel:h})=>{let S=r((K)=>K.getEventManager);if(!(d.isOpen&&d.event))return null;let N=S(d.event),F={event:d.event,operation:d.operation,resolve:u,cancel:h};return N?.renderSlot?.(Yt,F)};import{useEffect as ca,useMemo as ma}from"react";import{DndContext as Mo,MouseSensor as Ho,pointerWithin as Vo,TouchSensor as Io,useSensor as Wt,useSensors as Oo}from"@dnd-kit/core";import{useId as Ao,useRef as Kt}from"react";import{useCallback as et,useEffect as xo,useRef as So,useState as wo}from"react";var yt={isOpen:!1,operation:"edit",event:null};function tt(d){let{applyScopedEdit:u,applyScopedDelete:h}=r((ee)=>({applyScopedEdit:ee.applyScopedEdit,applyScopedDelete:ee.applyScopedDelete})),[S,N]=wo(yt),F=So(S);xo(()=>{F.current=S},[S]);let K=et((ee,te)=>{N({isOpen:!0,operation:"edit",event:ee,updates:te})},[]),j=et((ee)=>{N({isOpen:!0,operation:"delete",event:ee})},[]),J=et(()=>N(yt),[]),re=et((ee)=>{let te=F.current;if(!te.event)return;if(te.operation==="edit")u(te.event,te.updates??{},ee);else h(te.event,ee);N(yt),d?.()},[u,h,d]);return{dialogState:S,openEditDialog:K,openDeleteDialog:j,closeDialog:J,handleConfirm:re}}var Po=(d,u,h)=>{if(h===void 0||u===h)return{};if(!d.resourceIds)return{resourceId:h};let N=d.resourceIds.indexOf(u);if(N===-1)return{};let F=d.resourceIds.slice();if(F.splice(N,1),!F.includes(h))F.push(h);return{resourceIds:F}},jt=(d,u)=>{let{active:h,over:S}=d;if(!h||!S||!u)return null;let N=S.data.current||{},F=N.type==="time-cell",{resourceId:K,allDay:j}=N,J;if(F){let{date:ie,hour:se=0,minute:de=0}=N;J=t(ie).hour(se).minute(de)}else{let{date:ie}=N;J=t(ie)}let re=u.end.diff(u.start,"second"),ee=J.add(re,"second"),te=h.data.current?.sourceResourceId,oe={start:J,end:ee,...Po(u,te,K),allDay:F?!1:j??u.allDay};return{activeEvent:u,updates:oe}};import{DragOverlay as No}from"@dnd-kit/core";import{snapCenterToCursor as To}from"@dnd-kit/modifiers";import{useImperativeHandle as Ro,useState as ko}from"react";import{jsx as $t}from"react/jsx-runtime";var Ut=({ref:d})=>{let[u,h]=ko(null);return Ro(d,()=>({setActiveEvent:h})),$t(No,{modifiers:[To],children:u&&$t("div",{className:e("cursor-grab truncate rounded bg-amber-200 p-2 text-[10px] shadow-lg sm:text-xs w-20",u.backgroundColor||"bg-blue-500",u.color||"text-white"),children:u?.title})})};import{jsx as Zt,jsxs as qt,Fragment as Fo}from"react/jsx-runtime";function Xt({children:d}){let u=Ao(),h=Kt(null),S=Kt(null),{updateEvent:N,getEventManager:F,disableDragAndDrop:K}=r((le)=>({updateEvent:le.updateEvent,getEventManager:le.getEventManager,disableDragAndDrop:le.disableDragAndDrop})),{dialogState:j,openEditDialog:J,closeDialog:re,handleConfirm:ee}=tt(),te=Wt(Ho,{activationConstraint:{distance:2}}),oe=Wt(Io,{activationConstraint:{delay:100,tolerance:5}}),ie=Oo(te,oe),se=(le,pe)=>{let ce=!pe||Object.keys(pe).length===0;if(!le?.id||ce)return;if(F(le)?.applyEdit)J(le,pe);else N(le.id,pe)},de=(le)=>{let{active:pe}=le;if(pe.data.current?.type==="calendar-event")S.current?.setActiveEvent(pe.data.current.event),h.current=pe.data.current.event},ae=(le)=>{let pe=jt(le,h.current);if(pe){let{activeEvent:ce,updates:Se}=pe;se(ce,Se)}h.current=null,S.current?.setActiveEvent(null)},ue=(le)=>{h.current=null};if(K)return d;return qt(Fo,{children:[qt(Mo,{collisionDetection:Vo,id:u,onDragCancel:ue,onDragEnd:ae,onDragStart:de,sensors:ie,children:[d,Zt(Ut,{ref:S})]}),Zt(Je,{dialog:j,onCancel:re,onResolve:ee})]})}import{ChevronDownIcon as zo}from"lucide-react";import{useEffect as Go,useState as Bo}from"react";import*as Ee from"@radix-ui/react-popover";import{jsx as rt}from"react/jsx-runtime";function Pe({...d}){return rt(Ee.Root,{"data-slot":"popover",...d})}function Ne({...d}){return rt(Ee.Trigger,{"data-slot":"popover-trigger",...d})}function Te({className:d,align:u="center",sideOffset:h=4,...S}){return rt(Ee.Portal,{children:rt(Ee.Content,{align:u,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",d),"data-slot":"popover-content",sideOffset:h,...S})})}import{jsx as Re,jsxs as $e}from"react/jsx-runtime";var Qt=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ht=(d)=>Boolean(d&&Qt.test(d)),Lo=(d)=>{let u=d.match(/bg-([a-z]+)-\d+/)?.at(1);if(!u)return"Custom";return u.charAt(0).toUpperCase()+u.slice(1)};function Jt({value:d,onChange:u,swatches:h=[],className:S,"aria-label":N="Select color"}){let[F,K]=Bo(ht(d)?d:"");Go(()=>{K(ht(d)?d:"")},[d]);let j=(te)=>{let oe=te.target.value;if(K(oe),Qt.test(oe))u(oe)},J=ht(d),re=h.find((te)=>te.value===d),ee;if(re)ee=re.label;else if(J)ee=d;else if(d)ee=Lo(d);else ee="Pick a color";return $e(Pe,{children:[$e(Ne,{"aria-label":N,className:e("border-input focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 text-sm shadow-xs outline-none focus-visible:ring-[3px]",S),"data-slot":"color-picker-trigger",type:"button",children:[$e("span",{className:"flex items-center gap-2",children:[Re("span",{className:e("size-5 shrink-0 rounded-full border",!J&&d),style:J?{backgroundColor:d}:void 0}),Re("span",{className:e(J&&"font-mono text-xs"),children:ee})]}),Re(zo,{className:"size-4 shrink-0 opacity-50"})]}),$e(Te,{className:"w-56","data-slot":"color-picker-content",children:[h.length>0&&Re("div",{className:"grid grid-cols-7 gap-1.5",children:h.map((te)=>{let oe=d===te.value;return Re("button",{"aria-label":te.label,"aria-pressed":oe,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",te.value,oe&&"ring-ring ring-2 ring-offset-1"),onClick:()=>u(te.value),type:"button"},te.value)})}),Re("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),$e("div",{className:"flex items-center gap-2",children:[Re("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(te)=>u(te.target.value),type:"color",value:J?d:"#000000"}),Re(m,{"aria-label":"Hex color",className:"font-mono",onChange:j,placeholder:"#000000",value:F})]})]})]})}import{jsx as Yo}from"react/jsx-runtime";function er({className:d,...u}){return Yo("textarea",{className:e("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",d),"data-slot":"textarea",...u})}import{useEffect as an,useState as Ce}from"react";import{PopoverClose as qo}from"@radix-ui/react-popover";import{Calendar as Xo}from"lucide-react";import{useEffect as Qo,useRef as Jo,useState as en}from"react";import{useState as Uo}from"react";import{ChevronLeftIcon as _o,ChevronRightIcon as jo}from"lucide-react";import{jsx as Ue,jsxs as $o}from"react/jsx-runtime";function Fe({label:d,onPrev:u,onNext:h,prevLabel:S,nextLabel:N}){return $o("div",{className:"mb-2 flex items-center justify-between",children:[Ue(n,{"aria-label":S,onClick:u,size:"icon",variant:"ghost",children:Ue(_o,{className:"size-4"})}),Ue("div",{className:"text-sm font-medium select-none",children:d}),Ue(n,{"aria-label":N,onClick:h,size:"icon",variant:"ghost",children:Ue(jo,{className:"size-4"})})]})}import{jsx as xe,jsxs as tr}from"react/jsx-runtime";function Wo(d){let u=d.weekHover&&!d.isCurrentWeek;return e("p-0 text-center",d.weekHover&&"first:rounded-l-md last:rounded-r-md",u&&"group-hover/week:bg-accent",d.isCurrentWeek&&"bg-primary")}function Ko(d){return e("w-full aspect-square text-sm select-none",!d.isDisabled&&"cursor-pointer",!(d.weekHover||d.isDisabled)&&"hover:bg-accent rounded-md",d.isOutside&&"text-muted-foreground/50",d.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",d.isCurrentWeek&&"text-primary-foreground font-medium",d.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",d.isDisabled&&"opacity-50 cursor-not-allowed")}function Zo({day:d,state:u,onSelect:h}){return xe("td",{className:Wo(u),"data-disabled":u.isDisabled,"data-outside":u.isOutside,"data-selected":u.isSelected,role:"gridcell",tabIndex:-1,children:xe("button",{"aria-disabled":u.isDisabled,"aria-hidden":u.isOutside,className:Ko(u),"data-disabled":u.isDisabled,"data-selected":u.isSelected,disabled:u.isDisabled||u.isOutside,onClick:()=>h?.(d.toDate()),tabIndex:u.isOutside?-1:0,type:"button",children:d.format("D")})})}function We({selected:d,defaultMonth:u,onSelect:h,disabled:S,firstDayOfWeek:N=0,className:F,weekHover:K=!1,highlightedWeekOf:j}){let[J,re]=Uo(()=>t(u??d??new Date).startOf("month")),ee=O(J,N),te=d?t(d).format("YYYY-MM-DD"):void 0,oe=s(t(),N).map((ae)=>ae.format("dd")),ie,se;if(j){let ae=s(j,N);ie=ae.at(0),se=ae.at(-1)}let de=(ae)=>{let ue=ae.format("YYYY-MM-DD")===te,le=!1;if(ie&&se){let pe=!ae.isBefore(ie,"day"),ce=!ae.isAfter(se,"day");le=pe&&ce}return{isOutside:!ae.isSame(J,"month"),isSelected:ue,isDisabled:S?.(ae.toDate())??!1,isCurrent:l(ae)&&!ue,isCurrentWeek:le,weekHover:K}};return tr("div",{className:e("bg-background p-3 w-72",F),"data-slot":"calendar",children:[xe(Fe,{label:J.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>re((ae)=>ae.add(1,"month")),onPrev:()=>re((ae)=>ae.subtract(1,"month")),prevLabel:"Previous month"}),tr("table",{className:"w-full border-collapse",role:"grid",children:[xe("thead",{children:xe("tr",{children:oe.map((ae,ue)=>xe("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:ae},ue))})}),xe("tbody",{children:ee.map((ae,ue)=>xe("tr",{className:e(K&&"group/week"),children:ae.map((le)=>xe(Zo,{day:le,onSelect:h,state:de(le)},le.toISOString()))},ue))})]})]})}import{jsx as ze,jsxs as Ct}from"react/jsx-runtime";function rr({date:d,closeOnSelect:u,onChange:h,label:S="Pick a date",className:N,disabled:F}){let K=r((te)=>te.firstDayOfWeek),j=Jo(null),[J,re]=en(d);Qo(()=>{re(d)},[d]);let ee=(te)=>{if(re(te),u)j.current?.click();h?.(te)};return ze("div",{className:N,children:Ct(Pe,{children:[ze(Ne,{asChild:!0,children:Ct(n,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!d,variant:"outline",children:[ze(Xo,{}),J?t(J).format("ll"):ze("span",{children:S})]})}),Ct(Te,{align:"start",className:"w-auto p-0",children:[ze(qo,{ref:j,style:{display:"none"}}),ze(We,{defaultMonth:J,disabled:F,firstDayOfWeek:K,onSelect:ee,selected:J})]})]})})}import{Clock as rn}from"lucide-react";import{useEffect as on,useRef as nr,useState as Dt}from"react";import{useMemo as tn}from"react";function or({timeFormat:d="12-hour",minTime:u="00:00",maxTime:h="23:45"}){return{timeOptions:tn(()=>{let F=[],[K,j]=u.split(":").map(Number),[J,re]=h.split(":").map(Number),ee=K*60+j,te=J*60+re;for(let oe=ee;oe<=te;oe+=15){let ie=Math.floor(oe/60),se=oe%60,de=`${ie.toString().padStart(2,"0")}:${se.toString().padStart(2,"0")}`;F.push(de)}return F},[u,h]),formatTime:(F)=>{let[K,j]=F.split(":").map(Number);if(d==="24-hour")return`${K.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`;let J=K>=12?"PM":"AM",re=K;if(K===0)re=12;else if(K>12)re=K-12;return`${re}:${j.toString().padStart(2,"0")} ${J}`}}}import{jsx as ke,jsxs as bt}from"react/jsx-runtime";var nn=(d)=>{d.stopPropagation()};function ar({value:d,onChange:u,minTime:h="00:00",maxTime:S="23:45",timeFormat:N="12-hour",placeholder:F="Select time...",className:K,disabled:j=!1,name:J}){let[re,ee]=Dt(!1),[te,oe]=Dt(""),ie=nr(null),se=nr(null),[de,ae]=Dt(0),{timeOptions:ue,formatTime:le}=or({timeFormat:N,minTime:h,maxTime:S}),pe=ue.filter((ve)=>le(ve).toLowerCase().includes(te.toLowerCase())),ce=(ve)=>{u(ve),ee(!1),oe("")};on(()=>{if(re){if(se.current)ae(se.current.offsetWidth);setTimeout(()=>{ie.current?.focus()},0)}},[re]);let Se=d?le(d):F;return bt(Pe,{onOpenChange:ee,open:re,children:[ke(Ne,{asChild:!0,children:bt(n,{"aria-controls":"time-picker-listbox","aria-expanded":re,className:e("w-full justify-start",K),"data-testid":o.timePicker(J),disabled:j,ref:se,role:"combobox",variant:"outline",children:[ke(rn,{className:"mr-2 h-4 w-4"}),Se]})}),bt(Te,{align:"start",className:"p-0",style:{width:de},children:[ke("div",{className:"p-2 border-b",children:ke(m,{className:"h-8",onChange:(ve)=>oe(ve.target.value),placeholder:"Search time...",ref:ie,value:te})}),ke(c,{className:"h-[200px]",onWheel:nn,children:ke("div",{className:"p-1",children:pe.length===0?ke("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):pe.map((ve)=>{let qe=le(ve);return ke("button",{className:e("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",ve===d&&"bg-accent text-accent-foreground"),onClick:()=>ce(ve),type:"button",children:qe},ve)})})})]})]})}var ir=(d,u)=>{let[h,S]=u.split(":").map(Number);return t(d).hour(h).minute(S).second(0).millisecond(0)},sr=(d,u,h)=>{let S=ir(d,u);return h?S.hour(0).minute(0):S},lr=(d,u,h)=>{let S=ir(d,u);return h?S.add(1,"day").startOf("day"):S},Et=(d,u)=>{if(!u)return{min:"00:00",max:"23:59"};let h=t(d),{minStart:S,maxEnd:N,hasBusinessHours:F}=_({allDates:[h],businessHours:u,hideNonBusinessHours:!1});if(!F)return{min:"00:00",max:"23:59"};return{min:`${S.toString().padStart(2,"0")}:00`,max:`${(N-1).toString().padStart(2,"0")}:45`}};import{jsx as me,jsxs as ye,Fragment as mn}from"react/jsx-runtime";var dr="bg-blue-100 text-blue-800",sn=[{value:dr,label:"Blue"},{value:"bg-green-100 text-green-800",label:"Green"},{value:"bg-purple-100 text-purple-800",label:"Purple"},{value:"bg-red-100 text-red-800",label:"Red"},{value:"bg-yellow-100 text-yellow-800",label:"Yellow"},{value:"bg-pink-100 text-pink-800",label:"Pink"},{value:"bg-indigo-100 text-indigo-800",label:"Indigo"},{value:"bg-amber-100 text-amber-800",label:"Amber"},{value:"bg-emerald-100 text-emerald-800",label:"Emerald"},{value:"bg-sky-100 text-sky-800",label:"Sky"},{value:"bg-violet-100 text-violet-800",label:"Violet"},{value:"bg-rose-100 text-rose-800",label:"Rose"},{value:"bg-teal-100 text-teal-800",label:"Teal"},{value:"bg-orange-100 text-orange-800",label:"Orange"}],cr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ln=(d,u)=>{if(d&&cr.test(d))return d;return u??dr},dn=(d)=>{if(cr.test(d))return{backgroundColor:d,color:Z(d)};return{backgroundColor:void 0,color:d}},cn=({colorChanged:d,hadInitialColor:u,selectedColor:h,initialBackgroundColor:S,initialColor:N})=>{if(d||!u)return dn(h);return{backgroundColor:S,color:N}},xt=({name:d,label:u,placeholder:h,value:S,required:N=!1,multiline:F=!1,onChange:K})=>ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",htmlFor:d,children:u}),F?me(er,{className:"min-h-16 text-sm",id:d,name:d,onChange:K,placeholder:h,required:N,value:S}):me(m,{className:"h-8 text-sm sm:h-9",id:d,name:d,onChange:K,placeholder:h,required:N,value:S})]}),mr=({selectedEvent:d,onClose:u,onUpdate:h,onDelete:S,onAdd:N})=>{let{dialogState:F,openEditDialog:K,openDeleteDialog:j,closeDialog:J,handleConfirm:re}=tt(u),{t:ee,timeFormat:te,getEventManager:oe,resources:ie}=r((ne)=>({t:ne.t,timeFormat:ne.timeFormat,getEventManager:ne.getEventManager,resources:ne.resources??[]})),{id:se,resourceId:de,resourceIds:ae,start:ue=t(),end:le=t().add(1,"hour"),allDay:pe=!1,color:ce,backgroundColor:Se,title:ve="",description:qe="",location:Ht=""}=d??{},Vt=ie.length>0,It=de??ae?.at(0),Ot=Vt&&It===void 0,[dt,qr]=Ce(It),ct=Vt?dt:de,Xe=L(ct),At=Boolean(d&&oe(d)),Xr=le.isSame(le.startOf("day")),Qr=pe&&Xr?le.subtract(1,"day"):le,[Ve,Ft]=Ce(ue.toDate()),[Ae,mt]=Ce(Qr.toDate()),[we,Jr]=Ce(pe),[ut,eo]=Ce(ln(Se,ce)),[to,ro]=Ce(!1),oo=Boolean(ce||Se),no=(ne)=>{eo(ne),ro(!0)},[pt,zt]=Ce(ue.format("HH:mm")),[Qe,ft]=Ce(le.format("HH:mm")),[be,ao]=Ce({title:ve,description:qe,location:Ht}),[gt,io]=Ce({}),so={...d,...gt},lo=(ne)=>io((fe)=>({...fe,...ne})),co=(ne)=>{if(!ne)return;if(Ft(ne),t(ne).isAfter(t(Ae)))mt(ne)},mo=(ne)=>{if(!ne)return;if(mt(ne),ne&&t(ne).isBefore(t(Ve)))Ft(ne)},uo=(ne)=>{if(Jr(ne),!(ne&&Qe==="00:00"))return;mt((fe)=>t(fe).isAfter(t(Ve),"day")?t(fe).subtract(1,"day").toDate():fe)},po=(ne)=>{if(zt(ne),t(Ve).isSame(t(Ae),"day")&&ne>Qe)ft(ne)},fo=(ne)=>{if(ft(ne),t(Ve).isSame(t(Ae),"day")&&ne<pt)zt(ne)},vt=(ne)=>{let{name:fe,value:he}=ne.target;ao((_e)=>({..._e,[fe]:he}))};an(()=>{if(we)ft("23:59")},[we]);let go=(ne)=>ie.find((he)=>String(he.id)===ne)?.id??ne,Gt=Ot&&dt===void 0,vo=(ne)=>{if(ne.preventDefault(),Gt)return;let fe=sr(Ve,pt,we),he=lr(Ae,Qe,we),_e=cn({colorChanged:to,hadInitialColor:oo,selectedColor:ut,initialBackgroundColor:Se,initialColor:ce}),je={id:se||t().format("YYYYMMDDHHmmss"),title:be.title,start:fe,end:he,resourceId:ct,description:be.description,location:be.location,allDay:we,..._e,...gt};if(d?.id&&At){K(d,{title:be.title,start:fe,end:he,resourceId:ct,description:be.description,location:be.location,allDay:we,color:ut,...gt});return}if(se)h?.(je);else N?.(je);u()},yo=()=>{if(!d?.id)return;if(At){j(d);return}S?.(d),u()},Bt;if(Xe)Bt=(ne)=>!I(t(ne),Xe);let ho=Et(Ve,Xe),Co=Et(Ae,Xe),Do=[["startDate",Ve,co],["endDate",Ae,mo]],bo=[["startTime","start-time",pt,po,ho],["endTime","end-time",Qe,fo,Co]],Eo=dt?.toString();return ye(mn,{children:[ye("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:vo,children:[me(c,{className:"flex-1 min-h-0",children:ye("div",{className:"grid gap-3 sm:gap-4 p-1",children:[me(xt,{label:ee("title"),name:"title",onChange:vt,placeholder:ee("eventTitlePlaceholder"),required:!0,value:be.title}),me(xt,{label:ee("description"),multiline:!0,name:"description",onChange:vt,placeholder:ee("eventDescriptionPlaceholder"),value:be.description}),Ot&&ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ee("resource")}),ye(g,{onValueChange:(ne)=>qr(go(ne)),value:Eo,children:[me(C,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:me(v,{placeholder:ee("selectResource")})}),me(D,{children:ie.map((ne)=>me(p,{value:String(ne.id),children:ne.title},String(ne.id)))})]})]}),ye("div",{className:"flex items-center space-x-2",children:[me(y,{checked:we,id:"allDay",onCheckedChange:(ne)=>uo(ne===!0)}),me(a,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ee("allDay")})]}),me("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Do.map(([ne,fe,he])=>ye("div",{children:[me(a,{className:"text-xs sm:text-sm",children:ee(ne)}),me(rr,{className:"mt-1",closeOnSelect:!0,date:fe,disabled:Bt,onChange:he})]},ne))}),!we&&me("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:bo.map(([ne,fe,he,_e,je])=>ye("div",{children:[me(a,{className:"text-xs sm:text-sm",children:ee(ne)}),me(ar,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:je.max,minTime:je.min,name:fe,onChange:_e,placeholder:ee("searchTime"),timeFormat:te,value:he})]},ne))}),ye("div",{className:"grid gap-1 sm:gap-2",children:[me(a,{className:"text-xs sm:text-sm",children:ee("color")}),me(Jt,{"aria-label":ee("color"),onChange:no,swatches:sn,value:ut})]}),me(xt,{label:ee("location"),name:"location",onChange:vt,placeholder:ee("eventLocationPlaceholder"),value:be.location}),me(_t,{event:so,onChange:lo})]})}),ye(A,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[se&&me(n,{className:"w-full sm:mr-auto sm:w-auto",onClick:yo,size:"sm",type:"button",variant:"destructive",children:ee("delete")}),ye("div",{className:"flex w-full gap-2 sm:w-auto",children:[me(n,{className:"flex-1 sm:flex-none",onClick:u,size:"sm",type:"button",variant:"outline",children:ee("cancel")}),me(n,{className:"flex-1 sm:flex-none",disabled:Gt,size:"sm",type:"submit",children:se?ee("update"):ee("create")})]})]})]}),me(Je,{dialog:F,onCancel:J,onResolve:re})]})};import{jsx as ot,jsxs as ur}from"react/jsx-runtime";var pr=()=>{let{t:d,selectedEvent:u,isEventFormOpen:h,closeEventForm:S,addEvent:N,updateEvent:F,deleteEvent:K,renderEventForm:j}=r((te)=>({t:te.t,selectedEvent:te.selectedEvent,isEventFormOpen:te.isEventFormOpen,closeEventForm:te.closeEventForm,addEvent:te.addEvent,updateEvent:te.updateEvent,deleteEvent:te.deleteEvent,renderEventForm:te.renderEventForm})),ee={open:h,onClose:S,selectedEvent:u,onAdd:N,onUpdate:(te)=>{F(te.id,te)},onDelete:(te)=>{K(te.id)}};if(j)return j(ee);return ot(b,{onOpenChange:S,open:h,children:ur(R,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[ur(x,{className:"mb-2 sm:mb-4 shrink-0",children:[ot(w,{className:"text-base sm:text-lg",children:u?.id?d("editEvent"):d("createEvent")}),ot(V,{className:"text-xs sm:text-sm",children:u?.id?d("editEventDetails"):d("addNewEvent")})]}),ot(mr,{...ee})]})})};import{ChevronLeft as Mn,ChevronRight as Hn,Download as Vn,Plus as In}from"lucide-react";import{ChevronDown as yn}from"lucide-react";import{useState as hn}from"react";function fr(){let{currentLocale:d,timezone:u}=r((S)=>({currentLocale:S.currentLocale,timezone:S.timezone}));return{formatDateRange:(S,N)=>{let F=new Intl.DateTimeFormat(d,{timeZone:u,month:"short",day:"numeric"});if(S.year()===N.year())return F.formatRange(S.toDate(),N.toDate());return`${F.format(S.toDate())} – ${F.format(N.toDate())}`}}}import{useState as pn}from"react";import{jsx as un}from"react/jsx-runtime";function nt({label:d,isSelected:u,isCurrent:h,onSelect:S}){return un("button",{"aria-pressed":u,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",h&&"ring-1 ring-inset ring-foreground/40",u&&"bg-primary text-primary-foreground"),onClick:S,type:"button",children:d})}import{jsx as St,jsxs as fn}from"react/jsx-runtime";function gr({selected:d,onSelect:u}){let[h,S]=pn(()=>d.year()),N=t(),F=Array.from({length:12},(K,j)=>({index:j,label:d.month(j).format("MMM")}));return fn("div",{className:"w-72 p-3","data-slot":"month-grid",children:[St(Fe,{label:h,nextLabel:"Next year",onNext:()=>S((K)=>K+1),onPrev:()=>S((K)=>K-1),prevLabel:"Previous year"}),St("div",{className:"grid grid-cols-3 gap-1",children:F.map((K)=>{let j=h===d.year()&&K.index===d.month(),J=h===N.year()&&K.index===N.month()&&!j;return St(nt,{isCurrent:J,isSelected:j,label:K.label,onSelect:()=>u(d.year(h).month(K.index).date(1))},K.index)})})]})}import{useState as gn}from"react";import{jsx as wt,jsxs as vn}from"react/jsx-runtime";var Ke=12;function vr({selected:d,onSelect:u}){let[h,S]=gn(()=>d.year()-d.year()%Ke),N=t(),F=Array.from({length:Ke},(K,j)=>h+j);return vn("div",{className:"w-72 p-3","data-slot":"year-grid",children:[wt(Fe,{label:`${h} – ${h+Ke-1}`,nextLabel:"Next years",onNext:()=>S((K)=>K+Ke),onPrev:()=>S((K)=>K-Ke),prevLabel:"Previous years"}),wt("div",{className:"grid grid-cols-3 gap-1",children:F.map((K)=>{let j=K===d.year(),J=K===N.year()&&!j;return wt(nt,{isCurrent:J,isSelected:j,label:K,onSelect:()=>u(d.year(K))},K)})})]})}import{jsx as Ie,jsxs as yr}from"react/jsx-runtime";var Cn={day:"day",week:"week",month:"month",year:"year"};function Dn(d){let u=d?.navigationStep??{amount:1,unit:d?.navigationUnit??"day"};if(u.amount!==1)return"range";return Cn[u.unit]??"range"}function hr({className:d}){let{currentDate:u,currentRange:h,view:S,selectDate:N,firstDayOfWeek:F,getViews:K}=r((ce)=>({currentDate:ce.currentDate,currentRange:ce.currentRange,view:ce.view,selectDate:ce.selectDate,firstDayOfWeek:ce.firstDayOfWeek,getViews:ce.getViews})),{formatDateRange:j}=fr(),[J,re]=hn(!1),ee=s(u,F),te=ee.at(0)??u,oe=ee.at(-1)??u,ie=(ce)=>{N(ce),re(!1)},se=Dn(K().find((ce)=>ce.name===S)),ae={year:u.format("YYYY"),month:u.format("MMM YYYY"),week:j(te,oe),day:u.format("ddd, MMM D, YYYY"),range:j(h.start,h.end)}[se],ue=Ie(We,{defaultMonth:u.toDate(),firstDayOfWeek:F,onSelect:(ce)=>ce&&ie(t(ce)),selected:u.toDate()}),pe={year:Ie(vr,{onSelect:ie,selected:u}),month:Ie(gr,{onSelect:ie,selected:u}),week:Ie(We,{defaultMonth:u.toDate(),firstDayOfWeek:F,highlightedWeekOf:u,onSelect:(ce)=>ce&&ie(t(ce)),weekHover:!0}),day:ue,range:ue}[se];return yr(Pe,{onOpenChange:re,open:J,children:[Ie(Ne,{asChild:!0,children:yr(n,{className:e("font-semibold",d),"data-testid":"calendar-title",variant:"outline",children:[ae,Ie(yn,{className:"size-4 shrink-0 opacity-50"})]})}),Ie(Te,{align:"start",className:"w-auto p-0",children:pe})]})}var Pt=`\r
2
+ `,bn=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Pt),at=(d)=>d.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
+ `,"\\n").replaceAll("\r",""),Cr=(d,u=!1)=>{if(u)return d.format("YYYYMMDD");return d.utc().format("YYYYMMDD[T]HHmmss[Z]")},En=(d)=>d.uid||`${d.id}@ilamy.calendar`,xn=(d,u)=>{let h=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),S=d.allDay?";VALUE=DATE":"",N=["BEGIN:VEVENT",`UID:${En(d)}`,`DTSTART${S}:${Cr(d.start,d.allDay)}`,`DTEND${S}:${Cr(d.end,d.allDay)}`,`SUMMARY:${at(d.title)}`,d.description&&`DESCRIPTION:${at(d.description)}`,d.location&&`LOCATION:${at(d.location)}`].filter(Boolean),F=u("ical:vevent-properties",d).filter((j)=>typeof j==="string"),K=[`DTSTAMP:${h}`,`CREATED:${h}`,`LAST-MODIFIED:${h}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...N,...F,...K].join(Pt)},Sn=(d,u,h="ilamy Calendar")=>{let S=at(h),N=d.map((F)=>xn(F,u));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${S}`,`X-WR-CALDESC:Exported from ${S}`,bn,...N,"END:VCALENDAR"].join(Pt)},Dr=(d,u,h="calendar.ics",S="ilamy Calendar")=>{let N=new Blob([Sn(d,u,S)],{type:"text/calendar;charset=utf-8"}),F=URL.createObjectURL(N),K=h;if(!h.endsWith(".ics"))K=`${h}.ics`;let j=document.createElement("a");j.href=F,j.download=K,document.body.append(j),j.click(),j.remove(),URL.revokeObjectURL(F)};function br(){let{rawEvents:d,collect:u}=r((h)=>({rawEvents:h.rawEvents,collect:h.collect}));return()=>{let h=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Dr(d,u,h,"ilamy Calendar")}}import*as De from"@radix-ui/react-dropdown-menu";import{jsx as Ze}from"react/jsx-runtime";function Er({...d}){return Ze(De.Root,{"data-slot":"dropdown-menu",...d})}function xr({...d}){return Ze(De.Trigger,{"data-slot":"dropdown-menu-trigger",...d})}function Sr({className:d,sideOffset:u=4,align:h="end",...S}){return Ze(De.Portal,{children:Ze(De.Content,{align:h,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",d),"data-slot":"dropdown-menu-content",sideOffset:u,...S})})}function wr({className:d,...u}){return Ze(De.Item,{className:e("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",d),"data-slot":"dropdown-menu-item",...u})}import{Check as wn,ChevronDown as Pn}from"lucide-react";function it(){let{getViews:d,resources:u}=r((S)=>({getViews:S.getViews,resources:S.resources})),h=Boolean(u?.length);return d().filter((S)=>!h||S.supportsResources)}import{jsx as Me,jsxs as Nt}from"react/jsx-runtime";function Pr({className:d}){let{view:u,setView:h,t:S}=r((J)=>({view:J.view,setView:J.setView,t:J.t})),N=it(),F=N.find((J)=>J.name===u),K=F?S(F.label??F.name):"",j=F?.icon;return Nt(Er,{children:[Me(xr,{asChild:!0,className:d,children:Nt(n,{size:"default",variant:"outline",children:[j&&Me(j,{className:"size-4"}),Me("span",{children:K}),Me(Pn,{className:"size-4 opacity-50"})]})}),Me(Sr,{align:"end",className:"min-w-40",children:N.map((J)=>{let re=J.icon;return Nt(wr,{onSelect:()=>h(J.name),children:[Me(re,{className:"size-4"}),Me("span",{className:"flex-1",children:S(J.label??J.name)}),J.name===u&&Me(wn,{className:"size-4"})]},J.name)})})]})}import*as st from"@radix-ui/react-toggle-group";import{cva as Nn}from"class-variance-authority";import{createContext as Tn,useContext as Rn}from"react";import{jsx as Tt}from"react/jsx-runtime";var kn=Nn("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors outline-none hover:bg-muted hover:text-muted-foreground focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer select-none",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-2.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Nr=Tn({size:"default",variant:"default"});function Tr({className:d,variant:u,size:h,children:S,...N}){return Tt(st.Root,{className:e("flex items-center justify-center gap-1",d),"data-slot":"toggle-group",...N,children:Tt(Nr.Provider,{value:{variant:u,size:h},children:S})})}function Rr({className:d,children:u,variant:h,size:S,...N}){let F=Rn(Nr);return Tt(st.Item,{className:e(kn({variant:F.variant||h,size:F.size||S}),d),"data-slot":"toggle-group-item",...N,children:u})}import{jsx as kr}from"react/jsx-runtime";function Mr({className:d}){let{view:u,setView:h,t:S}=r((F)=>({view:F.view,setView:F.setView,t:F.t})),N=it();return kr(Tr,{className:e("bg-muted gap-0 rounded-lg p-0.75",d),onValueChange:(F)=>F&&h(F),size:"sm",type:"single",value:u,children:N.map((F)=>kr(Rr,{className:"text-muted-foreground data-[state=on]:bg-background data-[state=on]:text-foreground rounded-md px-3 font-medium data-[state=on]:shadow-sm",value:F.name,children:S(F.label??F.name)},F.name))})}import{jsx as ge,jsxs as Ge}from"react/jsx-runtime";var Hr=({className:d=""})=>{let{nextPeriod:u,prevPeriod:h,today:S,openEventForm:N,headerComponent:F,headerClassName:K,t:j,hideExportButton:J}=r((ee)=>({nextPeriod:ee.nextPeriod,prevPeriod:ee.prevPeriod,today:ee.today,openEventForm:ee.openEventForm,headerComponent:ee.headerComponent,headerClassName:ee.headerClassName,t:ee.t,hideExportButton:ee.hideExportButton})),re=br();if(F)return F;return ge("div",{className:e("@container/base-header w-full",K),"data-testid":"calendar-header",children:Ge("div",{className:e("flex flex-col items-center gap-2 @lg/base-header:flex-row @lg/base-header:justify-between",d),children:[Ge("div",{className:"flex min-w-0 items-center gap-2",children:[Ge("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[ge(n,{"aria-label":j("previous"),className:"h-full",onClick:h,size:"icon",variant:"ghost",children:ge(Mn,{className:"size-4"})}),ge(n,{"aria-label":j("next"),className:"h-full",onClick:u,size:"icon",variant:"ghost",children:ge(Hn,{className:"size-4"})})]}),ge(n,{onClick:S,size:"default",variant:"outline",children:j("today")}),ge(hr,{})]}),Ge("div",{className:"flex items-center gap-2",children:[ge(Mr,{className:"hidden @3xl/base-header:flex"}),ge(Pr,{className:"@3xl/base-header:hidden"}),!J&&Ge(n,{"aria-label":j("export"),onClick:re,size:"default",variant:"outline",children:[ge(Vn,{className:"size-4"}),ge("span",{className:"hidden @2xl/base-header:inline",children:j("export")})]}),Ge(n,{"aria-label":j("new"),onClick:()=>N(),size:"default",children:[ge(In,{className:"size-4"}),ge("span",{className:"hidden @2xl/base-header:inline",children:j("new")})]})]})]})})};import{useMemo as Ur}from"react";import{useRef as $n}from"react";import{useEffect as On,useRef as An}from"react";var Fn=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,zn="[data-hour]",Gn=(d)=>{let h=Fn.exec(d)?.at(1);if(!h)return null;let S=Number.parseInt(h,10);return S>=0&&S<=23?S:null},Rt=(d)=>Number.parseInt(d.getAttribute("data-hour")??"",10),Bn=(d,u)=>{let h=d.at(0),S=d.at(-1);if(!h||!S)return null;if(u<=Rt(h))return h;if(u>=Rt(S))return S;return d.find((N)=>Rt(N)===u)??null},Ln=(d,u,h,S)=>{let N=u.getBoundingClientRect(),F=h.getBoundingClientRect();if(S==="horizontal"){d.scrollTo({left:N.left-F.left,behavior:"auto"});return}d.scrollTo({top:N.top-F.top,behavior:"auto"})},lt=({viewportRef:d,scrollTime:u,enabled:h,scrollKey:S,axis:N="vertical"})=>{let F=An(null);On(()=>{if(!h||!u)return;if(F.current===S)return;let K=Gn(u);if(K===null)return;let j=d.current;if(!j)return;let J=Array.from(j.querySelectorAll(zn)),re=J.at(0),ee=Bn(J,K);if(!re||!ee)return;Ln(j,ee,re,N),F.current=S},[h,u,S,d,N])};import{memo as Yn}from"react";import{jsx as jn}from"react/jsx-runtime";var _n=({children:d,className:u})=>{let{stickyViewHeader:h,viewHeaderClassName:S}=r((N)=>({stickyViewHeader:N.stickyViewHeader,viewHeaderClassName:N.viewHeaderClassName}));return jn("div",{className:e("flex h-12 w-fit",h&&"sticky top-0 z-21 bg-background",u,S),"data-testid":"horizontal-grid-header",children:d})},Vr=Yn(_n);import{jsx as Be,jsxs as Ir}from"react/jsx-runtime";var Or=({rows:d,children:u,classes:h,allDay:S,gridType:N,variant:F="resource",dayNumberHeight:K})=>{let{currentDate:j,view:J,scrollTime:re}=r(),ee=$n(null),te=F==="resource",oe=!te;lt({viewportRef:ee,scrollTime:re,enabled:N==="hour"&&te,scrollKey:`${J}-${j.format("YYYY-MM-DD")}`,axis:"horizontal"});let se=u&&Be(Vr,{className:h?.header,children:u});return Ir("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",children:[oe&&se,Ir(c,{className:e("h-full",oe&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:ee},children:[te&&se,Be("div",{className:e("flex flex-1 w-fit",h?.body),"data-testid":"horizontal-grid-body",children:Be("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:d.map((de)=>Be(W,{allDay:de.allDay??S,dayNumberHeight:K,gridType:N,variant:F,...de},de.id))},j.format("YYYY-MM"))}),Be(f,{className:"z-30"}),Be(f,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as ia}from"react";import{memo as ea}from"react";import{memo as Xn}from"react";import{useMemo as zr}from"react";var Un=(d)=>{let u=[],h=[],S=null;for(let N of d){if(S&&N.start.isSameOrAfter(S)){if(h.length>0)u.push(h);h=[]}h.push(N),S=S?t.max(S,N.end):N.end}if(h.length>0)u.push(h);return u},Ar=(d,{gridStart:u,totalUnits:h,gridType:S,isDiscrete:N})=>{let F=d.start.diff(u,S,!0),K=d.end.diff(u,S,!0);if(N){if(F=Math.floor(F),K=Math.ceil(K),K<=F)K=F+1}let j=F<0,J=K>h;if(j)F=0;if(J)K=h;let re=Math.max(0,K-F);if(re===0)return null;return{top:F/h*100,height:re/h*100,isTruncatedStart:j,isTruncatedEnd:J}},Wn={2:25,3:50,4:60},Kn=70,Zn=(d)=>Wn[d]??Kn,qn=(d,u)=>{let h=d.length===1?d.at(0):void 0;if(h){let j=Ar(h,u);if(!j)return[];return[{kind:"vertical",event:h,left:0,width:100,...j}]}let S=[...d].sort((j,J)=>{let re=J.end.diff(J.start,"minute")-j.end.diff(j.start,"minute");return re!==0?re:j.start.diff(J.start)}),N=S.length,F=N>1?Zn(N)/(N-1):0,K=[];for(let j=0;j<N;j++){let J=S.at(j);if(!J)continue;let re=Ar(J,u);if(!re)continue;let ee=j===0?0:F*j;K.push({kind:"vertical",event:J,...re,left:ee,width:100-ee,zIndex:j+1})}return K},Fr=({days:d,gridType:u="hour",events:h})=>{let S=h.filter((F)=>!F.allDay).toSorted((F,K)=>F.start.diff(K.start));if(S.length===0)return[];let N={gridStart:d.at(0)||t(),totalUnits:d.length,gridType:u,isDiscrete:u==="day"};return Un(S).flatMap((F)=>qn(F,N))};var Gr=({days:d,gridType:u,resourceId:h})=>{let{getEventsForDateRange:S}=r(),N=d.at(0),F=d.at(-1),K=N?.startOf("day"),j=F?.endOf("day"),J=zr(()=>{if(!K||!j)return[];let ee=S(K,j);if(h)ee=E(ee,h);return ee.filter((te)=>!te.allDay)},[K,j,S,h]);return zr(()=>Fr({days:d,events:J,gridType:u}),[d,u,J])};import{jsx as kt,jsxs as Jn}from"react/jsx-runtime";var Qn=({days:d,gridType:u="hour",resourceId:h,resource:S,"data-testid":N})=>{let{resources:F}=r((te)=>({resources:te.resources})),K=Gr({days:d,gridType:u,resourceId:h}),j=d.at(0),J=d.at(-1)?.add(1,u),re=!h||F?.at(0)?.id===h,ee=u==="hour"&&Boolean(j&&J);return Jn("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":N,children:[ee&&j&&J&&kt(G,{rangeEnd:J,rangeStart:j,resource:S,withDot:re}),K.map((te,oe)=>{let{event:ie}=te,se=`event-${ie.id}-${oe}-${d.at(0)?.toISOString()}-${h??"no-resource"}`,de=ie.end.diff(ie.start,"minute")<=15;return kt("div",{className:"absolute",style:{left:`${te.left}%`,width:`calc(${te.width}% - var(--spacing) * 2)`,top:`${te.top}%`,height:`${te.height}%`},children:kt(k,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":de}),elementId:se,event:ie,isTruncatedEnd:te.isTruncatedEnd,isTruncatedStart:te.isTruncatedStart,sourceResourceId:h})},o.listKey(se,"wrapper"))})]})},Br=Xn(Qn);import{jsx as Le,jsxs as ra}from"react/jsx-runtime";var ta=({id:d,days:u,resource:h,"data-testid":S,gridType:N,className:F,renderCell:K,noEvents:j,slotDurationMinutes:J=60})=>{let re=h?.id,ee=Math.floor(60/J),te=Array.from({length:ee},(ie,se)=>se*J),oe=te.length>1;return Le("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",F),"data-testid":S||o.container.vertical.col(d),children:ra("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${u.length}, minmax(0, 1fr))`},children:[u.map((ie,se)=>{let de=ie.format("HH");if(K){let ae=d===o.col.time,ue=ae?o.cell.verticalTime(de):o.cell.vertical(ie,de,"00",re);return Le("div",{className:"min-h-[60px] bg-background","data-hour":ae?de:void 0,"data-testid":ue,children:K(ie)},o.listKey(d,se,de))}return Le("div",{className:"flex flex-col min-h-[60px]",children:te.map((ae,ue)=>{let le=String(ae).padStart(2,"0"),pe=o.cell.vertical(ie,de,le,re),ce=oe&&ue<te.length-1;return Le(H,{className:e("hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",ce&&"border-b border-dashed"),"data-testid":pe,day:oe?ie.minute(ae):ie,gridType:N,hour:N==="hour"?ie.hour():void 0,minute:oe?ae:void 0,resourceId:re,shouldRenderEvents:!1,slotDurationMinutes:J},o.listKey(d,se,le))})},o.listKey(d,se,de))}),!j&&Le("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Le(Br,{"data-testid":o.container.eventsLayer("vertical",d),days:u,gridType:N,resource:h,resourceId:re})})]})})},Lr=ea(ta);import{memo as oa}from"react";import{jsx as Yr,jsxs as aa}from"react/jsx-runtime";var na=({children:d,classes:u,allDayRow:h,expandAllDayRow:S=!1})=>{let{stickyViewHeader:N,viewHeaderClassName:F}=r((j)=>({stickyViewHeader:j.stickyViewHeader,viewHeaderClassName:j.viewHeaderClassName})),K="min-w-full w-fit";return aa("div",{className:e(S&&"flex h-full flex-col",N&&"sticky top-0 z-21 bg-background",F),children:[Yr("div",{className:e("min-h-12 border-b","min-w-full w-fit",u?.header),"data-testid":"vertical-grid-header",children:d}),h&&Yr("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",S&&"flex-1 overflow-hidden",u?.allDay),"data-testid":"vertical-grid-all-day",children:h})]})},_r=oa(na);import{jsx as Ye,jsxs as jr}from"react/jsx-runtime";var $r=({columns:d,children:u,gridType:h="day",variant:S="resource",classes:N,allDayRow:F,slotDurationMinutes:K,style:j})=>{let J=S==="resource",re=!J,ee=d.every((ue)=>!ue.days?.length),{currentDate:te,view:oe,scrollTime:ie}=r(),se=ia(null);lt({viewportRef:se,scrollTime:ie,enabled:h==="hour"&&!ee,scrollKey:`${oe}-${te.format("YYYY-MM-DD")}`});let ae=u&&Ye(_r,{allDayRow:F,classes:{header:N?.header,allDay:N?.allDay},expandAllDayRow:ee,children:u});if(ee&&ae)return Ye("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:j,children:ae});return jr("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:j,children:[re&&ae,jr(c,{className:e("h-full",re&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:se},children:[J&&ae,Ye("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",N?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:d.map((ue,le)=>Ye(Lr,{...ue,gridType:h,slotDurationMinutes:K},o.listKey(ue.id,le)))}),Ye(f,{className:"z-30"})," ",Ye(f,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Oe}from"react/jsx-runtime";var sa=(d,u)=>u==="vertical",la=({specs:d,header:u,composesResourceAxis:h,variant:S})=>{let{slotDuration:N}=r((oe)=>({slotDuration:oe.slotDuration})),F=d.some((oe)=>oe.gridType==="hour")?"hour":"day",K=d.filter((oe)=>!oe.noEvents).map((oe)=>oe.day).filter((oe)=>Boolean(oe)),j=d.find((oe)=>oe.noEvents),re=Boolean(j?.className?.includes(T))?{cell:"flex-1 min-w-0",spacer:T}:void 0,ee;if(F==="hour")ee=h?Oe(X,{columns:d}):Oe(U,{classes:re,days:K});return Oe($r,{allDayRow:ee,classes:h?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:d,gridType:F,slotDurationMinutes:N,variant:S,children:u})},da=({specs:d,header:u,composesResourceAxis:h,variant:S})=>{let N=d.some((j)=>j.columns?.some((J)=>J.gridType==="hour"))?"hour":"day",F=d.some((j)=>j.columns?.some((J)=>J.days)),K=h?{header:e(F&&q,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return Oe(Or,{classes:K,dayNumberHeight:h?0:void 0,gridType:N,rows:d,variant:S,children:u})},Wr=({view:d})=>{let{currentDate:u,firstDayOfWeek:h,hiddenDays:S,businessHours:N,hideNonBusinessHours:F,resources:K,orientation:j,weekViewGranularity:J}=r((ae)=>({currentDate:ae.currentDate,firstDayOfWeek:ae.firstDayOfWeek,hiddenDays:ae.hiddenDays,businessHours:ae.businessHours,hideNonBusinessHours:ae.hideNonBusinessHours,resources:ae.resources,orientation:ae.orientation,weekViewGranularity:ae.weekViewGranularity})),re=Ur(()=>({firstDayOfWeek:h,hiddenDays:S,businessHours:N,hideNonBusinessHours:F,resources:K,orientation:j,weekViewGranularity:J}),[h,S,N,F,K,j,J]),ee=Ur(()=>d.columns?.(u,re),[d,u,re]);if(!ee||!d.layout){let ae=d.component;if(ae)return Oe(ae,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${d.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let oe=Boolean(K?.length)&&Boolean(d.supportsResources),ie=oe?j??"horizontal":d.layout,se=oe?"resource":"regular",de=d.renderHeader?.({date:u,config:re});if(sa(ee,ie))return Oe(la,{composesResourceAxis:oe,header:de,specs:ee,variant:se});return Oe(da,{composesResourceAxis:oe,header:de,specs:ee,variant:se})};var Kr=(d)=>{if(!d||d.length===0)return;return new Set(d.map((u)=>P[u]))};function Zr(d){if(!d?.length)return[];return d.map((u)=>({...u,start:t(u.start),end:t(u.end)}))}import{jsx as He,jsxs as pa}from"react/jsx-runtime";var ua=()=>{let{view:d,getViews:u}=r((N)=>({view:N.view,getViews:N.getViews})),h=u().find((N)=>N.name===d);return pa("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[He(Hr,{className:"p-1 shrink-0 mb-1"}),He(Xt,{children:He(i,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:d,children:He("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:h?He(Wr,{view:h},d):null})})}),He(pr,{})]})},Mt=({events:d,firstDayOfWeek:u="sunday",initialView:h="month",initialDate:S,eventSpacing:N=z,eventHeight:F=B,stickyViewHeader:K=!0,viewHeaderClassName:j="",timeFormat:J="12-hour",hideNonBusinessHours:re=!1,hiddenDays:ee,resources:te,orientation:oe,...ie})=>{let se=Boolean(te?.length),de=ma(()=>Zr(d),[d]);return ca(()=>{if(typeof process<"u"&&!1)console.warn("[@ilamy/calendar] `orientation` was provided without `resources` — it only applies when the calendar has resources, so it is ignored.")},[oe,se]),He(M,{eventHeight:F,eventSpacing:N,events:de,firstDayOfWeek:P[u],hiddenDays:Kr(ee),hideNonBusinessHours:re,initialDate:S,initialView:h,orientation:oe,resources:te,stickyViewHeader:K,timeFormat:J,viewHeaderClassName:j,...ie,children:He(ua,{})})};import{jsx as ga}from"react/jsx-runtime";var fa=(d)=>ga(Mt,{...d});export{Mt as IlamyCalendar,fa as IlamyResourceCalendar,Lt as SLOT_EVENT_FORM,Yt as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,Y as defaultTranslations,Q as useIlamyCalendarContext};
@@ -350,4 +350,4 @@ interface AgendaViewOptions {
350
350
  declare const createAgendaView: ({ window }?: AgendaViewOptions) => PluginView;
351
351
  /** Opt-in agenda plugin: registers the `agenda` view. Pass to `IlamyCalendar`'s `plugins`. */
352
352
  declare const agendaPlugin: (options?: AgendaViewOptions) => IlamyPlugin;
353
- export { createAgendaView, agendaPlugin, AgendaWindow, AgendaViewOptions };
353
+ export { AgendaViewOptions, AgendaWindow, agendaPlugin, createAgendaView };
@@ -1 +1 @@
1
- import{I as s,K as J}from"../shared/chunk-6g0xvnsf.js";import{L as $}from"../shared/chunk-7vqv0k0j.js";import{List as w}from"lucide-react";import{createElement as y}from"react";import{useIlamyCalendarContext as d}from"@ilamy/calendar";import*as b from"@radix-ui/react-scroll-area";import{jsx as z,jsxs as S}from"react/jsx-runtime";function V({className:l,children:r,viewPortProps:c,...f}){return S(b.Root,{className:s("relative",l),"data-slot":"scroll-area",...f,children:[z(b.Viewport,{...c,className:s("focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",c?.className),"data-slot":"scroll-area-viewport",children:r}),z(k,{}),z(b.Corner,{})]})}function k({className:l,orientation:r="vertical",...c}){return z(b.ScrollAreaScrollbar,{className:s("flex touch-none p-px transition-colors select-none",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",l),"data-slot":"scroll-area-scrollbar",orientation:r,...c,children:z(b.ScrollAreaThumb,{className:"bg-border relative flex-1 rounded-full","data-slot":"scroll-area-thumb"})})}var R={day:(l)=>({start:l.startOf("day"),end:l.endOf("day")}),week:(l,r)=>{let c=(l.day()-r+7)%7,f=l.subtract(c,"day").startOf("day");return{start:f,end:f.add(6,"day").endOf("day")}},month:(l)=>({start:l.startOf("month"),end:l.endOf("month")})},u={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},q=(l,r,c=0)=>{if(typeof r==="number")return{start:l.startOf("day"),end:l.add(r-1,"day").endOf("day")};return R[r](l,c)},Y=(l)=>{if(typeof l==="number")return{amount:l,unit:"day"};return u[l]};var I=(l,r,c)=>{if(l.allDay)return l.start.isSameOrBefore(c)&&l.end.isSameOrAfter(r);return l.start.isSameOrAfter(r)&&l.start.isSameOrBefore(c)},E=(l,r)=>{let c=l.allDay?0:1,f=r.allDay?0:1;if(c!==f)return c-f;return l.start.valueOf()-r.start.valueOf()},Z=(l,r)=>{let c=[],f=r.end.startOf("day"),m=r.start.startOf("day");while(m.isSameOrBefore(f)){let i=m.startOf("day"),h=m.endOf("day"),N=l.filter((x)=>I(x,i,h)).sort(E);if(N.length>0)c.push({key:m.format("YYYY-MM-DD"),date:i,events:N});m=m.add(1,"day")}return c};import{useIlamyCalendarContext as g}from"@ilamy/calendar";import{memo as C}from"react";import{jsx as P,jsxs as _,Fragment as j}from"react/jsx-runtime";var D=({rangeStart:l,rangeEnd:r,now:c,axis:f="vertical",render:m,withDot:i=!0})=>{let h=c??$(),N=h.valueOf();if(!(N>=l.valueOf()&&N<r.valueOf()))return null;let x=r.diff(l,"minute"),o=h.diff(l,"minute")/x*100;if(m)return P(j,{children:m({currentTime:h,rangeStart:l,rangeEnd:r,progress:o,axis:f})});if(f==="horizontal")return _("div",{className:"absolute top-0 bottom-0 z-50 flex -translate-x-1/2 flex-col items-center pointer-events-none","data-testid":"current-time-indicator",style:{left:`${o}%`},children:[i&&P("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),P("div",{className:"w-0.5 flex-1 bg-red-500"})]});return _("div",{className:"absolute right-0 left-0 z-50 flex -translate-y-1/2 items-center pointer-events-none","data-testid":"current-time-indicator",style:{top:`${o}%`},children:[i&&P("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),P("div",{className:"h-0.5 flex-1 bg-red-500"})]})},F=C(D);import{jsx as G,jsxs as p}from"react/jsx-runtime";var O=({today:l,dayNumber:r,weekday:c,className:f,"data-testid":m})=>{return p("div",{className:s("flex flex-col items-center",f),"data-testid":m,"data-today":l?"true":void 0,children:[c!=null&&G("div",{className:s("w-full truncate text-center text-xs text-muted-foreground",l&&"text-primary"),children:c}),G("div",{className:s("flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-medium",l&&"bg-primary text-primary-foreground"),children:r})]})};import{useIlamyCalendarContext as v}from"@ilamy/calendar";import{jsx as H,jsxs as a}from"react/jsx-runtime";var t=(l)=>l==="24-hour"?"HH:mm":"h:mm A",L=({event:l,day:r})=>{let{t:c,timeFormat:f,onEventClick:m}=v(),i=l.start.format(t(f)),h=l.allDay?c("allDay"):i,N=l.start.startOf("day"),x=l.end.startOf("day").diff(N,"day")+1,o=r.startOf("day").diff(N,"day")+1,W=Boolean(l.allDay)&&x>1,A=`(${c("day")} ${o}/${x})`,U=W?A:null;return a("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>m(l),type:"button",children:[H("span",{className:"text-muted-foreground w-20 shrink-0",children:h}),H("span",{className:s("size-3 shrink-0 rounded-full border",l.backgroundColor||"bg-blue-500",l.color),style:{backgroundColor:l.backgroundColor}}),H("span",{className:"truncate",children:l.title}),U&&H("span",{className:"text-muted-foreground shrink-0 text-xs",children:U})]})};import{jsx as Q,jsxs as M}from"react/jsx-runtime";var B=({group:l})=>{let{view:r,renderCurrentTimeIndicator:c}=g(),f=l.date.isSame($(),"day"),m;if(c)m=(i)=>c({...i,view:r});return M("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":J("agenda-day",l.key),children:[Q("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:Q(O,{className:"flex-col-reverse",dayNumber:l.date.format("D"),today:f,weekday:l.date.format("ddd")})}),M("div",{className:"relative flex flex-1 flex-col gap-1",children:[f&&Q(F,{rangeEnd:l.date.endOf("day"),rangeStart:l.date.startOf("day"),render:m}),l.events.map((i)=>Q(L,{day:l.date,event:i},J(l.key,i.id)))]})]})};import{jsx as X}from"react/jsx-runtime";var T=({window:l})=>{let{currentDate:r,getEventsForDateRange:c,t:f,firstDayOfWeek:m}=d(),i=q(r,l,m),h=c(i.start,i.end),N=Z(h,i);if(N.length===0)return X("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-sm","data-testid":"agenda-empty",children:f("agendaNoEvents")});return X(V,{className:"h-full","data-testid":"agenda-view",children:X("div",{className:"flex flex-col",children:N.map((x)=>X(B,{group:x},x.key))})})};var K=({window:l="month"}={})=>({name:"agenda",label:"agenda",icon:w,navigationStep:Y(l),range:(r,c)=>q(r,l,c.firstDayOfWeek),supportsResources:!1,component:()=>y(T,{window:l})});var n=(l={})=>({name:"agenda",views:[K(l)]});export{K as createAgendaView,n as agendaPlugin};
1
+ import{e,F,u,S}from"../shared/chunk-d7599sry.js";import{c,h,j}from"../shared/chunk-w4nsrq2y.js";import{t}from"../shared/chunk-4jynmg6d.js";import{List as M}from"lucide-react";import{createElement as H}from"react";import{useIlamyCalendarContext as Y}from"@ilamy/calendar";var P={day:(a)=>({start:a.startOf("day"),end:a.endOf("day")}),week:(a,n)=>{let r=(a.day()-n+7)%7,o=a.subtract(r,"day").startOf("day");return{start:o,end:o.add(6,"day").endOf("day")}},month:(a)=>({start:a.startOf("month"),end:a.endOf("month")})},W={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},l=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return P[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return W[a]};var V=(a,n,r)=>{if(a.allDay)return u(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},I=(a,n)=>{let r=a.allDay?0:1,o=n.allDay?0:1;if(r!==o)return r-o;return a.start.valueOf()-n.start.valueOf()},v=(a,n)=>{let r=[],o=n.end.startOf("day"),d=n.start.startOf("day");while(d.isSameOrBefore(o)){let s=d.startOf("day"),m=d.endOf("day"),i=a.filter((y)=>V(y,s,m)).sort(I);if(i.length>0)r.push({key:d.format("YYYY-MM-DD"),date:s,events:i});d=d.add(1,"day")}return r};import{useIlamyCalendarContext as L}from"@ilamy/calendar";import{useIlamyCalendarContext as T}from"@ilamy/calendar";import{jsx as p,jsxs as B}from"react/jsx-runtime";var G=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:d}=T(),s=a.start.format(G(o)),m=a.allDay?r("allDay"):s,i=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(i,"day")+1,R=n.startOf("day").diff(i,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return B("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>d(a),type:"button",children:[p("span",{className:"text-muted-foreground w-20 shrink-0",children:m}),p("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),p("span",{className:"truncate",children:a.title}),x&&p("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as f,jsxs as b}from"react/jsx-runtime";var k=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=L(),o=F(a.date,t()),d;if(r)d=(s)=>r({...s,view:n});return b("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":S("agenda-day",a.key),children:[f("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:f(h,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),b("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&f(j,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:d}),a.events.map((s)=>f(O,{day:a.date,event:s},S(a.key,s.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var C=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:d}=Y(),s=l(n,a,d),m=r(s.start,s.end),i=v(m,s);if(i.length===0)return g("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-sm","data-testid":"agenda-empty",children:o("agendaNoEvents")});return g(c,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:i.map((y)=>g(k,{group:y},y.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:M,navigationStep:A(a),range:(n,r)=>l(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>H(C,{window:a})});var z=(a={})=>({name:"agenda",views:[D(a)]});export{z as agendaPlugin,D as createAgendaView};
@@ -365,4 +365,4 @@ interface DragToCreateOptions {
365
365
  * scrolls). Pass to `IlamyCalendar`'s `plugins`.
366
366
  */
367
367
  declare const dragToCreatePlugin: (options?: DragToCreateOptions) => IlamyPlugin;
368
- export { dragToCreatePlugin, DragToCreateOptions };
368
+ export { DragToCreateOptions, dragToCreatePlugin };
@@ -1 +1 @@
1
- import{L as E}from"../shared/chunk-7vqv0k0j.js";import{useIlamyCalendarContext as s}from"@ilamy/calendar";import{useRef as o,useState as r}from"react";import{createPortal as t}from"react-dom";import{useEffect as c,useRef as C}from"react";var P=(J,q)=>{let Q=Math.min(J.top,q.top),H=Math.min(J.left,q.left),B=Math.max(J.left+J.width,q.left+q.width),V=Math.max(J.top+J.height,q.top+q.height);return{top:Q,left:H,width:B-H,height:V-Q}},y=(J,q)=>{let Q=Math.max(J.top,q.top),H=Math.max(J.left,q.left),B=Math.min(J.left+J.width,q.left+q.width),V=Math.min(J.top+J.height,q.top+q.height),I=B-H,Y=V-Q;if(I<=0||Y<=0)return null;return{top:Q,left:H,width:I,height:Y}},b=(J,q,Q)=>{let H=0,B=0;if(J.clientY<q.top+Q.edge)B=-Q.speed;else if(J.clientY>q.top+q.height-Q.edge)B=Q.speed;if(J.clientX<q.left+Q.edge)H=-Q.speed;else if(J.clientX>q.left+q.width-Q.edge)H=Q.speed;let V=Q.axis??"both";return{x:V==="y"?0:H,y:V==="x"?0:B}};var S=new Set(["auto","scroll","overlay"]),d=(J)=>{let q=getComputedStyle(J),Q=S.has(q.overflowY)&&J.scrollHeight>J.clientHeight,H=S.has(q.overflowX)&&J.scrollWidth>J.clientWidth;return Q||H},f=(J)=>{let q=J instanceof HTMLElement?J:null;while(q){if(d(q))return q;q=q.parentElement}return null};var F=(J,q,Q=2)=>Math.hypot(J,q)>=Q,R=(J,q)=>{let Q=J.allDay===q.allDay,H=J.resourceId===q.resourceId;return Q&&H},h=(J,q)=>{let Q=J.start.isAfter(q.start),H=Q?q:J,B=Q?J:q;return{start:H.start,end:B.end,allDay:H.allDay,resourceId:H.resourceId}};var i=400,a=10,n=40,l=5;function m(J){let q=C(J);q.current=J;let Q=C(null);c(()=>{let H=()=>{document.body.style.setProperty("user-select","none"),document.body.style.setProperty("-webkit-user-select","none")},B=()=>{document.body.style.removeProperty("user-select"),document.body.style.removeProperty("-webkit-user-select")},V=null,I=()=>{if(V!==null)clearTimeout(V),V=null},Y=null,G=null,X=null,j=()=>{if(X!==null)cancelAnimationFrame(X),X=null},A=()=>{X=null;let $=Q.current;if(!$?.active)return;if(!Y||!G)return;let K=b(G,Y.getBoundingClientRect(),{edge:n,speed:l,axis:q.current.scrollAxis});if(K.x===0&&K.y===0)return;Y.scrollBy({left:K.x,top:K.y,behavior:"instant"}),q.current.onMove(G,$.payload),X=requestAnimationFrame(A)},O=()=>{if(X===null)X=requestAnimationFrame(A)},D=($)=>{if(Q.current?.active)$.preventDefault()},W=($)=>{$.stopImmediatePropagation(),$.preventDefault(),window.removeEventListener("click",W,{capture:!0})},N=()=>{I(),j(),window.removeEventListener("touchmove",D),B(),Y=null,G=null,Q.current=null},Z=()=>{let $=Q.current!==null;if(N(),$)q.current.onCancel?.()},k=($)=>{if($.active=!0,I(),H(),window.getSelection()?.removeAllRanges(),$.pointerType==="touch")window.addEventListener("touchmove",D,{passive:!1});q.current.onStart?.($.payload)},M=($)=>{if($.button!==0||!$.isPrimary)return;let K=q.current.resolvePress($);if(K===null)return;I();let U={pointerId:$.pointerId,pointerType:$.pointerType,originX:$.clientX,originY:$.clientY,payload:K,active:!1};if(Q.current=U,Y=f($.target),$.pointerType==="touch"){let _=q.current.longPressMs??i;V=setTimeout(()=>{if(Q.current===U)k(U)},_)}},z=($,K)=>{let U=K.clientX-$.originX,_=K.clientY-$.originY;if($.pointerType==="touch"){let u=q.current.touchCancelSlopPx??a;if(F(U,_,u))Z();return!1}if(!F(U,_,q.current.thresholdPx))return!1;return k($),!0},T=($)=>{let K=Q.current;if(!K||$.pointerId!==K.pointerId)return;if(!K.active&&!z(K,$))return;G={clientX:$.clientX,clientY:$.clientY},q.current.onMove(G,K.payload),O()},x=($)=>{let K=Q.current;if(!K||$.pointerId!==K.pointerId)return;if(!K.active){N();return}window.addEventListener("click",W,{capture:!0});let{payload:U}=K;N(),q.current.onEnd(U)},w=($)=>{if($.key==="Escape")Z()};return document.addEventListener("pointerdown",M),window.addEventListener("pointermove",T),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",Z),window.addEventListener("blur",Z),window.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",M),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",Z),window.removeEventListener("blur",Z),window.removeEventListener("keydown",w),window.removeEventListener("click",W,{capture:!0}),window.removeEventListener("touchmove",D),I(),j(),B()}},[])}var L=(J,q)=>{let Q=J?.closest("[data-start]");if(!Q)return null;if(Q.dataset.disabled==="true")return null;let H=Q.dataset.start,B=Q.dataset.end;if(!H||!B)return null;let V=(I)=>q?E.utc(I).tz(q):E.utc(I).local();return{start:V(H),end:V(B),resourceId:Q.dataset.resourceId,allDay:Q.dataset.allDay==="true",element:Q}};import{jsx as p,jsxs as Jq,Fragment as qq}from"react/jsx-runtime";var v=(J,q)=>{let Q=P(J.element.getBoundingClientRect(),q.element.getBoundingClientRect()),H=J.element.closest("[data-calendar-scroll-content]");if(H instanceof HTMLElement){let I=H.getBoundingClientRect();return{rect:{top:Q.top-I.top,left:Q.left-I.left,width:Q.width,height:Q.height},content:H}}let B=J.element.closest("[data-calendar-viewport]");if(!B)return{rect:Q,content:null};let V=y(Q,B.getBoundingClientRect());if(!V)return null;return{rect:V,content:null}};function e({rect:J,content:q}){return t(p("div",{"aria-hidden":"true",className:`pointer-events-none ${q?"absolute z-15":"fixed z-50"} rounded-sm border border-primary bg-primary/20`,style:{top:J.top,left:J.left,width:J.width,height:J.height}}),q??document.body)}function g({children:J,options:q}){let{openEventForm:Q,resources:H,timezone:B,orientation:V}=s(),[I,Y]=r(null),G=o(null),A=H.length>0?V==="vertical"?"y":"x":"both",O=()=>{G.current=null,Y(null)},D=(W,N)=>{let Z=h(W,N),k=H.find((z)=>String(z.id)===Z.resourceId),M={start:Z.start,end:Z.end,resource:k,allDay:Z.allDay};if(q.onSelect)q.onSelect(M,Q);else Q({start:Z.start,end:Z.end,allDay:Z.allDay,resourceId:Z.resourceId})};return m({scrollAxis:A,resolvePress:(W)=>L(W.target,B),onStart:(W)=>{G.current=W,Y(v(W,W))},onMove:({clientX:W,clientY:N},Z)=>{let k=L(document.elementFromPoint(W,N),B);if(k&&R(Z,k))G.current=k;let M=G.current??Z;Y(v(Z,M))},onEnd:(W)=>{let N=G.current??W;D(W,N),O()},onCancel:O}),Jq(qq,{children:[J,I&&p(e,{...I})]})}import{jsx as $q}from"react/jsx-runtime";var Qq=(J={})=>({name:"drag-to-create",provider:({children:q})=>$q(g,{options:J,children:q})});export{Qq as dragToCreatePlugin};
1
+ import{t}from"../shared/chunk-4jynmg6d.js";import{useIlamyCalendarContext as V}from"@ilamy/calendar";import{useRef as J,useState as Q}from"react";import{createPortal as Z}from"react-dom";import{useEffect as U,useRef as H}from"react";var M=(n,e)=>{let o=Math.min(n.top,e.top),l=Math.min(n.left,e.left),i=Math.max(n.left+n.width,e.left+e.width),s=Math.max(n.top+n.height,e.top+e.height);return{top:o,left:l,width:i-l,height:s-o}},I=(n,e)=>{let o=Math.max(n.top,e.top),l=Math.max(n.left,e.left),i=Math.min(n.left+n.width,e.left+e.width),s=Math.min(n.top+n.height,e.top+e.height),u=i-l,m=s-o;if(u<=0||m<=0)return null;return{top:o,left:l,width:u,height:m}},A=(n,e,o)=>{let l=0,i=0;if(n.clientY<e.top+o.edge)i=-o.speed;else if(n.clientY>e.top+e.height-o.edge)i=o.speed;if(n.clientX<e.left+o.edge)l=-o.speed;else if(n.clientX>e.left+e.width-o.edge)l=o.speed;let s=o.axis??"both";return{x:s==="y"?0:l,y:s==="x"?0:i}};var O=new Set(["auto","scroll","overlay"]),j=(n)=>{let e=getComputedStyle(n),o=O.has(e.overflowY)&&n.scrollHeight>n.clientHeight,l=O.has(e.overflowX)&&n.scrollWidth>n.clientWidth;return o||l},X=(n)=>{let e=n instanceof HTMLElement?n:null;while(e){if(j(e))return e;e=e.parentElement}return null};var C=(n,e,o=2)=>Math.hypot(n,e)>=o,_=(n,e)=>{let o=n.allDay===e.allDay,l=n.resourceId===e.resourceId;return o&&l},k=(n,e)=>{let o=n.start.isAfter(e.start),l=o?e:n,i=o?n:e;return{start:l.start,end:i.end,allDay:l.allDay,resourceId:l.resourceId}};var z=400,W=10,q=40,K=5;function Y(n){let e=H(n);e.current=n;let o=H(null);U(()=>{let l=()=>{document.body.style.setProperty("user-select","none"),document.body.style.setProperty("-webkit-user-select","none")},i=()=>{document.body.style.removeProperty("user-select"),document.body.style.removeProperty("-webkit-user-select")},s=null,u=()=>{if(s!==null)clearTimeout(s),s=null},m=null,p=null,y=null,P=()=>{if(y!==null)cancelAnimationFrame(y),y=null},E=()=>{y=null;let r=o.current;if(!r?.active)return;if(!m||!p)return;let c=A(p,m.getBoundingClientRect(),{edge:q,speed:K,axis:e.current.scrollAxis});if(c.x===0&&c.y===0)return;m.scrollBy({left:c.x,top:c.y,behavior:"instant"}),e.current.onMove(p,r.payload),y=requestAnimationFrame(E)},R=()=>{if(y===null)y=requestAnimationFrame(E)},v=(r)=>{if(o.current?.active)r.preventDefault()},d=(r)=>{r.stopImmediatePropagation(),r.preventDefault(),window.removeEventListener("click",d,{capture:!0})},f=()=>{u(),P(),window.removeEventListener("touchmove",v),i(),m=null,p=null,o.current=null},a=()=>{let r=o.current!==null;if(f(),r)e.current.onCancel?.()},g=(r)=>{if(r.active=!0,u(),l(),window.getSelection()?.removeAllRanges(),r.pointerType==="touch")window.addEventListener("touchmove",v,{passive:!1});e.current.onStart?.(r.payload)},w=(r)=>{if(r.button!==0||!r.isPrimary)return;let c=e.current.resolvePress(r);if(c===null)return;u();let h={pointerId:r.pointerId,pointerType:r.pointerType,originX:r.clientX,originY:r.clientY,payload:c,active:!1};if(o.current=h,m=X(r.target),r.pointerType==="touch"){let T=e.current.longPressMs??z;s=setTimeout(()=>{if(o.current===h)g(h)},T)}},x=(r,c)=>{let h=c.clientX-r.originX,T=c.clientY-r.originY;if(r.pointerType==="touch"){let N=e.current.touchCancelSlopPx??W;if(C(h,T,N))a();return!1}if(!C(h,T,e.current.thresholdPx))return!1;return g(r),!0},S=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active&&!x(c,r))return;p={clientX:r.clientX,clientY:r.clientY},e.current.onMove(p,c.payload),R()},b=(r)=>{let c=o.current;if(!c||r.pointerId!==c.pointerId)return;if(!c.active){f();return}window.addEventListener("click",d,{capture:!0});let{payload:h}=c;f(),e.current.onEnd(h)},L=(r)=>{if(r.key==="Escape")a()};return document.addEventListener("pointerdown",w),window.addEventListener("pointermove",S),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",a),window.addEventListener("blur",a),window.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",w),window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",a),window.removeEventListener("blur",a),window.removeEventListener("keydown",L),window.removeEventListener("click",d,{capture:!0}),window.removeEventListener("touchmove",v),u(),P(),i()}},[])}var D=(n,e)=>{let o=n?.closest("[data-start]");if(!o)return null;if(o.dataset.disabled==="true")return null;let l=o.dataset.start,i=o.dataset.end;if(!l||!i)return null;let s=(u)=>e?t.utc(u).tz(e):t.utc(u).local();return{start:s(l),end:s(i),resourceId:o.dataset.resourceId,allDay:o.dataset.allDay==="true",element:o}};import{jsx as B,jsxs as ne,Fragment as te}from"react/jsx-runtime";var G=(n,e)=>{let o=M(n.element.getBoundingClientRect(),e.element.getBoundingClientRect()),l=n.element.closest("[data-calendar-scroll-content]");if(l instanceof HTMLElement){let u=l.getBoundingClientRect();return{rect:{top:o.top-u.top,left:o.left-u.left,width:o.width,height:o.height},content:l}}let i=n.element.closest("[data-calendar-viewport]");if(!i)return{rect:o,content:null};let s=I(o,i.getBoundingClientRect());if(!s)return null;return{rect:s,content:null}};function ee({rect:n,content:e}){return Z(B("div",{"aria-hidden":"true",className:`pointer-events-none ${e?"absolute z-15":"fixed z-50"} rounded-sm border border-primary bg-primary/20`,style:{top:n.top,left:n.left,width:n.width,height:n.height}}),e??document.body)}function F({children:n,options:e}){let{openEventForm:o,resources:l,timezone:i,orientation:s}=V(),[u,m]=Q(null),p=J(null),E=l.length>0?s==="vertical"?"y":"x":"both",R=()=>{p.current=null,m(null)},v=(d,f)=>{let a=k(d,f),g=l.find((x)=>String(x.id)===a.resourceId),w={start:a.start,end:a.end,resource:g,allDay:a.allDay};if(e.onSelect)e.onSelect(w,o);else o({start:a.start,end:a.end,allDay:a.allDay,resourceId:a.resourceId})};return Y({scrollAxis:E,resolvePress:(d)=>D(d.target,i),onStart:(d)=>{p.current=d,m(G(d,d))},onMove:({clientX:d,clientY:f},a)=>{let g=D(document.elementFromPoint(d,f),i);if(g&&_(a,g))p.current=g;let w=p.current??a;m(G(a,w))},onEnd:(d)=>{let f=p.current??d;v(d,f),R()},onCancel:R}),ne(te,{children:[n,u&&B(ee,{...u})]})}import{jsx as re}from"react/jsx-runtime";var oe=(n={})=>({name:"drag-to-create",provider:({children:e})=>re(F,{options:n,children:e})});export{oe as dragToCreatePlugin};
@@ -1,3 +1,40 @@
1
+ import { RRule, Weekday } from "rrule";
2
+ import { Options } from "rrule";
3
+ /**
4
+ * Re-rrule.js Options with practical TypeScript interface.
5
+ * Makes all properties optional except freq and dtstart (which are required by RFC 5545).
6
+ * This allows clean object creation without needing explicit null values.
7
+ *
8
+ * @see https://tools.ietf.org/html/rfc5545 - RFC 5545 iCalendar specification
9
+ * @see https://github.com/jakubroztocil/rrule - rrule.js library documentation
10
+ */
11
+ type RRuleOptions = {
12
+ /**
13
+ * The frequency of the event. Must be one of the following: DAILY, WEEKLY, MONTHLY, etc.
14
+ */
15
+ freq: Options["freq"];
16
+ /**
17
+ * The start date of the recurrence rule. This defines when the recurrence pattern begins.
18
+ * Required for proper RRULE functionality according to RFC 5545.
19
+ * @important Same as the event start date.
20
+ */
21
+ dtstart: Date;
22
+ } & Partial<Omit<Options, "freq" | "dtstart">>;
23
+ declare module "@ilamy/calendar" {
24
+ interface CalendarEvent {
25
+ rrule?: RRuleOptions;
26
+ recurrenceId?: string;
27
+ exdates?: string[];
28
+ }
29
+ }
30
+ /**
31
+ * Marker re-exported by the recurrence entry so the declaration bundler keeps
32
+ * this module — and therefore the `declare module '@ilamy/calendar'`
33
+ * augmentation above — in the emitted `index.d.ts`. A side-effect-only
34
+ * `import './augment'` is otherwise tree-shaken from the type bundle, which
35
+ * would strip `rrule`/`recurrenceId`/`exdates` from the public `CalendarEvent`.
36
+ */
37
+ type RecurrenceAugmentation = RRuleOptions;
1
38
  import { ComponentType, ReactNode as ReactNode2 } from "react";
2
39
  import { Dayjs as Dayjs2, ManipulateType as ManipulateType2 } from "dayjs";
3
40
  /**
@@ -327,43 +364,6 @@ interface IlamyPlugin {
327
364
  }
328
365
  import dayjs from "dayjs";
329
366
  type Dayjs3 = dayjs.Dayjs3;
330
- import { RRule, Weekday } from "rrule";
331
- import { Options } from "rrule";
332
- /**
333
- * Re-rrule.js Options with practical TypeScript interface.
334
- * Makes all properties optional except freq and dtstart (which are required by RFC 5545).
335
- * This allows clean object creation without needing explicit null values.
336
- *
337
- * @see https://tools.ietf.org/html/rfc5545 - RFC 5545 iCalendar specification
338
- * @see https://github.com/jakubroztocil/rrule - rrule.js library documentation
339
- */
340
- type RRuleOptions = {
341
- /**
342
- * The frequency of the event. Must be one of the following: DAILY, WEEKLY, MONTHLY, etc.
343
- */
344
- freq: Options["freq"];
345
- /**
346
- * The start date of the recurrence rule. This defines when the recurrence pattern begins.
347
- * Required for proper RRULE functionality according to RFC 5545.
348
- * @important Same as the event start date.
349
- */
350
- dtstart: Date;
351
- } & Partial<Omit<Options, "freq" | "dtstart">>;
352
- declare module "@ilamy/calendar" {
353
- interface CalendarEvent {
354
- rrule?: RRuleOptions;
355
- recurrenceId?: string;
356
- exdates?: string[];
357
- }
358
- }
359
- /**
360
- * Marker re-exported by the recurrence entry so the declaration bundler keeps
361
- * this module — and therefore the `declare module '@ilamy/calendar'`
362
- * augmentation above — in the emitted `index.d.ts`. A side-effect-only
363
- * `import './augment'` is otherwise tree-shaken from the type bundle, which
364
- * would strip `rrule`/`recurrenceId`/`exdates` from the public `CalendarEvent`.
365
- */
366
- type RecurrenceAugmentation = RRuleOptions;
367
367
  /**
368
368
  * Returns the recurrence-specific VEVENT property lines for an event: an
369
369
  * `RRULE:` line when the event has an rrule, an `EXDATE:` line when it has
@@ -384,4 +384,4 @@ interface GenerateRecurringEventsProps {
384
384
  }
385
385
  declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent2[];
386
386
  declare const isRecurringEvent: (event: CalendarEvent2) => boolean;
387
- export { recurrencePlugin, recurrenceICalProperties, isRecurringEvent, generateRecurringEvents, Weekday, RecurrenceAugmentation, RRuleOptions, RRule };
387
+ export { RRule, RRuleOptions, RecurrenceAugmentation, Weekday, generateRecurringEvents, isRecurringEvent, recurrenceICalProperties, recurrencePlugin };
@@ -1,2 +1,2 @@
1
- import{I as J,J as li,K as mo}from"../shared/chunk-6g0xvnsf.js";import{L as H}from"../shared/chunk-7vqv0k0j.js";import{RRule as af,Weekday as Sf}from"rrule";import{RRule as gi}from"rrule";var Ko=(o,i=!1)=>{if(i)return o.format("YYYYMMDD");return o.utc().format("YYYYMMDD[T]HHmmss[Z]")},ki=(o)=>{try{return new gi(o).toString().split(`
2
- `).find((l)=>l.startsWith("RRULE:"))||""}catch{return""}},ko=(o)=>{let i=[],l=o.rrule?ki(o.rrule):"";if(l)i.push(l);if(o.exdates?.length){let m=o.exdates.map((f)=>Ko(H(f),o.allDay)).join(",");i.push(`EXDATE:${m}`)}if(o.recurrenceId){let m=Ko(H(o.recurrenceId),o.allDay);i.push(`RECURRENCE-ID:${m}`)}return i};import"@ilamy/calendar";import{SLOT_EVENT_FORM as Hl,SLOT_EVENT_MUTATION_SCOPE as Xl}from"@ilamy/calendar";import{useIlamyCalendarContext as _i}from"@ilamy/calendar";import{Slot as Gi}from"@radix-ui/react-slot";import{cva as Ji}from"class-variance-authority";import{jsx as Zi}from"react/jsx-runtime";var $i=Ji("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Go({className:o,variant:i,size:l,asChild:m=!1,...f}){return Zi(m?Gi:"button",{className:J($i({variant:i,size:l,className:o})),"data-slot":"button",...f})}import*as Y from"@radix-ui/react-dialog";import{XIcon as Hi}from"lucide-react";import{jsx as W,jsxs as Jo}from"react/jsx-runtime";function Yo({...o}){return W(Y.Root,{"data-slot":"dialog",...o})}function Xi({...o}){return W(Y.Portal,{"data-slot":"dialog-portal",...o})}function Qi({className:o,...i}){return W(Y.Overlay,{className:J("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",o),"data-slot":"dialog-overlay",...i})}function Bo({className:o,children:i,...l}){return Jo(Xi,{"data-slot":"dialog-portal",children:[W(Qi,{}),Jo(Y.Content,{className:J("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg max-h-[90%]",o),"data-slot":"dialog-content",...l,children:[i,Jo(Y.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[W(Hi,{}),W("span",{className:"sr-only",children:"Close"})]})]})]})}function Wo({className:o,...i}){return W("div",{className:J("flex flex-col gap-2 text-center sm:text-left",o),"data-slot":"dialog-header",...i})}function bo({className:o,...i}){return W("div",{className:J("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",o),"data-slot":"dialog-footer",...i})}function ho({className:o,...i}){return W(Y.Title,{className:J("text-lg leading-none font-semibold",o),"data-slot":"dialog-title",...i})}function Lo({className:o,...i}){return W(Y.Description,{className:J("text-muted-foreground text-sm",o),"data-slot":"dialog-description",...i})}import{jsx as F,jsxs as v}from"react/jsx-runtime";var qi=[{scope:"this",title:"thisEvent",editKey:"onlyChangeThis",deleteKey:"onlyDeleteThis"},{scope:"following",title:"thisAndFollowingEvents",editKey:"changeThisAndFuture",deleteKey:"deleteThisAndFuture"},{scope:"all",title:"allEvents",editKey:"changeEntireSeries",deleteKey:"deleteEntireSeries"}];function Fo({isOpen:o,onClose:i,onConfirm:l,operationType:m,eventTitle:f}){let{t:N}=_i(),z=(k)=>{l(k),i()},c=m==="edit",g=N("deleteRecurringEvent"),G=N("deleteRecurringEventQuestion");if(c)g=N("editRecurringEvent"),G=N("editRecurringEventQuestion");return F(Yo,{onOpenChange:(k)=>{if(!k)i()},open:o,children:v(Bo,{className:"max-w-md",children:[v(Wo,{children:[F(ho,{children:g}),v(Lo,{children:['"',f,'" ',G]})]}),F("div",{className:"space-y-3",children:qi.map(({scope:k,title:Q,editKey:_,deleteKey:K})=>F(Go,{className:"w-full justify-start h-auto p-4",onClick:()=>z(k),variant:"outline",children:v("div",{className:"text-left",children:[F("div",{className:"font-medium",children:N(Q)}),F("div",{className:"text-sm text-muted-foreground",children:N(c?_:K)})]})},k))}),F(bo,{children:F(Go,{onClick:i,variant:"outline",children:N("cancel")})})]})})}import{useIlamyCalendarContext as vi}from"@ilamy/calendar";import{useState as ti}from"react";import{useIlamyCalendarContext as di}from"@ilamy/calendar";import{jsx as t}from"react/jsx-runtime";function Mo({className:o,...i}){return t("div",{className:J("text-card-foreground flex flex-col gap-1 rounded-xl border shadow-sm",o),"data-slot":"card",...i})}function Ao({className:o,...i}){return t("div",{className:J("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-4 pb-0 has-data-[slot=card-action]:grid-cols-[1fr_auto]",o),"data-slot":"card-header",...i})}function Co({className:o,...i}){return t("div",{className:J("leading-none font-semibold",o),"data-slot":"card-title",...i})}function Po({className:o,...i}){return t("div",{className:J("p-4 pt-0",o),"data-slot":"card-content",...i})}import*as e from"@radix-ui/react-checkbox";import{CheckIcon as Vi}from"lucide-react";import{jsx as Zo}from"react/jsx-runtime";function y({className:o,...i}){return Zo(e.Root,{className:J("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",o),"data-slot":"checkbox",...i,children:Zo(e.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:Zo(Vi,{className:"size-3.5"})})})}import{useEffect as Ei,useState as _o}from"react";import{RRule as no}from"rrule";import{createContext as wi,useContext as Ki}from"react";var To=wi(null),Uo=To.Provider,b=()=>{let o=Ki(To);if(!o)throw Error("useRecurrenceEditor must be used within a RecurrenceEditor");return o};import{RRule as q}from"rrule";var Yi=[q.SU,q.MO,q.TU,q.WE,q.TH,q.FR,q.SA],Bi=[q.MO,q.TU,q.WE,q.TH,q.FR],Wi=["first","second","third","fourth"],Do=(o)=>Yi.at(H(o).day())??q.SU,Io=(o)=>{let i=H(o);return i.add(7,"day").month()!==i.month()?-1:Math.ceil(i.date()/7)},bi={daily:()=>({freq:q.DAILY}),weekdays:()=>({freq:q.WEEKLY,byweekday:Bi}),weeklyOnDay:(o)=>({freq:q.WEEKLY,byweekday:[Do(o)]}),monthlyOnDay:(o)=>({freq:q.MONTHLY,bymonthday:H(o).date()}),monthlyOnWeekday:(o)=>({freq:q.MONTHLY,byweekday:[Do(o).nth(Io(o))]})},S=(o,i)=>{let l=bi[o];if(!l)return null;return{interval:1,dtstart:i,...l(i)}},yo=(o)=>{if(o==null)return"";return(Array.isArray(o)?o:[o]).map((l)=>typeof l==="object"?`${l.weekday}:${l.n??""}`:`${l}:`).sort().join(",")},hi=(o,i)=>{if(!i)return!1;let l=o.freq===i.freq,m=yo(o.byweekday)===yo(i.byweekday),f=(o.bymonthday??null)===(i.bymonthday??null);return l&&m&&f},Li=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday"],j=(o,i)=>{if(!o)return"once";if(Boolean(o.interval)&&o.interval!==1)return"customize";return Li.find((f)=>hi(o,S(f,i)))??"customize"},R=(o,i,l)=>{let m=H(i).format("dddd"),f=Io(i),N=f===-1?"last":Wi.at(f-1)??"last",z=l(N);return{daily:l("daily"),weekdays:l("everyWeekday"),weeklyOnDay:`${l("weeklyOn")} ${m}`,monthlyOnDay:`${l("monthlyOnDay")} ${H(i).date()}`,monthlyOnWeekday:`${l("monthlyOnThe")} ${z} ${m}`}[o]??l("customRecurrence")},I=(o)=>{if(Array.isArray(o))return o;return o?[o]:[]};import{useIlamyCalendarContext as Pi}from"@ilamy/calendar";import{jsx as Fi}from"react/jsx-runtime";function oo({className:o,type:i,...l}){return Fi("input",{className:J("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",o),"data-slot":"input",type:i,...l})}import*as po from"@radix-ui/react-label";import{jsx as Mi}from"react/jsx-runtime";function B({className:o,...i}){return Mi(po.Root,{className:J("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",o),"data-slot":"label",...i})}import{jsx as Ci}from"react/jsx-runtime";var Ai="YYYY-MM-DD",Oo=({date:o,onChange:i,className:l})=>{let m=o?H(o).format(Ai):"",f=(N)=>{let z=N.target.value;if(!z){i?.(void 0);return}let c=H(z);i?.(c.isValid()?c.toDate():void 0)};return Ci("input",{className:J("flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-shadow focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",l),onChange:f,type:"date",value:m})};import{jsx as C,jsxs as $o,Fragment as Di}from"react/jsx-runtime";var Ti=[{type:"never",id:"never",labelKey:"never"},{type:"count",id:"after",labelKey:"after"},{type:"until",id:"on",labelKey:"on"}],Ui=(o)=>Math.max(1,Number.parseInt(o,10)||1),xo=()=>{let{t:o}=Pi(),{opts:i,update:l,setEndType:m,setUntil:f}=b(),N="never";if(i?.until)N="until";else if(i?.count)N="count";let z=i?.count||1,c=i?.until??void 0;return $o("div",{children:[C(B,{className:"text-xs",children:o("ends")}),C("div",{className:"space-y-2 mt-1",children:Ti.map(({type:g,id:G,labelKey:k})=>{let Q=g==="count"&&N==="count",_=g==="until"&&N==="until";return $o("div",{className:"flex items-center space-x-2",children:[C(y,{checked:N===g,id:G,onCheckedChange:()=>m(g)}),C(B,{className:"text-xs",htmlFor:G,children:o(k)}),Q&&$o(Di,{children:[C(oo,{className:"h-6 w-16 text-xs","data-testid":"count-input",min:"1",onChange:(K)=>l({count:Ui(K.target.value)}),type:"number",value:z}),C("span",{className:"text-xs",children:o("occurrences")})]}),_&&C(Oo,{className:"h-6",date:c,onChange:f})]},g)})})]})};import{useIlamyCalendarContext as xi}from"@ilamy/calendar";import*as Z from"@radix-ui/react-select";import{CheckIcon as yi,ChevronDownIcon as ao,ChevronUpIcon as Ii}from"lucide-react";import{jsx as w,jsxs as Ho}from"react/jsx-runtime";function p({...o}){return w(Z.Root,{"data-slot":"select",...o})}function O({...o}){return w(Z.Value,{"data-slot":"select-value",...o})}function x({className:o,size:i="default",children:l,...m}){return Ho(Z.Trigger,{className:J("cursor-pointer border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o),"data-size":i,"data-slot":"select-trigger",...m,children:[l,w(Z.Icon,{asChild:!0,children:w(ao,{className:"size-4 opacity-50"})})]})}function a({className:o,children:i,position:l="popper",align:m="center",...f}){return w(Z.Portal,{children:Ho(Z.Content,{align:m,className:J("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",l==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),"data-slot":"select-content",position:l,...f,children:[w(pi,{}),w(Z.Viewport,{className:J("p-1",l==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1"),children:i}),w(Oi,{})]})})}function P({className:o,children:i,...l}){return Ho(Z.Item,{className:J("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",o),"data-slot":"select-item",...l,children:[w("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:w(Z.ItemIndicator,{children:w(yi,{className:"size-4"})})}),w(Z.ItemText,{children:i})]})}function pi({className:o,...i}){return w(Z.ScrollUpButton,{className:J("flex cursor-default items-center justify-center py-1",o),"data-slot":"select-scroll-up-button",...i,children:w(Ii,{className:"size-4"})})}function Oi({className:o,...i}){return w(Z.ScrollDownButton,{className:J("flex cursor-default items-center justify-center py-1",o),"data-slot":"select-scroll-down-button",...i,children:w(ao,{className:"size-4"})})}import{RRule as s}from"rrule";import{jsx as T,jsxs as io}from"react/jsx-runtime";var Xo={DAILY:s.DAILY,WEEKLY:s.WEEKLY,MONTHLY:s.MONTHLY,YEARLY:s.YEARLY},ai=Object.fromEntries(Object.entries(Xo).map(([o,i])=>[i,o])),Si=(o)=>Math.max(1,Number.parseInt(o,10)||1),So=()=>{let{t:o}=xi(),{opts:i,custom:l,update:m}=b();if(!l)return null;let f=ai[i?.freq??s.DAILY]||"DAILY",N=i?.interval||1;return io("div",{className:"grid grid-cols-2 gap-4",children:[io("div",{children:[T(B,{className:"text-xs",htmlFor:"frequency",children:o("frequency")}),io(p,{onValueChange:(z)=>m({freq:Xo[z]}),value:f,children:[T(x,{className:"h-8 w-full","data-testid":"frequency-select",id:"frequency",children:T(O,{})}),T(a,{children:Object.keys(Xo).map((z)=>T(P,{value:z,children:o(z.toLowerCase())},z))})]})]}),io("div",{children:[T(B,{className:"text-xs",htmlFor:"interval",children:o("every")}),T(oo,{className:"h-8",id:"interval",min:"1",onChange:(z)=>m({interval:Si(z.target.value)}),type:"number",value:N})]})]})};import{useIlamyCalendarContext as ji}from"@ilamy/calendar";import{RRule as Ri}from"rrule";import{jsx as u,jsxs as Qo}from"react/jsx-runtime";var jo=()=>{let{t:o}=ji(),{opts:i,custom:l,reference:m,setMonthlyMode:f}=b();if(!l||i?.freq!==Ri.MONTHLY)return null;let z=I(i?.byweekday).some((c)=>typeof c==="object"&&c.n!=null)?"weekday":"day";return Qo("div",{children:[u(B,{className:"text-xs",htmlFor:"monthly-mode",children:o("repeatOn")}),Qo(p,{onValueChange:(c)=>f(c),value:z,children:[u(x,{className:"h-8 w-full","data-testid":"monthly-mode-select",id:"monthly-mode",children:u(O,{})}),Qo(a,{children:[u(P,{value:"day",children:R("monthlyOnDay",m,o)}),u(P,{value:"weekday",children:R("monthlyOnWeekday",m,o)})]})]})]})};import{useIlamyCalendarContext as si}from"@ilamy/calendar";import{jsx as r,jsxs as Ro}from"react/jsx-runtime";var ui=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday","customize"],so=()=>{let{t:o}=si(),{opts:i,custom:l,reference:m,selectPreset:f}=b(),N=l?"customize":j(i,m);return Ro("div",{children:[r(B,{className:"text-xs",htmlFor:"recurrence-preset",children:o("repeats")}),Ro(p,{onValueChange:(z)=>f(z),value:N,children:[r(x,{className:"h-8 w-full","data-testid":"preset-select",id:"recurrence-preset",children:r(O,{})}),r(a,{children:ui.map((z)=>r(P,{value:z,children:R(z,m,o)},z))})]})]})};import{useIlamyCalendarContext as ri}from"@ilamy/calendar";import{RRule as M}from"rrule";import{jsx as lo,jsxs as ro}from"react/jsx-runtime";var uo=[M.SU,M.MO,M.TU,M.WE,M.TH,M.FR,M.SA],Eo=()=>{let{t:o,firstDayOfWeek:i}=ri(),{opts:l,custom:m,toggleDay:f}=b();if(!m||l?.freq!==M.WEEKLY)return null;let N=I(l?.byweekday),z=uo.map((g,G)=>({value:g,label:H().day(G).format("ddd")})),c=uo.map((g,G)=>z[(G+i)%7]);return ro("div",{children:[lo(B,{className:"text-xs",children:o("repeatOn")}),lo("div",{className:"flex flex-wrap gap-1 mt-1",children:c.map((g,G)=>ro("div",{className:"flex items-center space-x-1",children:[lo(y,{checked:N.includes(g.value),id:mo("day",G),onCheckedChange:()=>f(g.value)}),lo(B,{className:"text-xs cursor-pointer",htmlFor:mo("day",G),children:g.label})]},mo("weekday",G)))})]})};import{jsx as h,jsxs as fo}from"react/jsx-runtime";var ni=(o,i)=>{if(!o)return i("customRecurrence");try{let l=new no(o).toText();if(!(Boolean(l)&&!l.toLowerCase().includes("error")))return i("customRecurrence");return l.charAt(0).toUpperCase()+l.slice(1)}catch{return i("customRecurrence")}},vo=({value:o,onChange:i,referenceDate:l})=>{let{t:m}=di(),f=($)=>$?.dtstart??l??H().toDate(),[N,z]=_o(Boolean(o)),[c,g]=_o(()=>o||null),[G,k]=_o(()=>j(o??null,f(o??null))==="customize");Ei(()=>{if(z(Boolean(o)),o){g(o);let $=o.dtstart??l??H().toDate();k(j(o,$)==="customize")}},[o,l]);let Q=f(c),_=($)=>{if(!c)return;let X={...c,...$};g(X),i(N?X:null)},K=($)=>{if(z($),!$){i(null);return}if(c){i(c);return}let X={freq:no.DAILY,interval:1};g(X),k(!1),i(X)},co={opts:c,custom:G,reference:Q,update:_,selectPreset:($)=>{if($==="customize"){k(!0);return}k(!1);let X=S($,Q);if(!X)return;let D={...X,count:c?.count,until:c?.until};g(D),i(D)},toggleDay:($)=>{let X=I(c?.byweekday),n=X.includes($)?X.filter((ci)=>ci!==$):[...X,$];_({byweekday:n.length?n:void 0})},setMonthlyMode:($)=>{if($==="weekday"){let D=S("monthlyOnWeekday",Q);_({byweekday:D?.byweekday,bymonthday:void 0});return}let X=S("monthlyOnDay",Q);_({bymonthday:X?.bymonthday,byweekday:void 0})},setEndType:($)=>{let X={count:void 0,until:void 0};if($==="count")X.count=c?.count||1;if($==="until")X.until=c?.until||H().add(1,"month").endOf("day").toDate();_(X)},setUntil:($)=>{let X=$?H($).endOf("day").toDate():void 0;_({until:X})}},go=Boolean(N&&o);return h(Uo,{value:co,children:fo(Mo,{"data-testid":"recurrence-editor",children:[fo(Ao,{className:"pb-3",children:[fo("div",{className:"flex items-center space-x-2",children:[h(y,{checked:N,"data-testid":"toggle-recurrence",id:"recurring",onCheckedChange:K}),h(Co,{className:"text-sm",children:m("repeat")})]}),go&&h("p",{className:"text-xs text-muted-foreground",children:ni(o??null,m)})]}),N&&h(Po,{className:"pt-0",children:fo("div",{className:"space-y-4",children:[h(so,{}),h(So,{}),h(Eo,{}),h(jo,{}),h(xo,{})]})})]})})};import{jsx as ei}from"react/jsx-runtime";var to=({event:o,onChange:i})=>{let{rawEvents:l}=vi(),m=o.uid,f;if(m)f=l.find((g)=>{return(g.uid||`${g.id}@ilamy.calendar`)===m&&Boolean(g.rrule)});let[N,z]=ti(o.rrule??f?.rrule??null);return ei(vo,{onChange:(g)=>{if(!g){z(null),i({rrule:void 0});return}let G=g.dtstart??o.start?.toDate(),k=G?{...g,dtstart:G}:g;z(k),i({rrule:k})},referenceDate:o.start?.toDate(),value:N})};var qo=(o)=>{return Boolean(o.rrule||o.recurrenceId||o.uid)},V=(o)=>{return o.uid||`${o.id}@ilamy.calendar`},No=(o,i)=>{let l=V(i),m=o.findIndex((f)=>{let N=V(f)===l,z=Boolean(f.rrule)&&!f.recurrenceId;return N&&z});if(m===-1)throw Error("Base recurring event not found");return m},zo=(o)=>o.start.subtract(1,"day").endOf("day").toDate(),Vo=(o)=>o.recurrenceId??o.start.toISOString(),eo=(o,i)=>{let l=Vo(i),m=o.exdates||[],f=m.includes(l)?m:[...m,l];return{baseEvent:{...o,exdates:f},targetEventStartISO:l}};var ol=({targetEvent:o,updatedEvents:i,baseEventIndex:l,baseEvent:m})=>{let f=Vo(o),N=V(m),{baseEvent:z}=eo(m,o);i[l]=z;let c=(k)=>{let Q=Boolean(k.recurrenceId),_=V(k)===N,K=k.recurrenceId===f;return Q&&_&&K},g=i.find(c);return{events:i.filter((k)=>!c(k)),updated:g?[]:[z],added:[],deleted:g?[g]:[]}},il=({targetEvent:o,updatedEvents:i,baseEventIndex:l,baseEvent:m})=>{let f={...m,rrule:{...m.rrule,until:zo(o)}};return i[l]=f,{events:i,updated:[f],added:[],deleted:[]}},ll=({targetEvent:o,updatedEvents:i})=>{let l=V(o),m=i.filter((N)=>V(N)===l);return{events:i.filter((N)=>V(N)!==l),updated:[],added:[],deleted:m}},ml={this:ol,following:il,all:ll},oi=({targetEvent:o,currentEvents:i,scope:l})=>{let m=[...i],f=No(m,o),N=m[f],z=ml[l];if(!z)throw Error(`Invalid scope: ${l}. Must be 'this', 'following', or 'all'`);return z({targetEvent:o,updatedEvents:m,baseEventIndex:f,baseEvent:N})};import{RRule as fl}from"rrule";var d=(o)=>{return new Date(Date.UTC(o.year(),o.month(),o.date(),o.hour(),o.minute(),o.second(),o.millisecond()))},ii=(o,i)=>{return i.year(o.getUTCFullYear()).month(o.getUTCMonth()).date(o.getUTCDate()).hour(o.getUTCHours()).minute(o.getUTCMinutes()).second(o.getUTCSeconds()).millisecond(o.getUTCMilliseconds())};var wo=({event:o,currentEvents:i,startDate:l,endDate:m})=>{if(!o.rrule)return[];try{let f=d(o.start),N;if(o.rrule.until)N=d(H(o.rrule.until));let z={...o.rrule,dtstart:f,until:N},c=new fl(z),g=V(o),G=i.filter((L)=>{let U=Boolean(L.recurrenceId),A=V(L)===g;return U&&A}),k=o.end.diff(o.start),Q=d(l.subtract(k,"millisecond")),_=d(m);return c.between(Q,_,!0).map((L,U)=>{let A=ii(L,o.start),E=G.find((n)=>li(n.recurrenceId)?.isSame(A));if(E)return{...o,...E};let co=o.end.diff(o.start),go=A.add(co,"millisecond"),$=`${o.id}_${U}`,X=V(o);return{...o,id:$,start:A,end:go,uid:X,rrule:void 0}}).filter((L)=>{let U=L.start.toISOString();if(o.exdates?.includes(U)??!1)return!1;return L.start.isSameOrBefore(m)&&L.end.isSameOrAfter(l)})}catch(f){throw Error(`Invalid RRULE options: ${JSON.stringify(o.rrule)}. Error: ${f instanceof Error?f.message:"Unknown error"}`)}};var mi=(o,i)=>{let l=i.diff(i.startOf("day"),"millisecond");return o.startOf("day").add(l,"millisecond")},Nl=(o,i,l)=>{let m=o.end.diff(o.start),f=l.start||i.start,N=l.end||f.add(m),z=`${o.id}_following`,c=`${z}@ilamy.calendar`;return{...o,...l,rrule:{...o.rrule,...l.rrule,dtstart:f.toDate()},id:z,uid:c,start:f,end:N,recurrenceId:void 0}},zl=(o,i)=>{return(l)=>{let m=Boolean(l.recurrenceId)&&!l.rrule,f=V(l)===o,N=Boolean(l.recurrenceId)&&H(l.recurrenceId).isAfter(i);return m&&f&&N}},cl=(o,i)=>{let l=o.start;if(i.start)l=mi(o.start,i.start);let m=o.end;if(i.start&&i.end)m=l.add(i.end.diff(i.start),"millisecond");else if(i.start)m=l.add(o.end.diff(o.start),"millisecond");else if(i.end)m=mi(o.end,i.end);let f=i.rrule??o.rrule,N;if(f)N={...f,dtstart:l.toDate()};return{start:l,end:m,rrule:N}},gl=(o,i)=>{if(i&&o.recurrenceId)return o.recurrenceId;return o.start.toISOString()},kl=({updatedEvents:o,targetEvent:i,detachedOverride:l,updatedBaseEvent:m,baseChanged:f})=>{let N=o.findIndex((z)=>z.id===i.id);if(N===-1)throw Error("Detached override not found");return o[N]=l,{events:o,updated:f?[m,l]:[l],added:[],deleted:[]}},Gl=({targetEvent:o,updates:i,updatedEvents:l,baseEventIndex:m,baseEvent:f})=>{let N=V(f),z=Boolean(o.recurrenceId&&!o.rrule),c=gl(o,z),g=f.exdates||[],G=g.includes(c)?g:[...g,c],k=G!==g||f.uid!==N,Q={...f,exdates:G,uid:N};l[m]=Q;let _={...o,...i,recurrenceId:c,rrule:void 0,uid:N};if(z)return kl({updatedEvents:l,targetEvent:o,detachedOverride:_,updatedBaseEvent:Q,baseChanged:k});let K={..._,id:`${f.id}_modified_${Date.now()}`};return l.push(K),{events:l,updated:[Q],added:[K],deleted:[]}},Jl=({targetEvent:o,updates:i,updatedEvents:l,baseEventIndex:m,baseEvent:f})=>{let N=zo(o),z=V(f),c=zl(z,N),g=(f.exdates??[]).filter((K)=>!H(K).isAfter(N)),G={...f,exdates:g,rrule:{...f.rrule,until:N}};l[m]=G;let k=Nl(f,o,i);l.push(k);let Q=l.filter(c);return{events:l.filter((K)=>!c(K)),updated:[G],added:[k],deleted:Q}},Zl=({updates:o,updatedEvents:i,baseEventIndex:l,baseEvent:m})=>{let f=V(m),N=cl(m,o),z={...m,...o,start:N.start,end:N.end,rrule:N.rrule,exdates:void 0,uid:f};i[l]=z;let c=(k)=>{let Q=Boolean(k.recurrenceId)&&!k.rrule,_=V(k)===f;return Q&&_},g=i.filter((k)=>!c(k)),G=i.filter(c);return{events:g,updated:[z],added:[],deleted:G}},$l={this:Gl,following:Jl,all:Zl},fi=({targetEvent:o,updates:i,currentEvents:l,scope:m})=>{let f=[...l],N=No(f,o),z=f[N],c=$l[m];if(!c)throw Error(`Invalid scope: ${m}. Must be 'this', 'following', or 'all'`);return c({targetEvent:o,updates:i,updatedEvents:f,baseEventIndex:N,baseEvent:z})};import{jsx as Ni}from"react/jsx-runtime";var Ql=()=>({name:"recurrence",transformEvents:(o,i)=>o.flatMap((l)=>{if(!l.rrule)return[l];return wo({event:l,currentEvents:o,startDate:i.start,endDate:i.end})}),managesEvent:(o)=>qo(o),applyEdit:({event:o,updates:i,currentEvents:l,scope:m})=>fi({targetEvent:o,updates:i??{},currentEvents:l,scope:m}),applyDelete:({event:o,currentEvents:i,scope:l})=>oi({targetEvent:o,currentEvents:i,scope:l}),contribute:(o,i)=>{if(o!=="ical:vevent-properties")return[];return ko(i)},renderSlot:(o,i)=>{if(o===Hl){let{event:l,onChange:m}=i;return Ni(to,{event:l,onChange:m})}if(o===Xl){let{event:l,operation:m,resolve:f,cancel:N}=i;return Ni(Fo,{eventTitle:l.title||"",isOpen:!0,onClose:N,onConfirm:(z)=>f(z),operationType:m})}return null}});export{Ql as recurrencePlugin,ko as recurrenceICalProperties,qo as isRecurringEvent,wo as generateRecurringEvents,Sf as Weekday,af as RRule};
1
+ import{t}from"../shared/chunk-4jynmg6d.js";import{e,N,u,S}from"../shared/chunk-d7599sry.js";import{n,y,m,a,g,v,C,D,p}from"../shared/chunk-4yfcvykw.js";import{b,R,x,A,w,V}from"../shared/chunk-n7xt0j3a.js";import{RRule as Gn,Weekday as Jn}from"rrule";import{RRule as et}from"rrule";var Se=(r,o=!1)=>{if(o)return r.format("YYYYMMDD");return r.utc().format("YYYYMMDD[T]HHmmss[Z]")},tt=(r)=>{try{return new et(r).toString().split(`
2
+ `).find((s)=>s.startsWith("RRULE:"))||""}catch{return""}},me=(r)=>{let o=[],s=r.rrule?tt(r.rrule):"";if(s)o.push(s);if(r.exdates?.length){let i=r.exdates.map((l)=>Se(t(l),r.allDay)).join(",");o.push(`EXDATE:${i}`)}if(r.recurrenceId){let i=Se(t(r.recurrenceId),r.allDay);o.push(`RECURRENCE-ID:${i}`)}return o};import"@ilamy/calendar";import{SLOT_EVENT_FORM as jt,SLOT_EVENT_MUTATION_SCOPE as Vt}from"@ilamy/calendar";import{useIlamyCalendarContext as rt}from"@ilamy/calendar";import{jsx as B,jsxs as oe}from"react/jsx-runtime";var nt=[{scope:"this",title:"thisEvent",editKey:"onlyChangeThis",deleteKey:"onlyDeleteThis"},{scope:"following",title:"thisAndFollowingEvents",editKey:"changeThisAndFuture",deleteKey:"deleteThisAndFuture"},{scope:"all",title:"allEvents",editKey:"changeEntireSeries",deleteKey:"deleteEntireSeries"}];function De({isOpen:r,onClose:o,onConfirm:s,operationType:i,eventTitle:l}){let{t:c}=rt(),d=(h)=>{s(h),o()},f=i==="edit",E=c("deleteRecurringEvent"),O=c("deleteRecurringEventQuestion");if(f)E=c("editRecurringEvent"),O=c("editRecurringEventQuestion");return B(b,{onOpenChange:(h)=>{if(!h)o()},open:r,children:oe(R,{className:"max-w-md",children:[oe(x,{children:[B(w,{children:E}),oe(V,{children:['"',l,'" ',O]})]}),B("div",{className:"space-y-3",children:nt.map(({scope:h,title:k,editKey:M,deleteKey:F})=>B(n,{className:"w-full justify-start h-auto p-4",onClick:()=>d(h),variant:"outline",children:oe("div",{className:"text-left",children:[B("div",{className:"font-medium",children:c(k)}),B("div",{className:"text-sm text-muted-foreground",children:c(f?M:F)})]})},h))}),B(A,{children:B(n,{onClick:o,variant:"outline",children:c("cancel")})})]})})}import{useIlamyCalendarContext as Tt}from"@ilamy/calendar";import{useState as kt}from"react";import{useIlamyCalendarContext as Pt}from"@ilamy/calendar";import{jsx as ae}from"react/jsx-runtime";function xe({className:r,...o}){return ae("div",{className:e("text-card-foreground flex flex-col gap-1 rounded-xl border shadow-sm",r),"data-slot":"card",...o})}function Oe({className:r,...o}){return ae("div",{className:e("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-4 pb-0 has-data-[slot=card-action]:grid-cols-[1fr_auto]",r),"data-slot":"card-header",...o})}function Pe({className:r,...o}){return ae("div",{className:e("leading-none font-semibold",r),"data-slot":"card-title",...o})}function we({className:r,...o}){return ae("div",{className:e("p-4 pt-0",r),"data-slot":"card-content",...o})}import{useEffect as wt,useState as Re}from"react";import{RRule as $e}from"rrule";import{createContext as ot,useContext as at}from"react";var Ie=ot(null),Te=Ie.Provider,L=()=>{let r=at(Ie);if(!r)throw Error("useRecurrenceEditor must be used within a RecurrenceEditor");return r};import{RRule as U}from"rrule";var st=[U.SU,U.MO,U.TU,U.WE,U.TH,U.FR,U.SA],it=[U.MO,U.TU,U.WE,U.TH,U.FR],lt=["first","second","third","fourth"],ke=(r)=>st.at(t(r).day())??U.SU,Me=(r)=>{let o=t(r);return o.add(7,"day").month()!==o.month()?-1:Math.ceil(o.date()/7)},ct={daily:()=>({freq:U.DAILY}),weekdays:()=>({freq:U.WEEKLY,byweekday:it}),weeklyOnDay:(r)=>({freq:U.WEEKLY,byweekday:[ke(r)]}),monthlyOnDay:(r)=>({freq:U.MONTHLY,bymonthday:t(r).date()}),monthlyOnWeekday:(r)=>({freq:U.MONTHLY,byweekday:[ke(r).nth(Me(r))]})},G=(r,o)=>{let s=ct[r];if(!s)return null;return{interval:1,dtstart:o,...s(o)}},be=(r)=>{if(r==null)return"";return(Array.isArray(r)?r:[r]).map((s)=>typeof s==="object"?`${s.weekday}:${s.n??""}`:`${s}:`).sort().join(",")},dt=(r,o)=>{if(!o)return!1;let s=r.freq===o.freq,i=be(r.byweekday)===be(o.byweekday),l=(r.bymonthday??null)===(o.bymonthday??null);return s&&i&&l},ut=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday"],J=(r,o)=>{if(!r)return"once";if(Boolean(r.interval)&&r.interval!==1)return"customize";return ut.find((l)=>dt(r,G(l,o)))??"customize"},X=(r,o,s)=>{let i=t(o).format("dddd"),l=Me(o),c=l===-1?"last":lt.at(l-1)??"last",d=s(c);return{daily:s("daily"),weekdays:s("everyWeekday"),weeklyOnDay:`${s("weeklyOn")} ${i}`,monthlyOnDay:`${s("monthlyOnDay")} ${t(o).date()}`,monthlyOnWeekday:`${s("monthlyOnThe")} ${d} ${i}`}[r]??s("customRecurrence")},z=(r)=>{if(Array.isArray(r))return r;return r?[r]:[]};import{useIlamyCalendarContext as ft}from"@ilamy/calendar";import{jsx as pt}from"react/jsx-runtime";var mt="YYYY-MM-DD",Ne=({date:r,onChange:o,className:s})=>{let i=r?t(r).format(mt):"",l=(c)=>{let d=c.target.value;if(!d){o?.(void 0);return}let f=t(d);o?.(f.isValid()?f.toDate():void 0)};return pt("input",{className:e("flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none transition-shadow focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",s),onChange:l,type:"date",value:i})};import{jsx as K,jsxs as pe,Fragment as gt}from"react/jsx-runtime";var yt=[{type:"never",id:"never",labelKey:"never"},{type:"count",id:"after",labelKey:"after"},{type:"until",id:"on",labelKey:"on"}],Rt=(r)=>Math.max(1,Number.parseInt(r,10)||1),Ue=()=>{let{t:r}=ft(),{opts:o,update:s,setEndType:i,setUntil:l}=L(),c="never";if(o?.until)c="until";else if(o?.count)c="count";let d=o?.count||1,f=o?.until??void 0;return pe("div",{children:[K(a,{className:"text-xs",children:r("ends")}),K("div",{className:"space-y-2 mt-1",children:yt.map(({type:E,id:O,labelKey:h})=>{let k=E==="count"&&c==="count",M=E==="until"&&c==="until";return pe("div",{className:"flex items-center space-x-2",children:[K(y,{checked:c===E,id:O,onCheckedChange:()=>i(E)}),K(a,{className:"text-xs",htmlFor:O,children:r(h)}),k&&pe(gt,{children:[K(m,{className:"h-6 w-16 text-xs","data-testid":"count-input",min:"1",onChange:(F)=>s({count:Rt(F.target.value)}),type:"number",value:d}),K("span",{className:"text-xs",children:r("occurrences")})]}),M&&K(Ne,{className:"h-6",date:f,onChange:l})]},E)})})]})};import{useIlamyCalendarContext as Et}from"@ilamy/calendar";import{RRule as Z}from"rrule";import{jsx as j,jsxs as se}from"react/jsx-runtime";var fe={DAILY:Z.DAILY,WEEKLY:Z.WEEKLY,MONTHLY:Z.MONTHLY,YEARLY:Z.YEARLY},vt=Object.fromEntries(Object.entries(fe).map(([r,o])=>[o,r])),Ct=(r)=>Math.max(1,Number.parseInt(r,10)||1),Fe=()=>{let{t:r}=Et(),{opts:o,custom:s,update:i}=L();if(!s)return null;let l=vt[o?.freq??Z.DAILY]||"DAILY",c=o?.interval||1;return se("div",{className:"grid grid-cols-2 gap-4",children:[se("div",{children:[j(a,{className:"text-xs",htmlFor:"frequency",children:r("frequency")}),se(g,{onValueChange:(d)=>i({freq:fe[d]}),value:l,children:[j(C,{className:"h-8 w-full","data-testid":"frequency-select",id:"frequency",children:j(v,{})}),j(D,{children:Object.keys(fe).map((d)=>j(p,{value:d,children:r(d.toLowerCase())},d))})]})]}),se("div",{children:[j(a,{className:"text-xs",htmlFor:"interval",children:r("every")}),j(m,{className:"h-8",id:"interval",min:"1",onChange:(d)=>i({interval:Ct(d.target.value)}),type:"number",value:c})]})]})};import{useIlamyCalendarContext as ht}from"@ilamy/calendar";import{RRule as St}from"rrule";import{jsx as ee,jsxs as ye}from"react/jsx-runtime";var Le=()=>{let{t:r}=ht(),{opts:o,custom:s,reference:i,setMonthlyMode:l}=L();if(!s||o?.freq!==St.MONTHLY)return null;let d=z(o?.byweekday).some((f)=>typeof f==="object"&&f.n!=null)?"weekday":"day";return ye("div",{children:[ee(a,{className:"text-xs",htmlFor:"monthly-mode",children:r("repeatOn")}),ye(g,{onValueChange:(f)=>l(f),value:d,children:[ee(C,{className:"h-8 w-full","data-testid":"monthly-mode-select",id:"monthly-mode",children:ee(v,{})}),ye(D,{children:[ee(p,{value:"day",children:X("monthlyOnDay",i,r)}),ee(p,{value:"weekday",children:X("monthlyOnWeekday",i,r)})]})]})]})};import{useIlamyCalendarContext as Dt}from"@ilamy/calendar";import{jsx as te,jsxs as Ae}from"react/jsx-runtime";var xt=["daily","weekdays","weeklyOnDay","monthlyOnDay","monthlyOnWeekday","customize"],Ye=()=>{let{t:r}=Dt(),{opts:o,custom:s,reference:i,selectPreset:l}=L(),c=s?"customize":J(o,i);return Ae("div",{children:[te(a,{className:"text-xs",htmlFor:"recurrence-preset",children:r("repeats")}),Ae(g,{onValueChange:(d)=>l(d),value:c,children:[te(C,{className:"h-8 w-full","data-testid":"preset-select",id:"recurrence-preset",children:te(v,{})}),te(D,{children:xt.map((d)=>te(p,{value:d,children:X(d,i,r)},d))})]})]})};import{useIlamyCalendarContext as Ot}from"@ilamy/calendar";import{RRule as _}from"rrule";import{jsx as ie,jsxs as Be}from"react/jsx-runtime";var We=[_.SU,_.MO,_.TU,_.WE,_.TH,_.FR,_.SA],_e=()=>{let{t:r,firstDayOfWeek:o}=Ot(),{opts:s,custom:i,toggleDay:l}=L();if(!i||s?.freq!==_.WEEKLY)return null;let c=z(s?.byweekday),d=We.map((E,O)=>({value:E,label:t().day(O).format("ddd")})),f=We.map((E,O)=>d[(O+o)%7]);return Be("div",{children:[ie(a,{className:"text-xs",children:r("repeatOn")}),ie("div",{className:"flex flex-wrap gap-1 mt-1",children:f.map((E,O)=>Be("div",{className:"flex items-center space-x-1",children:[ie(y,{checked:c.includes(E.value),id:S("day",O),onCheckedChange:()=>l(E.value)}),ie(a,{className:"text-xs cursor-pointer",htmlFor:S("day",O),children:E.label})]},S("weekday",O)))})]})};import{jsx as Y,jsxs as le}from"react/jsx-runtime";var It=(r,o)=>{if(!r)return o("customRecurrence");try{let s=new $e(r).toText();if(!(Boolean(s)&&!s.toLowerCase().includes("error")))return o("customRecurrence");return s.charAt(0).toUpperCase()+s.slice(1)}catch{return o("customRecurrence")}},qe=({value:r,onChange:o,referenceDate:s})=>{let{t:i}=Pt(),l=(P)=>P?.dtstart??s??t().toDate(),[c,d]=Re(Boolean(r)),[f,E]=Re(()=>r||null),[O,h]=Re(()=>J(r??null,l(r??null))==="customize");wt(()=>{if(d(Boolean(r)),r){E(r);let P=r.dtstart??s??t().toDate();h(J(r,P)==="customize")}},[r,s]);let k=l(f),M=(P)=>{if(!f)return;let I={...f,...P};E(I),o(c?I:null)},F=(P)=>{if(d(P),!P){o(null);return}if(f){o(f);return}let I={freq:$e.DAILY,interval:1};E(I),h(!1),o(I)},ue={opts:f,custom:O,reference:k,update:M,selectPreset:(P)=>{if(P==="customize"){h(!0);return}h(!1);let I=G(P,k);if(!I)return;let H={...I,count:f?.count,until:f?.until};E(H),o(H)},toggleDay:(P)=>{let I=z(f?.byweekday),ne=I.includes(P)?I.filter((he)=>he!==P):[...I,P];M({byweekday:ne.length?ne:void 0})},setMonthlyMode:(P)=>{if(P==="weekday"){let H=G("monthlyOnWeekday",k);M({byweekday:H?.byweekday,bymonthday:void 0});return}let I=G("monthlyOnDay",k);M({bymonthday:I?.bymonthday,byweekday:void 0})},setEndType:(P)=>{let I={count:void 0,until:void 0};if(P==="count")I.count=f?.count||1;if(P==="until")I.until=f?.until||t().add(1,"month").endOf("day").toDate();M(I)},setUntil:(P)=>{let I=P?t(P).endOf("day").toDate():void 0;M({until:I})}},Ce=Boolean(c&&r);return Y(Te,{value:ue,children:le(xe,{"data-testid":"recurrence-editor",children:[le(Oe,{className:"pb-3",children:[le("div",{className:"flex items-center space-x-2",children:[Y(y,{checked:c,"data-testid":"toggle-recurrence",id:"recurring",onCheckedChange:F}),Y(Pe,{className:"text-sm",children:i("repeat")})]}),Ce&&Y("p",{className:"text-xs text-muted-foreground",children:It(r??null,i)})]}),c&&Y(we,{className:"pt-0",children:le("div",{className:"space-y-4",children:[Y(Ye,{}),Y(Fe,{}),Y(_e,{}),Y(Le,{}),Y(Ue,{})]})})]})})};import{jsx as bt}from"react/jsx-runtime";var He=({event:r,onChange:o})=>{let{rawEvents:s}=Tt(),i=r.uid,l;if(i)l=s.find((E)=>(E.uid||`${E.id}@ilamy.calendar`)===i&&Boolean(E.rrule));let[c,d]=kt(r.rrule??l?.rrule??null);return bt(qe,{onChange:(E)=>{if(!E){d(null),o({rrule:void 0});return}let O=E.dtstart??r.start?.toDate(),h=O?{...E,dtstart:O}:E;d(h),o({rrule:h})},referenceDate:r.start?.toDate(),value:c})};var ge=(r)=>Boolean(r.rrule||r.recurrenceId||r.uid),T=(r)=>r.uid||`${r.id}@ilamy.calendar`,ce=(r,o)=>{let s=T(o),i=r.findIndex((l)=>{let c=T(l)===s,d=Boolean(l.rrule)&&!l.recurrenceId;return c&&d});if(i===-1)throw Error("Base recurring event not found");return i},de=(r)=>r.start.subtract(1,"day").endOf("day").toDate(),Ee=(r)=>r.recurrenceId??r.start.toISOString(),Ke=(r,o)=>{let s=Ee(o),i=r.exdates||[],l=i.includes(s)?i:[...i,s];return{baseEvent:{...r,exdates:l},targetEventStartISO:s}};var Mt=({targetEvent:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l=Ee(r),c=T(i),{baseEvent:d}=Ke(i,r);o[s]=d;let f=(h)=>{let k=Boolean(h.recurrenceId),M=T(h)===c,F=h.recurrenceId===l;return k&&M&&F},E=o.find(f);return{events:o.filter((h)=>!f(h)),updated:E?[]:[d],added:[],deleted:E?[E]:[]}},Nt=({targetEvent:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l={...i,rrule:{...i.rrule,until:de(r)}};return o[s]=l,{events:o,updated:[l],added:[],deleted:[]}},Ut=({targetEvent:r,updatedEvents:o})=>{let s=T(r),i=o.filter((c)=>T(c)===s);return{events:o.filter((c)=>T(c)!==s),updated:[],added:[],deleted:i}},Ft={this:Mt,following:Nt,all:Ut},je=({targetEvent:r,currentEvents:o,scope:s})=>{let i=[...o],l=ce(i,r),c=i[l],d=Ft[s];if(!d)throw Error(`Invalid scope: ${s}. Must be 'this', 'following', or 'all'`);return d({targetEvent:r,updatedEvents:i,baseEventIndex:l,baseEvent:c})};import{RRule as Lt}from"rrule";var re=(r)=>new Date(Date.UTC(r.year(),r.month(),r.date(),r.hour(),r.minute(),r.second(),r.millisecond())),Ve=(r,o)=>o.year(r.getUTCFullYear()).month(r.getUTCMonth()).date(r.getUTCDate()).hour(r.getUTCHours()).minute(r.getUTCMinutes()).second(r.getUTCSeconds()).millisecond(r.getUTCMilliseconds());var ve=({event:r,currentEvents:o,startDate:s,endDate:i})=>{if(!r.rrule)return[];try{let l=re(r.start),c;if(r.rrule.until)c=re(t(r.rrule.until));let d={...r.rrule,dtstart:l,until:c},f=new Lt(d),E=T(r),O=o.filter((W)=>{let Q=Boolean(W.recurrenceId),q=T(W)===E;return Q&&q}),h=r.end.diff(r.start),k=re(s.subtract(h,"millisecond")),M=re(i);return f.between(k,M,!0).map((W,Q)=>{let q=Ve(W,r.start);if(O.some((Ze)=>N(Ze.recurrenceId)?.isSame(q)))return;let ue=q.toISOString();if(r.exdates?.includes(ue)??!1)return;let P=r.end.diff(r.start),I=q.add(P,"millisecond"),H=`${r.id}_${Q}`,ne=T(r);return{...r,id:H,start:q,end:I,uid:ne,rrule:void 0}}).filter((W)=>W!==void 0).filter((W)=>u(W,s,i))}catch(l){throw Error(`Invalid RRULE options: ${JSON.stringify(r.rrule)}. Error: ${l instanceof Error?l.message:"Unknown error"}`)}};var ze=(r,o)=>{let s=o.diff(o.startOf("day"),"millisecond");return r.startOf("day").add(s,"millisecond")},At=(r,o,s)=>{let i=r.end.diff(r.start),l=s.start||o.start,c=s.end||l.add(i),d=`${r.id}_following`,f=`${d}@ilamy.calendar`;return{...r,...s,rrule:{...r.rrule,...s.rrule,dtstart:l.toDate()},id:d,uid:f,start:l,end:c,recurrenceId:void 0}},Yt=(r,o)=>(s)=>{let i=Boolean(s.recurrenceId)&&!s.rrule,l=T(s)===r,c=Boolean(s.recurrenceId)&&t(s.recurrenceId).isAfter(o);return i&&l&&c},Wt=(r,o)=>{let s=r.start;if(o.start)s=ze(r.start,o.start);let i=r.end;if(o.start&&o.end)i=s.add(o.end.diff(o.start),"millisecond");else if(o.start)i=s.add(r.end.diff(r.start),"millisecond");else if(o.end)i=ze(r.end,o.end);let l=o.rrule??r.rrule,c;if(l)c={...l,dtstart:s.toDate()};return{start:s,end:i,rrule:c}},Bt=(r,o)=>{if(o&&r.recurrenceId)return r.recurrenceId;return r.start.toISOString()},_t=({updatedEvents:r,targetEvent:o,detachedOverride:s,updatedBaseEvent:i,baseChanged:l})=>{let c=r.findIndex((d)=>d.id===o.id);if(c===-1)throw Error("Detached override not found");return r[c]=s,{events:r,updated:l?[i,s]:[s],added:[],deleted:[]}},$t=({targetEvent:r,updates:o,updatedEvents:s,baseEventIndex:i,baseEvent:l})=>{let c=T(l),d=Boolean(r.recurrenceId&&!r.rrule),f=Bt(r,d),E=l.exdates||[],O=E.includes(f)?E:[...E,f],h=O!==E||l.uid!==c,k={...l,exdates:O,uid:c};s[i]=k;let M={...r,...o,recurrenceId:f,rrule:void 0,uid:c};if(d)return _t({updatedEvents:s,targetEvent:r,detachedOverride:M,updatedBaseEvent:k,baseChanged:h});let F={...M,id:`${l.id}_modified_${Date.now()}`};return s.push(F),{events:s,updated:[k],added:[F],deleted:[]}},qt=({targetEvent:r,updates:o,updatedEvents:s,baseEventIndex:i,baseEvent:l})=>{let c=de(r),d=T(l),f=Yt(d,c),E=(l.exdates??[]).filter((F)=>!t(F).isAfter(c)),O={...l,exdates:E,rrule:{...l.rrule,until:c}};s[i]=O;let h=At(l,r,o);s.push(h);let k=s.filter(f);return{events:s.filter((F)=>!f(F)),updated:[O],added:[h],deleted:k}},Ht=({updates:r,updatedEvents:o,baseEventIndex:s,baseEvent:i})=>{let l=T(i),c=Wt(i,r),d={...i,...r,start:c.start,end:c.end,rrule:c.rrule,exdates:void 0,uid:l};o[s]=d;let f=(h)=>{let k=Boolean(h.recurrenceId)&&!h.rrule,M=T(h)===l;return k&&M},E=o.filter((h)=>!f(h)),O=o.filter(f);return{events:E,updated:[d],added:[],deleted:O}},Kt={this:$t,following:qt,all:Ht},Qe=({targetEvent:r,updates:o,currentEvents:s,scope:i})=>{let l=[...s],c=ce(l,r),d=l[c],f=Kt[i];if(!f)throw Error(`Invalid scope: ${i}. Must be 'this', 'following', or 'all'`);return f({targetEvent:r,updates:o,updatedEvents:l,baseEventIndex:c,baseEvent:d})};import{jsx as Ge}from"react/jsx-runtime";var zt=()=>({name:"recurrence",transformEvents:(r,o)=>{let s=new Map;for(let i of r)if(i.rrule)s.set(T(i),i);return r.flatMap((i)=>{if(i.rrule)return ve({event:i,currentEvents:r,startDate:o.start,endDate:o.end});if(i.recurrenceId){let l=s.get(T(i));if(l)return[{...l,...i,rrule:void 0}]}return[i]})},managesEvent:(r)=>ge(r),applyEdit:({event:r,updates:o,currentEvents:s,scope:i})=>Qe({targetEvent:r,updates:o??{},currentEvents:s,scope:i}),applyDelete:({event:r,currentEvents:o,scope:s})=>je({targetEvent:r,currentEvents:o,scope:s}),contribute:(r,o)=>{if(r!=="ical:vevent-properties")return[];return me(o)},renderSlot:(r,o)=>{if(r===jt){let{event:s,onChange:i}=o;return Ge(He,{event:s,onChange:i})}if(r===Vt){let{event:s,operation:i,resolve:l,cancel:c}=o;return Ge(De,{eventTitle:s.title||"",isOpen:!0,onClose:c,onConfirm:(d)=>l(d),operationType:i})}return null}});export{Gn as RRule,Jn as Weekday,ve as generateRecurringEvents,ge as isRecurringEvent,me as recurrenceICalProperties,zt as recurrencePlugin};
@@ -0,0 +1,2 @@
1
+ import e from"dayjs";import l from"dayjs/plugin/isSameOrAfter.js";import O from"dayjs/plugin/isSameOrBefore.js";import D from"dayjs/plugin/localeData.js";import g from"dayjs/plugin/localizedFormat.js";import x from"dayjs/plugin/minMax.js";import T from"dayjs/plugin/timezone.js";import b from"dayjs/plugin/utc.js";import z from"dayjs/plugin/weekday.js";import S from"dayjs/plugin/weekOfYear.js";var d,C=(a,o,f)=>{let y=o.prototype,n=f.tz.setDefault;f.tz.setDefault=(r)=>(d=r,n(r));let{startOf:s,endOf:u}=y;function p(r,i){let m=r.$x?.$timezone||d;if(!m)return i;let j=f.tz(i.format("YYYY-MM-DDTHH:mm:ss"),m).utcOffset();if(i.utcOffset()!==j)return i.tz(m,!0);return i}y.startOf=function(r,i){let m=s.call(this,r,i);return p(this,m)},y.endOf=u},h=(a,o)=>{let f=o.prototype,y={isBefore:(n,s)=>n<s,isAfter:(n,s)=>n>s,isSame:(n,s)=>n===s,isSameOrBefore:(n,s)=>n<=s,isSameOrAfter:(n,s)=>n>=s};for(let[n,s]of Object.entries(y)){let u=f[n];f[n]=function(p,r){if(r===void 0&&e.isDayjs(p))return s(this.valueOf(),p.valueOf());return u.call(this,p,r)}}};e.extend(z);e.extend(S);e.extend(l);e.extend(O);e.extend(x);e.extend(T);e.extend(b);e.extend(D);e.extend(g);e.extend(C);e.extend(h);var k=/(?:Z|[+-]\d{2}:?\d{2})$/i,I=(a)=>{let o=a.split(/[Tt\s]/).at(1);if(!o)return!1;return k.test(o)},K=(a)=>typeof a==="string"&&!I(a),c=(a)=>{let o=e(a);if(!o.isValid())return o;if(K(a))return e.tz(a);if(!d)return o;return o.tz(d)};Object.assign(c,e);var t=c;
2
+ export{K,t};
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-d7599sry.js";import{Slot as h}from"@radix-ui/react-slot";import{cva as P}from"class-variance-authority";import{jsx as k}from"react/jsx-runtime";var S=P("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function n({className:i,variant:r,size:s,asChild:l=!1,...d}){return k(l?h:"button",{className:e(S({variant:r,size:s,className:i})),"data-slot":"button",...d})}import*as c from"@radix-ui/react-checkbox";import{CheckIcon as w}from"lucide-react";import{jsx as u}from"react/jsx-runtime";function y({className:i,...r}){return u(c.Root,{className:e("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",i),"data-slot":"checkbox",...r,children:u(c.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:u(w,{className:"size-3.5"})})})}import{jsx as R}from"react/jsx-runtime";function m({className:i,type:r,...s}){return R("input",{className:e("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),"data-slot":"input",type:r,...s})}import*as b from"@radix-ui/react-label";import{jsx as z}from"react/jsx-runtime";function a({className:i,...r}){return z(b.Root,{className:e("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",i),"data-slot":"label",...r})}import*as t from"@radix-ui/react-select";import{CheckIcon as I,ChevronDownIcon as x,ChevronUpIcon as N}from"lucide-react";import{jsx as o,jsxs as f}from"react/jsx-runtime";function g({...i}){return o(t.Root,{"data-slot":"select",...i})}function v({...i}){return o(t.Value,{"data-slot":"select-value",...i})}function C({className:i,size:r="default",children:s,...l}){return f(t.Trigger,{className:e("cursor-pointer border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i),"data-size":r,"data-slot":"select-trigger",...l,children:[s,o(t.Icon,{asChild:!0,children:o(x,{className:"size-4 opacity-50"})})]})}function D({className:i,children:r,position:s="popper",align:l="center",...d}){return o(t.Portal,{children:f(t.Content,{align:l,className:e("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",i),"data-slot":"select-content",position:s,...d,children:[o(_,{}),o(t.Viewport,{className:e("p-1",s==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width) scroll-my-1"),children:r}),o(V,{})]})})}function p({className:i,children:r,...s}){return f(t.Item,{className:e("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",i),"data-slot":"select-item",...s,children:[o("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o(t.ItemIndicator,{children:o(I,{className:"size-4"})})}),o(t.ItemText,{children:r})]})}function _({className:i,...r}){return o(t.ScrollUpButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-up-button",...r,children:o(N,{className:"size-4"})})}function V({className:i,...r}){return o(t.ScrollDownButton,{className:e("flex cursor-default items-center justify-center py-1",i),"data-slot":"select-scroll-down-button",...r,children:o(x,{className:"size-4"})})}
2
+ export{n,y,m,a,g,v,C,D,p};
@@ -0,0 +1,2 @@
1
+ import{K,t}from"./chunk-4jynmg6d.js";import{e,N,d,F,u}from"./chunk-d7599sry.js";import{c,f,h,j}from"./chunk-w4nsrq2y.js";import{b,R,x,w}from"./chunk-n7xt0j3a.js";import{useContext as Pr}from"react";import{createContext as jr}from"react";var Ze=jr(void 0);var Vr=[];function r(n){let a=Pr(Ze);if(!a)throw Error("useSmartCalendarContext must be used within a CalendarProvider");return n?n(a):a}function Q(){let n=r();return{currentDate:n.currentDate,currentRange:n.currentRange,view:n.view,events:n.events,rawEvents:n.rawEvents,isEventFormOpen:n.isEventFormOpen,selectedEvent:n.selectedEvent,selectedDate:n.selectedDate,firstDayOfWeek:n.firstDayOfWeek,resources:n.resources??Vr,orientation:n.orientation,setCurrentDate:n.setCurrentDate,selectDate:n.selectDate,setView:n.setView,nextPeriod:n.nextPeriod,prevPeriod:n.prevPeriod,today:n.today,addEvent:n.addEvent,updateEvent:n.updateEvent,deleteEvent:n.deleteEvent,openEventForm:n.openEventForm,closeEventForm:n.closeEventForm,onEventClick:n.onEventClick,renderCurrentTimeIndicator:n.renderCurrentTimeIndicator,getEventsForResource:n.getEventsForResource,businessHours:n.businessHours,t:n.t,timeFormat:n.timeFormat,timezone:n.timezone,currentLocale:n.currentLocale,getEventsForDateRange:n.getEventsForDateRange,applyScopedEdit:n.applyScopedEdit,applyScopedDelete:n.applyScopedDelete,getEventManager:n.getEventManager,renderSlot:n.renderSlot,collect:n.collect,getViews:n.getViews}}var Y={today:"Today",create:"Create",new:"New",update:"Update",delete:"Delete",cancel:"Cancel",export:"Export",previous:"Previous",next:"Next",event:"Event",events:"Events",newEvent:"New Event",title:"Title",description:"Description",location:"Location",allDay:"All day",startDate:"Start Date",endDate:"End Date",startTime:"Start Time",searchTime:"Search time...",endTime:"End Time",color:"Color",createEvent:"Create Event",editEvent:"Edit Event",addNewEvent:"Add a new event to your calendar",editEventDetails:"Edit your event details",eventTitlePlaceholder:"Event title",eventDescriptionPlaceholder:"Event description (optional)",eventLocationPlaceholder:"Event location (optional)",repeat:"Repeat",repeats:"Repeats",customRecurrence:"Custom recurrence",frequency:"Frequency",everyWeekday:"Every weekday",weeklyOn:"Weekly on",monthlyOnDay:"Monthly on day",monthlyOnThe:"Monthly on the",first:"first",second:"second",third:"third",fourth:"fourth",last:"last",daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly",interval:"Interval",repeatOn:"Repeat on",never:"Never",count:"Count",every:"Every",ends:"Ends",after:"After",occurrences:"occurrences",on:"On",editRecurringEvent:"Edit recurring event",deleteRecurringEvent:"Delete recurring event",editRecurringEventQuestion:"is a recurring event. How would you like to edit it?",deleteRecurringEventQuestion:"is a recurring event. How would you like to delete it?",thisEvent:"This event",thisEventDescription:"Only change this specific occurrence",thisAndFollowingEvents:"This and following events",thisAndFollowingEventsDescription:"Edit this and all future occurrences",allEvents:"All events",allEventsDescription:"Edit the entire recurring series",onlyChangeThis:"Only change this specific occurrence",changeThisAndFuture:"Change this and all future occurrences",changeEntireSeries:"Change the entire recurring series",onlyDeleteThis:"Only delete this specific occurrence",deleteThisAndFuture:"Delete this and all future occurrences",deleteEntireSeries:"Delete the entire recurring series",month:"Month",week:"Week",day:"Day",year:"Year",agenda:"Agenda",agendaNoEvents:"No upcoming events",more:"more",resources:"Resources",resource:"Resource",selectResource:"Select a resource",time:"Time",date:"Date",noResourcesVisible:"No resources visible",addResourcesOrShowExisting:"Add resources or show existing ones"};import{useMemo as eo}from"react";import{useEffect as br,useMemo as hr,useRef as wr,useState as qn}from"react";import{useMemo as Pt,useState as Mr}from"react";var z=1,Tt=24,B=24,It=4,jt="bg-[color-mix(in_oklch,var(--background),var(--foreground)_3%)] text-muted-foreground pointer-events-none",P={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6},Je="h-12",q="h-24";var Vt=({firstDayOfWeek:n,dayMaxEvents:a=It,businessHours:m,locale:y,translations:p,translator:v,resources:C,orientation:D="horizontal",weekViewGranularity:V="hourly"})=>{let[A,J]=Mr(y||"en"),re=Pt(()=>{if(v)return v;let ne=p||Y;return(g)=>ne[g]||g},[p,v]);return Pt(()=>({firstDayOfWeek:n,dayMaxEvents:a,businessHours:m,currentLocale:A,setCurrentLocale:J,t:re,resources:C,orientation:D,weekViewGranularity:V}),[n,a,m,A,re,C,D,V])};import{useCallback as ke,useEffect as Or,useMemo as Mt,useRef as Ar,useState as Fr}from"react";var We=(n)=>{if(n.resourceIds)return n.resourceIds;if(n.resourceId!==void 0)return[n.resourceId];return[]};function E(n,a){return n.filter((m)=>We(m).includes(a))}var Ot=(n)=>!Array.isArray(n),At=(n,{onEventUpdate:a,onEventAdd:m,onEventDelete:y,setCurrentEvents:p})=>{for(let v of n.updated)a?.(v);for(let v of n.added)m?.(v);for(let v of n.deleted)y?.(v);p(n.events)},Ft=({events:n,pluginRuntime:a,getCurrentViewRange:m,resources:y,onEventAdd:p,onEventUpdate:v,onEventDelete:C})=>{let[D,V]=Fr(n),A=Ar(n),J=ke((Z,te)=>a.transformEvents(D,{start:Z,end:te}),[D,a]),re=Mt(()=>{let{start:Z,end:te}=m();return J(Z,te)},[J,m]);Or(()=>{if(n!==A.current)V(n),A.current=n},[n]);let ne=ke((Z)=>{V((te)=>[...te,Z]),p?.(Z)},[p]),g=ke((Z,te)=>{let se=D.find((ue)=>ue.id===Z);if(!se)return;let de={...se,...te};V((ue)=>ue.map((ye)=>ye.id===Z?de:ye)),v?.(de)},[D,v]),ee=ke((Z,te,se)=>{let de=a.getEventManager(Z);if(!de?.applyEdit)return;let ue=de.applyEdit({event:Z,updates:te,currentEvents:D,scope:se});if(Ot(ue)){At(ue,{onEventUpdate:v,onEventAdd:p,onEventDelete:C,setCurrentEvents:V});return}v?.({...Z,...te}),V(ue)},[D,p,v,C,a]),S=ke((Z,te)=>{let se=a.getEventManager(Z);if(!se?.applyDelete)return;let de=se.applyDelete({event:Z,currentEvents:D,scope:te});if(Ot(de)){At(de,{onEventUpdate:v,onEventAdd:p,onEventDelete:C,setCurrentEvents:V});return}C?.(Z),V(de)},[D,p,v,C,a]),ae=ke((Z)=>{let te=D.find((se)=>se.id===Z);if(!te)return;V((se)=>se.filter((de)=>de.id!==Z)),C?.(te)},[D,C]),oe=ke((Z)=>E(re,Z),[re]),ie=ke((Z)=>re.filter((te)=>We(te).some((se)=>Z.includes(se))),[re]),ce=ke((Z)=>{if(Z===void 0)return;return y.find((te)=>te.id===Z)},[y]),le=ke((Z)=>Boolean(Z.resourceIds&&Z.resourceIds.length>1),[]);return Mt(()=>({events:re,rawEvents:D,setCurrentEvents:V,getEventsForDateRange:J,addEvent:ne,updateEvent:g,deleteEvent:ae,applyScopedEdit:ee,applyScopedDelete:S,getEventsForResource:oe,getEventsForResources:ie,getResourceById:ce,isEventCrossResource:le}),[re,D,J,ne,g,ae,ee,S,oe,ie,ce,le])};import{useCallback as Ge,useMemo as Br,useState as gt}from"react";var _r=(n)=>n,Bt=({currentDate:n,t:a,disableEventClick:m,disableCellClick:y,onEventClick:p,onCellClick:v})=>{let[C,D]=gt(!1),[V,A]=gt(null),[J,re]=gt(null),ne=Ge((oe={})=>{let{start:ie,end:ce,resourceId:le,resource:Z,allDay:te}=oe;if(ie)re(ie);let se=(ie??n).second(0).millisecond(0);A(_r({title:a("newEvent"),start:se,end:ce??se.add(1,"hour"),resourceId:le??Z?.id,description:"",allDay:te??!1})),D(!0)},[n,a]),g=Ge(()=>{re(null),A(null),D(!1)},[]),ee=Ge((oe)=>{A(oe),D(!0)},[]),S=Ge((oe)=>{if(m)return;if(p)p(oe);else ee(oe)},[m,p,ee]),ae=Ge((oe)=>{if(y)return;if(v)v(oe);else ne(oe)},[v,y,ne]);return Br(()=>({isEventFormOpen:C,selectedEvent:V,selectedDate:J,setIsEventFormOpen:D,setSelectedEvent:A,setSelectedDate:re,openEventForm:ne,closeEventForm:g,handleEventClick:S,handleDateClick:ae}),[C,V,J,ne,g,S,ae])};import{useCallback as be,useMemo as Gn,useRef as $n,useState as Kn}from"react";import{Square as En}from"lucide-react";import{jsx as zr}from"react/jsx-runtime";var i=({children:n,transitionKey:a,delay:m=0,className:y,direction:p="vertical","data-testid":v,ref:C,style:D,...V})=>zr("div",{className:e("inline-block w-full animate-in fade-in fill-mode-backwards duration-500 ease-in-out",p==="horizontal"?"slide-in-from-right-2.5":"slide-in-from-top-2.5",y),"data-testid":v,ref:C,style:{animationDelay:`${m}s`,...D},...V,children:n},a);i.displayName="AnimatedSection";import{jsx as zt,Fragment as _t}from"react/jsx-runtime";var et=({date:n})=>{let{renderHour:a,timeFormat:m}=r();if(a)return zt(_t,{children:a(n)});return zt(_t,{children:n.format(m==="12-hour"?"h A":"H")})};function l(n){return F(n,t())}function s(n,a){let m=n.startOf("week").day(a),y=n.isBefore(m)?m.subtract(1,"week"):m;return Array.from({length:7},(p,v)=>y.add(v,"day"))}function O(n,a){let m=n.startOf("month"),p=s(m,a).at(0)??m;return Array.from({length:6},(v,C)=>{let D=p.add(C,"week");return s(D,a)})}function tt(n){let a=n.daysInMonth(),m=n.startOf("month");return Array.from({length:a},(y,p)=>m.add(p,"day"))}function Lt({referenceDate:n=t(),length:a=24}={}){let m=n.startOf("day");return Array.from({length:a},(y,p)=>m.hour(p).minute(0).second(0).millisecond(0))}var rt=(n,a)=>{let m=O(n,a),y=m.at(0)?.at(0)??n,p=m.at(-1)?.at(-1)??n;return{start:y.startOf("day"),end:p.endOf("day")}};var Fe=(n)=>String(n).padStart(2,"0"),Lr=(n)=>typeof n==="number"?Fe(n):n,o={col:{time:"time-col",date:"date-col",day:(n,a)=>{let m=`day-col-${d(n)}`;return a!=null?`${m}-resource-${a}`:m},resource:(n,a)=>`${n}-col-resource-${a}`,allDay:(n,a)=>`all-day-col-${d(n)}-${a}`,events:(n)=>`col-events-${n.toISOString()}`},cell:{day:(n,a,m=0)=>{let y=d(n);return a!=null?`day-cell-${y}-${Fe(a)}-${Fe(m)}`:`day-cell-${y}`},verticalTime:(n)=>`vertical-time-${Fe(n)}`,vertical:(n,a,m,y)=>{let p=`vertical-cell-${d(n)}-${Fe(a)}-${Fe(m)}`;return y!=null?`${p}-resource-${y}`:p}},container:{vertical:{col:(n)=>`vertical-col-${n}`},horizontal:{row:(n)=>`horizontal-row-${n}`,rowLabel:(n)=>`horizontal-row-label-${n}`,event:(n)=>`horizontal-event-${n}`},eventsLayer:(n,a)=>`${n}-events-${a}`},header:{resource:{weekDay:"resource-week-day-header",columnsHeader:"resource-columns-header",monthDay:(n)=>`resource-month-header-${n.toISOString()}`,timeLabel:(n,a)=>`resource-${n}-time-label-${Lr(a)}`},weekday:(n,a)=>`${n}-header-weekday-${a.toLowerCase()}`,week:{day:(n)=>`week-header-day-${n.toISOString()}`,hour:(n,a)=>`week-header-hour-${n.toISOString()}-${a}`,resource:(n)=>`week-header-resource-${n}`},year:{month:(n,a)=>a?`year-month-${a}-${n}`:`year-month-${n}`,day:(n,a)=>`year-day-${n}-${a}`}},allDayRow:(n)=>`allday-row-${n??"main"}`,listKey:(...n)=>n.join("-"),dayNumber:(n)=>l(n)?"day-number-today":`day-number-${n.format("D")}`,timePicker:(n)=>`time-picker-${n??""}`,droppable:{dayCell:(n,a)=>{let m=n.toISOString(),y=a?.allDay?"-allday":"",p=a?.resourceId!=null?`-resource-${a.resourceId}`:"";return`drop-day-cell-${m}${y}${p}`}}};import{jsx as Wt}from"react/jsx-runtime";var Me="w-16 min-w-16 max-w-16",Gt="w-[calc(100%-4rem)]",T="w-10 sm:w-16 min-w-10 sm:min-w-16 max-w-10 sm:max-w-16",we="shadow-[1px_0_0_0_color-mix(in_oklch,var(--background),var(--foreground)_10%)]",Ne=({days:n,gridType:a,renderLabel:m,widthClassName:y=Me})=>({id:a==="hour"?o.col.time:o.col.date,day:void 0,days:n,className:e("shrink-0",y,"sticky left-0 bg-background z-20",we),gridType:a,noEvents:!0,renderCell:(p)=>Wt("div",{className:"text-muted-foreground p-2 text-right text-[10px] sm:text-xs flex flex-col items-center",children:m?m(p):Wt(et,{date:p})})});var I=(n,a)=>{if(!a)return!0;let m=!1;return nt(a,{date:n,onMatch:()=>{m=!0}}),m},Wr=/^(\d{1,2}):(\d{2})$/,Dt=(n,a)=>{if(typeof n==="number")return Math.round(n)*60;if(typeof n==="string"){let m=n.match(Wr);if(m){let y=Number(m[1]),p=Number(m[2]),v=y*60+p<=1440;if(p<=59&&v)return y*60+p}}return a*60},$t=(n,a)=>{let m=Dt(n,a);return m===0?1440:m},Kt=({date:n,hour:a,minute:m=0,durationMinutes:y,businessHours:p})=>{if(!p)return!0;if(a===void 0)return I(n,p);let v=!1,C=a*60+m;return nt(p,{date:n,onMatch:(D)=>{let V=Dt(D.startTime,9),A=$t(D.endTime,17),J=C>=V,re=y?C+y<=A:C<A;if(J&&re)v=!0}}),v},nt=(n,a)=>{let{date:m,onMatch:y}=a;if(!n)return;let p=Array.isArray(n)?n:[n];for(let v of p)if(m&&v.daysOfWeek){let C=m.day();if(v.daysOfWeek.some((D)=>P[D]===C))y(v)}else y(v)},_=(n)=>{let{allDates:a,businessHours:m,resourceBusinessHours:y=[],hideNonBusinessHours:p}=n,v=24,C=0,D=!1,V=(J)=>{D=!0,v=Math.min(v,Dt(J.startTime,9)/60),C=Math.max(C,$t(J.endTime,17)/60)},A=(J)=>{nt(m,{date:J,onMatch:V});for(let re of y)nt(re,{date:J,onMatch:V})};for(let J of a)A(J);if(!D&&p){if(A(),!D)v=9,C=17,D=!0}return{minStart:v,maxEnd:C,hasBusinessHours:D}};function ot(n){return n.flatMap((a)=>a.businessHours?[a.businessHours]:[])}function at({referenceDate:n,businessHours:a,hideNonBusinessHours:m,allDates:y=[n],resourceBusinessHours:p=[]}){let v=Lt({referenceDate:n}),C=Boolean(a)||p.length>0;if(!(m&&C))return v;let{minStart:V,maxEnd:A,hasBusinessHours:J}=_({allDates:y,businessHours:a,resourceBusinessHours:p,hideNonBusinessHours:m});if(!J)return v;if(V>=A)return[];let re=Math.floor(V),ne=Math.ceil(A);return v.filter((g)=>{let ee=g.hour();return ee>=re&&ee<ne})}import{memo as Gr}from"react";import{jsx as Ut}from"react/jsx-runtime";var $r=({className:n})=>{let{t:a}=r();return Ut("div",{className:e("w-16 shrink-0 sticky left-0 bg-background z-20 flex items-center justify-center px-1 text-xs text-muted-foreground",we,n),children:Ut("span",{className:"truncate",children:a("allDay")})})},st=Gr($r);import{memo as Cn}from"react";import{memo as rr,useMemo as pn}from"react";import{useMemo as bt}from"react";var Kr=(n,a)=>{let m=(D)=>D.end.subtract(1,"millisecond").startOf(a).isAfter(D.start.startOf(a)),y=n.filter(m),p=n.filter((D)=>!m(D)),v=[...y].sort((D,V)=>{let A=D.start.diff(V.start);if(A!==0)return A;return V.end.diff(V.start)-D.end.diff(D.start)}),C=[...p].sort((D,V)=>D.start.diff(V.start));return{sortedMultiUnit:v,sortedSingleUnit:C}},Yt=(n,{firstUnit:a,lastUnit:m,unitCount:y,gridType:p})=>{let v=t.max(n.start.startOf(p),a),C=n.end.subtract(1,"millisecond"),D=t.min(C.startOf(p),m);return{startCol:Math.max(0,v.diff(a,p)),endCol:Math.min(y-1,D.diff(a,p)),isTruncatedStart:n.start.startOf(p).isBefore(a),isTruncatedEnd:C.startOf(p).isAfter(m)}},Et=(n,a,m)=>{for(let y=0;y<n.length;y++){let p=!0;for(let v=a;v<=m;v++)if(n[y][v]){p=!1;break}if(p)return y}return-1},qt=({days:n,events:a,dayMaxEvents:m,gridType:y="day"})=>{let p=n.at(0),v=n.at(-1);if(!p||!v)return[];let C={firstUnit:y==="hour"?p.startOf("hour"):p.startOf("day"),lastUnit:y==="hour"?v.endOf("hour"):v.endOf("day"),unitCount:n.length,gridType:y},{sortedMultiUnit:D,sortedSingleUnit:V}=Kr(a,y),A=Array.from({length:m},()=>Array.from({length:C.unitCount},()=>!1)),J=[],re=({row:ne,startCol:g,endCol:ee,event:S,isTruncatedStart:ae,isTruncatedEnd:oe})=>{for(let ce=g;ce<=ee;ce++)A[ne][ce]=!0;let ie=ee-g+1;J.push({kind:"horizontal",event:S,left:g/C.unitCount*100,width:ie/C.unitCount*100,row:ne,isTruncatedStart:ae,isTruncatedEnd:oe})};for(let ne of D){let g=Yt(ne,C),ee=Et(A,g.startCol,g.endCol);if(ee!==-1){re({row:ee,event:ne,...g});continue}for(let S=g.startCol+1;S<=g.endCol;S++){let ae=Et(A,S,g.endCol);if(ae!==-1){re({row:ae,startCol:S,endCol:g.endCol,event:ne,isTruncatedStart:!0,isTruncatedEnd:g.isTruncatedEnd});break}}}for(let ne of V){let ee=Yt(ne,C).startCol,S=Et(A,ee,ee);if(S!==-1)re({row:S,startCol:ee,endCol:ee,event:ne,isTruncatedStart:!1,isTruncatedEnd:!1})}return J};var ht=({days:n,allDay:a,resourceId:m,gridType:y})=>{let{getEventsForDateRange:p,dayMaxEvents:v}=r(),C=n.at(0),D=n.at(-1),V=C?.startOf("day"),A=D?.endOf("day"),J=bt(()=>{if(!V||!A)return[];let g=p(V,A);if(m)g=E(g,m);if(a)g=g.filter((ee)=>Boolean(ee.allDay));return g},[p,V,A,m,a]),re=bt(()=>{let g=new Map,ee=y??"day";for(let S of n){let ae=S.startOf(ee),oe=S.endOf(ee),ie=J.filter((ce)=>u(ce,ae,oe));g.set(o.col.events(S),ie)}return g},[n,J,y]);return{positionedEvents:bt(()=>qt({days:n,events:J,dayMaxEvents:v,gridType:y}),[n,v,J,y]),columnEventsMap:re}};import on,{memo as an,useMemo as Jt}from"react";import{useMemo as Ur}from"react";var L=(n)=>{let{businessHours:a,getResourceById:m}=r((y)=>({businessHours:y.businessHours,getResourceById:y.getResourceById}));return Ur(()=>{if(n!=null){let y=m(n);if(y?.businessHours)return y.businessHours}return a},[n,m,a])};import{useImperativeHandle as Jr,useState as Qt}from"react";import{useDraggable as Yr}from"@dnd-kit/core";import{memo as qr}from"react";import{jsx as $e,jsxs as Zr}from"react/jsx-runtime";var Qr=(n,a)=>{if(n&&a)return"rounded-none";if(n)return"rounded-r-md rounded-l-none";if(a)return"rounded-l-md rounded-r-none";return"rounded-md"};function Xr({elementId:n,event:a,className:m,style:y,disableDrag:p=!1,isTruncatedStart:v=!1,isTruncatedEnd:C=!1,sourceResourceId:D}){let{onEventClick:V,renderEvent:A,disableEventClick:J,disableDragAndDrop:re}=r(),{attributes:ne,listeners:g,setNodeRef:ee,isDragging:S}=Yr({id:n,data:{event:a,type:"calendar-event",sourceResourceId:D},disabled:p||re}),ae=()=>Zr("div",{className:e(a.backgroundColor||"bg-blue-500",a.color||"text-white","h-full w-full px-1 border-[1.5px] border-card text-left overflow-clip relative",Qr(v,C)),style:{backgroundColor:a.backgroundColor,color:a.color},children:[v&&$e("div",{className:"absolute left-0 top-0 bottom-0 w-0.5 bg-foreground/25"}),$e("p",{className:e("text-[10px] font-semibold sm:text-xs mt-0.5",v&&"pl-1",C&&"pr-1"),children:a.title}),C&&$e("div",{className:"absolute right-0 top-0 bottom-0 w-0.5 bg-foreground/25"})]}),oe=p||re,ce=oe?J?"cursor-default":"cursor-pointer":"cursor-grab",le=S&&!oe&&"cursor-grabbing shadow-lg",te=A?A(a,{isStart:!v,isEnd:!C}):$e(ae,{});return $e(i,{className:e("truncate h-full w-full",ce,le,m),onClick:(se)=>{se.stopPropagation(),V(a)},ref:ee,style:y,transitionKey:n,...ne,...g,children:te})}var k=qr(Xr,(n,a)=>n.elementId===a.elementId&&n.disableDrag===a.disableDrag&&n.className===a.className&&n.event===a.event&&n.isTruncatedStart===a.isTruncatedStart&&n.isTruncatedEnd===a.isTruncatedEnd);import{jsx as Ke,jsxs as en}from"react/jsx-runtime";var Xt=({ref:n})=>{let[a,m]=Qt(!1),[y,p]=Qt(null),{eventHeight:v}=r();return Jr(n,()=>({open:()=>m(!0),close:()=>m(!1),setSelectedDayEvents:(C)=>p(C)})),Ke(b,{onOpenChange:m,open:a,children:en(R,{className:"max-h-[80vh] max-w-md overflow-y-auto",children:[Ke(x,{children:Ke(w,{children:y?.day.format("MMMM D, YYYY")})}),Ke("div",{className:"mt-4 space-y-3",children:y?.events.map((C)=>Ke(k,{className:"relative my-1",elementId:`all-events-dialog-event-${C.id}`,event:C,style:{height:`${v}px`}},C.id))})]})})};import{useDroppable as tn}from"@dnd-kit/core";import{jsx as nn}from"react/jsx-runtime";function rn(n,a,m,y){let p=n.hour(a??0).minute(m??0);if(a!==void 0&&m!==void 0)return{start:p,end:p.add(y,"minute")};if(a!==void 0)return{start:p,end:p.hour(a+1).minute(0)};return{start:p,end:p.add(1,"day").startOf("day")}}function Zt({id:n,type:a,date:m,hour:y,minute:p,slotDurationMinutes:v,resourceId:C,allDay:D,children:V,className:A,style:J,"data-testid":re,disabled:ne=!1}){let{onCellClick:g,isCellDisabled:ee,getCellClassName:S,getResourceById:ae,disableDragAndDrop:oe,disableCellClick:ie,classesOverride:ce,view:le}=r(),{start:Z,end:te}=rn(m,y,p,v),se=ae?.(C),de={start:Z,end:te,resource:se,allDay:D},ue=ne||Boolean(ee?.(de)),ye=ie||ue,{isOver:pe,setNodeRef:ge}=tn({id:n,data:{type:a,date:m,hour:y,minute:p,resourceId:C,allDay:D},disabled:oe||ue}),Ce=(me)=>{if(me.stopPropagation(),ye)return;g(de)},xe=pe&&!oe&&!ue,De=ce?.disabledCell||jt,Se=S?.(de);return nn("div",{className:e("droppable-cell",A,Se,xe&&"bg-accent",ye?"cursor-default":"cursor-pointer",ue&&De),"data-all-day":D?"true":void 0,"data-disabled":ue.toString(),"data-end":te.toISOString(),"data-resource-id":C,"data-start":Z.toISOString(),"data-testid":re,"data-view":le,onClick:Ce,ref:ge,style:J,children:V})}import{jsx as it,jsxs as lt,Fragment as er}from"react/jsx-runtime";var sn=({day:n,hour:a,minute:m,slotDurationMinutes:y=60,className:p="",resourceId:v,gridType:C="day",shouldRenderEvents:D=!0,allDay:V=!1,precomputedEvents:A,"data-testid":J,showDayNumber:re=!1,children:ne})=>{let g=on.useRef(null),{dayMaxEvents:ee=0,getEventsForDateRange:S,currentDate:ae,t:oe,eventSpacing:ie,eventHeight:ce,onMoreEventsClick:le,view:Z}=r(),te=L(v),se=Jt(()=>{if(!D)return[];if(A)return A;let me=S(n.startOf(C),n.endOf(C));if(V)me=me.filter((Ee)=>Ee.allDay);if(v)return E(me,v);return me},[A,n,v,S,C,D,V]),de=(me,Ee)=>{if(le){le(me,Ee);return}g.current?.setSelectedDayEvents({day:me,events:Ee}),g.current?.open()},ue=Z==="month"&&n.month()!==ae.month(),ye=se.length-ee,pe=ye>0,ge=Jt(()=>{if(C==="hour")return Kt({date:n,hour:n.hour(),minute:n.minute(),durationMinutes:y,businessHours:te});return I(n,te)},[C,n,y,te]),Ce=o.cell.day(n,n.format("HH"),n.format("mm")),xe=o.cell.day(n),De=C==="hour"?Ce:xe,Se=o.droppable.dayCell(n,{allDay:V,resourceId:v});return lt(er,{children:[it(Zt,{allDay:V,className:e("cursor-pointer overflow-clip p-1 bg-background hover:bg-accent min-h-[60px] relative min-w-0",p),"data-testid":J||De,date:n,disabled:!ge||ue,hour:a,id:Se,minute:m,resourceId:v,slotDurationMinutes:y,type:"day-cell",children:lt("div",{className:"flex flex-col h-full w-full","data-testid":"grid-cell-content",style:{gap:`${ie}px`},children:[re&&it(h,{className:"items-start","data-testid":o.dayNumber(n),dayNumber:n.format("D"),today:l(n)}),D&&lt(er,{children:[se.slice(0,ee).map((me,Ee)=>it("div",{className:"w-full shrink-0","data-testid":me?.title,style:{height:`${ce}px`}},o.listKey("empty",Ee,me.id))),pe&&lt("div",{className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] whitespace-nowrap sm:text-xs shrink-0 mt-1",onClick:(me)=>{me.stopPropagation(),de(n,se)},onKeyDown:(me)=>{if(me.key==="Enter"||me.key===" ")me.preventDefault(),me.stopPropagation(),de(n,se)},role:"button",tabIndex:0,children:["+",ye," ",oe("more")]})]}),ne]})}),it(Xt,{ref:g})]})},H=an(sn);import{jsx as tr}from"react/jsx-runtime";var Be=({resource:n,className:a,children:m,"data-testid":y})=>{let{renderResource:p}=r();return tr("div",{className:e("flex items-center justify-center p-2",a),"data-testid":y,style:{color:n.color,backgroundColor:n.backgroundColor},children:p?p(n):m??tr("div",{className:"text-sm font-medium truncate",children:n.title})})};import{memo as un}from"react";import{memo as ln}from"react";import{jsx as cn}from"react/jsx-runtime";var dn=({rangeStart:n,rangeEnd:a,now:m,resource:y,axis:p="vertical",withDot:v})=>{let{renderCurrentTimeIndicator:C,view:D}=r((A)=>({renderCurrentTimeIndicator:A.renderCurrentTimeIndicator,view:A.view})),V;if(C)V=(A)=>C({...A,resource:y,view:D});return cn(j,{axis:p,now:m,rangeEnd:a,rangeStart:n,render:V,withDot:v})},G=ln(dn);import{jsx as wt,jsxs as yn}from"react/jsx-runtime";var mn=({gridType:n="day",days:a,resourceId:m,resource:y,"data-testid":p,positionedEvents:v,dayNumberHeight:C=Tt})=>{let{eventHeight:D,eventSpacing:V,resources:A}=r(),J=a.at(0)?.startOf("day"),re=!m||A?.at(0)?.id===m,ne=a.at(0),g=a.at(-1)?.add(1,n),ee=n==="hour"&&Boolean(ne&&g);return yn("div",{className:"absolute inset-0 pointer-events-none z-10 overflow-clip","data-testid":p,children:[ee&&ne&&g&&wt(G,{axis:"horizontal",rangeEnd:g,rangeStart:ne,resource:y,withDot:re}),v.map((S)=>{let{event:ae,row:oe}=S,ie=C+V+oe*(D+V),ce=`${ae.id}-${oe}-${J?.toISOString()}-${m??"no-resource"}`;return wt("div",{className:"absolute z-10 pointer-events-auto overflow-clip","data-left":S.left,"data-testid":o.container.horizontal.event(ae.id),"data-top":ie,"data-width":S.width,style:{left:`calc(${S.left}% + var(--spacing) * 0.25)`,width:`calc(${S.width}% - var(--spacing) * 1)`,top:`${ie}px`,height:`${D}px`},children:wt(k,{className:"h-full w-full shadow",elementId:ce,event:ae,isTruncatedEnd:S.isTruncatedEnd,isTruncatedStart:S.isTruncatedStart,sourceResourceId:m})},o.listKey(ce,"wrapper"))})]})},Rt=un(mn);import{jsx as Re,jsxs as xt}from"react/jsx-runtime";var fn=({id:n,resource:a,gridType:m="day",variant:y="resource",dayNumberHeight:p,className:v,columns:C=[],allDay:D,showDayNumber:V=!1})=>{let{renderResource:A}=r(),J=y==="resource",re=C.some((S)=>S.days),ne=pn(()=>{if(re)return[];return C.map((S)=>S.day).filter((S)=>Boolean(S))},[C,re]),{positionedEvents:g,columnEventsMap:ee}=ht({days:ne,gridType:m,resourceId:a?.id,allDay:D});return xt("div",{className:e("flex flex-1 relative min-w-0",v),"data-testid":o.container.horizontal.row(n),children:[J&&a&&Re(Be,{className:"w-20 sm:w-40 border-r sticky left-0 bg-background z-20 h-full","data-testid":o.container.horizontal.rowLabel(a.id),resource:a,children:A?A(a):Re("div",{className:"wrap-break-word text-sm",children:a.title})}),xt("div",{className:"relative flex-1 flex min-w-0",children:[Re("div",{className:"flex w-full min-w-0 gap-px bg-border",children:C.map((S)=>{if(S.days)return Re(vn,{allDay:D,col:S,dayNumberHeight:p,gridType:m,id:n,resource:a,resourceId:a?.id,showDayNumber:V},S.id);return S.day?Re(H,{allDay:D,className:e("flex-1 w-20",S.className),day:S.day,gridType:m,hour:m==="hour"?S.day.hour():void 0,precomputedEvents:ee.get(o.col.events(S.day)),resourceId:a?.id,showDayNumber:V},S.day.toISOString()):null})}),!re&&Re("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Re(Rt,{"data-testid":o.container.eventsLayer("horizontal",n),dayNumberHeight:p,days:ne,gridType:m,positionedEvents:g,resource:a,resourceId:a?.id})})]})]})},vn=rr(({col:n,gridType:a="day",allDay:m,resource:y,resourceId:p,dayNumberHeight:v,showDayNumber:C,id:D})=>{let V=n.days??[],{positionedEvents:A}=ht({days:V,gridType:a,resourceId:p,allDay:m});return xt("div",{className:"flex relative w-full",children:[Re("div",{className:"flex w-full gap-px bg-border",children:V.map((J)=>Re(H,{allDay:m,className:e("flex-1 w-20",n.className),day:J,gridType:a,hour:a==="hour"?J.hour():void 0,resourceId:p,showDayNumber:C},J.toISOString()))}),Re("div",{className:"absolute inset-0 z-10 pointer-events-none",children:Re(Rt,{"data-testid":o.container.eventsLayer("horizontal",D),dayNumberHeight:v,days:V,gridType:a,positionedEvents:A,resource:y,resourceId:p})})]})}),W=rr(fn);import{jsx as nr,jsxs as Dn}from"react/jsx-runtime";var gn=({days:n,classes:a,resource:m,showSpacer:y=!0})=>{let p=n.map((v,C)=>({id:o.col.allDay(v,C),day:v,gridType:"day",className:e("h-full min-h-12 bg-background",a?.cell)}));return Dn("div",{className:e("flex w-full gap-px bg-border",a?.row),"data-testid":"all-day-row",children:[y&&nr(st,{className:a?.spacer}),nr(W,{allDay:!0,className:"flex-1 min-h-fit",columns:p,dayNumberHeight:0,gridType:"day",id:o.allDayRow(m?.id),resource:m,variant:"regular"})]})},U=Cn(gn);import{jsx as _e,jsxs as or}from"react/jsx-runtime";var fe="min-w-20 flex-1",Oe=({resources:n,days:a,gridType:m,cellClassName:y})=>{let p=a.map((v)=>{let C=Array.isArray(v),D=C?v.at(0):v;return{id:D?o.col.day(D):"day-col-unknown",day:C?void 0:v,days:C?v:void 0,className:y,gridType:m}});return n.map((v)=>({id:String(v.id),resource:v,columns:p}))},Ae=({resources:n,gutter:a,columnsFor:m})=>[a,...n.flatMap((y)=>{let p=m(y);return(Array.isArray(p)?p:[p]).map((C)=>({...C,resource:y}))})],dt=({resources:n})=>or("div",{className:"flex gap-px bg-border h-12 flex-1","data-testid":o.header.resource.columnsHeader,children:[_e("div",{className:e("shrink-0 sticky top-0 left-0 bg-background z-20",Me,we)}),n.map((a)=>_e(Be,{className:e(fe,"bg-background"),resource:a},o.listKey("resource-cell",a.id)))]}),ze=()=>{let{t:n}=r((a)=>({t:a.t}));return _e("div",{className:"w-20 sm:w-40 border-b border-r shrink-0 flex justify-center items-center sticky top-0 left-0 bg-background z-20",children:_e("div",{className:"text-sm truncate px-1 min-w-0",children:n("resources")})})},X=({columns:n})=>{let a=[],m=new Map;for(let y of n){if(!y.resource||y.noEvents||!y.day)continue;let p=m.get(y.resource.id);if(!p)p={resource:y.resource,days:[],seenDayKeys:new Set},m.set(y.resource.id,p),a.push(p);let v=d(y.day);if(!p.seenDayKeys.has(v))p.seenDayKeys.add(v),p.days.push(y.day)}return or("div",{className:"flex w-full gap-px bg-border",children:[_e(st,{}),a.map(({resource:y,days:p})=>_e(U,{classes:{cell:e("min-w-20",p.length>1&&"flex-1")},days:p,resource:y,showSpacer:!1},o.allDayRow(y.id)))]})};import{jsx as ct}from"react/jsx-runtime";var ut=({hours:n,view:a})=>ct("div",{className:e("flex gap-px bg-border border-b",Je),children:n.map((m,y)=>{let p=m.isSame(t(),"hour"),v=m.format("HH"),C=o.listKey("time-header-hour",v,y);return ct("div",{className:e(fe,"bg-background flex items-center justify-center text-xs shrink-0",p&&"bg-blue-50 text-blue-600 font-medium"),"data-hour":v,"data-testid":o.header.resource.timeLabel(a,v),children:ct(i,{className:"text-center",transitionKey:C,children:ct(et,{date:m})})},C)})});import{jsx as Ie,jsxs as ir,Fragment as Rn}from"react/jsx-runtime";var bn=({date:n})=>{let{t:a}=r((y)=>({t:y.t})),m=l(n);return Ie("div",{className:"flex flex-1 justify-center items-center min-h-12","data-testid":"day-view-header",children:ir(i,{className:e("flex justify-center items-center text-center text-sm font-semibold sm:text-xl",m&&"text-primary"),transitionKey:d(n),children:[n.format("dddd, LL"),m&&Ie("span",{className:"bg-primary text-primary-foreground ml-2 rounded-full px-1 py-0.5 text-xs sm:px-2 sm:text-sm",children:a("today")})]})})},ar=(n,a)=>at({referenceDate:n,businessHours:a.businessHours,hideNonBusinessHours:a.hideNonBusinessHours,allDates:[n],resourceBusinessHours:ot(a.resources??[])}),hn=({date:n,config:a})=>{let m=ar(n,a);return ir(Rn,{children:[Ie(ze,{}),Ie("div",{className:"flex-1 flex flex-col",children:Ie(ut,{hours:m,view:"day"})})]})},wn=(n,a)=>{let m=a.resources??[],y=ar(n,a);if(!m.length)return[Ne({days:y,gridType:"hour"}),{id:o.col.day(n),day:n,days:y,className:e(Gt,"flex-1"),gridType:"hour"}];if(a.orientation==="vertical")return Ae({resources:m,gutter:Ne({days:y,gridType:"hour"}),columnsFor:(p)=>({id:o.col.day(n,p.id),days:y,day:n,gridType:"hour"})});return Oe({resources:m,days:y,gridType:"hour",cellClassName:fe})},sr={name:"day",label:"day",icon:En,navigationUnit:"day",layout:"vertical",supportsResources:!0,range:(n)=>({start:n.startOf("day"),end:n.endOf("day")}),columns:wn,renderHeader:({date:n,config:a})=>{let m=a.resources??[];if(!m.length)return Ie(bn,{date:n});if(a.orientation==="vertical")return Ie(dt,{resources:m});return Ie(hn,{config:a,date:n})}};import{Grid3x3 as xn}from"lucide-react";import{jsx as kt}from"react/jsx-runtime";var Te=({today:n,dayNumber:a,weekday:m,className:y})=>kt(h,{className:y,dayNumber:kt(i,{className:"w-auto",transitionKey:a,children:a}),today:n,weekday:m==null?void 0:kt(i,{transitionKey:m,children:m})});import{jsx as mt}from"react/jsx-runtime";var lr=({className:n})=>{let{firstDayOfWeek:a,stickyViewHeader:m,viewHeaderClassName:y,currentDate:p}=r(),v=s(p,a);return mt("div",{className:e("flex w-full gap-px bg-border border-b",m&&"sticky top-0 z-20",y,n),"data-testid":"month-header",children:v.map((C)=>{let D=C.format("ddd");return mt("div",{className:"py-2 text-center font-medium bg-background flex-1 min-w-0 flex items-center justify-center","data-testid":o.header.weekday("month",D),children:mt(i,{transitionKey:D,children:mt("span",{className:"text-sm capitalize truncate w-full block",children:D})})},D)})})};import{jsx as je,jsxs as Tn,Fragment as Nn}from"react/jsx-runtime";var kn=(n,a)=>{let m=tt(n);return Ae({resources:a,gutter:Ne({days:m,gridType:"day",renderLabel:(y)=>je(Te,{className:"flex-col-reverse",dayNumber:y.format("D"),today:l(y),weekday:y.format("ddd")})}),columnsFor:(y)=>({id:o.col.resource("month",y.id),day:void 0,days:m,gridType:"day"})})},Sn=({date:n})=>{let a=tt(n);return Tn(Nn,{children:[je(ze,{}),je("div",{className:"flex flex-1 gap-px bg-border border-b",children:a.map((m,y)=>{let p=o.listKey("resource-month-day",y),v=l(m);return je("div",{className:"flex-1 w-20 bg-background shrink-0 flex items-center justify-center flex-col",children:je(Te,{className:"flex-col-reverse",dayNumber:m.format("D"),today:v,weekday:m.format("ddd")})},p)})})]})},Hn=(n,a)=>{let m=a.resources??[];if(m.length){if(a.orientation==="vertical")return kn(n,m);return Oe({resources:m,days:tt(n),gridType:"day"})}return O(n,a.firstDayOfWeek).map((y,p)=>({id:o.listKey("week",p),columns:y.map((v)=>({id:o.col.day(v),day:v,className:"w-auto",gridType:"day"})),className:"flex-1",showDayNumber:!0}))},dr={name:"month",label:"month",icon:xn,navigationUnit:"month",layout:"horizontal",supportsResources:!0,range:(n,a)=>rt(n,a.firstDayOfWeek),columns:Hn,renderHeader:({date:n,config:a})=>{let m=a.resources??[];if(!m.length)return je(lr,{className:"h-12"});if(a.orientation==="vertical")return je(dt,{resources:m});return je(Sn,{date:n})}};import{Columns3 as jn}from"lucide-react";import{jsx as St}from"react/jsx-runtime";var cr=({days:n})=>{let{weekViewGranularity:a}=r(),m=a==="hourly";return St("div",{className:e("flex gap-px bg-border border-b",Je),children:n.map((y,p)=>{let v=l(y),C=o.listKey("resource-week-day",p);return St("div",{className:e("shrink-0 bg-background flex-1 flex items-center text-center font-medium min-w-20"),"data-testid":o.header.resource.weekDay,children:St(Te,{className:e(m?"sticky left-1/2":"w-full text-center"),dayNumber:y.format("D"),today:v,weekday:y.format("ddd")})},C)})})};import{jsx as yt,jsxs as In}from"react/jsx-runtime";var ur=({columns:n})=>{let{currentDate:a}=r();return In("div",{className:"flex h-12 gap-px bg-border",children:[yt("div",{className:e("shrink-0 z-20 bg-background sticky left-0",Me,we),children:yt("span",{className:"px-2 h-full w-full flex justify-center items-start font-medium",children:a.week()})}),n.map((m,y)=>{let p=m.day;if(!p)return null;let v=l(p),C=o.listKey("resource-week-day",m.resourceId??"",y);return yt("div",{className:e(fe,"flex flex-col items-center justify-center text-xs shrink-0 bg-background"),"data-testid":o.header.resource.timeLabel("week",p.format("HH")),children:yt(Te,{dayNumber:p.format("D"),today:v,weekday:p.format("ddd")})},C)})]})};import{jsx as Ue,jsxs as mr}from"react/jsx-runtime";var yr=({resources:n})=>{let{weekViewGranularity:a,t:m,currentDate:y}=r(),p=a==="hourly";return mr("div",{className:"flex h-12 gap-px bg-border",children:[Ue("div",{className:e("shrink-0 z-20 bg-background sticky left-0",Me,we),children:mr("span",{className:e("px-2 h-full w-full flex flex-col justify-center text-xs text-muted-foreground text-center min-w-0",p?"justify-end":"justify-center"),children:[Ue("span",{className:"truncate w-full",children:m("week")}),!p&&Ue("span",{className:"font-medium text-foreground truncate w-full",children:y.week()})]})}),n.map((v)=>Ue(Be,{className:e(fe,"bg-background border-b"),resource:v,children:Ue("div",{className:e("sticky text-sm font-medium truncate",p?"left-1/4":"left-1"),children:v.title})},o.listKey("resource-cell",v.id)))]})};import{jsx as ve,jsxs as Ye,Fragment as Bn}from"react/jsx-runtime";var pt=(n,a)=>{let m=s(n,a.firstDayOfWeek),{hiddenDays:y}=a;if(!y)return m;return m.filter((p)=>!y.has(p.day()))},ft=(n)=>(n.weekViewGranularity??"hourly")==="hourly",Pn=({date:n,config:a})=>{let{t:m,selectDate:y,openEventForm:p}=r((D)=>({t:D.t,selectDate:D.selectDate,openEventForm:D.openEventForm})),v=pt(n,a),C=String(n.week());return Ye("div",{className:"flex h-18 flex-1 gap-px bg-border","data-testid":"week-view-header",children:[ve("div",{className:e(T,"h-full shrink-0 items-center justify-center bg-background p-2 flex",we),children:Ye("div",{className:"flex flex-col items-center justify-center min-w-0 w-full",children:[ve("span",{className:"text-muted-foreground text-xs truncate w-full text-center",children:m("week")}),ve(i,{className:"font-medium truncate w-full text-center",transitionKey:C,children:C})]})}),v.map((D,V)=>{let A=l(D),J=o.listKey("week-header-day",V);return ve("div",{className:e("hover:bg-accent bg-background flex-1 min-w-0 flex flex-col justify-center cursor-pointer p-1 text-center sm:p-2 w-20 h-full"),"data-testid":o.header.weekday("week",D.format("dddd")),onClick:()=>{y(D),p({start:D})},children:ve(Te,{dayNumber:D.format("D"),today:A,weekday:D.format("ddd")})},J)})]})},Le=(n,a,m)=>at({referenceDate:n,businessHours:a.businessHours,hideNonBusinessHours:a.hideNonBusinessHours,allDates:m,resourceBusinessHours:ot(a.resources??[])}),Vn=(n,a,m)=>{let y=s(n,a.firstDayOfWeek);if(ft(a)){let p=pt(n,a);return Ae({resources:m,gutter:Ne({days:Le(n,a,y),gridType:"hour"}),columnsFor:(v)=>p.map((C)=>({id:o.col.day(C,v.id),className:fe,day:C,days:Le(C,a,y),gridType:"hour"}))})}return Ae({resources:m,gutter:Ne({days:y,gridType:"day",renderLabel:(p)=>ve(h,{dayNumber:p.format("D"),today:l(p),weekday:p.format("ddd")})}),columnsFor:(p)=>({id:o.col.resource("week",p.id),className:fe,day:void 0,days:y,gridType:"day"})})},Mn=(n,a,m)=>{let y=s(n,a.firstDayOfWeek);if(ft(a)){let p=y.map((v)=>Le(v,a));return Oe({resources:m,days:p,gridType:"hour",cellClassName:fe})}return Oe({resources:m,days:y,gridType:"day",cellClassName:fe})},On=({date:n,config:a,resources:m})=>{let y=pt(n,a),p=ft(a),v=p?m.flatMap((C)=>y.map((D)=>({day:D,resourceId:C.id}))):[];return Ye("div",{className:"flex-1 flex flex-col",children:[ve(yr,{resources:m}),p&&ve(ur,{columns:v})]})},An=({date:n,config:a})=>{let m=s(n,a.firstDayOfWeek),y=ft(a),p=y?m.flatMap((v)=>Le(v,a)):[];return Ye(Bn,{children:[ve(ze,{}),Ye("div",{className:"flex-1 flex flex-col",children:[ve(cr,{days:m}),y&&ve(ut,{hours:p,view:"week"})]})]})},Fn=(n,a)=>{let m=a.resources??[];if(m.length){if(a.orientation==="vertical")return Vn(n,a,m);return Mn(n,a,m)}let y=s(n,a.firstDayOfWeek),p=pt(n,a);return[Ne({days:Le(n,a,y),gridType:"hour",widthClassName:T}),...p.map((v)=>({id:o.col.day(v),day:v,days:Le(v,a,y),className:"flex-1 min-w-0",gridType:"hour"}))]},pr={name:"week",label:"week",icon:jn,navigationUnit:"week",layout:"vertical",supportsResources:!0,range:(n,a)=>{let m=s(n,a.firstDayOfWeek),y=m.at(0)??n,p=m.at(-1)??n;return{start:y.startOf("day"),end:p.endOf("day")}},columns:Fn,renderHeader:({date:n,config:a})=>{let m=a.resources??[];if(!m.length)return ve(Pn,{config:a,date:n});if(a.orientation==="vertical")return ve(On,{config:a,date:n,resources:m});return ve(An,{config:a,date:n,resources:m})}};import{Grid2x2 as Wn}from"lucide-react";import{useMemo as _n}from"react";import{jsx as Pe,jsxs as qe}from"react/jsx-runtime";var zn=["bg-primary","bg-blue-500","bg-green-500"],Ln=42,fr=()=>{let{currentDate:n,setView:a,getEventsForDateRange:m,t:y,firstDayOfWeek:p}=r(),v=n.year(),C=s(t(),p).map((g)=>({id:g.day().toString(),label:g.format("dd")})),D=_n(()=>{let g=d(t()),ee=d(n),S=Array.from({length:12},(le,Z)=>t().year(v).month(Z).startOf("month")),ae=S.map((le)=>{let te=s(le,p).at(0)??le;return Array.from({length:Ln},(se,de)=>te.add(de,"day"))}),oe=ae.at(0)?.at(0),ie=ae.at(-1)?.at(-1),ce=[];if(oe&&ie)ce=m(oe.startOf("day"),ie.endOf("day"));return S.map((le,Z)=>{let se=(ae.at(Z)??[]).map((ye)=>{let pe=ye.startOf("day"),ge=ye.endOf("day"),Ce=d(ye),xe=ce.filter((De)=>u(De,pe,ge));return{date:ye,dayKey:Ce,isInCurrentMonth:ye.month()===le.month(),isToday:Ce===g,isSelected:Ce===ee,eventCount:xe.length}}),de=le.endOf("month"),ue=ce.filter((ye)=>u(ye,le,de));return{date:le,name:le.format("MMMM"),eventCount:ue.length,monthKey:le.format("MM"),days:se}})},[v,n,p,m]),V=(g,ee,S)=>{S?.stopPropagation(),a(ee,g)},A=(g)=>{let ee=g===1?y("event"):y("events");return`${g} ${ee}`},J=(g)=>{let S=g.isInCurrentMonth?"":"text-muted-foreground opacity-50",ae=g.isToday?"bg-primary text-primary-foreground rounded-full":"",oe=g.isSelected&&!g.isToday?"bg-muted rounded-full font-bold":"",ie=g.eventCount>0&&!g.isToday&&!g.isSelected?"font-medium":"";return e("relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center hover:bg-accent rounded-sm transition-colors duration-200",S,ae,oe,ie)},re=(g,ee)=>e("h-[3px] w-[3px] rounded-full",ee?"bg-primary-foreground":g),ne=(g)=>{if(g===0)return"";return A(g)};return qe(c,{className:"h-full","data-testid":"year-view",children:[Pe("div",{className:"grid auto-rows-fr grid-cols-1 gap-4 p-4 sm:grid-cols-2 lg:grid-cols-3","data-testid":"year-grid",children:D.map((g)=>{let ee=g.days;return qe("div",{className:"hover:border-primary flex flex-col rounded-lg border p-3 text-left transition-all duration-200 hover:shadow-md","data-testid":o.header.year.month(g.monthKey),children:[qe(i,{className:"mb-2 flex items-center justify-between",transitionKey:o.listKey("month",g.monthKey),children:[Pe("button",{className:"text-lg font-medium hover:underline cursor-pointer","data-testid":o.header.year.month(g.monthKey,"title"),onClick:()=>V(g.date,"month"),type:"button",children:g.name}),g.eventCount>0&&Pe("span",{className:"bg-primary text-primary-foreground rounded-full px-2 py-1 text-xs","data-testid":o.header.year.month(g.monthKey,"count"),children:A(g.eventCount)})]},o.listKey("month",g.monthKey)),qe("div",{className:"grid grid-cols-7 gap-px text-[0.6rem]","data-testid":o.header.year.month(g.monthKey,"mini"),children:[C.map((S)=>Pe("div",{className:"text-muted-foreground h-3 text-center",children:S.label},o.listKey("header",g.monthKey,S.id))),ee.map((S)=>{let ae=o.header.year.day(g.date.format("YYYY-MM"),S.dayKey),oe=S.eventCount>0,ie=Math.min(S.eventCount,3),ce=zn.slice(0,ie);return qe("button",{className:J(S),"data-testid":ae,onClick:(le)=>V(S.date,"day",le),title:ne(S.eventCount),type:"button",children:[Pe("span",{className:"text-center leading-none",children:S.date.date()}),oe&&Pe("div",{className:e("absolute bottom-0 flex w-full justify-center space-x-px",S.isToday&&"bottom-px"),children:ce.map((le)=>Pe("span",{className:re(le,S.isToday)},le))})]},S.dayKey)})]})]},g.monthKey)})}),Pe(f,{className:"z-30"})]})};var vr={name:"year",label:"year",icon:Wn,navigationUnit:"year",supportsResources:!1,range:(n)=>({start:n.startOf("year"),end:n.endOf("year")}),component:fr};var Cr=[sr,pr,dr,vr];var gr=(n,a,m)=>a?.range?.(n,{firstDayOfWeek:m})??rt(n,m),Dr=({initialDate:n,initialView:a,firstDayOfWeek:m,onDateChange:y,onViewChange:p,pluginRuntime:v})=>{let[C,D]=Kn(()=>({date:t(n),view:a})),V=$n(C),A=be((Z)=>{let te={...V.current,...Z};return V.current=te,D(te),te},[]),J=be(()=>[...Cr,...v.getViews()],[v]),re=be((Z)=>J().find((te)=>te.name===Z),[J]),ne=be(()=>gr(C.date,re(C.view),m),[C,m,re]),g=be((Z)=>{let te=gr(Z.date,re(Z.view),m);y?.(Z.date,te)},[y,m,re]),ee=be((Z)=>{g(A({date:Z}))},[A,g]),S=be((Z)=>{let{date:te,view:se}=V.current,de=re(se),ue=de?.navigationStep??{amount:1,unit:de?.navigationUnit??"day"},ye=te.add(Z*ue.amount,ue.unit);g(A({date:ye}))},[A,g,re]),ae=be(()=>S(1),[S]),oe=be(()=>S(-1),[S]),ie=be(()=>g(A({date:t()})),[A,g]),ce=be((Z,te)=>{let se=A(te?{view:Z,date:te}:{view:Z});p?.(Z),g(se)},[A,p,g]),le=be((Z)=>{let te=typeof Z==="function"?Z(V.current.date):Z;A({date:te})},[A]);return Gn(()=>({currentDate:C.date,setCurrentDate:le,view:C.view,setView:ce,selectDate:ee,nextPeriod:ae,prevPeriod:oe,today:ie,getCurrentViewRange:ne,getAllViews:J}),[C,le,ce,ee,ae,oe,ie,ne,J])};import{createElement as Un,Fragment as Yn}from"react";var Er=(n)=>({transformEvents:(a,m)=>n.reduce((p,v)=>v.transformEvents?v.transformEvents(p,m):p,a).filter((p)=>u(p,m.start,m.end)),getEventManager:(a)=>n.find((m)=>m.managesEvent?.(a)),collect:(a,m)=>n.flatMap((y)=>y.contribute?.(a,m)??[]),renderSlot:(a,m)=>{let y=[];for(let p of n){let v=p.renderSlot?.(a,m);if(v!==null&&v!==void 0)y.push(Un(Yn,{key:p.name},v))}return y},getViews:()=>n.flatMap((a)=>a.views??[]),getProviders:()=>n.map((a)=>a.provider).filter((a)=>Boolean(a))});var Qn=[],Xn=[],Zn=(n,a)=>{if(!a)return N(n)??t();if(!n)return t().tz(a);if(K(n))return t.tz(n,a);return(N(n)??t()).tz(a)},Rr=(n)=>{let{events:a,firstDayOfWeek:m=0,initialView:y="month",initialDate:p,dayMaxEvents:v,businessHours:C,onEventAdd:D,onEventUpdate:V,onEventDelete:A,onDateChange:J,onViewChange:re,locale:ne,timezone:g,translations:ee,translator:S,onEventClick:ae,onCellClick:oe,disableEventClick:ie,disableCellClick:ce,resources:le,orientation:Z,weekViewGranularity:te}=n,{plugins:se=Xn}=n,de=Vt({firstDayOfWeek:m,dayMaxEvents:v,businessHours:C,locale:ne,translations:ee,translator:S,resources:le,orientation:Z,weekViewGranularity:te}),ue=hr(()=>Er(se),[se]),[ye]=qn(()=>Zn(p,g)),pe=Dr({initialDate:ye,initialView:y,firstDayOfWeek:m,onDateChange:J,onViewChange:re,pluginRuntime:ue}),ge=Ft({events:a,pluginRuntime:ue,getCurrentViewRange:pe.getCurrentViewRange,resources:de.resources??Qn,onEventAdd:D,onEventUpdate:V,onEventDelete:A}),Ce=Bt({currentDate:pe.currentDate,t:de.t,disableEventClick:ie,disableCellClick:ce,onEventClick:ae,onCellClick:oe}),{setCurrentLocale:xe}=de,{setCurrentDate:De}=pe,{setCurrentEvents:Se}=ge,me=wr(void 0);br(()=>{if(ne&&ne!==me.current)xe(ne),t.locale(ne),De((He)=>He.locale(ne)),me.current=ne},[ne,xe,De]);let Ee=wr(void 0);return br(()=>{if(g!==Ee.current){t.tz.setDefault(g);let He=(he)=>g?he.tz(g):he.local();De((he)=>He(he)),Se((he)=>he.map((Ve)=>({...Ve,start:He(Ve.start),end:He(Ve.end)}))),Ee.current=g}},[g,De,Se]),hr(()=>{let{setCurrentLocale:He,...he}=de,{getCurrentViewRange:Ve,getAllViews:Qe,...Xe}=pe,{setCurrentEvents:vt,...Ct}=ge;return{...he,...Xe,...Ct,...Ce,getViews:Qe,getEventManager:ue.getEventManager,renderSlot:ue.renderSlot,collect:ue.collect,getProviders:ue.getProviders,getEventResourceIds:We,currentRange:pe.getCurrentViewRange()}},[de,pe,ge,Ce,ue])};import{jsx as Jn}from"react/jsx-runtime";var xr=(n,a)=>n.reduceRight((m,y,p)=>Jn(y,{children:m},p),a);import{jsx as no}from"react/jsx-runtime";var to=[],ro=(n)=>{let{events:a=to,firstDayOfWeek:m=0,initialView:y="month",initialDate:p,renderEvent:v,onEventClick:C,onCellClick:D,isCellDisabled:V,getCellClassName:A,onViewChange:J,onEventAdd:re,onEventUpdate:ne,onEventDelete:g,onDateChange:ee,locale:S,timezone:ae,disableCellClick:oe,disableEventClick:ie,disableDragAndDrop:ce,dayMaxEvents:le,eventSpacing:Z=z,eventHeight:te=B,stickyViewHeader:se=!0,viewHeaderClassName:de="",headerComponent:ue,headerClassName:ye,businessHours:pe,renderEventForm:ge,onMoreEventsClick:Ce,translations:xe,translator:De,timeFormat:Se="12-hour",classesOverride:me,renderCurrentTimeIndicator:Ee,renderHour:He,hideNonBusinessHours:he=!1,hideExportButton:Ve=!1,hiddenDays:Qe,slotDuration:Xe=60,scrollTime:vt,plugins:Ct,resources:kr,renderResource:Ht,orientation:Sr,weekViewGranularity:Hr}=n,Nt=Rr({events:a,firstDayOfWeek:m,initialView:y,initialDate:p,dayMaxEvents:le,businessHours:pe,onEventAdd:re,onEventUpdate:ne,onEventDelete:g,onDateChange:ee,onViewChange:J,locale:S,timezone:ae,translations:xe,translator:De,plugins:Ct,onEventClick:C,onCellClick:D,disableEventClick:ie,disableCellClick:oe,resources:kr,orientation:Sr,weekViewGranularity:Hr});return eo(()=>{let{handleEventClick:Nr,handleDateClick:Tr,...Ir}=Nt;return{...Ir,renderEvent:v,onEventClick:Nr,onCellClick:Tr,isCellDisabled:V,getCellClassName:A,locale:S,timezone:ae,disableCellClick:oe,disableEventClick:ie,disableDragAndDrop:ce,eventSpacing:Z,eventHeight:te,stickyViewHeader:se,viewHeaderClassName:de,headerComponent:ue,headerClassName:ye,renderEventForm:ge,onMoreEventsClick:Ce,timeFormat:Se,classesOverride:me,renderCurrentTimeIndicator:Ee,renderHour:He,hideNonBusinessHours:he,hideExportButton:Ve,hiddenDays:Qe,slotDuration:Xe,scrollTime:vt,renderResource:Ht}},[Nt,v,Ht,V,A,S,ae,oe,ie,ce,Z,te,se,de,ue,ye,ge,Ce,Se,me,Ee,He,he,Ve,Qe,Xe,vt])},M=({children:n,...a})=>{let m=ro(a),y=xr(m.getProviders(),n);return no(Ze.Provider,{value:m,children:y})};
2
+ export{r,Q,i,l,s,O,o,L,z,B,P,q,I,_,E,k,H,G,W,T,U,X,Y,M};
@@ -0,0 +1,2 @@
1
+ import{t}from"./chunk-4jynmg6d.js";function N(s){if(s===void 0)return;if(t.isDayjs(s))return s;let n=t(s);return n.isValid()?n:void 0}var d=(s)=>s.format("YYYY-MM-DD"),F=(s,n)=>d(s)===d(n);function u(s,n,r){let a=s.start.isSameOrAfter(n)&&s.start.isSameOrBefore(r),o=s.end.isAfter(n)&&s.end.isSameOrBefore(r),f=s.start.isBefore(n)&&s.end.isAfter(r);return a||o||f}var S=(...s)=>s.join("-");function Z(s){let n=s.replace("#",""),r=n.length===3?n.split("").map((i)=>i+i).join(""):n;if(!/^[0-9a-fA-F]{6}$/.test(r))return"#000000";let a=Number.parseInt(r.slice(0,2),16),o=Number.parseInt(r.slice(2,4),16),f=Number.parseInt(r.slice(4,6),16);return(a*299+o*587+f*114)/1000>=128?"#000000":"#ffffff"}import{clsx as c}from"clsx";import{twMerge as p}from"tailwind-merge";function e(...s){return p(c(s))}
2
+ export{e,N,d,F,u,S,Z};
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-d7599sry.js";import*as o from"@radix-ui/react-dialog";import{XIcon as l}from"lucide-react";import{jsx as i,jsxs as n}from"react/jsx-runtime";function b({...t}){return i(o.Root,{"data-slot":"dialog",...t})}function s({...t}){return i(o.Portal,{"data-slot":"dialog-portal",...t})}function g({className:t,...a}){return i(o.Overlay,{className:e("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),"data-slot":"dialog-overlay",...a})}function R({className:t,children:a,...r}){return n(s,{"data-slot":"dialog-portal",children:[i(g,{}),n(o.Content,{className:e("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg max-h-[90%]",t),"data-slot":"dialog-content",...r,children:[a,n(o.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[i(l,{}),i("span",{className:"sr-only",children:"Close"})]})]})]})}function x({className:t,...a}){return i("div",{className:e("flex flex-col gap-2 text-center sm:text-left",t),"data-slot":"dialog-header",...a})}function A({className:t,...a}){return i("div",{className:e("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),"data-slot":"dialog-footer",...a})}function w({className:t,...a}){return i(o.Title,{className:e("text-lg leading-none font-semibold",t),"data-slot":"dialog-title",...a})}function V({className:t,...a}){return i(o.Description,{className:e("text-muted-foreground text-sm",t),"data-slot":"dialog-description",...a})}
2
+ export{b,R,x,A,w,V};
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-d7599sry.js";import*as m from"@radix-ui/react-scroll-area";import{jsx as b,jsxs as z}from"react/jsx-runtime";function c({className:t,children:r,viewPortProps:i,...n}){return z(m.Root,{className:e("relative",t),"data-slot":"scroll-area",...n,children:[b(m.Viewport,{...i,className:e("focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",i?.className),"data-slot":"scroll-area-viewport",children:r}),b(f,{}),b(m.Corner,{})]})}function f({className:t,orientation:r="vertical",...i}){return b(m.ScrollAreaScrollbar,{className:e("flex touch-none p-px transition-colors select-none",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),"data-slot":"scroll-area-scrollbar",orientation:r,...i,children:b(m.ScrollAreaThumb,{className:"bg-border relative flex-1 rounded-full","data-slot":"scroll-area-thumb"})})}import{jsx as g,jsxs as D}from"react/jsx-runtime";var h=({today:t,dayNumber:r,weekday:i,className:n,"data-testid":o})=>D("div",{className:e("flex flex-col items-center",n),"data-testid":o,"data-today":t?"true":void 0,children:[i!=null&&g("div",{className:e("w-full truncate text-center text-xs text-muted-foreground",t&&"text-primary"),children:i}),g("div",{className:e("flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-medium",t&&"bg-primary text-primary-foreground"),children:r})]});import l from"dayjs";import O from"dayjs/plugin/isSameOrAfter.js";import w from"dayjs/plugin/isSameOrBefore.js";import C from"dayjs/plugin/localeData.js";import T from"dayjs/plugin/localizedFormat.js";import I from"dayjs/plugin/minMax.js";import k from"dayjs/plugin/timezone.js";import M from"dayjs/plugin/utc.js";import V from"dayjs/plugin/weekday.js";import Y from"dayjs/plugin/weekOfYear.js";var S,B=(t,r,i)=>{let n=r.prototype,o=i.tz.setDefault;i.tz.setDefault=(s)=>(S=s,o(s));let{startOf:a,endOf:p}=n;function u(s,d){let v=s.$x?.$timezone||S;if(!v)return d;let x=i.tz(d.format("YYYY-MM-DDTHH:mm:ss"),v).utcOffset();if(d.utcOffset()!==x)return d.tz(v,!0);return d}n.startOf=function(s,d){let v=a.call(this,s,d);return u(this,v)},n.endOf=p},L=(t,r)=>{let i=r.prototype,n={isBefore:(o,a)=>o<a,isAfter:(o,a)=>o>a,isSame:(o,a)=>o===a,isSameOrBefore:(o,a)=>o<=a,isSameOrAfter:(o,a)=>o>=a};for(let[o,a]of Object.entries(n)){let p=i[o];i[o]=function(u,s){if(s===void 0&&l.isDayjs(u))return a(this.valueOf(),u.valueOf());return p.call(this,u,s)}}};l.extend(V);l.extend(Y);l.extend(O);l.extend(w);l.extend(I);l.extend(k);l.extend(M);l.extend(C);l.extend(T);l.extend(B);l.extend(L);var W=/(?:Z|[+-]\d{2}:?\d{2})$/i,F=(t)=>{let r=t.split(/[Tt\s]/).at(1);if(!r)return!1;return W.test(r)},A=(t)=>typeof t==="string"&&!F(t),N=(t)=>{let r=l(t);if(!r.isValid())return r;if(A(t))return l.tz(t);if(!S)return r;return r.tz(S)};Object.assign(N,l);var P=N;import{memo as H}from"react";import{jsx as y,jsxs as R,Fragment as q}from"react/jsx-runtime";var Z=({rangeStart:t,rangeEnd:r,now:i,axis:n="vertical",render:o,withDot:a=!0})=>{let p=i??P(),u=p.valueOf();if(!(u>=t.valueOf()&&u<r.valueOf()))return null;let d=r.diff(t,"minute"),x=p.diff(t,"minute")/d*100;if(o)return y(q,{children:o({currentTime:p,rangeStart:t,rangeEnd:r,progress:x,axis:n})});if(n==="horizontal")return R("div",{className:"absolute top-0 bottom-0 z-50 flex -translate-x-1/2 flex-col items-center pointer-events-none","data-testid":"current-time-indicator",style:{left:`${x}%`},children:[a&&y("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),y("div",{className:"w-0.5 flex-1 bg-red-500"})]});return R("div",{className:"absolute right-0 left-0 z-50 flex -translate-y-1/2 items-center pointer-events-none","data-testid":"current-time-indicator",style:{top:`${x}%`},children:[a&&y("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),y("div",{className:"h-0.5 flex-1 bg-red-500"})]})},j=H(Z);
2
+ export{c,f,h,j};
@@ -446,6 +446,26 @@ type TimeFormat = "12-hour" | "24-hour";
446
446
  */
447
447
  type SlotDuration = 15 | 30 | 60;
448
448
  /**
449
+ * Which slice of an event a `renderEvent` call is drawing.
450
+ *
451
+ * An event too long for the row it starts in is cut at the boundary and drawn
452
+ * as one bar per row, each through its own `renderEvent` call. Without knowing
453
+ * which slice it has, a custom renderer cannot tell a real end from a break —
454
+ * so it rounds both, marks neither, and two halves of one booking read as two
455
+ * bookings that happen to sit either side of a Sunday. The built-in renderer
456
+ * has always had this; a custom one had no way to ask.
457
+ *
458
+ * Named to match FullCalendar's event render hook, which gives its renderers
459
+ * the same two facts under the same names, so a renderer ported from there
460
+ * behaves the same here.
461
+ */
462
+ interface EventSegment {
463
+ /** This bar holds the event's real start, rather than resuming a cut one. */
464
+ isStart: boolean;
465
+ /** This bar holds the event's real end, rather than running past it. */
466
+ isEnd: boolean;
467
+ }
468
+ /**
449
469
  * Custom class names for calendar styling.
450
470
  * Allows users to override default styles for various calendar elements.
451
471
  */
@@ -515,8 +535,8 @@ interface CalendarProviderProps {
515
535
  events?: CalendarEvent[];
516
536
  firstDayOfWeek?: number;
517
537
  initialView?: CalendarView;
518
- initialDate?: Dayjs3;
519
- renderEvent?: (event: CalendarEvent) => ReactNode3;
538
+ initialDate?: Dayjs3 | Date | string;
539
+ renderEvent?: (event: CalendarEvent, segment: EventSegment) => ReactNode3;
520
540
  onEventClick?: (event: CalendarEvent) => void;
521
541
  onCellClick?: (info: CellInfo) => void;
522
542
  isCellDisabled?: (info: CellInfo) => boolean;
@@ -1 +1 @@
1
- import{H as b}from"../shared/chunk-b53nxddz.js";import"../shared/chunk-7vqv0k0j.js";import{jsx as q}from"react/jsx-runtime";var y=({children:g,...k})=>q(b,{dayMaxEvents:5,...k,children:g});export{y as CalendarTestProvider};
1
+ import"../shared/chunk-4jynmg6d.js";import{M}from"../shared/chunk-79d4xe20.js";import"../shared/chunk-d7599sry.js";import"../shared/chunk-w4nsrq2y.js";import"../shared/chunk-n7xt0j3a.js";import{jsx as a}from"react/jsx-runtime";var d=({children:r,...e})=>a(M,{dayMaxEvents:5,...e,children:r});export{d as CalendarTestProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilamy/calendar",
3
- "version": "2.0.3",
3
+ "version": "3.0.1",
4
4
  "description": "A full-featured React calendar component library built with Shadcn-Ui, Tailwind CSS, and TypeScript.",
5
5
  "author": "Sujeet Kc",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  "postpack": "bun scripts/postpack.ts"
71
71
  },
72
72
  "peerDependencies": {
73
- "dayjs": "^1.11.20",
73
+ "dayjs": "^1.11.23",
74
74
  "react": "^19.2.0",
75
75
  "react-dom": "^19.2.0",
76
76
  "tailwindcss": "^4.2.2",
@@ -1,2 +0,0 @@
1
- import{L as r}from"./chunk-7vqv0k0j.js";function n(e){if(e===void 0)return;if(r.isDayjs(e))return e;let t=r(e);return t.isValid()?t:void 0}var f=(...e)=>e.join("-");import{clsx as a}from"clsx";import{twMerge as s}from"tailwind-merge";function i(...e){return s(a(e))}
2
- export{i as I,n as J,f as K};
@@ -1,2 +0,0 @@
1
- import t from"dayjs";import O from"dayjs/plugin/isBetween.js";import c from"dayjs/plugin/isSameOrAfter.js";import z from"dayjs/plugin/isSameOrBefore.js";import v from"dayjs/plugin/localeData.js";import D from"dayjs/plugin/localizedFormat.js";import Y from"dayjs/plugin/minMax.js";import M from"dayjs/plugin/timezone.js";import $ from"dayjs/plugin/utc.js";import b from"dayjs/plugin/weekday.js";import h from"dayjs/plugin/weekOfYear.js";var i,J=(n,a,f)=>{let m=a.prototype,x=f.tz.setDefault;f.tz.setDefault=(r)=>{return i=r,x(r)};let{startOf:d,endOf:s}=m;function u(r,e){let o=r.$x?.$timezone||i;if(!o)return e;let l=f.tz(e.format("YYYY-MM-DDTHH:mm:ss"),o).utcOffset();if(e.utcOffset()!==l)return e.tz(o,!0);return e}m.startOf=function(r,e){let o=d.call(this,r,e);return u(this,o)},m.endOf=s};t.extend(b);t.extend(h);t.extend(c);t.extend(z);t.extend(O);t.extend(Y);t.extend(M);t.extend($);t.extend(v);t.extend(D);t.extend(J);var p=(...n)=>{return t.tz(...n)};Object.assign(p,t);var g=p;
2
- export{g as L};
@@ -1,2 +0,0 @@
1
- import{L as a5}from"./chunk-7vqv0k0j.js";import v from"dayjs";import h2 from"dayjs/plugin/isBetween.js";import D2 from"dayjs/plugin/isSameOrAfter.js";import E2 from"dayjs/plugin/isSameOrBefore.js";import x2 from"dayjs/plugin/localeData.js";import m2 from"dayjs/plugin/localizedFormat.js";import p2 from"dayjs/plugin/minMax.js";import v2 from"dayjs/plugin/timezone.js";import g2 from"dayjs/plugin/utc.js";import y2 from"dayjs/plugin/weekday.js";import c2 from"dayjs/plugin/weekOfYear.js";var A5,l2=(Q,q,J)=>{let $=q.prototype,X=J.tz.setDefault;J.tz.setDefault=(z)=>{return A5=z,X(z)};let{startOf:Z,endOf:P}=$;function K(z,G){let _=z.$x?.$timezone||A5;if(!_)return G;let V=J.tz(G.format("YYYY-MM-DDTHH:mm:ss"),_).utcOffset();if(G.utcOffset()!==V)return G.tz(_,!0);return G}$.startOf=function(z,G){let _=Z.call(this,z,G);return K(this,_)},$.endOf=P};v.extend(y2);v.extend(c2);v.extend(D2);v.extend(E2);v.extend(h2);v.extend(p2);v.extend(v2);v.extend(g2);v.extend(x2);v.extend(m2);v.extend(l2);var L5=(...Q)=>{return v.tz(...Q)};Object.assign(L5,v);var f=L5;import{useContext as i2}from"react";import{createContext as u2}from"react";var b0=u2(void 0);var d2=[];function R(Q){let q=i2(b0);if(!q)throw Error("useSmartCalendarContext must be used within a CalendarProvider");return Q?Q(q):q}function p9(){let Q=R();return{currentDate:Q.currentDate,currentRange:Q.currentRange,view:Q.view,events:Q.events,rawEvents:Q.rawEvents,isEventFormOpen:Q.isEventFormOpen,selectedEvent:Q.selectedEvent,selectedDate:Q.selectedDate,firstDayOfWeek:Q.firstDayOfWeek,resources:Q.resources??d2,orientation:Q.orientation,setCurrentDate:Q.setCurrentDate,selectDate:Q.selectDate,setView:Q.setView,nextPeriod:Q.nextPeriod,prevPeriod:Q.prevPeriod,today:Q.today,addEvent:Q.addEvent,updateEvent:Q.updateEvent,deleteEvent:Q.deleteEvent,openEventForm:Q.openEventForm,closeEventForm:Q.closeEventForm,onEventClick:Q.onEventClick,renderCurrentTimeIndicator:Q.renderCurrentTimeIndicator,getEventsForResource:Q.getEventsForResource,businessHours:Q.businessHours,t:Q.t,timeFormat:Q.timeFormat,timezone:Q.timezone,currentLocale:Q.currentLocale,getEventsForDateRange:Q.getEventsForDateRange,applyScopedEdit:Q.applyScopedEdit,applyScopedDelete:Q.applyScopedDelete,getEventManager:Q.getEventManager,renderSlot:Q.renderSlot,collect:Q.collect,getViews:Q.getViews}}var B5={today:"Today",create:"Create",new:"New",update:"Update",delete:"Delete",cancel:"Cancel",export:"Export",previous:"Previous",next:"Next",event:"Event",events:"Events",newEvent:"New Event",title:"Title",description:"Description",location:"Location",allDay:"All day",startDate:"Start Date",endDate:"End Date",startTime:"Start Time",searchTime:"Search time...",endTime:"End Time",color:"Color",createEvent:"Create Event",editEvent:"Edit Event",addNewEvent:"Add a new event to your calendar",editEventDetails:"Edit your event details",eventTitlePlaceholder:"Event title",eventDescriptionPlaceholder:"Event description (optional)",eventLocationPlaceholder:"Event location (optional)",repeat:"Repeat",repeats:"Repeats",customRecurrence:"Custom recurrence",frequency:"Frequency",everyWeekday:"Every weekday",weeklyOn:"Weekly on",monthlyOnDay:"Monthly on day",monthlyOnThe:"Monthly on the",first:"first",second:"second",third:"third",fourth:"fourth",last:"last",daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly",interval:"Interval",repeatOn:"Repeat on",never:"Never",count:"Count",every:"Every",ends:"Ends",after:"After",occurrences:"occurrences",on:"On",editRecurringEvent:"Edit recurring event",deleteRecurringEvent:"Delete recurring event",editRecurringEventQuestion:"is a recurring event. How would you like to edit it?",deleteRecurringEventQuestion:"is a recurring event. How would you like to delete it?",thisEvent:"This event",thisEventDescription:"Only change this specific occurrence",thisAndFollowingEvents:"This and following events",thisAndFollowingEventsDescription:"Edit this and all future occurrences",allEvents:"All events",allEventsDescription:"Edit the entire recurring series",onlyChangeThis:"Only change this specific occurrence",changeThisAndFuture:"Change this and all future occurrences",changeEntireSeries:"Change the entire recurring series",onlyDeleteThis:"Only delete this specific occurrence",deleteThisAndFuture:"Delete this and all future occurrences",deleteEntireSeries:"Delete the entire recurring series",month:"Month",week:"Week",day:"Day",year:"Year",agenda:"Agenda",agendaNoEvents:"No upcoming events",more:"more",resources:"Resources",resource:"Resource",selectResource:"Select a resource",time:"Time",date:"Date",noResourcesVisible:"No resources visible",addResourcesOrShowExisting:"Add resources or show existing ones"};import{useMemo as O9}from"react";import{useEffect as M2,useMemo as R2,useRef as S2}from"react";import{useMemo as N5,useState as o2}from"react";var _5=1,F5=24,U5=24,V5=4,O5="bg-[color-mix(in_oklch,var(--background),var(--foreground)_3%)] text-muted-foreground pointer-events-none",W5={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6},w0="h-12",y9="h-24";var M5=({firstDayOfWeek:Q,dayMaxEvents:q=V5,businessHours:J,locale:$,translations:X,translator:Z,resources:P,orientation:K="horizontal",weekViewGranularity:z="hourly"})=>{let[G,_]=o2($||"en"),V=N5(()=>{if(Z)return Z;let W=X||B5;return(A)=>W[A]||A},[X,Z]);return N5(()=>({firstDayOfWeek:Q,dayMaxEvents:q,businessHours:J,currentLocale:G,setCurrentLocale:_,t:V,resources:P,orientation:K,weekViewGranularity:z}),[Q,q,J,G,V,P,K,z])};import{useCallback as d,useEffect as r2,useMemo as R5,useRef as n2,useState as a2}from"react";var _0=(Q)=>{if(Q.resourceIds)return Q.resourceIds;if(Q.resourceId!==void 0)return[Q.resourceId];return[]};function K0(Q,q){return Q.filter((J)=>_0(J).includes(q))}function j0(Q,q,J){let $=Q.start.isSameOrAfter(q)&&Q.start.isSameOrBefore(J),X=Q.end.isSameOrAfter(q)&&Q.end.isSameOrBefore(J),Z=Q.start.isBefore(q)&&Q.end.isAfter(J);return $||X||Z}var S5=(Q)=>!Array.isArray(Q),H5=(Q,{onEventUpdate:q,onEventAdd:J,onEventDelete:$,setCurrentEvents:X})=>{for(let Z of Q.updated)q?.(Z);for(let Z of Q.added)J?.(Z);for(let Z of Q.deleted)$?.(Z);X(Q.events)},I5=({events:Q,pluginRuntime:q,getCurrentViewRange:J,resources:$,onEventAdd:X,onEventUpdate:Z,onEventDelete:P})=>{let[K,z]=a2(Q),G=n2(Q),_=d((B,O)=>q.transformEvents(K,{start:B,end:O}),[K,q]),V=R5(()=>{let{start:B,end:O}=J();return _(B,O)},[_,J]);r2(()=>{if(Q!==G.current)z(Q),G.current=Q},[Q]);let W=d((B)=>{z((O)=>[...O,B]),X?.(B)},[X]),A=d((B,O)=>{let S=K.find((w)=>w.id===B);if(!S)return;let b={...S,...O};z((w)=>w.map((C)=>C.id===B?b:C)),Z?.(b)},[K,Z]),M=d((B,O,S)=>{let b=q.getEventManager(B);if(!b?.applyEdit)return;let w=b.applyEdit({event:B,updates:O,currentEvents:K,scope:S});if(S5(w)){H5(w,{onEventUpdate:Z,onEventAdd:X,onEventDelete:P,setCurrentEvents:z});return}Z?.({...B,...O}),z(w)},[K,X,Z,P,q]),Y=d((B,O)=>{let S=q.getEventManager(B);if(!S?.applyDelete)return;let b=S.applyDelete({event:B,currentEvents:K,scope:O});if(S5(b)){H5(b,{onEventUpdate:Z,onEventAdd:X,onEventDelete:P,setCurrentEvents:z});return}P?.(B),z(b)},[K,X,Z,P,q]),N=d((B)=>{let O=K.find((S)=>S.id===B);if(!O)return;z((S)=>S.filter((b)=>b.id!==B)),P?.(O)},[K,P]),U=d((B)=>K0(V,B),[V]),H=d((B)=>V.filter((O)=>_0(O).some((S)=>B.includes(S))),[V]),I=d((B)=>{if(B===void 0)return;return $.find((O)=>O.id===B)},[$]),T=d((B)=>{return Boolean(B.resourceIds&&B.resourceIds.length>1)},[]);return R5(()=>({events:V,rawEvents:K,setCurrentEvents:z,getEventsForDateRange:_,addEvent:W,updateEvent:A,deleteEvent:N,applyScopedEdit:M,applyScopedDelete:Y,getEventsForResource:U,getEventsForResources:H,getResourceById:I,isEventCrossResource:T}),[V,K,_,W,A,N,M,Y,U,H,I,T])};import{useCallback as F0,useMemo as s2,useState as a0}from"react";var t2=(Q)=>Q,T5=({currentDate:Q,t:q,disableEventClick:J,disableCellClick:$,onEventClick:X,onCellClick:Z})=>{let[P,K]=a0(!1),[z,G]=a0(null),[_,V]=a0(null),W=F0((U={})=>{let{start:H,end:I,resourceId:T,resource:B,allDay:O}=U;if(H)V(H);let S=H??Q;G(t2({title:q("newEvent"),start:S,end:I??S.add(1,"hour"),resourceId:T??B?.id,description:"",allDay:O??!1})),K(!0)},[Q,q]),A=F0(()=>{V(null),G(null),K(!1)},[]),M=F0((U)=>{G(U),K(!0)},[]),Y=F0((U)=>{if(J)return;if(X)X(U);else M(U)},[J,X,M]),N=F0((U)=>{if($)return;if(Z)Z(U);else W(U)},[Z,$,W]);return s2(()=>({isEventFormOpen:P,selectedEvent:z,selectedDate:_,setIsEventFormOpen:K,setSelectedEvent:G,setSelectedDate:V,openEventForm:W,closeEventForm:A,handleEventClick:Y,handleDateClick:N}),[P,z,_,W,A,Y,N])};import{useCallback as c,useMemo as z9,useRef as A9,useState as L9}from"react";import{clsx as e2}from"clsx";import{twMerge as QQ}from"tailwind-merge";function L(...Q){return QQ(e2(Q))}import{Square as gQ}from"lucide-react";import{jsx as qQ}from"react/jsx-runtime";var k=({children:Q,transitionKey:q,delay:J=0,className:$,direction:X="vertical","data-testid":Z,ref:P,style:K,...z})=>{return qQ("div",{className:L("inline-block w-full animate-in fade-in fill-mode-backwards duration-500 ease-in-out",X==="horizontal"?"slide-in-from-right-2.5":"slide-in-from-top-2.5",$),"data-testid":Z,ref:P,style:{animationDelay:`${J}s`,...K},...z,children:Q},q)};k.displayName="AnimatedSection";import{jsx as w5,Fragment as b5}from"react/jsx-runtime";var f0=({date:Q})=>{let{renderHour:q,timeFormat:J}=R();if(q)return w5(b5,{children:q(Q)});return w5(b5,{children:Q.format(J==="12-hour"?"h A":"H")})};function h(Q){return Q.isSame(f(),"day")}function D(Q){return Q.format("YYYY-MM-DD")}function m(Q,q){let J=Q.startOf("week").day(q),$=Q.isBefore(J)?J.subtract(1,"week"):J;return Array.from({length:7},(X,Z)=>$.add(Z,"day"))}function s0(Q,q){let J=Q.startOf("month"),X=m(J,q).at(0)??J;return Array.from({length:6},(Z,P)=>{let K=X.add(P,"week");return m(K,q)})}function k0(Q){let q=Q.daysInMonth(),J=Q.startOf("month");return Array.from({length:q},($,X)=>J.add(X,"day"))}function j5({referenceDate:Q=f(),length:q=24}={}){let J=Q.startOf("day");return Array.from({length:q},($,X)=>J.hour(X).minute(0).second(0).millisecond(0))}var C0=(Q,q)=>{let J=s0(Q,q),$=J.at(0)?.at(0)??Q,X=J.at(-1)?.at(-1)??Q;return{start:$.startOf("day"),end:X.endOf("day")}};var G0=(Q)=>String(Q).padStart(2,"0"),JQ=(Q)=>typeof Q==="number"?G0(Q):Q,F={col:{time:"time-col",date:"date-col",day:(Q,q)=>{let J=`day-col-${D(Q)}`;return q!=null?`${J}-resource-${q}`:J},resource:(Q,q)=>`${Q}-col-resource-${q}`,allDay:(Q,q)=>`all-day-col-${D(Q)}-${q}`},cell:{day:(Q,q,J=0)=>{let $=D(Q);return q!=null?`day-cell-${$}-${G0(q)}-${G0(J)}`:`day-cell-${$}`},verticalTime:(Q)=>`vertical-time-${G0(Q)}`,vertical:(Q,q,J,$)=>{let X=`vertical-cell-${D(Q)}-${G0(q)}-${G0(J)}`;return $!=null?`${X}-resource-${$}`:X}},container:{vertical:{col:(Q)=>`vertical-col-${Q}`},horizontal:{row:(Q)=>`horizontal-row-${Q}`,rowLabel:(Q)=>`horizontal-row-label-${Q}`,event:(Q)=>`horizontal-event-${Q}`},eventsLayer:(Q,q)=>`${Q}-events-${q}`},header:{resource:{weekDay:"resource-week-day-header",columnsHeader:"resource-columns-header",monthDay:(Q)=>`resource-month-header-${Q.toISOString()}`,timeLabel:(Q,q)=>`resource-${Q}-time-label-${JQ(q)}`},weekday:(Q,q)=>`${Q}-header-weekday-${q.toLowerCase()}`,week:{day:(Q)=>`week-header-day-${Q.toISOString()}`,hour:(Q,q)=>`week-header-hour-${Q.toISOString()}-${q}`,resource:(Q)=>`week-header-resource-${Q}`},year:{month:(Q,q)=>q?`year-month-${q}-${Q}`:`year-month-${Q}`,day:(Q,q)=>`year-day-${Q}-${q}`}},allDayRow:(Q)=>`allday-row-${Q??"main"}`,listKey:(...Q)=>Q.join("-"),dayNumber:(Q)=>h(Q)?"day-number-today":`day-number-${Q.format("D")}`,timePicker:(Q)=>`time-picker-${Q??""}`,droppable:{dayCell:(Q,q)=>{let J=Q.toISOString(),$=q?.allDay?"-allday":"",X=q?.resourceId!=null?`-resource-${q.resourceId}`:"";return`drop-day-cell-${J}${$}${X}`}}};import{jsx as f5}from"react/jsx-runtime";var Z0="w-16 min-w-16 max-w-16",k5="w-[calc(100%-4rem)]",t0="w-10 sm:w-16 min-w-10 sm:min-w-16 max-w-10 sm:max-w-16",l="shadow-[1px_0_0_0_color-mix(in_oklch,var(--background),var(--foreground)_10%)]",e=({days:Q,gridType:q,renderLabel:J,widthClassName:$=Z0})=>({id:q==="hour"?F.col.time:F.col.date,day:void 0,days:Q,className:L("shrink-0",$,"sticky left-0 bg-background z-20",l),gridType:q,noEvents:!0,renderCell:(X)=>f5("div",{className:"text-muted-foreground p-2 text-right text-[10px] sm:text-xs flex flex-col items-center",children:J?J(X):f5(f0,{date:X})})});var e0=(Q,q)=>{if(!q)return!0;let J=!1;return D0(q,{date:Q,onMatch:()=>{J=!0}}),J},$Q=/^(\d{1,2}):(\d{2})$/,h0=(Q,q)=>{if(typeof Q==="number")return Math.round(Q)*60;if(typeof Q==="string"){let J=Q.match($Q);if(J){let $=Number(J[1]),X=Number(J[2]),Z=$*60+X<=1440;if(X<=59&&Z)return $*60+X}}return q*60},C5=({date:Q,hour:q,minute:J=0,durationMinutes:$,businessHours:X})=>{if(!X)return!0;if(q===void 0)return e0(Q,X);let Z=!1,P=q*60+J;return D0(X,{date:Q,onMatch:(K)=>{let z=h0(K.startTime,9),G=h0(K.endTime,17),_=P>=z,V=$?P+$<=G:P<G;if(_&&V)Z=!0}}),Z},D0=(Q,q)=>{let{date:J,onMatch:$}=q;if(!Q)return;let X=Array.isArray(Q)?Q:[Q];for(let Z of X)if(J&&Z.daysOfWeek){let P=J.day();if(Z.daysOfWeek.some((K)=>W5[K]===P))$(Z)}else $(Z)},h5=(Q)=>{let{allDates:q,businessHours:J,resourceBusinessHours:$=[],hideNonBusinessHours:X}=Q,Z=24,P=0,K=!1,z=(_)=>{K=!0,Z=Math.min(Z,h0(_.startTime,9)/60),P=Math.max(P,h0(_.endTime,17)/60)},G=(_)=>{D0(J,{date:_,onMatch:z});for(let V of $)D0(V,{date:_,onMatch:z})};for(let _ of q)G(_);if(!K&&X){if(G(),!K)Z=9,P=17,K=!0}return{minStart:Z,maxEnd:P,hasBusinessHours:K}};function E0(Q){return Q.flatMap((q)=>q.businessHours?[q.businessHours]:[])}function x0({referenceDate:Q,businessHours:q,hideNonBusinessHours:J,allDates:$=[Q],resourceBusinessHours:X=[]}){let Z=j5({referenceDate:Q}),P=Boolean(q)||X.length>0;if(!(J&&P))return Z;let{minStart:z,maxEnd:G,hasBusinessHours:_}=h5({allDates:$,businessHours:q,resourceBusinessHours:X,hideNonBusinessHours:J});if(!_)return Z;if(z>=G)return[];let V=Math.floor(z),W=Math.ceil(G);return Z.filter((A)=>{let M=A.hour();return M>=V&&M<W})}import{memo as XQ}from"react";import{jsx as D5}from"react/jsx-runtime";var ZQ=({className:Q})=>{let{t:q}=R();return D5("div",{className:L("w-16 shrink-0 sticky left-0 bg-background z-20 flex items-center justify-center px-1 text-xs text-muted-foreground",l,Q),children:D5("span",{className:"truncate",children:q("allDay")})})},m0=XQ(ZQ);import{memo as mQ}from"react";import{memo as e5,useMemo as DQ}from"react";import{useMemo as q5}from"react";var PQ=(Q,q)=>{let J=Q.filter((P)=>P.end.diff(P.start,q)>0),$=Q.filter((P)=>P.end.diff(P.start,q)===0),X=[...J].sort((P,K)=>{let z=P.start.diff(K.start);if(z!==0)return z;return K.end.diff(K.start)-P.end.diff(P.start)}),Z=[...$].sort((P,K)=>P.start.diff(K.start));return{sortedMultiUnit:X,sortedSingleUnit:Z}},E5=(Q,{firstUnit:q,lastUnit:J,unitCount:$,gridType:X})=>{let Z=f.max(Q.start.startOf(X),q),P=X==="hour"?Q.end.subtract(1,"minute"):Q.end,K=f.min(P.startOf(X),J);return{startCol:Math.max(0,Z.diff(q,X)),endCol:Math.min($-1,K.diff(q,X)),isTruncatedStart:Q.start.startOf(X).isBefore(q),isTruncatedEnd:Q.end.startOf(X).isAfter(J)}},Q5=(Q,q,J)=>{for(let $=0;$<Q.length;$++){let X=!0;for(let Z=q;Z<=J;Z++)if(Q[$][Z]){X=!1;break}if(X)return $}return-1},x5=({days:Q,events:q,dayMaxEvents:J,gridType:$="day"})=>{let X=Q.at(0),Z=Q.at(-1);if(!X||!Z)return[];let P={firstUnit:$==="hour"?X.startOf("hour"):X.startOf("day"),lastUnit:$==="hour"?Z.endOf("hour"):Z.endOf("day"),unitCount:Q.length,gridType:$},{sortedMultiUnit:K,sortedSingleUnit:z}=PQ(q,$),G=Array.from({length:J},()=>Array.from({length:P.unitCount},()=>!1)),_=[],V=({row:W,startCol:A,endCol:M,event:Y,isTruncatedStart:N,isTruncatedEnd:U})=>{for(let I=A;I<=M;I++)G[W][I]=!0;let H=M-A+1;_.push({kind:"horizontal",event:Y,left:A/P.unitCount*100,width:H/P.unitCount*100,row:W,isTruncatedStart:N,isTruncatedEnd:U})};for(let W of K){let A=E5(W,P),M=Q5(G,A.startCol,A.endCol);if(M!==-1){V({row:M,event:W,...A});continue}for(let Y=A.startCol+1;Y<=A.endCol;Y++){let N=Q5(G,Y,A.endCol);if(N!==-1){V({row:N,startCol:Y,endCol:A.endCol,event:W,isTruncatedStart:!0,isTruncatedEnd:A.isTruncatedEnd});break}}}for(let W of z){let M=E5(W,P).startCol,Y=Q5(G,M,M);if(Y!==-1)V({row:Y,startCol:M,endCol:M,event:W,isTruncatedStart:!1,isTruncatedEnd:!1})}return _};var J5=({days:Q,allDay:q,resourceId:J,gridType:$})=>{let{getEventsForDateRange:X,dayMaxEvents:Z}=R(),P=Q.at(0),K=Q.at(-1),z=P?.startOf("day"),G=K?.endOf("day"),_=q5(()=>{if(!z||!G)return[];let A=X(z,G);if(J)A=K0(A,J);if(q)A=A.filter((M)=>Boolean(M.allDay));return A},[X,z,G,J,q]),V=q5(()=>{let A=new Map;for(let M of Q){let Y=D(M),N=M.startOf("day"),U=M.endOf("day"),H=_.filter((I)=>j0(I,N,U));A.set(Y,H)}return A},[Q,_]);return{positionedEvents:q5(()=>{return x5({days:Q,events:_,dayMaxEvents:Z,gridType:$})},[Q,Z,_,$]),dayEventsMap:V}};import{jsx as m5,jsxs as YQ}from"react/jsx-runtime";var y=({today:Q,dayNumber:q,weekday:J,className:$,"data-testid":X})=>{return YQ("div",{className:L("flex flex-col items-center",$),"data-testid":X,"data-today":Q?"true":void 0,children:[J!=null&&m5("div",{className:L("w-full truncate text-center text-xs text-muted-foreground",Q&&"text-primary"),children:J}),m5("div",{className:L("flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-medium",Q&&"bg-primary text-primary-foreground"),children:q})]})};import RQ,{memo as SQ,useMemo as d5}from"react";import{useMemo as KQ}from"react";var p5=(Q)=>{let{businessHours:q,getResourceById:J}=R(($)=>({businessHours:$.businessHours,getResourceById:$.getResourceById}));return KQ(()=>{if(Q!=null){let $=J(Q);if($?.businessHours)return $.businessHours}return q},[Q,J,q])};import*as E from"@radix-ui/react-dialog";import{XIcon as GQ}from"lucide-react";import{jsx as o,jsxs as $5}from"react/jsx-runtime";function v5({...Q}){return o(E.Root,{"data-slot":"dialog",...Q})}function zQ({...Q}){return o(E.Portal,{"data-slot":"dialog-portal",...Q})}function AQ({className:Q,...q}){return o(E.Overlay,{className:L("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",Q),"data-slot":"dialog-overlay",...q})}function g5({className:Q,children:q,...J}){return $5(zQ,{"data-slot":"dialog-portal",children:[o(AQ,{}),$5(E.Content,{className:L("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg max-h-[90%]",Q),"data-slot":"dialog-content",...J,children:[q,$5(E.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o(GQ,{}),o("span",{className:"sr-only",children:"Close"})]})]})]})}function y5({className:Q,...q}){return o("div",{className:L("flex flex-col gap-2 text-center sm:text-left",Q),"data-slot":"dialog-header",...q})}function uq({className:Q,...q}){return o("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",Q),"data-slot":"dialog-footer",...q})}function c5({className:Q,...q}){return o(E.Title,{className:L("text-lg leading-none font-semibold",Q),"data-slot":"dialog-title",...q})}function iq({className:Q,...q}){return o(E.Description,{className:L("text-muted-foreground text-sm",Q),"data-slot":"dialog-description",...q})}import{useImperativeHandle as VQ,useState as l5}from"react";import{useDraggable as LQ}from"@dnd-kit/core";import{memo as BQ}from"react";import{jsx as U0,jsxs as UQ}from"react/jsx-runtime";var _Q=(Q,q)=>{if(Q&&q)return"rounded-none";if(Q)return"rounded-r-md rounded-l-none";if(q)return"rounded-l-md rounded-r-none";return"rounded-md"};function FQ({elementId:Q,event:q,className:J,style:$,disableDrag:X=!1,isTruncatedStart:Z=!1,isTruncatedEnd:P=!1}){let{onEventClick:K,renderEvent:z,disableEventClick:G,disableDragAndDrop:_}=R(),{attributes:V,listeners:W,setNodeRef:A,isDragging:M}=LQ({id:Q,data:{event:q,type:"calendar-event"},disabled:X||_}),Y=()=>{return UQ("div",{className:L(q.backgroundColor||"bg-blue-500",q.color||"text-white","h-full w-full px-1 border-[1.5px] border-card text-left overflow-clip relative",_Q(Z,P)),style:{backgroundColor:q.backgroundColor,color:q.color},children:[Z&&U0("div",{className:"absolute left-0 top-0 bottom-0 w-0.5 bg-foreground/25"}),U0("p",{className:L("text-[10px] font-semibold sm:text-xs mt-0.5",Z&&"pl-1",P&&"pr-1"),children:q.title}),P&&U0("div",{className:"absolute right-0 top-0 bottom-0 w-0.5 bg-foreground/25"})]})},N=X||_;return U0(k,{className:L("truncate h-full w-full",N?G?"cursor-default":"cursor-pointer":"cursor-grab",M&&!N&&"cursor-grabbing shadow-lg",J),onClick:(T)=>{T.stopPropagation(),K(q)},ref:A,style:$,transitionKey:Q,...V,...W,children:z?z(q):U0(Y,{})})}var p0=BQ(FQ,(Q,q)=>{return Q.elementId===q.elementId&&Q.disableDrag===q.disableDrag&&Q.className===q.className&&Q.event===q.event&&Q.isTruncatedStart===q.isTruncatedStart&&Q.isTruncatedEnd===q.isTruncatedEnd});import{jsx as V0,jsxs as OQ}from"react/jsx-runtime";var u5=({ref:Q})=>{let[q,J]=l5(!1),[$,X]=l5(null),{eventHeight:Z}=R();return VQ(Q,()=>({open:()=>J(!0),close:()=>J(!1),setSelectedDayEvents:(P)=>X(P)})),V0(v5,{onOpenChange:J,open:q,children:OQ(g5,{className:"max-h-[80vh] max-w-md overflow-y-auto",children:[V0(y5,{children:V0(c5,{children:$?.day.format("MMMM D, YYYY")})}),V0("div",{className:"mt-4 space-y-3",children:$?.events.map((P)=>{return V0(p0,{className:"relative my-1",elementId:`all-events-dialog-event-${P.id}`,event:P,style:{height:`${Z}px`}},P.id)})})]})})};import{useDroppable as WQ}from"@dnd-kit/core";import{jsx as MQ}from"react/jsx-runtime";function NQ(Q,q,J){let $=Q.hour(q??0).minute(J??0);if(q!==void 0&&J!==void 0)return{start:$,end:$.minute(J+15)};if(q!==void 0)return{start:$,end:$.hour(q+1).minute(0)};return{start:$,end:$.hour(23).minute(59)}}function i5({id:Q,type:q,date:J,hour:$,minute:X,resourceId:Z,allDay:P,children:K,className:z,style:G,"data-testid":_,disabled:V=!1}){let{onCellClick:W,isCellDisabled:A,getCellClassName:M,getResourceById:Y,disableDragAndDrop:N,disableCellClick:U,classesOverride:H,view:I}=R(),{start:T,end:B}=NQ(J,$,X),O=Y?.(Z),S={start:T,end:B,resource:O,allDay:P},b=V||Boolean(A?.(S)),w=U||b,{isOver:C,setNodeRef:n}=WQ({id:Q,data:{type:q,date:J,hour:$,minute:X,resourceId:Z,allDay:P},disabled:N||b}),a=(j)=>{if(j.stopPropagation(),w)return;W(S)},s=C&&!N&&!b,i=H?.disabledCell||O5,q0=M?.(S);return MQ("div",{className:L("droppable-cell",z,q0,s&&"bg-accent",w?"cursor-default":"cursor-pointer",b&&i),"data-all-day":P?"true":void 0,"data-disabled":b.toString(),"data-end":B.toISOString(),"data-resource-id":Z,"data-start":T.toISOString(),"data-testid":_,"data-view":I,onClick:a,ref:n,style:G,children:K})}import{jsx as v0,jsxs as g0,Fragment as o5}from"react/jsx-runtime";var HQ=({day:Q,hour:q,minute:J,slotDurationMinutes:$=60,className:X="",resourceId:Z,gridType:P="day",shouldRenderEvents:K=!0,allDay:z=!1,precomputedEvents:G,"data-testid":_,showDayNumber:V=!1,children:W})=>{let A=RQ.useRef(null),{dayMaxEvents:M=0,getEventsForDateRange:Y,currentDate:N,t:U,eventSpacing:H,eventHeight:I,onMoreEventsClick:T}=R(),B=p5(Z),O=d5(()=>{if(!K)return[];if(G)return G;let j=Y(Q.startOf(P),Q.endOf(P));if(z)j=j.filter((g)=>g.allDay);if(Z)return K0(j,Z);return j},[G,Q,Z,Y,P,K,z]),S=(j,g)=>{if(T){T(j,g);return}A.current?.setSelectedDayEvents({day:j,events:g}),A.current?.open()},b=Q.month()===N.month(),w=O.length-M,C=w>0,n=d5(()=>{if(P==="hour")return C5({date:Q,hour:Q.hour(),minute:Q.minute(),durationMinutes:$,businessHours:B});return e0(Q,B)},[P,Q,$,B]),a=F.cell.day(Q,Q.format("HH"),Q.format("mm")),s=F.cell.day(Q),i=P==="hour"?a:s,q0=F.droppable.dayCell(Q,{allDay:z,resourceId:Z});return g0(o5,{children:[v0(i5,{allDay:z,className:L("cursor-pointer overflow-clip p-1 bg-background hover:bg-accent min-h-[60px] relative min-w-0",X),"data-testid":_||i,date:Q,disabled:!n||!b,hour:q,id:q0,minute:J,resourceId:Z,type:"day-cell",children:g0("div",{className:"flex flex-col h-full w-full","data-testid":"grid-cell-content",style:{gap:`${H}px`},children:[V&&v0(y,{className:"items-start","data-testid":F.dayNumber(Q),dayNumber:Q.format("D"),today:h(Q)}),K&&g0(o5,{children:[O.slice(0,M).map((j,g)=>v0("div",{className:"w-full shrink-0","data-testid":j?.title,style:{height:`${I}px`}},F.listKey("empty",g,j.id))),C&&g0("div",{className:"text-muted-foreground hover:text-foreground cursor-pointer text-[10px] whitespace-nowrap sm:text-xs shrink-0 mt-1",onClick:(j)=>{j.stopPropagation(),S(Q,O)},onKeyDown:(j)=>{if(j.key==="Enter"||j.key===" ")j.preventDefault(),j.stopPropagation(),S(Q,O)},role:"button",tabIndex:0,children:["+",w," ",U("more")]})]}),W]})}),v0(u5,{ref:A})]})},X5=SQ(HQ);import{jsx as r5}from"react/jsx-runtime";var z0=({resource:Q,className:q,children:J,"data-testid":$})=>{let{renderResource:X}=R();return r5("div",{className:L("flex items-center justify-center p-2",q),"data-testid":$,style:{color:Q.color,backgroundColor:Q.backgroundColor},children:X?X(Q):J??r5("div",{className:"text-sm font-medium truncate",children:Q.title})})};import{memo as kQ}from"react";import{memo as IQ}from"react";import{jsx as O0,jsxs as n5,Fragment as bQ}from"react/jsx-runtime";var TQ=({rangeStart:Q,rangeEnd:q,now:J,axis:$="vertical",render:X,withDot:Z=!0})=>{let P=J??a5(),K=P.valueOf();if(!(K>=Q.valueOf()&&K<q.valueOf()))return null;let G=q.diff(Q,"minute"),V=P.diff(Q,"minute")/G*100;if(X)return O0(bQ,{children:X({currentTime:P,rangeStart:Q,rangeEnd:q,progress:V,axis:$})});if($==="horizontal")return n5("div",{className:"absolute top-0 bottom-0 z-50 flex -translate-x-1/2 flex-col items-center pointer-events-none","data-testid":"current-time-indicator",style:{left:`${V}%`},children:[Z&&O0("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),O0("div",{className:"w-0.5 flex-1 bg-red-500"})]});return n5("div",{className:"absolute right-0 left-0 z-50 flex -translate-y-1/2 items-center pointer-events-none","data-testid":"current-time-indicator",style:{top:`${V}%`},children:[Z&&O0("div",{className:"size-2 shrink-0 rounded-full bg-red-500"}),O0("div",{className:"h-0.5 flex-1 bg-red-500"})]})},s5=IQ(TQ);import{memo as wQ}from"react";import{jsx as fQ}from"react/jsx-runtime";var jQ=({rangeStart:Q,rangeEnd:q,now:J,resource:$,axis:X="vertical",withDot:Z})=>{let{renderCurrentTimeIndicator:P,view:K}=R((G)=>({renderCurrentTimeIndicator:G.renderCurrentTimeIndicator,view:G.view})),z;if(P)z=(G)=>P({...G,resource:$,view:K});return fQ(s5,{axis:X,now:J,rangeEnd:q,rangeStart:Q,render:z,withDot:Z})},t5=wQ(jQ);import{jsx as Z5,jsxs as hQ}from"react/jsx-runtime";var CQ=({gridType:Q="day",days:q,resourceId:J,resource:$,"data-testid":X,positionedEvents:Z,dayNumberHeight:P=F5})=>{let{eventHeight:K,eventSpacing:z,resources:G}=R(),_=q.at(0)?.startOf("day"),V=!J||G?.at(0)?.id===J,W=q.at(0),A=q.at(-1)?.add(1,Q),M=Q==="hour"&&Boolean(W&&A);return hQ("div",{className:"absolute inset-0 pointer-events-none z-10 overflow-clip","data-testid":X,children:[M&&W&&A&&Z5(t5,{axis:"horizontal",rangeEnd:A,rangeStart:W,resource:$,withDot:V}),Z.map((Y)=>{let{event:N,row:U}=Y,H=P+z+U*(K+z),I=`${N.id}-${U}-${_?.toISOString()}-${J??"no-resource"}`;return Z5("div",{className:"absolute z-10 pointer-events-auto overflow-clip","data-left":Y.left,"data-testid":F.container.horizontal.event(N.id),"data-top":H,"data-width":Y.width,style:{left:`calc(${Y.left}% + var(--spacing) * 0.25)`,width:`calc(${Y.width}% - var(--spacing) * 1)`,top:`${H}px`,height:`${K}px`},children:Z5(p0,{className:"h-full w-full shadow",elementId:I,event:N,isTruncatedEnd:Y.isTruncatedEnd,isTruncatedStart:Y.isTruncatedStart})},F.listKey(I,"wrapper"))})]})},P5=kQ(CQ);import{jsx as u,jsxs as Y5}from"react/jsx-runtime";var EQ=({id:Q,resource:q,gridType:J="day",variant:$="resource",dayNumberHeight:X,className:Z,columns:P=[],allDay:K,showDayNumber:z=!1})=>{let{renderResource:G}=R(),_=$==="resource",V=P.some((Y)=>Y.days),W=DQ(()=>{if(V)return[];return P.map((Y)=>Y.day).filter((Y)=>Boolean(Y))},[P,V]),{positionedEvents:A,dayEventsMap:M}=J5({days:W,gridType:J,resourceId:q?.id,allDay:K});return Y5("div",{className:L("flex flex-1 relative min-w-0",Z),"data-testid":F.container.horizontal.row(Q),children:[_&&q&&u(z0,{className:"w-20 sm:w-40 border-r sticky left-0 bg-background z-20 h-full","data-testid":F.container.horizontal.rowLabel(q.id),resource:q,children:G?G(q):u("div",{className:"wrap-break-word text-sm",children:q.title})}),Y5("div",{className:"relative flex-1 flex min-w-0",children:[u("div",{className:"flex w-full min-w-0 gap-px bg-border",children:P.map((Y)=>{if(Y.days)return u(xQ,{allDay:K,col:Y,dayNumberHeight:X,gridType:J,id:Q,resource:q,resourceId:q?.id,showDayNumber:z},Y.id);return Y.day?u(X5,{allDay:K,className:L("flex-1 w-20",Y.className),day:Y.day,gridType:J,hour:J==="hour"?Y.day.hour():void 0,precomputedEvents:M.get(D(Y.day)),resourceId:q?.id,showDayNumber:z},Y.day.toISOString()):null})}),!V&&u("div",{className:"absolute inset-0 z-10 pointer-events-none",children:u(P5,{"data-testid":F.container.eventsLayer("horizontal",Q),dayNumberHeight:X,days:W,gridType:J,positionedEvents:A,resource:q,resourceId:q?.id})})]})]})},xQ=e5(({col:Q,gridType:q="day",allDay:J,resource:$,resourceId:X,dayNumberHeight:Z,showDayNumber:P,id:K})=>{let z=Q.days??[],{positionedEvents:G}=J5({days:z,gridType:q,resourceId:X,allDay:J});return Y5("div",{className:"flex relative w-full",children:[u("div",{className:"flex w-full gap-px bg-border",children:z.map((_)=>u(X5,{allDay:J,className:L("flex-1 w-20",Q.className),day:_,gridType:q,hour:q==="hour"?_.hour():void 0,resourceId:X,showDayNumber:P},_.toISOString()))}),u("div",{className:"absolute inset-0 z-10 pointer-events-none",children:u(P5,{"data-testid":F.container.eventsLayer("horizontal",K),dayNumberHeight:Z,days:z,gridType:q,positionedEvents:G,resource:$,resourceId:X})})]})}),Q2=e5(EQ);import{jsx as q2,jsxs as vQ}from"react/jsx-runtime";var pQ=({days:Q,classes:q,resource:J,showSpacer:$=!0})=>{let X=Q.map((Z,P)=>({id:F.col.allDay(Z,P),day:Z,gridType:"day",className:L("h-full min-h-12 bg-background",q?.cell)}));return vQ("div",{className:L("flex w-full gap-px bg-border",q?.row),"data-testid":"all-day-row",children:[$&&q2(m0,{className:q?.spacer}),q2(Q2,{allDay:!0,className:"flex-1 min-h-fit",columns:X,dayNumberHeight:0,gridType:"day",id:F.allDayRow(J?.id),resource:J,variant:"regular"})]})},J2=mQ(pQ);import{jsx as A0,jsxs as $2}from"react/jsx-runtime";var p="min-w-20 flex-1",P0=({resources:Q,days:q,gridType:J,cellClassName:$})=>{let X=q.map((Z)=>{let P=Array.isArray(Z),K=P?Z.at(0):Z;return{id:K?F.col.day(K):"day-col-unknown",day:P?void 0:Z,days:P?Z:void 0,className:$,gridType:J}});return Q.map((Z)=>({id:String(Z.id),resource:Z,columns:X}))},Y0=({resources:Q,gutter:q,columnsFor:J})=>[q,...Q.flatMap(($)=>{let X=J($);return(Array.isArray(X)?X:[X]).map((P)=>({...P,resource:$}))})],y0=({resources:Q})=>$2("div",{className:"flex gap-px bg-border h-12 flex-1","data-testid":F.header.resource.columnsHeader,children:[A0("div",{className:L("shrink-0 sticky top-0 left-0 bg-background z-20",Z0,l)}),Q.map((q)=>A0(z0,{className:L(p,"bg-background"),resource:q},F.listKey("resource-cell",q.id)))]}),L0=()=>{let{t:Q}=R((q)=>({t:q.t}));return A0("div",{className:"w-20 sm:w-40 border-b border-r shrink-0 flex justify-center items-center sticky top-0 left-0 bg-background z-20",children:A0("div",{className:"text-sm truncate px-1 min-w-0",children:Q("resources")})})},WJ=({columns:Q})=>{let q=[],J=new Map;for(let $ of Q){if(!$.resource||$.noEvents||!$.day)continue;let X=J.get($.resource.id);if(!X)X={resource:$.resource,days:[],seenDayKeys:new Set},J.set($.resource.id,X),q.push(X);let Z=D($.day);if(!X.seenDayKeys.has(Z))X.seenDayKeys.add(Z),X.days.push($.day)}return $2("div",{className:"flex w-full gap-px bg-border",children:[A0(m0,{}),q.map(({resource:$,days:X})=>A0(J2,{classes:{cell:L("min-w-20",X.length>1&&"flex-1")},days:X,resource:$,showSpacer:!1},F.allDayRow($.id)))]})};import{jsx as c0}from"react/jsx-runtime";var l0=({hours:Q,view:q})=>c0("div",{className:L("flex gap-px bg-border border-b",w0),children:Q.map((J,$)=>{let X=J.isSame(f(),"hour"),Z=J.format("HH"),P=F.header.week.hour(J,$);return c0("div",{className:L(p,"bg-background flex items-center justify-center text-xs shrink-0",X&&"bg-blue-50 text-blue-600 font-medium"),"data-hour":Z,"data-testid":F.header.resource.timeLabel(q,Z),children:c0(k,{className:"text-center",transitionKey:P,children:c0(f0,{date:J})})},P)})});import{jsx as $0,jsxs as P2,Fragment as uQ}from"react/jsx-runtime";var yQ=({date:Q})=>{let{t:q}=R(($)=>({t:$.t})),J=h(Q);return $0("div",{className:"flex flex-1 justify-center items-center min-h-12","data-testid":"day-view-header",children:P2(k,{className:L("flex justify-center items-center text-center text-sm font-semibold sm:text-xl",J&&"text-primary"),transitionKey:D(Q),children:[Q.format("dddd, LL"),J&&$0("span",{className:"bg-primary text-primary-foreground ml-2 rounded-full px-1 py-0.5 text-xs sm:px-2 sm:text-sm",children:q("today")})]})})},X2=(Q,q)=>x0({referenceDate:Q,businessHours:q.businessHours,hideNonBusinessHours:q.hideNonBusinessHours,allDates:[Q],resourceBusinessHours:E0(q.resources??[])}),cQ=({date:Q,config:q})=>{let J=X2(Q,q);return P2(uQ,{children:[$0(L0,{}),$0("div",{className:"flex-1 flex flex-col",children:$0(l0,{hours:J,view:"day"})})]})},lQ=(Q,q)=>{let J=q.resources??[],$=X2(Q,q);if(!J.length)return[e({days:$,gridType:"hour"}),{id:F.col.day(Q),day:Q,days:$,className:L(k5,"flex-1"),gridType:"hour"}];if(q.orientation==="vertical")return Y0({resources:J,gutter:e({days:$,gridType:"hour"}),columnsFor:(X)=>({id:F.col.day(Q,X.id),days:$,day:Q,gridType:"hour"})});return P0({resources:J,days:$,gridType:"hour",cellClassName:p})},Z2={name:"day",label:"day",icon:gQ,navigationUnit:"day",layout:"vertical",supportsResources:!0,range:(Q)=>({start:Q.startOf("day"),end:Q.endOf("day")}),columns:lQ,renderHeader:({date:Q,config:q})=>{let J=q.resources??[];if(!J.length)return $0(yQ,{date:Q});if(q.orientation==="vertical")return $0(y0,{resources:J});return $0(cQ,{config:q,date:Q})}};import{Grid3x3 as iQ}from"lucide-react";import{jsx as u0}from"react/jsx-runtime";var Y2=({className:Q})=>{let{firstDayOfWeek:q,stickyViewHeader:J,viewHeaderClassName:$,currentDate:X}=R(),Z=m(X,q);return u0("div",{className:L("flex w-full gap-px bg-border border-b",J&&"sticky top-0 z-20",$,Q),"data-testid":"month-header",children:Z.map((P)=>u0("div",{className:"py-2 text-center font-medium bg-background flex-1 min-w-0 flex items-center justify-center","data-testid":F.header.weekday("month",P.format("ddd")),children:u0(k,{transitionKey:P.toISOString(),children:u0("span",{className:"text-sm capitalize truncate w-full block",children:P.format("ddd")})})},P.toISOString()))})};import{jsx as Q0,jsxs as aQ,Fragment as nQ}from"react/jsx-runtime";var dQ=(Q,q)=>{let J=k0(Q);return Y0({resources:q,gutter:e({days:J,gridType:"day",renderLabel:($)=>Q0(y,{className:"flex-col-reverse",dayNumber:$.format("D"),today:h($),weekday:$.format("ddd")})}),columnsFor:($)=>({id:F.col.resource("month",$.id),day:void 0,days:J,gridType:"day"})})},oQ=({date:Q})=>{let q=k0(Q);return aQ(nQ,{children:[Q0(L0,{}),Q0("div",{className:"flex flex-1 gap-px bg-border border-b",children:q.map((J,$)=>{let X=F.header.resource.monthDay(J),Z=h(J);return Q0("div",{className:"flex-1 w-20 bg-background shrink-0 flex items-center justify-center flex-col",children:Q0(k,{transitionKey:X,children:Q0(y,{className:"flex-col-reverse",dayNumber:J.format("D"),today:Z,weekday:J.format("ddd")})})},X)})})]})},rQ=(Q,q)=>{let J=q.resources??[];if(J.length){if(q.orientation==="vertical")return dQ(Q,J);return P0({resources:J,days:k0(Q),gridType:"day"})}return s0(Q,q.firstDayOfWeek).map(($,X)=>({id:F.listKey("week",X),columns:$.map((Z)=>({id:F.col.day(Z),day:Z,className:"w-auto",gridType:"day"})),className:"flex-1",showDayNumber:!0}))},K2={name:"month",label:"month",icon:iQ,navigationUnit:"month",layout:"horizontal",supportsResources:!0,range:(Q,q)=>C0(Q,q.firstDayOfWeek),columns:rQ,renderHeader:({date:Q,config:q})=>{let J=q.resources??[];if(!J.length)return Q0(Y2,{className:"h-12"});if(q.orientation==="vertical")return Q0(y0,{resources:J});return Q0(oQ,{date:Q})}};import{Columns3 as tQ}from"lucide-react";import{jsx as i0}from"react/jsx-runtime";var G2=({days:Q})=>{let{weekViewGranularity:q}=R(),J=q==="hourly";return i0("div",{className:L("flex gap-px bg-border border-b",w0),children:Q.map(($,X)=>{let Z=h($),P=F.header.week.day($);return i0("div",{className:L("shrink-0 bg-background flex-1 flex items-center text-center font-medium min-w-20"),"data-testid":F.header.resource.weekDay,children:i0(k,{className:L(J?"sticky left-1/2":"w-full text-center"),transitionKey:P,children:i0(y,{dayNumber:$.format("D"),today:Z,weekday:$.format("ddd")})})},P)})})};import{jsx as W0,jsxs as sQ}from"react/jsx-runtime";var z2=({columns:Q})=>{let{currentDate:q}=R();return sQ("div",{className:"flex h-12 gap-px bg-border",children:[W0("div",{className:L("shrink-0 z-20 bg-background sticky left-0",Z0,l),children:W0("span",{className:"px-2 h-full w-full flex justify-center items-start font-medium",children:q.week()})}),Q.map((J,$)=>{let X=J.day;if(!X)return null;let Z=h(X),P=F.header.week.hour(X,J.resourceId??"");return W0("div",{className:L(p,"flex flex-col items-center justify-center text-xs shrink-0 bg-background"),"data-testid":F.header.resource.timeLabel("week",X.format("HH")),children:W0(k,{transitionKey:P,children:W0(y,{dayNumber:X.format("D"),today:Z,weekday:X.format("ddd")})})},P)})]})};import{jsx as N0,jsxs as A2}from"react/jsx-runtime";var L2=({resources:Q})=>{let{weekViewGranularity:q,t:J,currentDate:$}=R(),X=q==="hourly";return A2("div",{className:"flex h-12 gap-px bg-border",children:[N0("div",{className:L("shrink-0 z-20 bg-background sticky left-0",Z0,l),children:A2("span",{className:L("px-2 h-full w-full flex flex-col justify-center text-xs text-muted-foreground text-center min-w-0",X?"justify-end":"justify-center"),children:[N0("span",{className:"truncate w-full",children:J("week")}),!X&&N0("span",{className:"font-medium text-foreground truncate w-full",children:$.week()})]})}),Q.map((Z)=>{return N0(z0,{className:L(p,"bg-background border-b"),resource:Z,children:N0("div",{className:L("sticky text-sm font-medium truncate",X?"left-1/4":"left-1"),children:Z.title})},F.listKey("resource-cell",Z.id))})]})};import{jsx as x,jsxs as M0,Fragment as Z9}from"react/jsx-runtime";var d0=(Q,q)=>{let J=m(Q,q.firstDayOfWeek),{hiddenDays:$}=q;if(!$)return J;return J.filter((X)=>!$.has(X.day()))},o0=(Q)=>(Q.weekViewGranularity??"hourly")==="hourly",eQ=({date:Q,config:q})=>{let{t:J,selectDate:$,openEventForm:X}=R((P)=>({t:P.t,selectDate:P.selectDate,openEventForm:P.openEventForm})),Z=d0(Q,q);return M0("div",{className:"flex h-18 flex-1 gap-px bg-border","data-testid":"week-view-header",children:[x("div",{className:L(t0,"h-full shrink-0 items-center justify-center bg-background p-2 flex",l),children:M0("div",{className:"flex flex-col items-center justify-center min-w-0 w-full",children:[x("span",{className:"text-muted-foreground text-xs truncate w-full text-center",children:J("week")}),x("span",{className:"font-medium truncate w-full text-center",children:Q.week()})]})}),Z.map((P,K)=>{let z=h(P),G=F.header.week.day(P);return x("div",{className:L("hover:bg-accent bg-background flex-1 min-w-0 flex flex-col justify-center cursor-pointer p-1 text-center sm:p-2 w-20 h-full"),"data-testid":F.header.weekday("week",P.format("dddd")),onClick:()=>{$(P),X({start:P})},children:x(k,{transitionKey:G,children:x(y,{dayNumber:P.format("D"),today:z,weekday:P.format("ddd")})})},G)})]})},B0=(Q,q,J)=>x0({referenceDate:Q,businessHours:q.businessHours,hideNonBusinessHours:q.hideNonBusinessHours,allDates:J,resourceBusinessHours:E0(q.resources??[])}),Q9=(Q,q,J)=>{let $=m(Q,q.firstDayOfWeek);if(o0(q)){let X=d0(Q,q);return Y0({resources:J,gutter:e({days:B0(Q,q,$),gridType:"hour"}),columnsFor:(Z)=>X.map((P)=>({id:F.col.day(P,Z.id),className:p,day:P,days:B0(P,q,$),gridType:"hour"}))})}return Y0({resources:J,gutter:e({days:$,gridType:"day",renderLabel:(X)=>x(y,{dayNumber:X.format("D"),today:h(X),weekday:X.format("ddd")})}),columnsFor:(X)=>({id:F.col.resource("week",X.id),className:p,day:void 0,days:$,gridType:"day"})})},q9=(Q,q,J)=>{let $=m(Q,q.firstDayOfWeek);if(o0(q)){let X=$.map((Z)=>B0(Z,q));return P0({resources:J,days:X,gridType:"hour",cellClassName:p})}return P0({resources:J,days:$,gridType:"day",cellClassName:p})},J9=({date:Q,config:q,resources:J})=>{let $=d0(Q,q),X=o0(q),Z=X?J.flatMap((P)=>$.map((K)=>({day:K,resourceId:P.id}))):[];return M0("div",{className:"flex-1 flex flex-col",children:[x(L2,{resources:J}),X&&x(z2,{columns:Z})]})},$9=({date:Q,config:q})=>{let J=m(Q,q.firstDayOfWeek),$=o0(q),X=$?J.flatMap((Z)=>B0(Z,q)):[];return M0(Z9,{children:[x(L0,{}),M0("div",{className:"flex-1 flex flex-col",children:[x(G2,{days:J}),$&&x(l0,{hours:X,view:"week"})]})]})},X9=(Q,q)=>{let J=q.resources??[];if(J.length){if(q.orientation==="vertical")return Q9(Q,q,J);return q9(Q,q,J)}let $=m(Q,q.firstDayOfWeek),X=d0(Q,q);return[e({days:B0(Q,q,$),gridType:"hour",widthClassName:t0}),...X.map((Z)=>({id:F.col.day(Z),day:Z,days:B0(Z,q,$),className:"flex-1 min-w-0",gridType:"hour"}))]},B2={name:"week",label:"week",icon:tQ,navigationUnit:"week",layout:"vertical",supportsResources:!0,range:(Q,q)=>{let J=m(Q,q.firstDayOfWeek),$=J.at(0)??Q,X=J.at(-1)??Q;return{start:$.startOf("day"),end:X.endOf("day")}},columns:X9,renderHeader:({date:Q,config:q})=>{let J=q.resources??[];if(!J.length)return x(eQ,{config:q,date:Q});if(q.orientation==="vertical")return x(J9,{config:q,date:Q,resources:J});return x($9,{config:q,date:Q,resources:J})}};import{Grid2x2 as G9}from"lucide-react";import*as r from"@radix-ui/react-scroll-area";import{jsx as R0,jsxs as P9}from"react/jsx-runtime";function _2({className:Q,children:q,viewPortProps:J,...$}){return P9(r.Root,{className:L("relative",Q),"data-slot":"scroll-area",...$,children:[R0(r.Viewport,{...J,className:L("focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",J?.className),"data-slot":"scroll-area-viewport",children:q}),R0(K5,{}),R0(r.Corner,{})]})}function K5({className:Q,orientation:q="vertical",...J}){return R0(r.ScrollAreaScrollbar,{className:L("flex touch-none p-px transition-colors select-none",q==="vertical"&&"h-full w-2.5 border-l border-l-transparent",q==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",Q),"data-slot":"scroll-area-scrollbar",orientation:q,...J,children:R0(r.ScrollAreaThumb,{className:"bg-border relative flex-1 rounded-full","data-slot":"scroll-area-thumb"})})}import{jsx as X0,jsxs as S0}from"react/jsx-runtime";var Y9=["bg-primary","bg-blue-500","bg-green-500"],K9=42,F2=()=>{let{currentDate:Q,setView:q,getEventsForDateRange:J,t:$,firstDayOfWeek:X}=R(),Z=Q.year(),P=m(f(),X).map((Y)=>({id:Y.day().toString(),label:Y.format("dd")})),K=()=>{return Array.from({length:12},(Y,N)=>{let U=f().year(Z).month(N).startOf("month"),H=J(U,U.endOf("month"));return{date:U,name:U.format("MMMM"),eventCount:H.length,monthKey:U.format("MM")}})},z=(Y)=>{let N=Y.startOf("month"),U=m(N,X).at(0)??N;return Array.from({length:K9},(H,I)=>{let T=U.add(I,"day"),B=T.startOf("day"),O=T.endOf("day"),S=J(B,O);return{date:T,dayKey:D(T),isInCurrentMonth:T.month()===Y.month(),isToday:h(T),isSelected:T.isSame(Q,"day"),eventCount:S.length}})},G=(Y,N,U)=>{U?.stopPropagation(),q(N,Y)},_=(Y)=>{let N=Y===1?$("event"):$("events");return`${Y} ${N}`},V=(Y)=>{let U=Y.isInCurrentMonth?"":"text-muted-foreground opacity-50",H=Y.isToday?"bg-primary text-primary-foreground rounded-full":"",I=Y.isSelected&&!Y.isToday?"bg-muted rounded-full font-bold":"",T=Y.eventCount>0&&!Y.isToday&&!Y.isSelected?"font-medium":"";return L("relative flex aspect-square w-full cursor-pointer flex-col items-center justify-center hover:bg-accent rounded-sm transition-colors duration-200",U,H,I,T)},W=(Y,N)=>{return L("h-[3px] w-[3px] rounded-full",N?"bg-primary-foreground":Y)},A=K(),M=(Y)=>{if(Y===0)return"";return _(Y)};return S0(_2,{className:"h-full","data-testid":"year-view",children:[X0("div",{className:"grid auto-rows-fr grid-cols-1 gap-4 p-4 sm:grid-cols-2 lg:grid-cols-3","data-testid":"year-grid",children:A.map((Y)=>{let N=z(Y.date);return S0("div",{className:"hover:border-primary flex flex-col rounded-lg border p-3 text-left transition-all duration-200 hover:shadow-md","data-testid":F.header.year.month(Y.monthKey),children:[S0(k,{className:"mb-2 flex items-center justify-between",transitionKey:F.listKey("month",Y.monthKey),children:[X0("button",{className:"text-lg font-medium hover:underline cursor-pointer","data-testid":F.header.year.month(Y.monthKey,"title"),onClick:()=>G(Y.date,"month"),type:"button",children:Y.name}),Y.eventCount>0&&X0("span",{className:"bg-primary text-primary-foreground rounded-full px-2 py-1 text-xs","data-testid":F.header.year.month(Y.monthKey,"count"),children:_(Y.eventCount)})]},F.listKey("month",Y.monthKey)),S0("div",{className:"grid grid-cols-7 gap-px text-[0.6rem]","data-testid":F.header.year.month(Y.monthKey,"mini"),children:[P.map((U)=>X0("div",{className:"text-muted-foreground h-3 text-center",children:U.label},F.listKey("header",Y.monthKey,U.id))),N.map((U)=>{let H=F.header.year.day(Y.date.format("YYYY-MM"),U.dayKey),I=U.eventCount>0,T=Math.min(U.eventCount,3),B=Y9.slice(0,T);return S0("button",{className:V(U),"data-testid":H,onClick:(O)=>G(U.date,"day",O),title:M(U.eventCount),type:"button",children:[X0("span",{className:"text-center leading-none",children:U.date.date()}),I&&X0("div",{className:L("absolute bottom-0 flex w-full justify-center space-x-px",U.isToday&&"bottom-px"),children:B.map((O)=>X0("span",{className:W(O,U.isToday)},O))})]},U.dayKey)})]})]},Y.monthKey)})}),X0(K5,{className:"z-30"})]})};var U2={name:"year",label:"year",icon:G9,navigationUnit:"year",supportsResources:!1,range:(Q)=>({start:Q.startOf("year"),end:Q.endOf("year")}),component:F2};var V2=[Z2,B2,K2,U2];var O2=(Q,q,J)=>q?.range?.(Q,{firstDayOfWeek:J})??C0(Q,J),W2=({initialDate:Q,initialView:q,firstDayOfWeek:J,onDateChange:$,onViewChange:X,pluginRuntime:Z})=>{let[P,K]=L9(()=>({date:f.isDayjs(Q)?Q:f(Q),view:q})),z=A9(P),G=c((B)=>{let O={...z.current,...B};return z.current=O,K(O),O},[]),_=c(()=>[...V2,...Z.getViews()],[Z]),V=c((B)=>_().find((O)=>O.name===B),[_]),W=c(()=>{return O2(P.date,V(P.view),J)},[P,J,V]),A=c((B)=>{let O=O2(B.date,V(B.view),J);$?.(B.date,O)},[$,J,V]),M=c((B)=>{A(G({date:B}))},[G,A]),Y=c((B)=>{let{date:O,view:S}=z.current,b=V(S),w=b?.navigationStep??{amount:1,unit:b?.navigationUnit??"day"},C=O.add(B*w.amount,w.unit);A(G({date:C}))},[G,A,V]),N=c(()=>Y(1),[Y]),U=c(()=>Y(-1),[Y]),H=c(()=>A(G({date:f()})),[G,A]),I=c((B,O)=>{let S=G(O?{view:B,date:O}:{view:B});X?.(B),A(S)},[G,X,A]),T=c((B)=>{let O=typeof B==="function"?B(z.current.date):B;G({date:O})},[G]);return z9(()=>({currentDate:P.date,setCurrentDate:T,view:P.view,setView:I,selectDate:M,nextPeriod:N,prevPeriod:U,today:H,getCurrentViewRange:W,getAllViews:_}),[P,T,I,M,N,U,H,W,_])};import{createElement as B9,Fragment as _9}from"react";var N2=(Q)=>({transformEvents:(q,J)=>{return Q.reduce((X,Z)=>Z.transformEvents?Z.transformEvents(X,J):X,q).filter((X)=>j0(X,J.start,J.end))},getEventManager:(q)=>Q.find((J)=>J.managesEvent?.(q)),collect:(q,J)=>Q.flatMap(($)=>$.contribute?.(q,J)??[]),renderSlot:(q,J)=>{let $=[];for(let X of Q){let Z=X.renderSlot?.(q,J);if(Z!==null&&Z!==void 0)$.push(B9(_9,{key:X.name},Z))}return $},getViews:()=>Q.flatMap((q)=>q.views??[]),getProviders:()=>Q.map((q)=>q.provider).filter((q)=>Boolean(q))});var F9=[],U9=[],H2=(Q)=>{let{events:q,firstDayOfWeek:J=0,initialView:$="month",initialDate:X=f(),dayMaxEvents:Z,businessHours:P,onEventAdd:K,onEventUpdate:z,onEventDelete:G,onDateChange:_,onViewChange:V,locale:W,timezone:A,translations:M,translator:Y,onEventClick:N,onCellClick:U,disableEventClick:H,disableCellClick:I,resources:T,orientation:B,weekViewGranularity:O}=Q,{plugins:S=U9}=Q,b=M5({firstDayOfWeek:J,dayMaxEvents:Z,businessHours:P,locale:W,translations:M,translator:Y,resources:T,orientation:B,weekViewGranularity:O}),w=R2(()=>N2(S),[S]),C=W2({initialDate:X,initialView:$,firstDayOfWeek:J,onDateChange:_,onViewChange:V,pluginRuntime:w}),n=I5({events:q,pluginRuntime:w,getCurrentViewRange:C.getCurrentViewRange,resources:b.resources??F9,onEventAdd:K,onEventUpdate:z,onEventDelete:G}),a=T5({currentDate:C.currentDate,t:b.t,disableEventClick:H,disableCellClick:I,onEventClick:N,onCellClick:U}),{setCurrentLocale:s}=b,{setCurrentDate:i}=C,{setCurrentEvents:q0}=n,j=S2(void 0);M2(()=>{if(W&&W!==j.current)s(W),f.locale(W),i((t)=>t.locale(W)),j.current=W},[W,s,i]);let g=S2(A);return M2(()=>{if(A&&A!==g.current)f.tz.setDefault(A),i((t)=>t.tz(A)),q0((t)=>t.map((J0)=>({...J0,start:J0.start.tz(A),end:J0.end.tz(A)}))),g.current=A},[A,i,q0]),R2(()=>{let{setCurrentLocale:t,...J0}=b,{getCurrentViewRange:r0,getAllViews:H0,...I0}=C,{setCurrentEvents:n0,...T0}=n;return{...J0,...I0,...T0,...a,getViews:H0,getEventManager:w.getEventManager,renderSlot:w.renderSlot,collect:w.collect,getProviders:w.getProviders,getEventResourceIds:_0,currentRange:C.getCurrentViewRange()}},[b,C,n,a,w])};import{jsx as V9}from"react/jsx-runtime";var I2=(Q,q)=>Q.reduceRight((J,$,X)=>V9($,{children:J},X),q);import{jsx as M9}from"react/jsx-runtime";var W9=[],N9=(Q)=>{let{events:q=W9,firstDayOfWeek:J=0,initialView:$="month",initialDate:X,renderEvent:Z,onEventClick:P,onCellClick:K,isCellDisabled:z,getCellClassName:G,onViewChange:_,onEventAdd:V,onEventUpdate:W,onEventDelete:A,onDateChange:M,locale:Y,timezone:N,disableCellClick:U,disableEventClick:H,disableDragAndDrop:I,dayMaxEvents:T,eventSpacing:B=_5,eventHeight:O=U5,stickyViewHeader:S=!0,viewHeaderClassName:b="",headerComponent:w,headerClassName:C,businessHours:n,renderEventForm:a,onMoreEventsClick:s,translations:i,translator:q0,timeFormat:j="12-hour",classesOverride:g,renderCurrentTimeIndicator:t,renderHour:J0,hideNonBusinessHours:r0=!1,hideExportButton:H0=!1,hiddenDays:I0,slotDuration:n0=60,scrollTime:T0,plugins:T2,resources:b2,renderResource:G5,orientation:w2,weekViewGranularity:j2}=Q,z5=H2({events:q,firstDayOfWeek:J,initialView:$,initialDate:X,dayMaxEvents:T,businessHours:n,onEventAdd:V,onEventUpdate:W,onEventDelete:A,onDateChange:M,onViewChange:_,locale:Y,timezone:N,translations:i,translator:q0,plugins:T2,onEventClick:P,onCellClick:K,disableEventClick:H,disableCellClick:U,resources:b2,orientation:w2,weekViewGranularity:j2});return O9(()=>{let{handleEventClick:f2,handleDateClick:k2,...C2}=z5;return{...C2,renderEvent:Z,onEventClick:f2,onCellClick:k2,isCellDisabled:z,getCellClassName:G,locale:Y,timezone:N,disableCellClick:U,disableEventClick:H,disableDragAndDrop:I,eventSpacing:B,eventHeight:O,stickyViewHeader:S,viewHeaderClassName:b,headerComponent:w,headerClassName:C,renderEventForm:a,onMoreEventsClick:s,timeFormat:j,classesOverride:g,renderCurrentTimeIndicator:t,renderHour:J0,hideNonBusinessHours:r0,hideExportButton:H0,hiddenDays:I0,slotDuration:n0,scrollTime:T0,renderResource:G5}},[z5,Z,G5,z,G,Y,N,U,H,I,B,O,S,b,w,C,a,s,j,g,t,J0,r0,H0,I0,n0,T0])},v$=({children:Q,...q})=>{let J=N9(q),$=I2(J.getProviders(),Q);return M9(b0.Provider,{value:J,children:$})};
2
- export{f as a,R as b,p9 as c,L as d,k as e,v5 as f,g5 as g,y5 as h,uq as i,c5 as j,iq as k,_2 as l,K5 as m,h as n,m as o,s0 as p,F as q,p5 as r,_5 as s,U5 as t,W5 as u,y9 as v,e0 as w,h5 as x,K0 as y,p0 as z,X5 as A,t5 as B,Q2 as C,t0 as D,J2 as E,WJ as F,B5 as G,v$ as H};