@ilamy/calendar 3.1.0 → 3.2.0

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
@@ -129,6 +129,32 @@ interface PluginMutationResult {
129
129
  deleted: CalendarEvent[];
130
130
  }
131
131
  /**
132
+ * One user action and every stored row it touched, reported once through
133
+ * `onEventsChange` (#309). A recurring edit touches several rows (the series,
134
+ * an override, deleted overrides) that the per-row callbacks report one by
135
+ * one; this reports them together so they can be saved, or refused, as a unit.
136
+ * FullCalendar reports an action once the same way (`eventChange` with
137
+ * `relatedEvents`).
138
+ */
139
+ interface EventsChange {
140
+ /** What the user did. */
141
+ action: "add" | "update" | "delete";
142
+ /** The event the user acted on, as it was shown (an occurrence, for a series). */
143
+ event: CalendarEvent;
144
+ /**
145
+ * The scope chosen in the plugin's scope dialog, when a plugin manages the
146
+ * event; otherwise undefined. The recurrence plugin passes its
147
+ * `RecurrenceEditScope` (`'this' | 'following' | 'all'`).
148
+ */
149
+ scope?: unknown;
150
+ /** New rows, the same ones passed to `onEventAdd`. */
151
+ added: CalendarEvent[];
152
+ /** Changed rows, the same ones passed to `onEventUpdate`. */
153
+ updated: CalendarEvent[];
154
+ /** Removed rows, the same ones passed to `onEventDelete`. */
155
+ deleted: CalendarEvent[];
156
+ }
157
+ /**
132
158
  * Calendar configuration handed to a view's `columns()`/`renderHeader()`.
133
159
  * Carries the resource axis (`resources`, `orientation`) so a resource-capable
134
160
  * view can compose both arrangements. `range()` receives only the
@@ -342,9 +368,10 @@ interface EventMutationScopeSlotContext {
342
368
  resolve: (scope: unknown) => void;
343
369
  cancel: () => void;
344
370
  }
371
+ import { ConfigType, Dayjs as DayjsInstance, ManipulateType as DayjsManipulateType } from "dayjs";
345
372
  import dayjs from "dayjs";
346
- type Dayjs3 = dayjs.Dayjs3;
347
- type ManipulateType3 = dayjs.ManipulateType3;
373
+ type Dayjs3 = DayjsInstance;
374
+ type ManipulateType3 = DayjsManipulateType;
348
375
  /**
349
376
  * dayjs's statics without its call signatures. Mapping over the keys drops the
350
377
  * call signatures, which is what lets the exported type re-advertise only the
@@ -364,27 +391,8 @@ type DayjsStatics = { [K in keyof typeof dayjs] : (typeof dayjs)[K] };
364
391
  * (https://day.js.org/docs/en/parse/string-format). To read a bare wall-clock
365
392
  * string as a time in a given zone, call `dayjs.tz(input, timezone)`.
366
393
  */
367
- type ConfiguredDayjs = ((date?: dayjs.ConfigType) => dayjs.Dayjs3) & DayjsStatics;
394
+ type ConfiguredDayjs = ((date?: ConfigType) => DayjsInstance) & DayjsStatics;
368
395
  declare const _default: ConfiguredDayjs;
369
- /**
370
- * The calendar's plugin mount points. These belong to the host (the components
371
- * that render them: the event form and the drag-and-drop flow), NOT to the
372
- * plugin kernel and NOT to any individual plugin. The kernel's `renderSlot`
373
- * takes a plain `slotName: string` and knows nothing about this list; the core
374
- * renders these named slots and any plugin may fill the ones it cares about.
375
- */
376
- declare const SLOT_EVENT_FORM = "event-form";
377
- declare const SLOT_EVENT_MUTATION_SCOPE = "event-mutation-scope";
378
- interface EventFormProps {
379
- open?: boolean;
380
- selectedEvent?: CalendarEvent | null;
381
- onAdd?: (event: CalendarEvent) => void;
382
- onUpdate?: (event: CalendarEvent) => void;
383
- onDelete?: (event: CalendarEvent) => void;
384
- onClose: () => void;
385
- }
386
- import React4 from "react";
387
- import React3 from "react";
388
396
  declare const defaultTranslations: {
389
397
  today: string;
390
398
  create: string;
@@ -477,6 +485,25 @@ type Translations = Record<keyof typeof defaultTranslations, string>;
477
485
  type TranslationKey = keyof Translations;
478
486
  type TranslatorFunction = (key: TranslationKey | string) => string;
479
487
  /**
488
+ * The calendar's plugin mount points. These belong to the host (the components
489
+ * that render them: the event form and the drag-and-drop flow), NOT to the
490
+ * plugin kernel and NOT to any individual plugin. The kernel's `renderSlot`
491
+ * takes a plain `slotName: string` and knows nothing about this list; the core
492
+ * renders these named slots and any plugin may fill the ones it cares about.
493
+ */
494
+ declare const SLOT_EVENT_FORM = "event-form";
495
+ declare const SLOT_EVENT_MUTATION_SCOPE = "event-mutation-scope";
496
+ interface EventFormProps {
497
+ open?: boolean;
498
+ selectedEvent?: CalendarEvent | null;
499
+ onAdd?: (event: CalendarEvent) => void;
500
+ onUpdate?: (event: CalendarEvent) => void;
501
+ onDelete?: (event: CalendarEvent) => void;
502
+ onClose: () => void;
503
+ }
504
+ import React3 from "react";
505
+ import { ReactNode as ReactNode4 } from "react";
506
+ /**
480
507
  * Available calendar view types. The built-in views (day, week, month, year)
481
508
  * are `PluginView` specs in `features/calendar/components/views`; plugins may
482
509
  * contribute additional view names, so this is a broad `string`.
@@ -627,7 +654,7 @@ interface IlamyCalendarProps {
627
654
  * and `top: var(--ilamy-sticky-top)`, which each grid publishes to clear
628
655
  * its own sticky column and header.
629
656
  */
630
- renderEvent?: (event: CalendarEvent, segment: EventSegment) => React3.ReactNode;
657
+ renderEvent?: (event: CalendarEvent, segment: EventSegment) => ReactNode4;
631
658
  /**
632
659
  * Callback when an event is clicked.
633
660
  * Provides the clicked event object.
@@ -673,6 +700,13 @@ interface IlamyCalendarProps {
673
700
  */
674
701
  onEventDelete?: (event: CalendarEvent) => void;
675
702
  /**
703
+ * Callback once per user action, with every stored row it touched: what
704
+ * `onEventAdd`, `onEventUpdate` and `onEventDelete` report one row at a time.
705
+ * Use it to save a recurring edit (series, override, deleted overrides) as
706
+ * one unit. The per-row callbacks still fire; use one or the other.
707
+ */
708
+ onEventsChange?: (change: EventsChange) => void;
709
+ /**
676
710
  * Callback when the current date changes (navigation).
677
711
  * Provides the new current date and the current visible range.
678
712
  */
@@ -747,7 +781,7 @@ interface IlamyCalendarProps {
747
781
  * Custom header component to replace the default calendar header.
748
782
  * Useful for adding custom branding or additional controls.
749
783
  */
750
- headerComponent?: React3.ReactNode;
784
+ headerComponent?: ReactNode4;
751
785
  /**
752
786
  * Custom class name for the calendar header.
753
787
  * Useful for applying custom styles to the header.
@@ -765,7 +799,7 @@ interface IlamyCalendarProps {
765
799
  * If provided, it will override the default event form component.
766
800
  * The function receives EventFormProps and should return a React node.
767
801
  */
768
- renderEventForm?: (props: EventFormProps) => React3.ReactNode;
802
+ renderEventForm?: (props: EventFormProps) => ReactNode4;
769
803
  /**
770
804
  * Called when the "+N more" overflow indicator in a month/grid cell is
771
805
  * clicked, receiving the cell's day and its full list of events.
@@ -834,7 +868,7 @@ interface IlamyCalendarProps {
834
868
  * }}
835
869
  * ```
836
870
  */
837
- renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React3.ReactNode;
871
+ renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => ReactNode4;
838
872
  /**
839
873
  * Days of the week to hide from the week view.
840
874
  * Hidden days won't render as columns, giving remaining days more space.
@@ -858,7 +892,7 @@ interface IlamyCalendarProps {
858
892
  * Custom render function for the hour labels in the gutter/header.
859
893
  * Receives a Dayjs object for the hour and should return a React node.
860
894
  */
861
- renderHour?: (date: Dayjs3) => React3.ReactNode;
895
+ renderHour?: (date: Dayjs3) => ReactNode4;
862
896
  /**
863
897
  * Granularity of the time grid in minutes for day, week, and resource hour views.
864
898
  * Quarter-hour increments only: `15`, `30`, or `60`.
@@ -939,7 +973,7 @@ interface IlamyCalendarProps {
939
973
  */
940
974
  resources?: Resource[];
941
975
  /** Custom render function for resource header cells. */
942
- renderResource?: (resource: Resource) => React3.ReactNode;
976
+ renderResource?: (resource: Resource) => ReactNode4;
943
977
  /**
944
978
  * How resources are arranged. Only applies when `resources` is set.
945
979
  * - "horizontal": resources are rows, time is columns (default)
@@ -954,8 +988,8 @@ interface IlamyCalendarProps {
954
988
  */
955
989
  weekViewGranularity?: "hourly" | "daily";
956
990
  }
957
- declare const IlamyCalendar: React4.FC<IlamyCalendarProps>;
958
- import React5 from "react";
991
+ declare const IlamyCalendar: React3.FC<IlamyCalendarProps>;
992
+ import React4 from "react";
959
993
  /**
960
994
  * @deprecated Since v2.0 `IlamyCalendar` accepts `resources`, `renderResource`,
961
995
  * `orientation`, and `weekViewGranularity` directly — use it instead. This
@@ -963,8 +997,8 @@ import React5 from "react";
963
997
  */
964
998
  type IlamyResourceCalendarProps = IlamyCalendarProps;
965
999
  /** @deprecated Since v2.0 — use `IlamyCalendar` with the `resources` prop. */
966
- declare const IlamyResourceCalendar: React5.FC<IlamyResourceCalendarProps>;
967
- import React6 from "react";
1000
+ declare const IlamyResourceCalendar: React4.FC<IlamyResourceCalendarProps>;
1001
+ import React5 from "react";
968
1002
  /**
969
1003
  * The public calendar API surface exposed by useIlamyCalendarContext() — for consumers and plugin
970
1004
  * components. The full internal context is intentionally not exported.
@@ -1006,7 +1040,7 @@ interface IlamyCalendarApi {
1006
1040
  * plugin views (e.g. agenda) render the indicator consistently with the
1007
1041
  * built-in views via the shared `@ilamy/ui` CurrentTimeIndicator.
1008
1042
  */
1009
- readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React6.ReactNode;
1043
+ readonly renderCurrentTimeIndicator?: (props: RenderCurrentTimeIndicatorProps) => React5.ReactNode;
1010
1044
  /**
1011
1045
  * Events whose resource membership (`resourceIds`, falling back to
1012
1046
  * `resourceId`) contains the given resource. On a calendar without
@@ -1022,7 +1056,7 @@ interface IlamyCalendarApi {
1022
1056
  readonly applyScopedEdit: (event: CalendarEvent, updates: Partial<CalendarEvent>, scope: unknown) => void;
1023
1057
  readonly applyScopedDelete: (event: CalendarEvent, scope: unknown) => void;
1024
1058
  readonly getEventManager: (event: CalendarEvent) => IlamyPlugin | undefined;
1025
- readonly renderSlot: (slotName: string, context: unknown) => React6.ReactNode[];
1059
+ readonly renderSlot: (slotName: string, context: unknown) => React5.ReactNode[];
1026
1060
  readonly collect: (point: string, context: unknown) => unknown[];
1027
1061
  readonly getViews: () => PluginView[];
1028
1062
  }
@@ -1031,4 +1065,4 @@ interface IlamyCalendarApi {
1031
1065
  * Returns a limited set of commonly used properties and methods.
1032
1066
  */
1033
1067
  declare function useIlamyCalendarContext(): IlamyCalendarApi;
1034
- 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 };
1068
+ export { BusinessHours, CalendarClassesOverride, CalendarEvent, CalendarView, CellInfo, ColumnSpec, Dayjs3 as Dayjs, EventFormProps, EventFormSlotContext, EventMutationScopeSlotContext, EventSegment, EventsChange, 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{t}from"./shared/chunk-kpzykmz4.js";import{r,me,l,oe,p,g,U,ie,le,k,N,O,a,i,V,Y,n,K,q,X,I,de,j,Z,x,L,H,z,Q,J,ee,te,re,M,ne,ce,ae,B}from"./shared/chunk-tvq5v791.js";import{e,d,ue}from"./shared/chunk-h5d5q285.js";import{R,w,S,F,P,_}from"./shared/chunk-5kjrv081.js";import{o,v,m,s,C,D,h,E,f}from"./shared/chunk-jge2sq3v.js";import{u,y}from"./shared/chunk-m1q73v86.js";var lr="event-form",dr="event-mutation-scope",cr=({event:c,onChange:b})=>r((A)=>A.renderSlot)(lr,{event:c,onChange:b}),ft=({dialog:c,onResolve:b,onCancel:T})=>{let A=r((pe)=>pe.getEventManager);if(!(c.isOpen&&c.event))return null;let G=A(c.event),W={event:c.event,operation:c.operation,resolve:b,cancel:T};return G?.renderSlot?.(dr,W)};import{useEffect as ri,useMemo as oi}from"react";import{DndContext as hn,pointerWithin as En}from"@dnd-kit/core";import{useId as bn}from"react";import{MouseSensor as rn,TouchSensor as on,useSensor as ur,useSensors as nn}from"@dnd-kit/core";import{useEffect as an,useRef as gt,useState as sn}from"react";var en=(c)=>c.hour!==void 0,Lt=(c,b,T=g)=>{let{date:A,hour:G=0,minute:W=0,allDay:pe}=b,se=c.end.diff(c.start,"second"),fe=(xe)=>({start:xe,end:xe.add(se,"second")});if(en(b)){let Re=t(A).hour(G).minute(W).subtract(T.minutes,"minute");return{...fe(Re),allDay:!1}}let ve=t(A).subtract(T.days,"day"),ge=pe===!0,ye=pe===void 0,Ce=Boolean(c.allDay);if(ge||ye&&Ce)return{...fe(ve.startOf("day")),allDay:!0};let Ee=ve.format("YYYY-MM-DD"),De=c.start.format("HH:mm:ss.SSS"),we=t(`${Ee}T${De}`);return{...fe(we),allDay:!1}},tn=(c,b,T)=>{if(T===void 0||b===T)return{};if(!c.resourceIds)return{resourceId:T};let G=c.resourceIds.indexOf(b);if(G===-1)return{};let W=c.resourceIds.slice();if(W.splice(G,1),!W.includes(T))W.push(T);return{resourceIds:W}},mr=(c,b,T=g)=>{let{active:A,over:G}=c;if(!A||!G||!b)return null;let W=G.data.current||{};if(W.disabled)return null;let{resourceId:pe}=W,{start:se,end:fe,allDay:ve}=Lt(b,W,T),ge=A.data.current?.sourceResourceId,ye={start:se,end:fe,...tn(b,ge,pe),allDay:ve};return{activeEvent:b,updates:ye}};var ln=(c,b)=>{if(!c)return!1;let T=c.start.isSame(b.start)&&c.end.isSame(b.end),A=c.resourceId===b.resourceId&&c.allDay===b.allDay,G=c.isDropAllowed===b.isDropAllowed;return T&&A&&G},dn=({active:c,activatorEvent:b})=>{if(c.data.current?.type!=="calendar-event")return null;let T=c.data.current.event,A=c.data.current.dragSegment;if(!A)return{calendarEvent:T,pending:null};let G=c.data.current.getBarRect;return{calendarEvent:T,pending:{calendarEvent:T,segment:A,activatorEvent:b,barRect:G?.()}}},cn=(c,b,T)=>{let A=b??{},{start:G,end:W,allDay:pe}=Lt(c,A,T);return{event:c,start:G,end:W,resourceId:A.resourceId??c.resourceId,allDay:pe,isDropAllowed:!A.disabled}},mn=(c)=>{let b=le(c);an(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},un=()=>{let c=ur(rn,{activationConstraint:{distance:2}}),b=ur(on,{activationConstraint:{delay:100,tolerance:5}});return nn(c,b)},pr=(c)=>{let b=r((he)=>he.slotDuration),T=un(),A=gt(null),G=gt(g),W=gt(null),pe=gt(null),[se,fe]=sn(null);mn(se);let ve=()=>{A.current=null,G.current=g,W.current=null,fe(null),pe.current?.setActiveEvent(null)},ge=(he)=>{let Ee=dn(he);if(!Ee)return;pe.current?.setActiveEvent(Ee.calendarEvent),A.current=Ee.calendarEvent,G.current=g,W.current=Ee.pending},ye=(he)=>{let Ee=W.current;if(!Ee)return;let De=Ee.barRect??he.active.rect.current.initial;if(!De)return;G.current=ie({activeEvent:Ee.calendarEvent,initialRect:De,activatorEvent:Ee.activatorEvent,segment:Ee.segment,slotDurationMinutes:b}),W.current=null};return{sensors:T,dragPreview:se,overlayRef:pe,handlers:{onDragStart:ge,onDragOver:(he)=>{ye(he);let Ee=A.current;if(!Ee||!he.over){fe(null);return}let De=cn(Ee,he.over.data.current,G.current);fe((we)=>{if(ln(we,De))return we;return De})},onDragEnd:(he)=>{let Ee=mr(he,A.current,G.current);if(Ee)c(Ee.activeEvent,Ee.updates);ve()},onDragCancel:ve}}};import{useCallback as vt,useEffect as pn,useRef as fn,useState as gn}from"react";var Ft={isOpen:!1,operation:"edit",event:null};function yt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ge)=>({applyScopedEdit:ge.applyScopedEdit,applyScopedDelete:ge.applyScopedDelete})),[A,G]=gn(Ft),W=fn(A);pn(()=>{W.current=A},[A]);let pe=vt((ge,ye)=>{G({isOpen:!0,operation:"edit",event:ge,updates:ye})},[]),se=vt((ge)=>{G({isOpen:!0,operation:"delete",event:ge})},[]),fe=vt(()=>G(Ft),[]),ve=vt((ge)=>{let ye=W.current;if(!ye.event)return;if(ye.operation==="edit")b(ye.event,ye.updates??{},ge);else T(ye.event,ge);G(Ft),c?.()},[b,T,c]);return{dialogState:A,openEditDialog:pe,openDeleteDialog:se,closeDialog:fe,handleConfirm:ve}}var fr=()=>{let{updateEvent:c,getEventManager:b}=r((se)=>({updateEvent:se.updateEvent,getEventManager:se.getEventManager})),{dialogState:T,openEditDialog:A,closeDialog:G,handleConfirm:W}=yt();return{commitDrop:(se,fe)=>{let ve=Object.keys(fe).length===0;if(!se.id||ve)return;if(b(se)?.applyEdit){A(se,fe);return}c(se.id,fe)},scopeDialog:{dialog:T,onCancel:G,onResolve:W}}};import{DragOverlay as vn}from"@dnd-kit/core";import{snapCenterToCursor as yn}from"@dnd-kit/modifiers";import{useImperativeHandle as Dn,useState as Cn}from"react";import{jsx as gr}from"react/jsx-runtime";var vr=({ref:c})=>{let[b,T]=Cn(null),A=p();if(Dn(c,()=>({setActiveEvent:T})),A)return null;return gr(vn,{modifiers:[yn],children:b&&gr("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",k(b)),style:N(b),children:b.title})})};import{jsx as yr,jsxs as Dr}from"react/jsx-runtime";function Cr({children:c}){let b=bn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:A,scopeDialog:G}=fr(),{sensors:W,dragPreview:pe,overlayRef:se,handlers:fe}=pr(A);if(T)return c;return Dr(oe.Provider,{value:pe,children:[Dr(hn,{collisionDetection:En,id:b,sensors:W,...fe,children:[c,yr(vr,{ref:se})]}),yr(ft,{...G})]})}import{ChevronDownIcon as Sn}from"lucide-react";import{useEffect as xn,useState as wn}from"react";import*as Le from"@radix-ui/react-popover";import{jsx as Dt}from"react/jsx-runtime";function ze({...c}){return Dt(Le.Root,{"data-slot":"popover",...c})}function Ye({...c}){return Dt(Le.Trigger,{"data-slot":"popover-trigger",...c})}function _e({className:c,align:b="center",sideOffset:T=4,...A}){return Dt(Le.Portal,{children:Dt(Le.Content,{align:b,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",c),"data-slot":"popover-content",sideOffset:T,...A})})}import{jsx as je,jsxs as it}from"react/jsx-runtime";var hr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Gt=(c)=>Boolean(c&&hr.test(c)),Pn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function Er({value:c,onChange:b,swatches:T=[],className:A,"aria-label":G="Select color"}){let[W,pe]=wn(Gt(c)?c:"");xn(()=>{pe(Gt(c)?c:"")},[c]);let se=(ye)=>{let Ce=ye.target.value;if(pe(Ce),hr.test(Ce))b(Ce)},fe=Gt(c),ve=T.find((ye)=>ye.value===c),ge;if(ve)ge=ve.label;else if(fe)ge=c;else if(c)ge=Pn(c);else ge="Pick a color";return it(ze,{children:[it(Ye,{"aria-label":G,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]",A),"data-slot":"color-picker-trigger",type:"button",children:[it("span",{className:"flex items-center gap-2",children:[je("span",{className:e("size-5 shrink-0 rounded-full border",!fe&&c),style:fe?{backgroundColor:c}:void 0}),je("span",{className:e(fe&&"font-mono text-xs"),children:ge})]}),je(Sn,{className:"size-4 shrink-0 opacity-50"})]}),it(_e,{className:"w-56","data-slot":"color-picker-content",children:[T.length>0&&je("div",{className:"grid grid-cols-7 gap-1.5",children:T.map((ye)=>{let Ce=c===ye.value;return je("button",{"aria-label":ye.label,"aria-pressed":Ce,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",ye.value,Ce&&"ring-ring ring-2 ring-offset-1"),onClick:()=>b(ye.value),type:"button"},ye.value)})}),je("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),it("div",{className:"flex items-center gap-2",children:[je("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(ye)=>b(ye.target.value),type:"color",value:fe?c:"#000000"}),je(m,{"aria-label":"Hex color",className:"font-mono",onChange:se,placeholder:"#000000",value:W})]})]})]})}import{jsx as Tn}from"react/jsx-runtime";function br({className:c,...b}){return Tn("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",c),"data-slot":"textarea",...b})}import{useEffect as jn,useState as Oe}from"react";import{PopoverClose as Vn}from"@radix-ui/react-popover";import{Calendar as An}from"lucide-react";import{useEffect as Ln,useRef as Fn,useState as Gn}from"react";import{useState as Mn}from"react";import{ChevronLeftIcon as Rn,ChevronRightIcon as Nn}from"lucide-react";import{jsx as st,jsxs as kn}from"react/jsx-runtime";function Qe({label:c,onPrev:b,onNext:T,prevLabel:A,nextLabel:G}){return kn("div",{className:"mb-2 flex items-center justify-between",children:[st(o,{"aria-label":A,onClick:b,size:"icon",variant:"ghost",children:st(Rn,{className:"size-4"})}),st("div",{className:"text-sm font-medium select-none",children:c}),st(o,{"aria-label":G,onClick:T,size:"icon",variant:"ghost",children:st(Nn,{className:"size-4"})})]})}import{jsx as Fe,jsxs as Sr}from"react/jsx-runtime";function Hn(c){let b=c.weekHover&&!c.isCurrentWeek;return e("p-0 text-center",c.weekHover&&"first:rounded-l-md last:rounded-r-md",b&&"group-hover/week:bg-accent",c.isCurrentWeek&&"bg-primary")}function In(c){return e("w-full aspect-square text-sm select-none",!c.isDisabled&&"cursor-pointer",!(c.weekHover||c.isDisabled)&&"hover:bg-accent rounded-md",c.isOutside&&"text-muted-foreground/50",c.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",c.isCurrentWeek&&"text-primary-foreground font-medium",c.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",c.isDisabled&&"opacity-50 cursor-not-allowed")}function On({day:c,state:b,onSelect:T}){return Fe("td",{className:Hn(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Fe("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:In(b),"data-disabled":b.isDisabled,"data-selected":b.isSelected,disabled:b.isDisabled||b.isOutside,onClick:()=>T?.(c.toDate()),tabIndex:b.isOutside?-1:0,type:"button",children:c.format("D")})})}function lt({selected:c,defaultMonth:b,onSelect:T,disabled:A,firstDayOfWeek:G=0,className:W,weekHover:pe=!1,highlightedWeekOf:se}){let[fe,ve]=Mn(()=>t(b??c??new Date).startOf("month")),ge=V(fe,G),ye=c?t(c).format("YYYY-MM-DD"):void 0,Ce=i(t(),G).map((De)=>De.format("dd")),Se,he;if(se){let De=i(se,G);Se=De.at(0),he=De.at(-1)}let Ee=(De)=>{let we=De.format("YYYY-MM-DD")===ye,xe=!1;if(Se&&he){let Re=!De.isBefore(Se,"day"),Pe=!De.isAfter(he,"day");xe=Re&&Pe}return{isOutside:!De.isSame(fe,"month"),isSelected:we,isDisabled:A?.(De.toDate())??!1,isCurrent:a(De)&&!we,isCurrentWeek:xe,weekHover:pe}};return Sr("div",{className:e("bg-background p-3 w-72",W),"data-slot":"calendar",children:[Fe(Qe,{label:fe.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ve((De)=>De.add(1,"month")),onPrev:()=>ve((De)=>De.subtract(1,"month")),prevLabel:"Previous month"}),Sr("table",{className:"w-full border-collapse",role:"grid",children:[Fe("thead",{children:Fe("tr",{children:Ce.map((De,we)=>Fe("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:De},we))})}),Fe("tbody",{children:ge.map((De,we)=>Fe("tr",{className:e(pe&&"group/week"),children:De.map((xe)=>Fe(On,{day:xe,onSelect:T,state:Ee(xe)},xe.toISOString()))},we))})]})]})}import{jsx as Je,jsxs as Bt}from"react/jsx-runtime";function xr({date:c,closeOnSelect:b,onChange:T,label:A="Pick a date",className:G,disabled:W}){let pe=r((ye)=>ye.firstDayOfWeek),se=Fn(null),[fe,ve]=Gn(c);Ln(()=>{ve(c)},[c]);let ge=(ye)=>{if(ve(ye),b)se.current?.click();T?.(ye)};return Je("div",{className:G,children:Bt(ze,{children:[Je(Ye,{asChild:!0,children:Bt(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[Je(An,{}),fe?t(fe).format("ll"):Je("span",{children:A})]})}),Bt(_e,{align:"start",className:"w-auto p-0",children:[Je(Vn,{ref:se,style:{display:"none"}}),Je(lt,{defaultMonth:fe,disabled:W,firstDayOfWeek:pe,onSelect:ge,selected:fe})]})]})})}import{Clock as zn}from"lucide-react";import{useEffect as Yn,useRef as Pr,useState as zt}from"react";import{useMemo as Bn}from"react";function wr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:Bn(()=>{let W=[],[pe,se]=b.split(":").map(Number),[fe,ve]=T.split(":").map(Number),ge=pe*60+se,ye=fe*60+ve;for(let Ce=ge;Ce<=ye;Ce+=15){let Se=Math.floor(Ce/60),he=Ce%60,Ee=`${Se.toString().padStart(2,"0")}:${he.toString().padStart(2,"0")}`;W.push(Ee)}return W},[b,T]),formatTime:(W)=>{let[pe,se]=W.split(":").map(Number);if(c==="24-hour")return`${pe.toString().padStart(2,"0")}:${se.toString().padStart(2,"0")}`;let fe=pe>=12?"PM":"AM",ve=pe;if(pe===0)ve=12;else if(pe>12)ve=pe-12;return`${ve}:${se.toString().padStart(2,"0")} ${fe}`}}}import{jsx as $e,jsxs as Yt}from"react/jsx-runtime";var _n=(c)=>{c.stopPropagation()};function Tr({value:c,onChange:b,minTime:T="00:00",maxTime:A="23:45",timeFormat:G="12-hour",placeholder:W="Select time...",className:pe,disabled:se=!1,name:fe}){let[ve,ge]=zt(!1),[ye,Ce]=zt(""),Se=Pr(null),he=Pr(null),[Ee,De]=zt(0),{timeOptions:we,formatTime:xe}=wr({timeFormat:G,minTime:T,maxTime:A}),Re=we.filter((Me)=>xe(Me).toLowerCase().includes(ye.toLowerCase())),Pe=(Me)=>{b(Me),ge(!1),Ce("")};Yn(()=>{if(ve){if(he.current)De(he.current.offsetWidth);setTimeout(()=>{Se.current?.focus()},0)}},[ve]);let Ge=c?xe(c):W;return Yt(ze,{onOpenChange:ge,open:ve,children:[$e(Ye,{asChild:!0,children:Yt(o,{"aria-controls":"time-picker-listbox","aria-expanded":ve,className:e("w-full justify-start",pe),"data-testid":n.timePicker(fe),disabled:se,ref:he,role:"combobox",variant:"outline",children:[$e(zn,{className:"mr-2 h-4 w-4"}),Ge]})}),Yt(_e,{align:"start",className:"p-0",style:{width:Ee},children:[$e("div",{className:"p-2 border-b",children:$e(m,{className:"h-8",onChange:(Me)=>Ce(Me.target.value),placeholder:"Search time...",ref:Se,value:ye})}),$e(u,{className:"h-[200px]",onWheel:_n,children:$e("div",{className:"p-1",children:Re.length===0?$e("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):Re.map((Me)=>{let mt=xe(Me);return $e("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",Me===c&&"bg-accent text-accent-foreground"),onClick:()=>Pe(Me),type:"button",children:mt},Me)})})})]})]})}var Rr=(c,b)=>{let[T,A]=b.split(":").map(Number);return t(c).hour(T).minute(A).second(0).millisecond(0)},Nr=(c,b,T)=>{let A=Rr(c,b);return T?A.hour(0).minute(0):A},kr=(c,b,T)=>{let A=Rr(c,b);return T?A.add(1,"day").startOf("day"):A},_t=(c,b)=>{if(!b)return{min:"00:00",max:"23:59"};let T=t(c),{minStart:A,maxEnd:G,hasBusinessHours:W}=Z({allDates:[T],businessHours:b,hideNonBusinessHours:!1});if(!W)return{min:"00:00",max:"23:59"};return{min:`${A.toString().padStart(2,"0")}:00`,max:`${(G-1).toString().padStart(2,"0")}:45`}};import{jsx as Te,jsxs as He,Fragment as Zn}from"react/jsx-runtime";var Mr="bg-blue-100 text-blue-800",$n=[{value:Mr,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"}],Hr=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Wn=(c,b)=>{if(c&&Hr.test(c))return c;return b??Mr},Un=(c)=>{if(Hr.test(c))return{backgroundColor:c,color:ue(c)};return{backgroundColor:void 0,color:c}},Kn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:A,initialColor:G})=>{if(c||!b)return Un(T);return{backgroundColor:A,color:G}},jt=({name:c,label:b,placeholder:T,value:A,required:G=!1,multiline:W=!1,onChange:pe})=>He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),W?Te(br,{className:"min-h-16 text-sm",id:c,name:c,onChange:pe,placeholder:T,required:G,value:A}):Te(m,{className:"h-8 text-sm sm:h-9",id:c,name:c,onChange:pe,placeholder:T,required:G,value:A})]}),Ir=({selectedEvent:c,onClose:b,onUpdate:T,onDelete:A,onAdd:G})=>{let{dialogState:W,openEditDialog:pe,openDeleteDialog:se,closeDialog:fe,handleConfirm:ve}=yt(b),{t:ge,timeFormat:ye,getEventManager:Ce,resources:Se}=r((be)=>({t:be.t,timeFormat:be.timeFormat,getEventManager:be.getEventManager,resources:be.resources??[]})),{id:he,resourceId:Ee,resourceIds:De,start:we=t(),end:xe=t().add(1,"hour"),allDay:Re=!1,color:Pe,backgroundColor:Ge,title:Me="",description:mt="",location:Jt=""}=c??{},er=Se.length>0,tr=Ee??De?.at(0),rr=er&&tr===void 0,[Nt,Ro]=Oe(tr),kt=er?Nt:Ee,ut=K(kt),or=Boolean(c&&Ce(c)),No=xe.isSame(xe.startOf("day")),ko=Re&&No?xe.subtract(1,"day"):xe,[Ke,nr]=Oe(we.toDate()),[Xe,Mt]=Oe(ko.toDate()),[Be,Mo]=Oe(Re),[Ht,Ho]=Oe(Wn(Ge,Pe)),[Io,Oo]=Oe(!1),Vo=Boolean(Pe||Ge),Ao=(be)=>{Ho(be),Oo(!0)},[It,ar]=Oe(we.format("HH:mm")),[pt,Ot]=Oe(xe.format("HH:mm")),[Ae,Lo]=Oe({title:Me,description:mt,location:Jt}),[Vt,Fo]=Oe({}),Go={...c,...Vt},Bo=(be)=>Fo((Ne)=>({...Ne,...be})),zo=(be)=>{if(!be)return;if(nr(be),t(be).isAfter(t(Xe)))Mt(be)},Yo=(be)=>{if(!be)return;if(Mt(be),be&&t(be).isBefore(t(Ke)))nr(be)},_o=(be)=>{if(Mo(be),!(be&&pt==="00:00"))return;Mt((Ne)=>t(Ne).isAfter(t(Ke),"day")?t(Ne).subtract(1,"day").toDate():Ne)},jo=(be)=>{if(ar(be),t(Ke).isSame(t(Xe),"day")&&be>pt)Ot(be)},$o=(be)=>{if(Ot(be),t(Ke).isSame(t(Xe),"day")&&be<It)ar(be)},At=(be)=>{let{name:Ne,value:Ie}=be.target;Lo((nt)=>({...nt,[Ne]:Ie}))};jn(()=>{if(Be)Ot("23:59")},[Be]);let Wo=(be)=>Se.find((Ie)=>String(Ie.id)===be)?.id??be,ir=rr&&Nt===void 0,Uo=(be)=>{if(be.preventDefault(),ir)return;let Ne=Nr(Ke,It,Be),Ie=kr(Xe,pt,Be),nt=Kn({colorChanged:Io,hadInitialColor:Vo,selectedColor:Ht,initialBackgroundColor:Ge,initialColor:Pe}),at={id:he||t().format("YYYYMMDDHHmmss"),title:Ae.title,start:Ne,end:Ie,resourceId:kt,description:Ae.description,location:Ae.location,allDay:Be,...nt,...Vt};if(c?.id&&or){pe(c,{title:Ae.title,start:Ne,end:Ie,resourceId:kt,description:Ae.description,location:Ae.location,allDay:Be,color:Ht,...Vt});return}if(he)T?.(at);else G?.(at);b()},Ko=()=>{if(!c?.id)return;if(or){se(c);return}A?.(c),b()},sr;if(ut)sr=(be)=>!j(t(be),ut);let Zo=_t(Ke,ut),qo=_t(Xe,ut),Xo=[["startDate",Ke,zo],["endDate",Xe,Yo]],Qo=[["startTime","start-time",It,jo,Zo],["endTime","end-time",pt,$o,qo]],Jo=Nt?.toString();return He(Zn,{children:[He("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:Uo,children:[Te(u,{className:"flex-1 min-h-0",children:He("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Te(jt,{label:ge("title"),name:"title",onChange:At,placeholder:ge("eventTitlePlaceholder"),required:!0,value:Ae.title}),Te(jt,{label:ge("description"),multiline:!0,name:"description",onChange:At,placeholder:ge("eventDescriptionPlaceholder"),value:Ae.description}),rr&&He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ge("resource")}),He(C,{onValueChange:(be)=>Ro(Wo(be)),value:Jo,children:[Te(h,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Te(D,{placeholder:ge("selectResource")})}),Te(E,{children:Se.map((be)=>Te(f,{value:String(be.id),children:be.title},String(be.id)))})]})]}),He("div",{className:"flex items-center space-x-2",children:[Te(v,{checked:Be,id:"allDay",onCheckedChange:(be)=>_o(be===!0)}),Te(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ge("allDay")})]}),Te("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Xo.map(([be,Ne,Ie])=>He("div",{children:[Te(s,{className:"text-xs sm:text-sm",children:ge(be)}),Te(xr,{className:"mt-1",closeOnSelect:!0,date:Ne,disabled:sr,onChange:Ie})]},be))}),!Be&&Te("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Qo.map(([be,Ne,Ie,nt,at])=>He("div",{children:[Te(s,{className:"text-xs sm:text-sm",children:ge(be)}),Te(Tr,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:at.max,minTime:at.min,name:Ne,onChange:nt,placeholder:ge("searchTime"),timeFormat:ye,value:Ie})]},be))}),He("div",{className:"grid gap-1 sm:gap-2",children:[Te(s,{className:"text-xs sm:text-sm",children:ge("color")}),Te(Er,{"aria-label":ge("color"),onChange:Ao,swatches:$n,value:Ht})]}),Te(jt,{label:ge("location"),name:"location",onChange:At,placeholder:ge("eventLocationPlaceholder"),value:Ae.location}),Te(cr,{event:Go,onChange:Bo})]})}),He(F,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[he&&Te(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:Ko,size:"sm",type:"button",variant:"destructive",children:ge("delete")}),He("div",{className:"flex w-full gap-2 sm:w-auto",children:[Te(o,{className:"flex-1 sm:flex-none",onClick:b,size:"sm",type:"button",variant:"outline",children:ge("cancel")}),Te(o,{className:"flex-1 sm:flex-none",disabled:ir,size:"sm",type:"submit",children:he?ge("update"):ge("create")})]})]})]}),Te(ft,{dialog:W,onCancel:fe,onResolve:ve})]})};import{jsx as Ct,jsxs as Or}from"react/jsx-runtime";var Vr=()=>{let{t:c,selectedEvent:b,isEventFormOpen:T,closeEventForm:A,addEvent:G,updateEvent:W,deleteEvent:pe,renderEventForm:se}=r((ye)=>({t:ye.t,selectedEvent:ye.selectedEvent,isEventFormOpen:ye.isEventFormOpen,closeEventForm:ye.closeEventForm,addEvent:ye.addEvent,updateEvent:ye.updateEvent,deleteEvent:ye.deleteEvent,renderEventForm:ye.renderEventForm})),ge={open:T,onClose:A,selectedEvent:b,onAdd:G,onUpdate:(ye)=>{W(ye.id,ye)},onDelete:(ye)=>{pe(ye.id)}};if(se)return se(ge);return Ct(R,{onOpenChange:A,open:T,children:Or(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Or(S,{className:"mb-2 sm:mb-4 shrink-0",children:[Ct(P,{className:"text-base sm:text-lg",children:b?.id?c("editEvent"):c("createEvent")}),Ct(_,{className:"text-xs sm:text-sm",children:b?.id?c("editEventDetails"):c("addNewEvent")})]}),Ct(Ir,{...ge})]})})};import{ChevronLeft as ga,ChevronRight as va,Download as ya,Plus as Da}from"lucide-react";import{ChevronDown as ta}from"lucide-react";import{useState as ra}from"react";function Ar(){let{currentLocale:c,timezone:b}=r((A)=>({currentLocale:A.currentLocale,timezone:A.timezone}));return{formatDateRange:(A,G)=>{let W=new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric"});if(A.year()===G.year())return W.formatRange(A.toDate(),G.toDate());return`${W.format(A.toDate())} – ${W.format(G.toDate())}`}}}import{useState as Xn}from"react";import{jsx as qn}from"react/jsx-runtime";function ht({label:c,isSelected:b,isCurrent:T,onSelect:A}){return qn("button",{"aria-pressed":b,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",T&&"ring-1 ring-inset ring-foreground/40",b&&"bg-primary text-primary-foreground"),onClick:A,type:"button",children:c})}import{jsx as $t,jsxs as Qn}from"react/jsx-runtime";function Lr({selected:c,onSelect:b}){let[T,A]=Xn(()=>c.year()),G=t(),W=Array.from({length:12},(pe,se)=>({index:se,label:c.month(se).format("MMM")}));return Qn("div",{className:"w-72 p-3","data-slot":"month-grid",children:[$t(Qe,{label:T,nextLabel:"Next year",onNext:()=>A((pe)=>pe+1),onPrev:()=>A((pe)=>pe-1),prevLabel:"Previous year"}),$t("div",{className:"grid grid-cols-3 gap-1",children:W.map((pe)=>{let se=T===c.year()&&pe.index===c.month(),fe=T===G.year()&&pe.index===G.month()&&!se;return $t(ht,{isCurrent:fe,isSelected:se,label:pe.label,onSelect:()=>b(c.year(T).month(pe.index).date(1))},pe.index)})})]})}import{useState as Jn}from"react";import{jsx as Wt,jsxs as ea}from"react/jsx-runtime";var dt=12;function Fr({selected:c,onSelect:b}){let[T,A]=Jn(()=>c.year()-c.year()%dt),G=t(),W=Array.from({length:dt},(pe,se)=>T+se);return ea("div",{className:"w-72 p-3","data-slot":"year-grid",children:[Wt(Qe,{label:`${T} – ${T+dt-1}`,nextLabel:"Next years",onNext:()=>A((pe)=>pe+dt),onPrev:()=>A((pe)=>pe-dt),prevLabel:"Previous years"}),Wt("div",{className:"grid grid-cols-3 gap-1",children:W.map((pe)=>{let se=pe===c.year(),fe=pe===G.year()&&!se;return Wt(ht,{isCurrent:fe,isSelected:se,label:pe,onSelect:()=>b(c.year(pe))},pe)})})]})}import{jsx as Ze,jsxs as Gr}from"react/jsx-runtime";var oa={day:"day",week:"week",month:"month",year:"year"};function na(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return oa[b.unit]??"range"}function Br({className:c}){let{currentDate:b,currentRange:T,view:A,selectDate:G,firstDayOfWeek:W,getViews:pe}=r((Pe)=>({currentDate:Pe.currentDate,currentRange:Pe.currentRange,view:Pe.view,selectDate:Pe.selectDate,firstDayOfWeek:Pe.firstDayOfWeek,getViews:Pe.getViews})),{formatDateRange:se}=Ar(),[fe,ve]=ra(!1),ge=i(b,W),ye=ge.at(0)??b,Ce=ge.at(-1)??b,Se=(Pe)=>{G(Pe),ve(!1)},he=na(pe().find((Pe)=>Pe.name===A)),De={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:se(ye,Ce),day:b.format("ddd, MMM D, YYYY"),range:se(T.start,T.end)}[he],we=Ze(lt,{defaultMonth:b.toDate(),firstDayOfWeek:W,onSelect:(Pe)=>Pe&&Se(t(Pe)),selected:b.toDate()}),Re={year:Ze(Fr,{onSelect:Se,selected:b}),month:Ze(Lr,{onSelect:Se,selected:b}),week:Ze(lt,{defaultMonth:b.toDate(),firstDayOfWeek:W,highlightedWeekOf:b,onSelect:(Pe)=>Pe&&Se(t(Pe)),weekHover:!0}),day:we,range:we}[he];return Gr(ze,{onOpenChange:ve,open:fe,children:[Ze(Ye,{asChild:!0,children:Gr(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[De,Ze(ta,{className:"size-4 shrink-0 opacity-50"})]})}),Ze(_e,{align:"start",className:"w-auto p-0",children:Re})]})}var Ut=`\r
2
- `,aa=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Ut),Et=(c)=>c.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
- `,"\\n").replaceAll("\r",""),zr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ia=(c)=>c.uid||`${c.id}@ilamy.calendar`,sa=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),A=c.allDay?";VALUE=DATE":"",G=["BEGIN:VEVENT",`UID:${ia(c)}`,`DTSTART${A}:${zr(c.start,c.allDay)}`,`DTEND${A}:${zr(c.end,c.allDay)}`,`SUMMARY:${Et(c.title)}`,c.description&&`DESCRIPTION:${Et(c.description)}`,c.location&&`LOCATION:${Et(c.location)}`].filter(Boolean),W=b("ical:vevent-properties",c).filter((se)=>typeof se==="string"),pe=[`DTSTAMP:${T}`,`CREATED:${T}`,`LAST-MODIFIED:${T}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...G,...W,...pe].join(Ut)},la=(c,b,T="ilamy Calendar")=>{let A=Et(T),G=c.map((W)=>sa(W,b));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${A}`,`X-WR-CALDESC:Exported from ${A}`,aa,...G,"END:VCALENDAR"].join(Ut)},Yr=(c,b,T="calendar.ics",A="ilamy Calendar")=>{let G=new Blob([la(c,b,A)],{type:"text/calendar;charset=utf-8"}),W=URL.createObjectURL(G),pe=T;if(!T.endsWith(".ics"))pe=`${T}.ics`;let se=document.createElement("a");se.href=W,se.download=pe,document.body.append(se),se.click(),se.remove(),URL.revokeObjectURL(W)};function _r(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Yr(c,b,T,"ilamy Calendar")}}import*as Ve from"@radix-ui/react-dropdown-menu";import{jsx as ct}from"react/jsx-runtime";function jr({...c}){return ct(Ve.Root,{"data-slot":"dropdown-menu",...c})}function $r({...c}){return ct(Ve.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Wr({className:c,sideOffset:b=4,align:T="end",...A}){return ct(Ve.Portal,{children:ct(Ve.Content,{align:T,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",c),"data-slot":"dropdown-menu-content",sideOffset:b,...A})})}function Ur({className:c,...b}){return ct(Ve.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",c),"data-slot":"dropdown-menu-item",...b})}import{Check as da,ChevronDown as ca}from"lucide-react";function bt(){let{getViews:c,resources:b}=r((A)=>({getViews:A.getViews,resources:A.resources})),T=Boolean(b?.length);return c().filter((A)=>!T||A.supportsResources)}import{jsx as We,jsxs as Kt}from"react/jsx-runtime";function Kr({className:c}){let{view:b,setView:T,t:A}=r((fe)=>({view:fe.view,setView:fe.setView,t:fe.t})),G=bt(),W=G.find((fe)=>fe.name===b),pe=W?A(W.label??W.name):"",se=W?.icon;return Kt(jr,{children:[We($r,{asChild:!0,className:c,children:Kt(o,{size:"default",variant:"outline",children:[se&&We(se,{className:"size-4"}),We("span",{children:pe}),We(ca,{className:"size-4 opacity-50"})]})}),We(Wr,{align:"end",className:"min-w-40",children:G.map((fe)=>{let ve=fe.icon;return Kt(Ur,{onSelect:()=>T(fe.name),children:[We(ve,{className:"size-4"}),We("span",{className:"flex-1",children:A(fe.label??fe.name)}),fe.name===b&&We(da,{className:"size-4"})]},fe.name)})})]})}import*as St from"@radix-ui/react-toggle-group";import{cva as ma}from"class-variance-authority";import{createContext as ua,useContext as pa}from"react";import{jsx as Zt}from"react/jsx-runtime";var fa=ma("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"}}),Zr=ua({size:"default",variant:"default"});function qr({className:c,variant:b,size:T,children:A,...G}){return Zt(St.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...G,children:Zt(Zr.Provider,{value:{variant:b,size:T},children:A})})}function Xr({className:c,children:b,variant:T,size:A,...G}){let W=pa(Zr);return Zt(St.Item,{className:e(fa({variant:W.variant||T,size:W.size||A}),c),"data-slot":"toggle-group-item",...G,children:b})}import{jsx as Qr}from"react/jsx-runtime";function Jr({className:c}){let{view:b,setView:T,t:A}=r((W)=>({view:W.view,setView:W.setView,t:W.t})),G=bt();return Qr(qr,{className:e("bg-muted gap-0 rounded-lg p-0.75",c),onValueChange:(W)=>W&&T(W),size:"sm",type:"single",value:b,children:G.map((W)=>Qr(Xr,{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:W.name,children:A(W.label??W.name)},W.name))})}import{jsx as ke,jsxs as et}from"react/jsx-runtime";var eo=({className:c=""})=>{let{nextPeriod:b,prevPeriod:T,today:A,openEventForm:G,headerComponent:W,headerClassName:pe,t:se,hideExportButton:fe}=r((ge)=>({nextPeriod:ge.nextPeriod,prevPeriod:ge.prevPeriod,today:ge.today,openEventForm:ge.openEventForm,headerComponent:ge.headerComponent,headerClassName:ge.headerClassName,t:ge.t,hideExportButton:ge.hideExportButton})),ve=_r();if(W)return W;return ke("div",{className:e("@container/base-header w-full",pe),"data-testid":"calendar-header",children:et("div",{className:e("flex flex-col items-center gap-2 @lg/base-header:flex-row @lg/base-header:justify-between",c),children:[et("div",{className:"flex min-w-0 items-center gap-2",children:[et("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[ke(o,{"aria-label":se("previous"),className:"h-full",onClick:T,size:"icon",variant:"ghost",children:ke(ga,{className:"size-4"})}),ke(o,{"aria-label":se("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:ke(va,{className:"size-4"})})]}),ke(o,{onClick:A,size:"default",variant:"outline",children:se("today")}),ke(Br,{})]}),et("div",{className:"flex items-center gap-2",children:[ke(Jr,{className:"hidden @3xl/base-header:flex"}),ke(Kr,{className:"@3xl/base-header:hidden"}),!fe&&et(o,{"aria-label":se("export"),onClick:ve,size:"default",variant:"outline",children:[ke(ya,{className:"size-4"}),ke("span",{className:"hidden @2xl/base-header:inline",children:se("export")})]}),et(o,{"aria-label":se("new"),onClick:()=>G(),size:"default",children:[ke(Da,{className:"size-4"}),ke("span",{className:"hidden @2xl/base-header:inline",children:se("new")})]})]})]})})};import{useMemo as xo}from"react";import{useRef as ao}from"react";import{useEffect as Ca,useRef as ha}from"react";var Ea=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,ba="[data-hour]",Sa='[data-start]:not([data-all-day="true"])',xa=(c)=>{let T=Ea.exec(c)?.at(1);if(!T)return null;let A=Number.parseInt(T,10);return A>=0&&A<=23?A:null},qt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),wa=(c,b)=>{let T=c.at(0),A=c.at(-1);if(!T||!A)return null;if(b<=qt(T))return T;if(b>=qt(A))return A;return c.find((G)=>qt(G)===b)??null},Pa=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ta=(c)=>{let b=Array.from(c.querySelectorAll(Sa)),T=b.at(0),A=t(),G=b.find((W)=>d(Pa(W),A,A));if(!T||!G)return null;return{target:G,origin:T}},Ra=(c,b)=>{let T=b?xa(b):null;if(T===null)return null;let A=Array.from(c.querySelectorAll(ba)),G=A.at(0),W=wa(A,T);if(!G||!W)return null;return{target:W,origin:G}},Na=(c,b,T,A)=>{let G=b.getBoundingClientRect(),W=T.getBoundingClientRect(),pe=G.left-W.left,se=G.top-W.top;to(c,A,A==="horizontal"?pe:se)},to=(c,b,T)=>{let A=b==="horizontal"?"left":"top";c.scrollTo({[A]:T,behavior:"auto"})},ka=(c,{scrollTime:b,scrollToNow:T,axis:A})=>{let W=(T?Ta(c):null)??Ra(c,b);if(W)return Na(c,W.target,W.origin,A),!0;if(T)return to(c,A,0),!0;return!1},xt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:A,scrollKey:G,axis:W="vertical"})=>{let pe=ha(null);Ca(()=>{if(!A)return;let se=`${G}|${b}|${T}`;if(pe.current===se)return;let fe=c.current;if(!fe)return;if(ka(fe,{scrollTime:b,scrollToNow:T,axis:W}))pe.current=se},[A,b,T,G,c,W])};import{useLayoutEffect as Ma}from"react";var Xt="data-sticky-inset",wt=(c)=>c?"top":void 0,ro={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},oo=new Set(["hidden","scroll","auto","overlay","clip"]),Ha=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:A,overflowY:G}=getComputedStyle(T);if(oo.has(A)||oo.has(G))b.push(T)}return b},Ia=(c,b,T)=>{let A=b.getBoundingClientRect(),G={left:-A.left,top:-A.top};for(let pe of T){let se=pe.getBoundingClientRect();G.left=Math.max(G.left,se.left-A.left),G.top=Math.max(G.top,se.top-A.top)}let W=c.querySelectorAll(`[${Xt}]`);for(let pe of W){let se=pe.getAttribute(Xt),fe=pe.getBoundingClientRect();if(se==="left")G.left=Math.max(G.left,fe.right-A.left);if(se==="top")G.top=Math.max(G.top,fe.bottom-A.top)}return{left:Math.max(0,G.left),top:Math.max(0,G.top)}},Pt=(c,b,T)=>{let{currentDate:A,view:G,stickyViewHeader:W}=r((se)=>({currentDate:se.currentDate,view:se.view,stickyViewHeader:se.stickyViewHeader})),pe=n.stickyInsets(G,A,W,T);Ma(()=>{let se=c.current,fe=b.current;if(!se||!fe)return;let ve=Ha(se),ge=()=>{let Ee=Ia(se,fe,ve);fe.style.setProperty(ro.left,`${Ee.left}px`),fe.style.setProperty(ro.top,`${Ee.top}px`)};ge();let ye,Ce=()=>{if(ye!==void 0)return;ye=requestAnimationFrame(()=>{ye=void 0,ge()})},Se=[...ve,window];for(let Ee of Se)Ee.addEventListener("scroll",Ce,{passive:!0});window.addEventListener("resize",Ce,{passive:!0});let he=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ge);he?.observe(fe);for(let Ee of se.querySelectorAll(`[${Xt}]`))he?.observe(Ee);return()=>{for(let Ee of Se)Ee.removeEventListener("scroll",Ce);if(window.removeEventListener("resize",Ce),he?.disconnect(),ye!==void 0)cancelAnimationFrame(ye)}},[c,b,pe])};import{memo as Oa}from"react";import{jsx as Aa}from"react/jsx-runtime";var Va=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:A}=r((G)=>({stickyViewHeader:G.stickyViewHeader,viewHeaderClassName:G.viewHeaderClassName}));return Aa("div",{className:e("flex h-12 w-fit",T&&"sticky top-0 z-21 bg-background",b,A),"data-sticky-inset":wt(T),"data-testid":"horizontal-grid-header",children:c})},no=Oa(Va);import{jsx as tt,jsxs as io}from"react/jsx-runtime";var so=({rows:c,children:b,classes:T,allDay:A,gridType:G,variant:W="resource",dayNumberHeight:pe})=>{let{currentDate:se,view:fe,scrollTime:ve,scrollToNow:ge}=r(),ye=ao(null),Ce=ao(null),Se=W==="resource",he=!Se;xt({viewportRef:Ce,scrollTime:ve,scrollToNow:ge,enabled:Se,scrollKey:`${fe}-${se.format("YYYY-MM-DD")}`,axis:"horizontal"}),Pt(ye,Ce,c.length);let Ee=b&&tt(no,{className:T?.header,children:b});return io("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:ye,children:[he&&Ee,io(u,{className:e("h-full",he&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Ce},children:[Se&&Ee,tt("div",{className:e("flex flex-1 w-fit",T?.body),"data-testid":"horizontal-grid-body",children:tt("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:c.map((De)=>tt(re,{allDay:De.allDay??A,dayNumberHeight:pe,gridType:G,variant:W,...De},De.id))},se.format("YYYY-MM"))}),tt(y,{className:"z-30"}),tt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as Eo}from"react";import{memo as Ua}from"react";import{memo as _a,useMemo as ja}from"react";import{useMemo as co}from"react";var La=(c)=>{let b=[],T=[],A=null;for(let G of c){if(A&&G.start.isSameOrAfter(A)){if(T.length>0)b.push(T);T=[]}T.push(G),A=A?t.max(A,G.end):G.end}if(T.length>0)b.push(T);return b},lo=(c,{gridStart:b,totalUnits:T,gridType:A,isDiscrete:G})=>{let W=c.start.diff(b,A,!0),pe=c.end.diff(b,A,!0);if(G){if(W=Math.floor(W),pe=Math.ceil(pe),pe<=W)pe=W+1}let se=W<0,fe=pe>T;if(se)W=0;if(fe)pe=T;let ve=Math.max(0,pe-W);if(ve===0)return null;return{top:W/T*100,height:ve/T*100,isTruncatedStart:se,isTruncatedEnd:fe}},Fa={2:25,3:50,4:60},Ga=70,Ba=(c)=>Fa[c]??Ga,za=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let se=lo(T,b);if(!se)return[];return[{kind:"vertical",event:T,left:0,width:100,...se}]}let A=[...c].sort((se,fe)=>{let ve=fe.end.diff(fe.start,"minute")-se.end.diff(se.start,"minute");return ve!==0?ve:se.start.diff(fe.start)}),G=A.length,W=G>1?Ba(G)/(G-1):0,pe=[];for(let se=0;se<G;se++){let fe=A.at(se);if(!fe)continue;let ve=lo(fe,b);if(!ve)continue;let ge=se===0?0:W*se;pe.push({kind:"vertical",event:fe,...ve,left:ge,width:100-ge,zIndex:se+1})}return pe},Tt=({days:c,gridType:b="hour",events:T})=>{let A=T.filter((W)=>!W.allDay).toSorted((W,pe)=>W.start.diff(pe.start));if(A.length===0)return[];let G={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return La(A).flatMap((W)=>za(W,G))};var mo=({days:c,gridType:b,resourceId:T})=>{let{getEventsForDateRange:A}=r(),G=c.at(0),W=c.at(-1),pe=G?.startOf("day"),se=W?.endOf("day"),fe=co(()=>{if(!pe||!se)return[];let ge=A(pe,se);if(T)ge=x(ge,T);return ge.filter((ye)=>!ye.allDay)},[pe,se,A,T]);return co(()=>Tt({days:c,events:fe,gridType:b}),[c,b,fe])};import{jsx as Ya,jsxs as uo}from"react/jsx-runtime";function po({previewPositioned:c}){let b=r((pe)=>pe.timeFormat),{event:T,isTruncatedStart:A,isTruncatedEnd:G}=c,W=Y(b);return uo(ee,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:G,isTruncatedStart:A,orientation:"vertical",style:te(c),children:[uo("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(W)," – ",T.end.format(W)]}),Ya("p",{className:e("text-[10px] font-bold sm:text-xs truncate",O.vertical),children:T.title})]})}import{jsx as fo}from"react/jsx-runtime";var go=(c,b,T,A)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${A??"no-resource"}`;function vo({positioned:c,elementId:b,range:T,resourceId:A,draggedEventId:G}){let{event:W}=c,pe=W.end.diff(W.start,"minute")<=15;return fo("div",{className:"absolute","data-testid":n.container.verticalEvent(W.id),style:te(c),children:fo(H,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":pe}),dragSegment:U(W,T,"vertical"),elementId:b,event:W,isBeingDragged:G===W.id,isTruncatedEnd:c.isTruncatedEnd,isTruncatedStart:c.isTruncatedStart,sourceResourceId:A})})}import{jsx as Rt,jsxs as Wa}from"react/jsx-runtime";var $a=({days:c,gridType:b="hour",resourceId:T,resource:A,"data-testid":G})=>{let W=r((he)=>he.resources),pe=p(),se=mo({days:c,gridType:b,resourceId:T}),fe=c.at(0),ve=c.at(-1)?.add(1,b),ge=!T||W?.at(0)?.id===T,ye=b==="hour"&&Boolean(fe&&ve),Ce=J({days:c,gridType:b,resourceId:T}),Se=ja(()=>{if(!Ce)return null;return Tt({days:c,gridType:b,events:[Ce]}).at(0)??null},[Ce,c,b]);return Rt(L.Provider,{value:"vertical",children:Wa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":G,children:[ye&&fe&&ve&&Rt(Q,{rangeEnd:ve,rangeStart:fe,resource:A,withDot:ge}),se.map((he,Ee)=>{let De=go(he.event.id,Ee,c,T);return Rt(vo,{draggedEventId:pe?.event.id,elementId:De,positioned:he,range:{start:fe,end:ve},resourceId:T},n.listKey(De,"wrapper"))}),Se&&Rt(po,{previewPositioned:Se})]})})},yo=_a($a);import{jsx as rt,jsxs as Za}from"react/jsx-runtime";var Ka=({id:c,days:b,resource:T,"data-testid":A,"data-sticky-inset":G,gridType:W,className:pe,renderCell:se,noEvents:fe,slotDurationMinutes:ve=60})=>{let ge=T?.id,ye=Math.floor(60/ve),Ce=Array.from({length:ye},(he,Ee)=>Ee*ve),Se=Ce.length>1;return rt("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",pe),"data-sticky-inset":G,"data-testid":A||n.container.vertical.col(c),children:Za("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${b.length}, minmax(0, 1fr))`},children:[b.map((he,Ee)=>{let De=he.format("HH");if(se){let we=c===n.col.time,xe=we?n.cell.verticalTime(De):n.cell.vertical(he,De,"00",ge);return rt("div",{className:"min-h-[60px] bg-background","data-hour":we?De:void 0,"data-testid":xe,children:se(he)},n.listKey(c,Ee,De))}return rt("div",{className:"flex flex-col min-h-[60px]",children:Ce.map((we,xe)=>{let Re=String(we).padStart(2,"0"),Pe=n.cell.vertical(he,De,Re,ge),Ge=Se&&xe<Ce.length-1;return rt(z,{className:e("hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Ge&&"border-b border-dashed"),"data-testid":Pe,day:Se?he.minute(we):he,gridType:W,hour:W==="hour"?he.hour():void 0,isSubDivider:Ge,minute:Se?we:void 0,resourceId:ge,shouldRenderEvents:!1,slotDurationMinutes:ve},n.listKey(c,Ee,Re))})},n.listKey(c,Ee,De))}),!fe&&rt("div",{className:"absolute inset-0 z-10 pointer-events-none",children:rt(yo,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:W,resource:T,resourceId:ge})})]})})},Do=Ua(Ka);import{memo as qa}from"react";import{jsx as Co,jsxs as Qa}from"react/jsx-runtime";var Xa=({children:c,classes:b,allDayRow:T,expandAllDayRow:A=!1})=>{let{stickyViewHeader:G,viewHeaderClassName:W}=r((se)=>({stickyViewHeader:se.stickyViewHeader,viewHeaderClassName:se.viewHeaderClassName})),pe="min-w-full w-fit";return Qa("div",{className:e(A&&"flex h-full flex-col",G&&"sticky top-0 z-21 bg-background",W),"data-sticky-inset":wt(G),children:[Co("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&Co("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",A&&"flex-1 overflow-hidden",b?.allDay),"data-testid":"vertical-grid-all-day",children:T})]})},ho=qa(Xa);import{jsx as ot,jsxs as bo}from"react/jsx-runtime";var So=({columns:c,children:b,gridType:T="day",variant:A="resource",classes:G,allDayRow:W,slotDurationMinutes:pe,style:se})=>{let fe=A==="resource",ve=!fe,ge=c.every((Re)=>!Re.days?.length),{currentDate:ye,view:Ce,scrollTime:Se,scrollToNow:he}=r(),Ee=Eo(null),De=Eo(null);xt({viewportRef:De,scrollTime:Se,scrollToNow:he,enabled:!ge,scrollKey:`${Ce}-${ye.format("YYYY-MM-DD")}`}),Pt(Ee,De,c.length);let xe=b&&ot(ho,{allDayRow:W,classes:{header:G?.header,allDay:G?.allDay},expandAllDayRow:ge,children:b});if(ge&&xe)return ot("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:se,children:xe});return bo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:se,children:[ve&&xe,bo(u,{className:e("h-full",ve&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:De},children:[fe&&xe,ot("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",G?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:c.map((Re,Pe)=>ot(Do,{...Re,gridType:T,slotDurationMinutes:pe},n.listKey(Re.id,Pe)))}),ot(y,{className:"z-30"})," ",ot(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as qe}from"react/jsx-runtime";var Ja=(c,b)=>b==="vertical",ei=({specs:c,header:b,composesResourceAxis:T,variant:A})=>{let{slotDuration:G}=r((Ce)=>({slotDuration:Ce.slotDuration})),W=c.some((Ce)=>Ce.gridType==="hour")?"hour":"day",pe=c.filter((Ce)=>!Ce.noEvents).map((Ce)=>Ce.day).filter((Ce)=>Boolean(Ce)),se=c.find((Ce)=>Ce.noEvents),ve=Boolean(se?.className?.includes(M))?{cell:"flex-1 min-w-0",spacer:M}:void 0,ge;if(W==="hour")ge=T?qe(ce,{columns:c}):qe(ne,{classes:ve,days:pe});return qe(So,{allDayRow:ge,classes:T?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:c,gridType:W,slotDurationMinutes:G,variant:A,children:b})},ti=({specs:c,header:b,composesResourceAxis:T,variant:A})=>{let G=c.some((se)=>se.columns?.some((fe)=>fe.gridType==="hour"))?"hour":"day",W=c.some((se)=>se.columns?.some((fe)=>fe.days)),pe=T?{header:e(W&&de,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return qe(so,{classes:pe,dayNumberHeight:T?0:void 0,gridType:G,rows:c,variant:A,children:b})},wo=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:A,businessHours:G,hideNonBusinessHours:W,resources:pe,orientation:se,weekViewGranularity:fe}=r((De)=>({currentDate:De.currentDate,firstDayOfWeek:De.firstDayOfWeek,hiddenDays:De.hiddenDays,businessHours:De.businessHours,hideNonBusinessHours:De.hideNonBusinessHours,resources:De.resources,orientation:De.orientation,weekViewGranularity:De.weekViewGranularity})),ve=xo(()=>({firstDayOfWeek:T,hiddenDays:A,businessHours:G,hideNonBusinessHours:W,resources:pe,orientation:se,weekViewGranularity:fe}),[T,A,G,W,pe,se,fe]),ge=xo(()=>c.columns?.(b,ve),[c,b,ve]);if(!ge||!c.layout){let De=c.component;if(De)return qe(De,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${c.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let Ce=Boolean(pe?.length)&&Boolean(c.supportsResources),Se=Ce?se??"horizontal":c.layout,he=Ce?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ve});if(Ja(ge,Se))return qe(ei,{composesResourceAxis:Ce,header:Ee,specs:ge,variant:he});return qe(ti,{composesResourceAxis:Ce,header:Ee,specs:ge,variant:he})};var Po=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>I[b]))};function To(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ue,jsxs as ai}from"react/jsx-runtime";var ni=()=>{let{view:c,getViews:b}=r((G)=>({view:G.view,getViews:G.getViews})),T=b().find((G)=>G.name===c);return ai("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ue(eo,{className:"p-1 shrink-0 mb-1"}),Ue(Cr,{children:Ue(l,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:c,children:Ue("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:T?Ue(wo,{view:T},c):null})})}),Ue(Vr,{})]})},Qt=({events:c,firstDayOfWeek:b="sunday",initialView:T="month",initialDate:A,eventSpacing:G=q,eventHeight:W=X,stickyViewHeader:pe=!0,viewHeaderClassName:se="",timeFormat:fe="12-hour",hideNonBusinessHours:ve=!1,hiddenDays:ge,resources:ye,orientation:Ce,...Se})=>{let he=Boolean(ye?.length),Ee=oi(()=>To(c),[c]);return ri(()=>{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.")},[Ce,he]),Ue(B,{eventHeight:W,eventSpacing:G,events:Ee,firstDayOfWeek:I[b],hiddenDays:Po(ge),hideNonBusinessHours:ve,initialDate:A,initialView:T,orientation:Ce,resources:ye,stickyViewHeader:pe,timeFormat:fe,viewHeaderClassName:se,...Se,children:Ue(ni,{})})};import{jsx as si}from"react/jsx-runtime";var ii=(c)=>si(Qt,{...c});export{Qt as IlamyCalendar,ii as IlamyResourceCalendar,lr as SLOT_EVENT_FORM,dr as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,ae as defaultTranslations,me as useIlamyCalendarContext};
1
+ import{t}from"./shared/chunk-cn24081x.js";import{R,w,S,G,P,W}from"./shared/chunk-1x8xjsbq.js";import{se,r,fe,l,g,K,de,ce,ie,p,O,I,M,a,i,L,q,n,X,Z,Q,H,ue,B,J,x,F,A,z,ee,te,re,ne,oe,j,ae,me,_}from"./shared/chunk-mn44xvnt.js";import{e,d,N,pe}from"./shared/chunk-tfk3a0d4.js";import{o,v,m,s,C,D,E,h,f}from"./shared/chunk-p26ryh5z.js";import{u,y}from"./shared/chunk-xf8cy2gp.js";var cr="event-form",mr="event-mutation-scope",ur=({event:c,onChange:b})=>r((k)=>k.renderSlot)(cr,{event:c,onChange:b}),gt=({dialog:c,onResolve:b,onCancel:T})=>{let k=r((le)=>le.getEventManager);if(!(c.isOpen&&c.event))return null;let V=k(c.event),Y={event:c.event,operation:c.operation,resolve:b,cancel:T};return V?.renderSlot?.(mr,Y)};import{useEffect as ii,useMemo as si}from"react";import{DndContext as wn}from"@dnd-kit/core";import{useId as Pn}from"react";import{MouseSensor as nn,TouchSensor as an,useSensor as fr,useSensors as sn}from"@dnd-kit/core";import{useEffect as ln,useRef as vt,useState as dn}from"react";var rn=(c)=>c.hour!==void 0,Ft=(c,b,T=g)=>{let{date:k,hour:V=0,minute:Y=0,allDay:le}=b,U=c.end.diff(c.start,"second"),ge=(Pe)=>({start:Pe,end:Pe.add(U,"second")});if(rn(b)){let Ne=t(k).hour(V).minute(Y).subtract(T.minutes,"minute");return{...ge(Ne),allDay:!1}}let ye=t(k).subtract(T.days,"day"),ve=le===!0,De=le===void 0,Ce=Boolean(c.allDay);if(ve||De&&Ce)return{...ge(ye.startOf("day")),allDay:!0};let Ee=ye.format("YYYY-MM-DD"),he=c.start.format("HH:mm:ss.SSS"),we=t(`${Ee}T${he}`);return{...ge(we),allDay:!1}},on=(c,b,T)=>{if(T===void 0||b===T)return{};if(!c.resourceIds)return{resourceId:T};let V=c.resourceIds.indexOf(b);if(V===-1)return{};let Y=c.resourceIds.slice();if(Y.splice(V,1),!Y.includes(T))Y.push(T);return{resourceIds:Y}},pr=(c,b,T=g)=>{let{active:k,over:V}=c;if(!k||!V||!b)return null;let Y=V.data.current||{};if(Y.disabled)return null;let{resourceId:le}=Y,{start:U,end:ge,allDay:ye}=Ft(b,Y,T),ve=k.data.current?.sourceResourceId,De={start:U,end:ge,...on(b,ve,le),allDay:ye};return{activeEvent:b,updates:De}};var cn=(c,b)=>{if(!c)return!1;let T=c.start.isSame(b.start)&&c.end.isSame(b.end),k=c.resourceId===b.resourceId&&c.allDay===b.allDay,V=c.isDropAllowed===b.isDropAllowed;return T&&k&&V},mn=({active:c,activatorEvent:b})=>{if(c.data.current?.type!=="calendar-event")return null;let T=c.data.current.event,k=c.data.current.dragSegment;if(!k)return{calendarEvent:T,pending:null};let V=c.data.current.getBarRect;return{calendarEvent:T,pending:{calendarEvent:T,segment:k,activatorEvent:b,barRect:V?.()}}},un=(c,b,T)=>{let k=b??{},{start:V,end:Y,allDay:le}=Ft(c,k,T);return{event:c,start:V,end:Y,resourceId:k.resourceId??c.resourceId,allDay:le,isDropAllowed:!k.disabled}},pn=(c)=>{let b=ce(c);ln(()=>{if(!b)return;let T=document.body.style.cursor;return document.body.style.cursor=b,()=>{document.body.style.cursor=T}},[b])},fn={activationConstraint:{distance:2}},gn={activationConstraint:{delay:100,tolerance:5}},vn=()=>{let c=fr(nn,fn),b=fr(an,gn);return sn(c,b)},gr=(c)=>{let b=r((be)=>be.slotDuration),T=vn(),k=vt(null),V=vt(g),Y=vt(null),le=vt(null),[U,ge]=dn(null);pn(U);let ye=()=>{k.current=null,V.current=g,Y.current=null,ge(null),le.current?.setActiveEvent(null)},ve=(be)=>{let Ee=mn(be);if(!Ee)return;le.current?.setActiveEvent(Ee.calendarEvent),k.current=Ee.calendarEvent,V.current=g,Y.current=Ee.pending},De=(be)=>{let Ee=Y.current;if(!Ee)return;let he=Ee.barRect??be.active.rect.current.initial;if(!he)return;V.current=de({activeEvent:Ee.calendarEvent,initialRect:he,activatorEvent:Ee.activatorEvent,segment:Ee.segment,slotDurationMinutes:b}),Y.current=null};return{sensors:T,dragPreview:U,overlayRef:le,handlers:{onDragStart:ve,onDragOver:(be)=>{De(be);let Ee=k.current;if(!Ee||!be.over){ge(null);return}let he=un(Ee,be.over.data.current,V.current);ge((we)=>{if(cn(we,he))return we;return he})},onDragEnd:(be)=>{let Ee=pr(be,k.current,V.current);if(Ee)c(Ee.activeEvent,Ee.updates);ye()},onDragCancel:ye}}};import{useCallback as yt,useEffect as yn,useRef as Dn,useState as Cn}from"react";var Gt={isOpen:!1,operation:"edit",event:null};function Dt(c){let{applyScopedEdit:b,applyScopedDelete:T}=r((ve)=>({applyScopedEdit:ve.applyScopedEdit,applyScopedDelete:ve.applyScopedDelete})),[k,V]=Cn(Gt),Y=Dn(k);yn(()=>{Y.current=k},[k]);let le=yt((ve,De)=>{V({isOpen:!0,operation:"edit",event:ve,updates:De})},[]),U=yt((ve)=>{V({isOpen:!0,operation:"delete",event:ve})},[]),ge=yt(()=>V(Gt),[]),ye=yt((ve)=>{let De=Y.current;if(!De.event)return;if(De.operation==="edit")b(De.event,De.updates??{},ve);else T(De.event,ve);V(Gt),c?.()},[b,T,c]);return{dialogState:k,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}}var vr=()=>{let{updateEvent:c,getEventManager:b}=r((U)=>({updateEvent:U.updateEvent,getEventManager:U.getEventManager})),{dialogState:T,openEditDialog:k,closeDialog:V,handleConfirm:Y}=Dt();return{commitDrop:(U,ge)=>{let ye=Object.keys(ge).length===0;if(!U.id||ye)return;if(b(U)?.applyEdit){k(U,ge);return}c(U.id,ge)},scopeDialog:{dialog:T,onCancel:V,onResolve:Y}}};import{pointerWithin as hn}from"@dnd-kit/core";var yr=(c)=>{let{droppableContainers:b,droppableRects:T,pointerCoordinates:k}=c;if(!k)return[];let{x:V,y:Y}=k,le=(ge)=>{if(!(ge.top<=Y))return!1;if(!(Y<=ge.bottom))return!1;if(!(ge.left<=V))return!1;return V<=ge.right},U=b.filter((ge)=>{let ye=T.get(ge.id);return ye!==void 0&&le(ye)});return hn({...c,droppableContainers:U})};import{DragOverlay as En}from"@dnd-kit/core";import{snapCenterToCursor as bn}from"@dnd-kit/modifiers";import{useImperativeHandle as Sn,useState as xn}from"react";import{jsx as Dr}from"react/jsx-runtime";var Cr=({ref:c})=>{let[b,T]=xn(null),k=p();if(Sn(c,()=>({setActiveEvent:T})),k)return null;return Dr(En,{modifiers:[bn],children:b&&Dr("div",{className:e("cursor-grabbing truncate rounded-md px-3 py-1.5 text-xs font-medium shadow-xl opacity-80",O(b)),style:I(b),children:b.title})})};import{jsx as Bt,jsxs as hr}from"react/jsx-runtime";function Er({children:c}){let b=Pn(),T=r((ve)=>ve.disableDragAndDrop),{commitDrop:k,scopeDialog:V}=vr(),{sensors:Y,dragPreview:le,overlayRef:U,handlers:ge}=gr(k),ye=le!==null;if(T)return c;return hr(ie.Provider,{value:le,children:[hr(wn,{collisionDetection:yr,id:b,sensors:Y,...ge,children:[Bt("div",{className:"contents","data-dragging":ye?"true":void 0,children:c}),Bt(Cr,{ref:U})]}),Bt(gt,{...V})]})}import{ChevronDownIcon as Tn}from"lucide-react";import{useEffect as Rn,useState as Nn}from"react";import*as Fe from"@radix-ui/react-popover";import{jsx as Ct}from"react/jsx-runtime";function Ye({...c}){return Ct(Fe.Root,{"data-slot":"popover",...c})}function _e({...c}){return Ct(Fe.Trigger,{"data-slot":"popover-trigger",...c})}function je({className:c,align:b="center",sideOffset:T=4,...k}){return Ct(Fe.Portal,{children:Ct(Fe.Content,{align:b,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",c),"data-slot":"popover-content",sideOffset:T,...k})})}import{jsx as $e,jsxs as st}from"react/jsx-runtime";var br=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,zt=(c)=>Boolean(c&&br.test(c)),kn=(c)=>{let b=c.match(/bg-([a-z]+)-\d+/)?.at(1);if(!b)return"Custom";return b.charAt(0).toUpperCase()+b.slice(1)};function Sr({value:c,onChange:b,swatches:T=[],className:k,"aria-label":V="Select color"}){let[Y,le]=Nn(zt(c)?c:"");Rn(()=>{le(zt(c)?c:"")},[c]);let U=(De)=>{let Ce=De.target.value;if(le(Ce),br.test(Ce))b(Ce)},ge=zt(c),ye=T.find((De)=>De.value===c),ve;if(ye)ve=ye.label;else if(ge)ve=c;else if(c)ve=kn(c);else ve="Pick a color";return st(Ye,{children:[st(_e,{"aria-label":V,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]",k),"data-slot":"color-picker-trigger",type:"button",children:[st("span",{className:"flex items-center gap-2",children:[$e("span",{className:e("size-5 shrink-0 rounded-full border",!ge&&c),style:ge?{backgroundColor:c}:void 0}),$e("span",{className:e(ge&&"font-mono text-xs"),children:ve})]}),$e(Tn,{className:"size-4 shrink-0 opacity-50"})]}),st(je,{className:"w-56","data-slot":"color-picker-content",children:[T.length>0&&$e("div",{className:"grid grid-cols-7 gap-1.5",children:T.map((De)=>{let Ce=c===De.value;return $e("button",{"aria-label":De.label,"aria-pressed":Ce,className:e("focus-visible:ring-ring size-6 cursor-pointer rounded-full border outline-none focus-visible:ring-2",De.value,Ce&&"ring-ring ring-2 ring-offset-1"),onClick:()=>b(De.value),type:"button"},De.value)})}),$e("div",{className:"text-muted-foreground mt-3 mb-1.5 text-xs",children:"Custom"}),st("div",{className:"flex items-center gap-2",children:[$e("input",{"aria-label":"Custom color",className:"size-9 shrink-0 cursor-pointer rounded-md border bg-transparent",onChange:(De)=>b(De.target.value),type:"color",value:ge?c:"#000000"}),$e(m,{"aria-label":"Hex color",className:"font-mono",onChange:U,placeholder:"#000000",value:Y})]})]})]})}import{jsx as Mn}from"react/jsx-runtime";function xr({className:c,...b}){return Mn("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",c),"data-slot":"textarea",...b})}import{useEffect as Kn,useState as Ve}from"react";import{PopoverClose as Gn}from"@radix-ui/react-popover";import{Calendar as Bn}from"lucide-react";import{useEffect as zn,useRef as Yn,useState as _n}from"react";import{useState as Vn}from"react";import{ChevronLeftIcon as On,ChevronRightIcon as Hn}from"lucide-react";import{jsx as lt,jsxs as In}from"react/jsx-runtime";function Je({label:c,onPrev:b,onNext:T,prevLabel:k,nextLabel:V}){return In("div",{className:"mb-2 flex items-center justify-between",children:[lt(o,{"aria-label":k,onClick:b,size:"icon",variant:"ghost",children:lt(On,{className:"size-4"})}),lt("div",{className:"text-sm font-medium select-none",children:c}),lt(o,{"aria-label":V,onClick:T,size:"icon",variant:"ghost",children:lt(Hn,{className:"size-4"})})]})}import{jsx as Ge,jsxs as wr}from"react/jsx-runtime";function An(c){let b=c.weekHover&&!c.isCurrentWeek;return e("p-0 text-center",c.weekHover&&"first:rounded-l-md last:rounded-r-md",b&&"group-hover/week:bg-accent",c.isCurrentWeek&&"bg-primary")}function Ln(c){return e("w-full aspect-square text-sm select-none",!c.isDisabled&&"cursor-pointer",!(c.weekHover||c.isDisabled)&&"hover:bg-accent rounded-md",c.isOutside&&"text-muted-foreground/50",c.isCurrent&&"rounded-md ring-1 ring-inset ring-foreground/40",c.isCurrentWeek&&"text-primary-foreground font-medium",c.isSelected&&"bg-primary text-primary-foreground rounded-md font-medium",c.isDisabled&&"opacity-50 cursor-not-allowed")}function Fn({day:c,state:b,onSelect:T}){return Ge("td",{className:An(b),"data-disabled":b.isDisabled,"data-outside":b.isOutside,"data-selected":b.isSelected,role:"gridcell",tabIndex:-1,children:Ge("button",{"aria-disabled":b.isDisabled,"aria-hidden":b.isOutside,className:Ln(b),"data-disabled":b.isDisabled,"data-selected":b.isSelected,disabled:b.isDisabled||b.isOutside,onClick:()=>T?.(c.toDate()),tabIndex:b.isOutside?-1:0,type:"button",children:c.format("D")})})}function dt({selected:c,defaultMonth:b,onSelect:T,disabled:k,firstDayOfWeek:V=0,className:Y,weekHover:le=!1,highlightedWeekOf:U}){let[ge,ye]=Vn(()=>t(b??c??new Date).startOf("month")),ve=L(ge,V),De=c?t(c).format("YYYY-MM-DD"):void 0,Ce=i(t(),V).map((he)=>he.format("dd")),xe,be;if(U){let he=i(U,V);xe=he.at(0),be=he.at(-1)}let Ee=(he)=>{let we=he.format("YYYY-MM-DD")===De,Pe=!1;if(xe&&be){let Ne=!he.isBefore(xe,"day"),Te=!he.isAfter(be,"day");Pe=Ne&&Te}return{isOutside:!he.isSame(ge,"month"),isSelected:we,isDisabled:k?.(he.toDate())??!1,isCurrent:a(he)&&!we,isCurrentWeek:Pe,weekHover:le}};return wr("div",{className:e("bg-background p-3 w-72",Y),"data-slot":"calendar",children:[Ge(Je,{label:ge.format("MMMM YYYY"),nextLabel:"Next month",onNext:()=>ye((he)=>he.add(1,"month")),onPrev:()=>ye((he)=>he.subtract(1,"month")),prevLabel:"Previous month"}),wr("table",{className:"w-full border-collapse",role:"grid",children:[Ge("thead",{children:Ge("tr",{children:Ce.map((he,we)=>Ge("th",{className:"text-muted-foreground text-xs font-medium select-none py-1",children:he},we))})}),Ge("tbody",{children:ve.map((he,we)=>Ge("tr",{className:e(le&&"group/week"),children:he.map((Pe)=>Ge(Fn,{day:Pe,onSelect:T,state:Ee(Pe)},Pe.toISOString()))},we))})]})]})}import{jsx as et,jsxs as Yt}from"react/jsx-runtime";function Pr({date:c,closeOnSelect:b,onChange:T,label:k="Pick a date",className:V,disabled:Y}){let le=r((De)=>De.firstDayOfWeek),U=Yn(null),[ge,ye]=_n(c);zn(()=>{ye(c)},[c]);let ve=(De)=>{if(ye(De),b)U.current?.click();T?.(De)};return et("div",{className:V,children:Yt(Ye,{children:[et(_e,{asChild:!0,children:Yt(o,{className:e("data-[empty=true]:text-muted-foreground w-full justify-start text-left font-normal"),"data-empty":!c,variant:"outline",children:[et(Bn,{}),ge?t(ge).format("ll"):et("span",{children:k})]})}),Yt(je,{align:"start",className:"w-auto p-0",children:[et(Gn,{ref:U,style:{display:"none"}}),et(dt,{defaultMonth:ge,disabled:Y,firstDayOfWeek:le,onSelect:ve,selected:ge})]})]})})}import{Clock as $n}from"lucide-react";import{useEffect as Wn,useRef as Rr,useState as _t}from"react";import{useMemo as jn}from"react";function Tr({timeFormat:c="12-hour",minTime:b="00:00",maxTime:T="23:45"}){return{timeOptions:jn(()=>{let Y=[],[le,U]=b.split(":").map(Number),[ge,ye]=T.split(":").map(Number),ve=le*60+U,De=ge*60+ye;for(let Ce=ve;Ce<=De;Ce+=15){let xe=Math.floor(Ce/60),be=Ce%60,Ee=`${xe.toString().padStart(2,"0")}:${be.toString().padStart(2,"0")}`;Y.push(Ee)}return Y},[b,T]),formatTime:(Y)=>{let[le,U]=Y.split(":").map(Number);if(c==="24-hour")return`${le.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`;let ge=le>=12?"PM":"AM",ye=le;if(le===0)ye=12;else if(le>12)ye=le-12;return`${ye}:${U.toString().padStart(2,"0")} ${ge}`}}}import{jsx as We,jsxs as jt}from"react/jsx-runtime";var Un=(c)=>{c.stopPropagation()};function Nr({value:c,onChange:b,minTime:T="00:00",maxTime:k="23:45",timeFormat:V="12-hour",placeholder:Y="Select time...",className:le,disabled:U=!1,name:ge}){let[ye,ve]=_t(!1),[De,Ce]=_t(""),xe=Rr(null),be=Rr(null),[Ee,he]=_t(0),{timeOptions:we,formatTime:Pe}=Tr({timeFormat:V,minTime:T,maxTime:k}),Ne=we.filter((Oe)=>Pe(Oe).toLowerCase().includes(De.toLowerCase())),Te=(Oe)=>{b(Oe),ve(!1),Ce("")};Wn(()=>{if(ye){if(be.current)he(be.current.offsetWidth);setTimeout(()=>{xe.current?.focus()},0)}},[ye]);let Be=c?Pe(c):Y;return jt(Ye,{onOpenChange:ve,open:ye,children:[We(_e,{asChild:!0,children:jt(o,{"aria-controls":"time-picker-listbox","aria-expanded":ye,className:e("w-full justify-start",le),"data-testid":n.timePicker(ge),disabled:U,ref:be,role:"combobox",variant:"outline",children:[We($n,{className:"mr-2 h-4 w-4"}),Be]})}),jt(je,{align:"start",className:"p-0",style:{width:Ee},children:[We("div",{className:"p-2 border-b",children:We(m,{className:"h-8",onChange:(Oe)=>Ce(Oe.target.value),placeholder:"Search time...",ref:xe,value:De})}),We(u,{className:"h-[200px]",onWheel:Un,children:We("div",{className:"p-1",children:Ne.length===0?We("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"N/A"}):Ne.map((Oe)=>{let ut=Pe(Oe);return We("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",Oe===c&&"bg-accent text-accent-foreground"),onClick:()=>Te(Oe),type:"button",children:ut},Oe)})})})]})]})}var kr=(c,b)=>{let[T,k]=b.split(":").map(Number);return t(c).hour(T).minute(k).second(0).millisecond(0)},Mr=(c,b,T)=>{let k=kr(c,b);return T?k.hour(0).minute(0):k},Or=(c,b,T)=>{let k=kr(c,b);return T?k.add(1,"day").startOf("day"):k},$t=(c,b)=>{if(!b)return{min:"00:00",max:"23:59"};let T=t(c),{minStart:k,maxEnd:V,hasBusinessHours:Y}=J({allDates:[T],businessHours:b,hideNonBusinessHours:!1});if(!Y)return{min:"00:00",max:"23:59"};return{min:`${k.toString().padStart(2,"0")}:00`,max:`${(V-1).toString().padStart(2,"0")}:45`}};import{jsx as Re,jsxs as He,Fragment as Jn}from"react/jsx-runtime";var Hr="bg-blue-100 text-blue-800",Zn=[{value:Hr,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"}],Ir=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,qn=(c,b)=>{if(c&&Ir.test(c))return c;return b??Hr},Xn=(c)=>{if(Ir.test(c))return{backgroundColor:c,color:pe(c)};return{backgroundColor:void 0,color:c}},Qn=({colorChanged:c,hadInitialColor:b,selectedColor:T,initialBackgroundColor:k,initialColor:V})=>{if(c||!b)return Xn(T);return{backgroundColor:k,color:V}},Wt=({name:c,label:b,placeholder:T,value:k,required:V=!1,multiline:Y=!1,onChange:le})=>He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:c,children:b}),Y?Re(xr,{className:"min-h-16 text-sm",id:c,name:c,onChange:le,placeholder:T,required:V,value:k}):Re(m,{className:"h-8 text-sm sm:h-9",id:c,name:c,onChange:le,placeholder:T,required:V,value:k})]}),Vr=({selectedEvent:c,onClose:b,onUpdate:T,onDelete:k,onAdd:V})=>{let{dialogState:Y,openEditDialog:le,openDeleteDialog:U,closeDialog:ge,handleConfirm:ye}=Dt(b),{t:ve,timeFormat:De,getEventManager:Ce,resources:xe}=r((Se)=>({t:Se.t,timeFormat:Se.timeFormat,getEventManager:Se.getEventManager,resources:Se.resources??[]})),{id:be,resourceId:Ee,resourceIds:he,start:we=t(),end:Pe=t().add(1,"hour"),allDay:Ne=!1,color:Te,backgroundColor:Be,title:Oe="",description:ut="",location:tr=""}=c??{},rr=xe.length>0,or=Ee??he?.at(0),nr=rr&&or===void 0,[kt,ko]=Ve(or),Mt=rr?kt:Ee,pt=X(Mt),ar=Boolean(c&&Ce(c)),Mo=Pe.isSame(Pe.startOf("day")),Oo=Ne&&Mo?Pe.subtract(1,"day"):Pe,[Ze,ir]=Ve(we.toDate()),[Qe,Ot]=Ve(Oo.toDate()),[ze,Ho]=Ve(Ne),[Ht,Io]=Ve(qn(Be,Te)),[Vo,Ao]=Ve(!1),Lo=Boolean(Te||Be),Fo=(Se)=>{Io(Se),Ao(!0)},[It,sr]=Ve(we.format("HH:mm")),[ft,Vt]=Ve(Pe.format("HH:mm")),[Le,Go]=Ve({title:Oe,description:ut,location:tr}),[At,Bo]=Ve({}),zo={...c,...At},Yo=(Se)=>Bo((ke)=>({...ke,...Se})),_o=(Se)=>{if(!Se)return;if(ir(Se),t(Se).isAfter(t(Qe)))Ot(Se)},jo=(Se)=>{if(!Se)return;if(Ot(Se),Se&&t(Se).isBefore(t(Ze)))ir(Se)},$o=(Se)=>{if(Ho(Se),!(Se&&ft==="00:00"))return;Ot((ke)=>t(ke).isAfter(t(Ze),"day")?t(ke).subtract(1,"day").toDate():ke)},Wo=(Se)=>{if(sr(Se),t(Ze).isSame(t(Qe),"day")&&Se>ft)Vt(Se)},Uo=(Se)=>{if(Vt(Se),t(Ze).isSame(t(Qe),"day")&&Se<It)sr(Se)},Lt=(Se)=>{let{name:ke,value:Ie}=Se.target;Go((at)=>({...at,[ke]:Ie}))};Kn(()=>{if(ze)Vt("23:59")},[ze]);let Ko=(Se)=>xe.find((Ie)=>String(Ie.id)===Se)?.id??Se,lr=nr&&kt===void 0,Zo=(Se)=>{if(Se.preventDefault(),lr)return;let ke=Mr(Ze,It,ze),Ie=Or(Qe,ft,ze),at=Qn({colorChanged:Vo,hadInitialColor:Lo,selectedColor:Ht,initialBackgroundColor:Be,initialColor:Te}),it={id:be||t().format("YYYYMMDDHHmmss"),title:Le.title,start:ke,end:Ie,resourceId:Mt,description:Le.description,location:Le.location,allDay:ze,...at,...At};if(c?.id&&ar){le(c,{title:Le.title,start:ke,end:Ie,resourceId:Mt,description:Le.description,location:Le.location,allDay:ze,color:Ht,...At});return}if(be)T?.(it);else V?.(it);b()},qo=()=>{if(!c?.id)return;if(ar){U(c);return}k?.(c),b()},dr;if(pt)dr=(Se)=>!B(t(Se),pt);let Xo=$t(Ze,pt),Qo=$t(Qe,pt),Jo=[["startDate",Ze,_o],["endDate",Qe,jo]],en=[["startTime","start-time",It,Wo,Xo],["endTime","end-time",ft,Uo,Qo]],tn=kt?.toString();return He(Jn,{children:[He("form",{className:"flex flex-col flex-1 min-h-0",onSubmit:Zo,children:[Re(u,{className:"flex-1 min-h-0",children:He("div",{className:"grid gap-3 sm:gap-4 p-1",children:[Re(Wt,{label:ve("title"),name:"title",onChange:Lt,placeholder:ve("eventTitlePlaceholder"),required:!0,value:Le.title}),Re(Wt,{label:ve("description"),multiline:!0,name:"description",onChange:Lt,placeholder:ve("eventDescriptionPlaceholder"),value:Le.description}),nr&&He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",htmlFor:"resource",children:ve("resource")}),He(C,{onValueChange:(Se)=>ko(Ko(Se)),value:tn,children:[Re(E,{className:"h-8 text-sm sm:h-9","data-testid":"resource-select",id:"resource",children:Re(D,{placeholder:ve("selectResource")})}),Re(h,{children:xe.map((Se)=>Re(f,{value:String(Se.id),children:Se.title},String(Se.id)))})]})]}),He("div",{className:"flex items-center space-x-2",children:[Re(v,{checked:ze,id:"allDay",onCheckedChange:(Se)=>$o(Se===!0)}),Re(s,{className:"text-xs sm:text-sm",htmlFor:"allDay",children:ve("allDay")})]}),Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:Jo.map(([Se,ke,Ie])=>He("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Pr,{className:"mt-1",closeOnSelect:!0,date:ke,disabled:dr,onChange:Ie})]},Se))}),!ze&&Re("div",{className:"grid grid-cols-2 gap-2 sm:gap-4",children:en.map(([Se,ke,Ie,at,it])=>He("div",{children:[Re(s,{className:"text-xs sm:text-sm",children:ve(Se)}),Re(Nr,{className:"mt-1 h-8 text-sm sm:h-9",maxTime:it.max,minTime:it.min,name:ke,onChange:at,placeholder:ve("searchTime"),timeFormat:De,value:Ie})]},Se))}),He("div",{className:"grid gap-1 sm:gap-2",children:[Re(s,{className:"text-xs sm:text-sm",children:ve("color")}),Re(Sr,{"aria-label":ve("color"),onChange:Fo,swatches:Zn,value:Ht})]}),Re(Wt,{label:ve("location"),name:"location",onChange:Lt,placeholder:ve("eventLocationPlaceholder"),value:Le.location}),Re(ur,{event:zo,onChange:Yo})]})}),He(G,{className:"mt-4 shrink-0 flex flex-col-reverse gap-2 sm:flex-row sm:gap-0",children:[be&&Re(o,{className:"w-full sm:mr-auto sm:w-auto",onClick:qo,size:"sm",type:"button",variant:"destructive",children:ve("delete")}),He("div",{className:"flex w-full gap-2 sm:w-auto",children:[Re(o,{className:"flex-1 sm:flex-none",onClick:b,size:"sm",type:"button",variant:"outline",children:ve("cancel")}),Re(o,{className:"flex-1 sm:flex-none",disabled:lr,size:"sm",type:"submit",children:be?ve("update"):ve("create")})]})]})]}),Re(gt,{dialog:Y,onCancel:ge,onResolve:ye})]})};import{jsx as ht,jsxs as Ar}from"react/jsx-runtime";var Lr=()=>{let{t:c,selectedEvent:b,isEventFormOpen:T,closeEventForm:k,addEvent:V,updateEvent:Y,deleteEvent:le,renderEventForm:U}=r((De)=>({t:De.t,selectedEvent:De.selectedEvent,isEventFormOpen:De.isEventFormOpen,closeEventForm:De.closeEventForm,addEvent:De.addEvent,updateEvent:De.updateEvent,deleteEvent:De.deleteEvent,renderEventForm:De.renderEventForm})),ve={open:T,onClose:k,selectedEvent:b,onAdd:V,onUpdate:(De)=>{Y(De.id,De)},onDelete:(De)=>{le(De.id)}};if(U)return U(ve);return ht(R,{onOpenChange:k,open:T,children:Ar(w,{className:"flex flex-col h-[90vh] w-[90vw] max-w-[500px] p-4 sm:p-6 overflow-hidden gap-0",children:[Ar(S,{className:"mb-2 sm:mb-4 shrink-0",children:[ht(P,{className:"text-base sm:text-lg",children:b?.id?c("editEvent"):c("createEvent")}),ht(W,{className:"text-xs sm:text-sm",children:b?.id?c("editEventDetails"):c("addNewEvent")})]}),ht(Vr,{...ve})]})})};import{ChevronLeft as Ca,ChevronRight as ha,Download as Ea,Plus as ba}from"lucide-react";var Ut=`\r
2
+ `,ea=["BEGIN:VTIMEZONE","TZID:UTC","BEGIN:STANDARD","DTSTART:19700101T000000","TZNAME:UTC","TZOFFSETFROM:+0000","TZOFFSETTO:+0000","END:STANDARD","END:VTIMEZONE"].join(Ut),Et=(c)=>c.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll(`
3
+ `,"\\n").replaceAll("\r",""),Fr=(c,b=!1)=>{if(b)return c.format("YYYYMMDD");return c.utc().format("YYYYMMDD[T]HHmmss[Z]")},ta=(c)=>c.uid||`${c.id}@ilamy.calendar`,ra=(c,b)=>{let T=t().utc().format("YYYYMMDD[T]HHmmss[Z]"),k=c.allDay?";VALUE=DATE":"",V=["BEGIN:VEVENT",`UID:${ta(c)}`,`DTSTART${k}:${Fr(c.start,c.allDay)}`,`DTEND${k}:${Fr(c.end,c.allDay)}`,`SUMMARY:${Et(c.title)}`,c.description&&`DESCRIPTION:${Et(c.description)}`,c.location&&`LOCATION:${Et(c.location)}`].filter(Boolean),Y=b("ical:vevent-properties",c).filter((U)=>typeof U==="string"),le=[`DTSTAMP:${T}`,`CREATED:${T}`,`LAST-MODIFIED:${T}`,"STATUS:CONFIRMED","SEQUENCE:0","TRANSP:OPAQUE","END:VEVENT"];return[...V,...Y,...le].join(Ut)},oa=(c,b,T="ilamy Calendar")=>{let k=Et(T),V=c.map((Y)=>ra(Y,b));return["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//ilamy//ilamy Calendar//EN","CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${k}`,`X-WR-CALDESC:Exported from ${k}`,ea,...V,"END:VCALENDAR"].join(Ut)},Gr=(c,b,T="calendar.ics",k="ilamy Calendar")=>{let V=new Blob([oa(c,b,k)],{type:"text/calendar;charset=utf-8"}),Y=URL.createObjectURL(V),le=T;if(!T.endsWith(".ics"))le=`${T}.ics`;let U=document.createElement("a");U.href=Y,U.download=le,document.body.append(U),U.click(),U.remove(),URL.revokeObjectURL(Y)};function Br(){let{rawEvents:c,collect:b}=r((T)=>({rawEvents:T.rawEvents,collect:T.collect}));return()=>{let T=`ilamy-calendar-${t().format("YYYY-MM-DD")}.ics`;Gr(c,b,T,"ilamy Calendar")}}import{ChevronDown as da}from"lucide-react";import{useState as ca}from"react";function zr(){let{currentLocale:c,timezone:b}=r((k)=>({currentLocale:k.currentLocale,timezone:k.timezone}));return{formatDateRange:(k,V)=>{let Y=new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric"});if(k.year()===V.year())return Y.formatRange(k.toDate(),V.toDate());return`${Y.format(k.toDate())} – ${Y.format(V.toDate())}`}}}import{useState as aa}from"react";import{jsx as na}from"react/jsx-runtime";function bt({label:c,isSelected:b,isCurrent:T,onSelect:k}){return na("button",{"aria-pressed":b,className:e("hover:bg-accent rounded-md py-2 text-sm font-medium cursor-pointer select-none",T&&"ring-1 ring-inset ring-foreground/40",b&&"bg-primary text-primary-foreground"),onClick:k,type:"button",children:c})}import{jsx as Kt,jsxs as ia}from"react/jsx-runtime";function Yr({selected:c,onSelect:b}){let[T,k]=aa(()=>c.year()),V=t(),Y=Array.from({length:12},(le,U)=>({index:U,label:c.month(U).format("MMM")}));return ia("div",{className:"w-72 p-3","data-slot":"month-grid",children:[Kt(Je,{label:T,nextLabel:"Next year",onNext:()=>k((le)=>le+1),onPrev:()=>k((le)=>le-1),prevLabel:"Previous year"}),Kt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=T===c.year()&&le.index===c.month(),ge=T===V.year()&&le.index===V.month()&&!U;return Kt(bt,{isCurrent:ge,isSelected:U,label:le.label,onSelect:()=>b(c.year(T).month(le.index).date(1))},le.index)})})]})}import{useState as sa}from"react";import{jsx as Zt,jsxs as la}from"react/jsx-runtime";var ct=12;function _r({selected:c,onSelect:b}){let[T,k]=sa(()=>c.year()-c.year()%ct),V=t(),Y=Array.from({length:ct},(le,U)=>T+U);return la("div",{className:"w-72 p-3","data-slot":"year-grid",children:[Zt(Je,{label:`${T} – ${T+ct-1}`,nextLabel:"Next years",onNext:()=>k((le)=>le+ct),onPrev:()=>k((le)=>le-ct),prevLabel:"Previous years"}),Zt("div",{className:"grid grid-cols-3 gap-1",children:Y.map((le)=>{let U=le===c.year(),ge=le===V.year()&&!U;return Zt(bt,{isCurrent:ge,isSelected:U,label:le,onSelect:()=>b(c.year(le))},le)})})]})}import{jsx as qe,jsxs as jr}from"react/jsx-runtime";var ma={day:"day",week:"week",month:"month",year:"year"};function ua(c){let b=c?.navigationStep??{amount:1,unit:c?.navigationUnit??"day"};if(b.amount!==1)return"range";return ma[b.unit]??"range"}function $r({className:c}){let{currentDate:b,currentRange:T,view:k,selectDate:V,firstDayOfWeek:Y,getViews:le}=r((Te)=>({currentDate:Te.currentDate,currentRange:Te.currentRange,view:Te.view,selectDate:Te.selectDate,firstDayOfWeek:Te.firstDayOfWeek,getViews:Te.getViews})),{formatDateRange:U}=zr(),[ge,ye]=ca(!1),ve=i(b,Y),De=ve.at(0)??b,Ce=ve.at(-1)??b,xe=(Te)=>{V(Te),ye(!1)},be=ua(le().find((Te)=>Te.name===k)),he={year:b.format("YYYY"),month:b.format("MMM YYYY"),week:U(De,Ce),day:b.format("ddd, MMM D, YYYY"),range:U(T.start,T.end)}[be],we=qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,onSelect:(Te)=>Te&&xe(t(Te)),selected:b.toDate()}),Ne={year:qe(_r,{onSelect:xe,selected:b}),month:qe(Yr,{onSelect:xe,selected:b}),week:qe(dt,{defaultMonth:b.toDate(),firstDayOfWeek:Y,highlightedWeekOf:b,onSelect:(Te)=>Te&&xe(t(Te)),weekHover:!0}),day:we,range:we}[be];return jr(Ye,{onOpenChange:ye,open:ge,children:[qe(_e,{asChild:!0,children:jr(o,{className:e("font-semibold",c),"data-testid":"calendar-title",variant:"outline",children:[he,qe(da,{className:"size-4 shrink-0 opacity-50"})]})}),qe(je,{align:"start",className:"w-auto p-0",children:Ne})]})}import*as Ae from"@radix-ui/react-dropdown-menu";import{jsx as mt}from"react/jsx-runtime";function Wr({...c}){return mt(Ae.Root,{"data-slot":"dropdown-menu",...c})}function Ur({...c}){return mt(Ae.Trigger,{"data-slot":"dropdown-menu-trigger",...c})}function Kr({className:c,sideOffset:b=4,align:T="end",...k}){return mt(Ae.Portal,{children:mt(Ae.Content,{align:T,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",c),"data-slot":"dropdown-menu-content",sideOffset:b,...k})})}function Zr({className:c,...b}){return mt(Ae.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",c),"data-slot":"dropdown-menu-item",...b})}import{Check as pa,ChevronDown as fa}from"lucide-react";function St(){let{getViews:c,resources:b}=r((k)=>({getViews:k.getViews,resources:k.resources})),T=Boolean(b?.length);return c().filter((k)=>!T||k.supportsResources)}import{jsx as Ue,jsxs as qt}from"react/jsx-runtime";function qr({className:c}){let{view:b,setView:T,t:k}=r((ge)=>({view:ge.view,setView:ge.setView,t:ge.t})),V=St(),Y=V.find((ge)=>ge.name===b),le=Y?k(Y.label??Y.name):"",U=Y?.icon;return qt(Wr,{children:[Ue(Ur,{asChild:!0,className:c,children:qt(o,{size:"default",variant:"outline",children:[U&&Ue(U,{className:"size-4"}),Ue("span",{children:le}),Ue(fa,{className:"size-4 opacity-50"})]})}),Ue(Kr,{align:"end",className:"min-w-40",children:V.map((ge)=>{let ye=ge.icon;return qt(Zr,{onSelect:()=>T(ge.name),children:[Ue(ye,{className:"size-4"}),Ue("span",{className:"flex-1",children:k(ge.label??ge.name)}),ge.name===b&&Ue(pa,{className:"size-4"})]},ge.name)})})]})}import*as xt from"@radix-ui/react-toggle-group";import{cva as ga}from"class-variance-authority";import{createContext as va,useContext as ya}from"react";import{jsx as Xt}from"react/jsx-runtime";var Da=ga("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"}}),Xr=va({size:"default",variant:"default"});function Qr({className:c,variant:b,size:T,children:k,...V}){return Xt(xt.Root,{className:e("flex items-center justify-center gap-1",c),"data-slot":"toggle-group",...V,children:Xt(Xr.Provider,{value:{variant:b,size:T},children:k})})}function Jr({className:c,children:b,variant:T,size:k,...V}){let Y=ya(Xr);return Xt(xt.Item,{className:e(Da({variant:Y.variant||T,size:Y.size||k}),c),"data-slot":"toggle-group-item",...V,children:b})}import{jsx as eo}from"react/jsx-runtime";function to({className:c}){let{view:b,setView:T,t:k}=r((Y)=>({view:Y.view,setView:Y.setView,t:Y.t})),V=St();return eo(Qr,{className:e("bg-muted gap-0 rounded-lg p-0.75",c),onValueChange:(Y)=>Y&&T(Y),size:"sm",type:"single",value:b,children:V.map((Y)=>eo(Jr,{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:Y.name,children:k(Y.label??Y.name)},Y.name))})}import{jsx as Me,jsxs as tt}from"react/jsx-runtime";var ro=({className:c=""})=>{let{nextPeriod:b,prevPeriod:T,today:k,openEventForm:V,headerComponent:Y,headerClassName:le,t:U,hideExportButton:ge}=r((ve)=>({nextPeriod:ve.nextPeriod,prevPeriod:ve.prevPeriod,today:ve.today,openEventForm:ve.openEventForm,headerComponent:ve.headerComponent,headerClassName:ve.headerClassName,t:ve.t,hideExportButton:ve.hideExportButton})),ye=Br();if(Y)return Y;return Me("div",{className:e("@container/base-header w-full",le),"data-testid":"calendar-header",children:tt("div",{className:e("flex flex-col items-center gap-2 @xl/base-header:flex-row @xl/base-header:justify-between",c),children:[tt("div",{className:"flex min-w-0 flex-wrap items-center justify-center gap-2",children:[tt("div",{className:"bg-background flex h-9 items-center rounded-lg border",children:[Me(o,{"aria-label":U("previous"),className:"h-full",onClick:T,size:"icon",variant:"ghost",children:Me(Ca,{className:"size-4"})}),Me(o,{"aria-label":U("next"),className:"h-full",onClick:b,size:"icon",variant:"ghost",children:Me(ha,{className:"size-4"})})]}),Me(o,{onClick:k,size:"default",variant:"outline",children:U("today")}),Me($r,{})]}),tt("div",{className:"flex items-center gap-2",children:[Me(to,{className:"hidden @4xl/base-header:flex"}),Me(qr,{className:"@4xl/base-header:hidden"}),!ge&&tt(o,{"aria-label":U("export"),onClick:ye,size:"default",variant:"outline",children:[Me(Ea,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("export")})]}),tt(o,{"aria-label":U("new"),onClick:()=>V(),size:"default",children:[Me(ba,{className:"size-4"}),Me("span",{className:"hidden @2xl/base-header:inline",children:U("new")})]})]})]})})};import{useMemo as Po}from"react";import{useRef as so}from"react";import{useEffect as Sa,useRef as xa}from"react";var wa=/^(\d{1,2})(?::\d{1,2})?(?::\d{1,2})?$/,Pa="[data-hour]",Ta='[data-start]:not([data-all-day="true"])',Ra=(c)=>{let T=wa.exec(c)?.at(1);if(!T)return null;let k=Number.parseInt(T,10);return k>=0&&k<=23?k:null},Qt=(c)=>Number.parseInt(c.getAttribute("data-hour")??"",10),Na=(c,b)=>{let T=c.at(0),k=c.at(-1);if(!T||!k)return null;if(b<=Qt(T))return T;if(b>=Qt(k))return k;return c.find((V)=>Qt(V)===b)??null},ka=(c)=>({start:t(c.dataset.start??""),end:t(c.dataset.end??"")}),Ma=(c)=>{let b=Array.from(c.querySelectorAll(Ta)),T=b.at(0),k=t(),V=b.find((Y)=>d(ka(Y),k,k));if(!T||!V)return null;return{target:V,origin:T}},Oa=(c,b)=>{let T=b?Ra(b):null;if(T===null)return null;let k=Array.from(c.querySelectorAll(Pa)),V=k.at(0),Y=Na(k,T);if(!V||!Y)return null;return{target:Y,origin:V}},Ha=(c,b,T,k)=>{let V=b.getBoundingClientRect(),Y=T.getBoundingClientRect(),le=V.left-Y.left,U=V.top-Y.top;oo(c,k,k==="horizontal"?le:U)},oo=(c,b,T)=>{let k=b==="horizontal"?"left":"top";c.scrollTo({[k]:T,behavior:"auto"})},Ia=(c,{scrollTime:b,scrollToNow:T,axis:k})=>{let Y=(T?Ma(c):null)??Oa(c,b);if(Y)return Ha(c,Y.target,Y.origin,k),!0;if(T)return oo(c,k,0),!0;return!1},wt=({viewportRef:c,scrollTime:b,scrollToNow:T=!1,enabled:k,scrollKey:V,axis:Y="vertical"})=>{let le=xa(null);Sa(()=>{if(!k)return;let U=`${V}|${b}|${T}`;if(le.current===U)return;let ge=c.current;if(!ge)return;if(Ia(ge,{scrollTime:b,scrollToNow:T,axis:Y}))le.current=U},[k,b,T,V,c,Y])};import{useLayoutEffect as Va}from"react";var Jt="data-sticky-inset",Pt=(c)=>c?"top":void 0,no={left:"--ilamy-sticky-left",top:"--ilamy-sticky-top"},ao=new Set(["hidden","scroll","auto","overlay","clip"]),Aa=(c)=>{let b=[];for(let T=c.parentElement;T;T=T.parentElement){let{overflowX:k,overflowY:V}=getComputedStyle(T);if(ao.has(k)||ao.has(V))b.push(T)}return b},La=(c,b,T)=>{let k=b.getBoundingClientRect(),V={left:-k.left,top:-k.top};for(let le of T){let U=le.getBoundingClientRect();V.left=Math.max(V.left,U.left-k.left),V.top=Math.max(V.top,U.top-k.top)}let Y=c.querySelectorAll(`[${Jt}]`);for(let le of Y){let U=le.getAttribute(Jt),ge=le.getBoundingClientRect();if(U==="left")V.left=Math.max(V.left,ge.right-k.left);if(U==="top")V.top=Math.max(V.top,ge.bottom-k.top)}return{left:Math.max(0,V.left),top:Math.max(0,V.top)}},Tt=(c,b,T)=>{let{currentDate:k,view:V,stickyViewHeader:Y}=r((U)=>({currentDate:U.currentDate,view:U.view,stickyViewHeader:U.stickyViewHeader})),le=n.stickyInsets(V,k,Y,T);Va(()=>{let U=c.current,ge=b.current;if(!U||!ge)return;let ye=Aa(U),ve=()=>{let Ee=La(U,ge,ye);ge.style.setProperty(no.left,`${Ee.left}px`),ge.style.setProperty(no.top,`${Ee.top}px`)};ve();let De,Ce=()=>{if(De!==void 0)return;De=requestAnimationFrame(()=>{De=void 0,ve()})},xe=[...ye,window];for(let Ee of xe)Ee.addEventListener("scroll",Ce,{passive:!0});window.addEventListener("resize",Ce,{passive:!0});let be=typeof ResizeObserver>"u"?void 0:new ResizeObserver(ve);be?.observe(ge);for(let Ee of U.querySelectorAll(`[${Jt}]`))be?.observe(Ee);return()=>{for(let Ee of xe)Ee.removeEventListener("scroll",Ce);if(window.removeEventListener("resize",Ce),be?.disconnect(),De!==void 0)cancelAnimationFrame(De)}},[c,b,le])};import{memo as Fa}from"react";import{jsx as Ba}from"react/jsx-runtime";var Ga=({children:c,className:b})=>{let{stickyViewHeader:T,viewHeaderClassName:k}=r((V)=>({stickyViewHeader:V.stickyViewHeader,viewHeaderClassName:V.viewHeaderClassName}));return Ba("div",{className:e("flex h-12 w-fit",T&&"sticky top-0 z-21 bg-background",b,k),"data-sticky-inset":Pt(T),"data-testid":"horizontal-grid-header",children:c})},io=Fa(Ga);import{jsx as rt,jsxs as lo}from"react/jsx-runtime";var co=({rows:c,children:b,classes:T,allDay:k,gridType:V,variant:Y="resource",dayNumberHeight:le})=>{let{currentDate:U,view:ge,scrollTime:ye,scrollToNow:ve}=r(),De=so(null),Ce=so(null),xe=Y==="resource",be=!xe;wt({viewportRef:Ce,scrollTime:ye,scrollToNow:ve,enabled:xe,scrollKey:`${ge}-${U.format("YYYY-MM-DD")}`,axis:"horizontal"}),Tt(De,Ce,c.length);let Ee=b&&rt(io,{className:T?.header,children:b});return lo("div",{className:"h-full flex flex-col","data-testid":"horizontal-grid-container",ref:De,children:[be&&Ee,lo(u,{className:e("h-full",be&&"overflow-auto"),"data-testid":"horizontal-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full",ref:Ce},children:[xe&&Ee,rt("div",{className:e("flex flex-1 w-fit",T?.body),"data-testid":"horizontal-grid-body",children:rt("div",{className:"relative w-full flex flex-col flex-1 gap-px bg-border","data-calendar-scroll-content":"true",children:c.map((he)=>rt(oe,{allDay:he.allDay??k,dayNumberHeight:le,gridType:V,variant:Y,...he},he.id))})}),rt(y,{className:"z-30"}),rt(y,{className:"z-30",orientation:"horizontal"})]})]})};import{useRef as So}from"react";import{memo as Xa}from"react";import{memo as Ua,useMemo as Ka}from"react";import{useMemo as uo}from"react";var za=(c)=>{let b=[],T=[],k=null;for(let V of c){if(k&&V.start.isSameOrAfter(k)){if(T.length>0)b.push(T);T=[]}T.push(V),k=k?t.max(k,V.end):V.end}if(T.length>0)b.push(T);return b},mo=(c,{gridStart:b,totalUnits:T,gridType:k,isDiscrete:V})=>{let Y=N(c.start,b,k),le=N(c.end,b,k);if(V){if(Y=Math.floor(Y),le=Math.ceil(le),le<=Y)le=Y+1}let U=Y<0,ge=le>T;if(U)Y=0;if(ge)le=T;let ye=Math.max(0,le-Y);if(ye===0)return null;return{top:Y/T*100,height:ye/T*100,isTruncatedStart:U,isTruncatedEnd:ge}},Ya={2:25,3:50,4:60},_a=70,ja=(c)=>Ya[c]??_a,$a=(c,b)=>{let T=c.length===1?c.at(0):void 0;if(T){let U=mo(T,b);if(!U)return[];return[{kind:"vertical",event:T,left:0,width:100,...U}]}let k=[...c].sort((U,ge)=>{let ye=ge.end.diff(ge.start,"minute")-U.end.diff(U.start,"minute");return ye!==0?ye:U.start.diff(ge.start)}),V=k.length,Y=V>1?ja(V)/(V-1):0,le=[];for(let U=0;U<V;U++){let ge=k.at(U);if(!ge)continue;let ye=mo(ge,b);if(!ye)continue;let ve=U===0?0:Y*U;le.push({kind:"vertical",event:ge,...ye,left:ve,width:100-ve,zIndex:U+1})}return le},Rt=({days:c,gridType:b="hour",events:T})=>{let k=T.filter((Y)=>!Y.allDay).toSorted((Y,le)=>Y.start.diff(le.start));if(k.length===0)return[];let V={gridStart:c.at(0)||t(),totalUnits:c.length,gridType:b,isDiscrete:b==="day"};return za(k).flatMap((Y)=>$a(Y,V))};var po=({days:c,gridType:b,resourceId:T})=>{let{getEventsForDateRange:k}=r(),V=c.at(0),Y=c.at(-1),le=V?.startOf("day"),U=Y?.endOf("day"),ge=uo(()=>{if(!le||!U)return[];let ve=k(le,U);return x(ve,T).filter((Ce)=>!Ce.allDay)},[le,U,k,T]);return uo(()=>Rt({days:c,events:ge,gridType:b}),[c,b,ge])};import{jsx as Wa,jsxs as fo}from"react/jsx-runtime";function go({previewPositioned:c}){let b=r((le)=>le.timeFormat),{event:T,isTruncatedStart:k,isTruncatedEnd:V}=c,Y=q(b);return fo(re,{contentClassName:"px-1.5 py-1 relative",event:T,isTruncatedEnd:V,isTruncatedStart:k,orientation:"vertical",style:ne(c),children:[fo("p",{className:"text-[10px] font-semibold sm:text-xs",children:[T.start.format(Y)," – ",T.end.format(Y)]}),Wa("p",{className:e("text-[10px] font-bold sm:text-xs truncate",M.vertical),children:T.title})]})}import{jsx as vo}from"react/jsx-runtime";var yo=(c,b,T,k)=>`event-${c}-${b}-${T.at(0)?.toISOString()}-${k??"no-resource"}`;function Do({positioned:c,elementId:b,range:T,resourceId:k,draggedEventId:V}){let{event:Y}=c,le=Y.end.diff(Y.start,"minute")<=15;return vo("div",{className:"absolute","data-testid":n.container.verticalEvent(Y.id),style:ne(c),children:vo(A,{className:e("pointer-events-auto",{"[&_p]:text-[10px] [&_p]:mt-0":le}),dragSegment:K(Y,T,"vertical"),elementId:b,event:Y,isBeingDragged:V===Y.id,isTruncatedEnd:c.isTruncatedEnd,isTruncatedStart:c.isTruncatedStart,sourceResourceId:k})})}import{jsx as Nt,jsxs as qa}from"react/jsx-runtime";var Za=({days:c,gridType:b="hour",resourceId:T,resource:k,"data-testid":V})=>{let Y=r((Ee)=>Ee.resources),le=p(),U=po({days:c,gridType:b,resourceId:T}),ge=c.at(0),ye=c.at(-1)?.add(1,b),De=T===void 0||Y?.at(0)?.id===T,Ce=b==="hour"&&Boolean(ge&&ye),xe=te({days:c,gridType:b,resourceId:T}),be=Ka(()=>{if(!xe)return null;return Rt({days:c,gridType:b,events:[xe]}).at(0)??null},[xe,c,b]);return Nt(F.Provider,{value:"vertical",children:qa("div",{className:"relative w-full h-full pointer-events-none z-10 overflow-clip","data-testid":V,children:[Ce&&ge&&ye&&Nt(ee,{rangeEnd:ye,rangeStart:ge,resource:k,withDot:De}),U.map((Ee,he)=>{let we=yo(Ee.event.id,he,c,T);return Nt(Do,{draggedEventId:le?.event.id,elementId:we,positioned:Ee,range:{start:ge,end:ye},resourceId:T},n.listKey(we,"wrapper"))}),be&&Nt(go,{previewPositioned:be})]})})},Co=Ua(Za);import{jsx as ot,jsxs as Ja}from"react/jsx-runtime";var Qa=({id:c,days:b,resource:T,"data-testid":k,"data-sticky-inset":V,gridType:Y,className:le,renderCell:U,noEvents:ge,slotDurationMinutes:ye=60})=>{let ve=T?.id,De=Math.floor(60/ye),Ce=Array.from({length:De},(be,Ee)=>Ee*ye),xe=Ce.length>1;return ot("div",{className:e("flex flex-col flex-1 items-center min-w-20 justify-center bg-background relative",le),"data-sticky-inset":V,"data-testid":k||n.container.vertical.col(c),children:Ja("div",{className:"w-full h-full relative grid gap-px bg-border",style:{gridTemplateRows:`repeat(${b.length}, minmax(0, 1fr))`},children:[b.map((be,Ee)=>{let he=be.format("HH");if(U){let we=c===n.col.time,Pe=we?n.cell.verticalTime(he):n.cell.vertical(be,he,"00",ve);return ot("div",{className:"min-h-[60px] bg-background","data-hour":we?he:void 0,"data-testid":Pe,children:U(be)},n.listKey(Ee,he))}return ot("div",{className:"flex flex-col min-h-[60px]",children:Ce.map((we,Pe)=>{let Ne=String(we).padStart(2,"0"),Te=n.cell.vertical(be,he,Ne,ve),Be=xe&&Pe<Ce.length-1;return ot(z,{className:e("not-in-data-dragging:hover:bg-accent relative z-10 flex-1 min-h-0 cursor-pointer",Be&&"border-b border-dashed"),"data-testid":Te,day:xe?be.minute(we):be,gridType:Y,hour:Y==="hour"?be.hour():void 0,isSubDivider:Be,minute:xe?we:void 0,resourceId:ve,shouldRenderEvents:!1,slotDurationMinutes:ye},n.listKey(Ee,Ne))})},n.listKey(Ee,he))}),!ge&&ot("div",{className:"absolute inset-0 z-10 pointer-events-none",children:ot(Co,{"data-testid":n.container.eventsLayer("vertical",c),days:b,gridType:Y,resource:T,resourceId:ve})})]})})},ho=Xa(Qa);import{memo as ei}from"react";import{jsx as Eo,jsxs as ri}from"react/jsx-runtime";var ti=({children:c,classes:b,allDayRow:T,expandAllDayRow:k=!1})=>{let{stickyViewHeader:V,viewHeaderClassName:Y}=r((U)=>({stickyViewHeader:U.stickyViewHeader,viewHeaderClassName:U.viewHeaderClassName})),le="min-w-full w-fit";return ri("div",{className:e(k&&"flex h-full flex-col",V&&"sticky top-0 z-21 bg-background",Y),"data-sticky-inset":Pt(V),children:[Eo("div",{className:e("min-h-12 border-b","min-w-full w-fit",b?.header),"data-testid":"vertical-grid-header",children:c}),T&&Eo("div",{className:e("flex min-h-12 border-b","min-w-full w-fit",k&&"flex-1 overflow-hidden",b?.allDay),"data-testid":"vertical-grid-all-day",children:T})]})},bo=ei(ti);import{jsx as nt,jsxs as xo}from"react/jsx-runtime";var wo=({columns:c,children:b,gridType:T="day",variant:k="resource",classes:V,allDayRow:Y,slotDurationMinutes:le,style:U})=>{let ge=k==="resource",ye=!ge,ve=c.every((Ne)=>!Ne.days?.length),{currentDate:De,view:Ce,scrollTime:xe,scrollToNow:be}=r(),Ee=So(null),he=So(null);wt({viewportRef:he,scrollTime:xe,scrollToNow:be,enabled:!ve,scrollKey:`${Ce}-${De.format("YYYY-MM-DD")}`}),Tt(Ee,he,c.length);let Pe=b&&nt(bo,{allDayRow:Y,classes:{header:V?.header,allDay:V?.allDay},expandAllDayRow:ve,children:b});if(ve&&Pe)return nt("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",style:U,children:Pe});return xo("div",{className:"h-full flex flex-col","data-testid":"vertical-grid-container",ref:Ee,style:U,children:[ye&&Pe,xo(u,{className:e("h-full",ye&&"overflow-auto"),"data-testid":"vertical-grid-scroll",viewPortProps:{className:"*:flex! *:flex-col! *:min-h-full *:w-max",ref:he},children:[ge&&Pe,nt("div",{className:e("relative flex flex-1 min-w-full w-fit gap-px bg-border",V?.body),"data-calendar-scroll-content":"true","data-testid":"vertical-grid-body",children:c.map((Ne,Te)=>nt(ho,{...Ne,gridType:T,slotDurationMinutes:le},n.listKey("col",Te)))}),nt(y,{className:"z-30"})," ",nt(y,{className:"z-30",orientation:"horizontal"})," "]})]})};import{jsx as Xe}from"react/jsx-runtime";var oi=(c,b)=>b==="vertical",ni=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let{slotDuration:V}=r((Ce)=>({slotDuration:Ce.slotDuration})),Y=c.some((Ce)=>Ce.gridType==="hour")?"hour":"day",le=c.filter((Ce)=>!Ce.noEvents).map((Ce)=>Ce.day).filter((Ce)=>Boolean(Ce)),U=c.find((Ce)=>Ce.noEvents),ye=Boolean(U?.className?.includes(j))?{cell:"flex-1 min-w-0",spacer:j}:void 0,ve;if(Y==="hour")ve=T?Xe(me,{columns:c}):Xe(ae,{classes:ye,days:le});return Xe(wo,{allDayRow:ve,classes:T?void 0:{header:"w-full",body:"w-full",allDay:"w-full"},columns:c,gridType:Y,slotDurationMinutes:V,variant:k,children:b})},ai=({specs:c,header:b,composesResourceAxis:T,variant:k})=>{let V=c.some((U)=>U.columns?.some((ge)=>ge.gridType==="hour"))?"hour":"day",Y=c.some((U)=>U.columns?.some((ge)=>ge.days)),le=T?{header:e(Y&&ue,"min-w-full"),body:"min-w-full"}:{body:"w-full",header:"w-full"};return Xe(co,{classes:le,dayNumberHeight:T?0:void 0,gridType:V,rows:c,variant:k,children:b})},To=({view:c})=>{let{currentDate:b,firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}=r((he)=>({currentDate:he.currentDate,firstDayOfWeek:he.firstDayOfWeek,hiddenDays:he.hiddenDays,businessHours:he.businessHours,hideNonBusinessHours:he.hideNonBusinessHours,resources:he.resources,orientation:he.orientation,weekViewGranularity:he.weekViewGranularity})),ye=Po(()=>({firstDayOfWeek:T,hiddenDays:k,businessHours:V,hideNonBusinessHours:Y,resources:le,orientation:U,weekViewGranularity:ge}),[T,k,V,Y,le,U,ge]),ve=Po(()=>c.columns?.(b,ye),[c,b,ye]);if(!ve||!c.layout){let he=c.component;if(he)return Xe(he,{});if(typeof process<"u"&&!1)console.warn(`[@ilamy/calendar] view "${c.name}" declares neither \`columns\` + \`layout\` nor \`component\` — rendering nothing.`);return null}let Ce=Boolean(le?.length)&&Boolean(c.supportsResources),xe=Ce?U??"horizontal":c.layout,be=Ce?"resource":"regular",Ee=c.renderHeader?.({date:b,config:ye});if(oi(ve,xe))return Xe(ni,{composesResourceAxis:Ce,header:Ee,specs:ve,variant:be});return Xe(ai,{composesResourceAxis:Ce,header:Ee,specs:ve,variant:be})};var Ro=(c)=>{if(!c||c.length===0)return;return new Set(c.map((b)=>H[b]))};function No(c){if(!c?.length)return[];return c.map((b)=>({...b,start:t(b.start),end:t(b.end)}))}import{jsx as Ke,jsxs as di}from"react/jsx-runtime";var li=()=>{let{view:c,getViews:b}=r((V)=>({view:V.view,getViews:V.getViews})),T=b().find((V)=>V.name===c);return di("div",{className:"flex flex-col w-full h-full","data-testid":"ilamy-calendar",children:[Ke(ro,{className:"p-1 shrink-0 mb-1"}),Ke(Er,{children:Ke(l,{className:"w-full min-h-0 flex-1",direction:"horizontal",transitionKey:c,children:Ke("div",{className:"border h-full w-full","data-calendar-viewport":"true","data-testid":"calendar-body",children:T?Ke(To,{view:T},c):null})})}),Ke(Lr,{})]})},er=({events:c,firstDayOfWeek:b="sunday",initialView:T="month",initialDate:k,eventSpacing:V=Z,eventHeight:Y=Q,stickyViewHeader:le=!0,viewHeaderClassName:U="",timeFormat:ge="12-hour",hideNonBusinessHours:ye=!1,hiddenDays:ve,resources:De,orientation:Ce,...xe})=>{let be=Boolean(De?.length),Ee=si(()=>No(c),[c]);return ii(()=>{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.")},[Ce,be]),Ke(_,{eventHeight:Y,eventSpacing:V,events:Ee,firstDayOfWeek:H[b],hiddenDays:Ro(ve),hideNonBusinessHours:ye,initialDate:k,initialView:T,orientation:Ce,resources:De,stickyViewHeader:le,timeFormat:ge,viewHeaderClassName:U,...xe,children:Ke(li,{})})};import{jsx as mi}from"react/jsx-runtime";var ci=(c)=>mi(er,{...c});export{er as IlamyCalendar,ci as IlamyResourceCalendar,cr as SLOT_EVENT_FORM,mr as SLOT_EVENT_MUTATION_SCOPE,t as dayjs,se as defaultTranslations,fe as useIlamyCalendarContext};
@@ -1 +1 @@
1
- import{e,W,d,T}from"../shared/chunk-h5d5q285.js";import{u,b,G}from"../shared/chunk-m1q73v86.js";import{t}from"../shared/chunk-kpzykmz4.js";import{List as M}from"lucide-react";import{createElement as H}from"react";import{useIlamyCalendarContext as Y}from"@ilamy/calendar";var S={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")})},P={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},p=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return S[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return P[a]};var V=(a,n,r)=>{if(a.allDay)return d(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},j=(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"),s=n.start.startOf("day");while(s.isSameOrBefore(o)){let i=s.startOf("day"),y=s.endOf("day"),m=a.filter((l)=>V(l,i,y)).sort(j);if(m.length>0)r.push({key:s.format("YYYY-MM-DD"),date:i,events:m});s=s.add(1,"day")}return r};import{useIlamyCalendarContext as L}from"@ilamy/calendar";import{useIlamyCalendarContext as I}from"@ilamy/calendar";import{jsx as f,jsxs as F}from"react/jsx-runtime";var B=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:s}=I(),i=a.start.format(B(o)),y=a.allDay?r("allDay"):i,m=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,R=n.startOf("day").diff(m,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return F("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>s(a),type:"button",children:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:y}),f("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),f("span",{className:"truncate",children:a.title}),x&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as c,jsxs as k}from"react/jsx-runtime";var C=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=L(),o=W(a.date,t()),s;if(r)s=(i)=>r({...i,view:n});return k("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":T("agenda-day",a.key),children:[c("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:c(b,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),k("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&c(G,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:s}),a.events.map((i)=>c(O,{day:a.date,event:i},T(a.key,i.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var h=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:s}=Y(),i=p(n,a,s),y=r(i.start,i.end),m=v(y,i);if(m.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(u,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:m.map((l)=>g(C,{group:l},l.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:M,navigationStep:A(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>H(h,{window:a})});var z=(a={})=>({name:"agenda",views:[D(a)]});export{z as agendaPlugin,D as createAgendaView};
1
+ import{e,Y,d,T}from"../shared/chunk-tfk3a0d4.js";import{u,b,U}from"../shared/chunk-xf8cy2gp.js";import{t}from"../shared/chunk-cn24081x.js";import{List as L}from"lucide-react";import{createElement as M}from"react";import{useIlamyCalendarContext as F}from"@ilamy/calendar";var S={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")})},P={day:{amount:1,unit:"day"},week:{amount:1,unit:"week"},month:{amount:1,unit:"month"}},p=(a,n,r=0)=>{if(typeof n==="number")return{start:a.startOf("day"),end:a.add(n-1,"day").endOf("day")};return S[n](a,r)},A=(a)=>{if(typeof a==="number")return{amount:a,unit:"day"};return P[a]};var W=(a,n,r)=>{if(a.allDay)return d(a,n,r);return a.start.isSameOrAfter(n)&&a.start.isSameOrBefore(r)},V=(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"),s=n.start.startOf("day");while(s.isSameOrBefore(o)){let i=s.startOf("day"),y=s.endOf("day"),m=a.filter((l)=>W(l,i,y)).sort(V);if(m.length>0)r.push({key:s.format("YYYY-MM-DD"),date:i,events:m});s=s.add(1,"day")}return r};import{useIlamyCalendarContext as B}from"@ilamy/calendar";import{useIlamyCalendarContext as j}from"@ilamy/calendar";import{jsx as f,jsxs as G}from"react/jsx-runtime";var I=(a)=>a==="24-hour"?"HH:mm":"h:mm A",O=({event:a,day:n})=>{let{t:r,timeFormat:o,onEventClick:s}=j(),i=a.start.format(I(o)),y=a.allDay?r("allDay"):i,m=a.start.startOf("day"),w=a.end.subtract(1,"millisecond").startOf("day").diff(m,"day")+1,R=n.startOf("day").diff(m,"day")+1,E=Boolean(a.allDay)&&w>1,N=`(${r("day")} ${R}/${w})`,x=E?N:null;return G("button",{className:"hover:bg-accent flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1 text-left text-sm",onClick:()=>s(a),type:"button",children:[f("span",{className:"text-muted-foreground w-20 shrink-0",children:y}),f("span",{className:e("size-3 shrink-0 rounded-full border",a.backgroundColor||"bg-blue-500",a.color),style:{backgroundColor:a.backgroundColor}}),f("span",{className:"truncate",children:a.title}),x&&f("span",{className:"text-muted-foreground shrink-0 text-xs",children:x})]})};import{jsx as c,jsxs as k}from"react/jsx-runtime";var C=({group:a})=>{let{view:n,renderCurrentTimeIndicator:r}=B(),o=Y(a.date,t()),s;if(r)s=(i)=>r({...i,view:n});return k("div",{className:"flex gap-4 border-b px-2 py-3","data-testid":T("agenda-day",a.key),children:[c("div",{className:"text-muted-foreground flex w-16 shrink-0 flex-col items-center text-center",children:c(b,{className:"flex-col-reverse",dayNumber:a.date.format("D"),today:o,weekday:a.date.format("ddd")})}),k("div",{className:"relative flex flex-1 flex-col gap-1",children:[o&&c(U,{rangeEnd:a.date.endOf("day"),rangeStart:a.date.startOf("day"),render:s}),a.events.map((i)=>c(O,{day:a.date,event:i},T(a.key,i.id)))]})]})};import{jsx as g}from"react/jsx-runtime";var h=({window:a})=>{let{currentDate:n,getEventsForDateRange:r,t:o,firstDayOfWeek:s}=F(),i=p(n,a,s),y=r(i.start,i.end),m=v(y,i);if(m.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(u,{className:"h-full","data-testid":"agenda-view",children:g("div",{className:"flex flex-col",children:m.map((l)=>g(C,{group:l},l.key))})})};var D=({window:a="month"}={})=>({name:"agenda",label:"agenda",icon:L,navigationStep:A(a),range:(n,r)=>p(n,a,r.firstDayOfWeek),supportsResources:!1,component:()=>M(h,{window:a})});var H=(a={})=>({name:"agenda",views:[D(a)]});export{H as agendaPlugin,D as createAgendaView};
@@ -325,8 +325,8 @@ interface IlamyPlugin {
325
325
  children: ReactNode2;
326
326
  }>;
327
327
  }
328
- import dayjs from "dayjs";
329
- type Dayjs3 = dayjs.Dayjs3;
328
+ import { Dayjs as DayjsInstance } from "dayjs";
329
+ type Dayjs3 = DayjsInstance;
330
330
  interface CellInfo {
331
331
  /** Start date/time of the cell */
332
332
  start: Dayjs3;
@@ -1 +1 @@
1
- import{t}from"../shared/chunk-kpzykmz4.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
+ import{t}from"../shared/chunk-cn24081x.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,6 +1,11 @@
1
1
  import { RRule, Weekday } from "rrule";
2
2
  import { Options } from "rrule";
3
3
  /**
4
+ * Scope options for recurring event operations (Google Calendar style)
5
+ * Determines how many events in a recurring series should be affected
6
+ */
7
+ type RecurrenceEditScope = "this" | "following" | "all";
8
+ /**
4
9
  * Re-rrule.js Options with practical TypeScript interface.
5
10
  * Makes all properties optional except freq and dtstart (which are required by RFC 5545).
6
11
  * This allows clean object creation without needing explicit null values.
@@ -362,8 +367,8 @@ interface IlamyPlugin {
362
367
  children: ReactNode2;
363
368
  }>;
364
369
  }
365
- import dayjs from "dayjs";
366
- type Dayjs3 = dayjs.Dayjs3;
370
+ import { Dayjs as DayjsInstance } from "dayjs";
371
+ type Dayjs3 = DayjsInstance;
367
372
  /**
368
373
  * Returns the recurrence-specific VEVENT property lines for an event: an
369
374
  * `RRULE:` line when the event has an rrule, an `EXDATE:` line when it has
@@ -384,4 +389,4 @@ interface GenerateRecurringEventsProps {
384
389
  }
385
390
  declare const generateRecurringEvents: ({ event, currentEvents, startDate, endDate }: GenerateRecurringEventsProps) => CalendarEvent2[];
386
391
  declare const isRecurringEvent: (event: CalendarEvent2) => boolean;
387
- export { RRule, RRuleOptions, RecurrenceAugmentation, Weekday, generateRecurringEvents, isRecurringEvent, recurrenceICalProperties, recurrencePlugin };
392
+ export { RRule, RRuleOptions, RecurrenceAugmentation, RecurrenceEditScope, Weekday, generateRecurringEvents, isRecurringEvent, recurrenceICalProperties, recurrencePlugin };