@mlw-packages/react-components 1.7.18 → 1.7.19

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.js CHANGED
@@ -486,7 +486,9 @@ var require_colors2 = __commonJS({
486
486
  var index_exports = {};
487
487
  __export(index_exports, {
488
488
  AddButton: () => AddButton,
489
+ Agenda: () => Agenda,
489
490
  AgendaDaysToShow: () => AgendaDaysToShow,
491
+ AgendaDaysToShowAgenda: () => AgendaDaysToShowAgenda,
490
492
  AgendaView: () => AgendaView,
491
493
  AlertDialogActionBase: () => AlertDialogActionBase,
492
494
  AlertDialogBase: () => AlertDialogBase,
@@ -517,6 +519,7 @@ __export(index_exports, {
517
519
  ButtonGroupBase: () => ButtonGroupBase,
518
520
  CalendarBase: () => CalendarBase,
519
521
  CalendarDndProvider: () => CalendarDndProvider,
522
+ CalendarDndProviderAgenda: () => CalendarDndProviderAgenda,
520
523
  CardBase: () => CardBase,
521
524
  CardContentBase: () => CardContentBase,
522
525
  CardDescriptionBase: () => CardDescriptionBase,
@@ -567,9 +570,12 @@ __export(index_exports, {
567
570
  CopyButton: () => CopyButton,
568
571
  DateTimePicker: () => DateTimePicker,
569
572
  DayView: () => DayView,
573
+ DayViewAgenda: () => DayViewAgenda,
570
574
  DebouncedInput: () => DebouncedInput,
571
575
  DefaultEndHour: () => DefaultEndHour,
576
+ DefaultEndHourAgenda: () => DefaultEndHourAgenda,
572
577
  DefaultStartHour: () => DefaultStartHour,
578
+ DefaultStartHourAgenda: () => DefaultStartHourAgenda,
573
579
  DestructiveDialog: () => DestructiveDialog,
574
580
  DialogBase: () => DialogBase,
575
581
  DialogCloseBase: () => DialogCloseBase,
@@ -610,14 +616,20 @@ __export(index_exports, {
610
616
  DropDownMenuSubTriggerBase: () => DropDownMenuSubTriggerBase,
611
617
  DropDownMenuTriggerBase: () => DropDownMenuTriggerBase,
612
618
  DroppableCell: () => DroppableCell,
619
+ DroppableCellAgenda: () => DroppableCellAgenda,
613
620
  EditButton: () => EditButton,
614
621
  EndHour: () => EndHour,
622
+ EndHourAgenda: () => EndHourAgenda,
615
623
  ErrorMessage: () => ErrorMessage_default,
624
+ EventAgenda: () => EventAgenda,
616
625
  EventCalendar: () => EventCalendar,
617
626
  EventDialog: () => EventDialog,
618
627
  EventGap: () => EventGap,
628
+ EventGapAgenda: () => EventGapAgenda,
619
629
  EventHeight: () => EventHeight,
630
+ EventHeightAgenda: () => EventHeightAgenda,
620
631
  EventItem: () => EventItem,
632
+ EventItemAgenda: () => EventItemAgenda,
621
633
  EventsPopup: () => EventsPopup,
622
634
  FavoriteButton: () => FavoriteButton,
623
635
  FileUploader: () => FileUploader,
@@ -649,6 +661,7 @@ __export(index_exports, {
649
661
  ModalTriggerBase: () => ModalTriggerBase,
650
662
  ModeToggleBase: () => ModeToggleBase,
651
663
  MonthView: () => MonthView,
664
+ MonthViewAgenda: () => MonthViewAgenda,
652
665
  MoreButton: () => MoreButton,
653
666
  MultiCombobox: () => MultiCombobox,
654
667
  MultiSelectBase: () => MultiSelectBase,
@@ -734,6 +747,7 @@ __export(index_exports, {
734
747
  SkeletonBase: () => SkeletonBase,
735
748
  SlideBase: () => SlideBase,
736
749
  StartHour: () => StartHour,
750
+ StartHourAgenda: () => StartHourAgenda,
737
751
  StatusIndicator: () => StatusIndicator,
738
752
  SwitchBase: () => SwitchBase,
739
753
  TableBase: () => TableBase,
@@ -759,6 +773,7 @@ __export(index_exports, {
759
773
  TooltipSimple: () => TooltipSimple_default,
760
774
  TooltipTriggerBase: () => TooltipTriggerBase,
761
775
  TooltipWithTotal: () => TooltipWithTotal_default,
776
+ UndatedEvents: () => UndatedEvents,
762
777
  UniversalTooltipRenderer: () => UniversalTooltipRenderer,
763
778
  UnlockButton: () => UnlockButton,
764
779
  UploadButton: () => UploadButton,
@@ -766,8 +781,11 @@ __export(index_exports, {
766
781
  ViewButton: () => ViewButton,
767
782
  VisibilityButton: () => VisibilityButton,
768
783
  WeekCellsHeight: () => WeekCellsHeight,
784
+ WeekCellsHeightAgenda: () => WeekCellsHeightAgenda,
769
785
  WeekView: () => WeekView,
786
+ WeekViewAgenda: () => WeekViewAgenda,
770
787
  addHoursToDate: () => addHoursToDate,
788
+ addHoursToDateAgenda: () => addHoursToDateAgenda,
771
789
  badgeVariants: () => badgeVariants,
772
790
  buttonVariantsBase: () => buttonVariantsBase,
773
791
  compactTick: () => compactTick,
@@ -778,13 +796,19 @@ __export(index_exports, {
778
796
  formatFieldName: () => formatFieldName,
779
797
  generateAdditionalColors: () => generateAdditionalColors,
780
798
  getAgendaEventsForDay: () => getAgendaEventsForDay,
799
+ getAgendaEventsForDayAgenda: () => getAgendaEventsForDayAgenda,
781
800
  getAllEventsForDay: () => getAllEventsForDay,
801
+ getAllEventsForDayAgenda: () => getAllEventsForDayAgenda,
782
802
  getArrowByType: () => getArrowByType,
783
803
  getBorderRadiusClasses: () => getBorderRadiusClasses,
804
+ getBorderRadiusClassesAgenda: () => getBorderRadiusClassesAgenda,
784
805
  getDateByType: () => getDateByType,
785
806
  getEventColorClasses: () => getEventColorClasses,
807
+ getEventColorClassesAgenda: () => getEventColorClassesAgenda,
786
808
  getEventsForDay: () => getEventsForDay,
809
+ getEventsForDayAgenda: () => getEventsForDayAgenda,
787
810
  getSpanningEventsForDay: () => getSpanningEventsForDay,
811
+ getSpanningEventsForDayAgenda: () => getSpanningEventsForDayAgenda,
788
812
  getValid12Hour: () => getValid12Hour,
789
813
  getValidArrow12Hour: () => getValidArrow12Hour,
790
814
  getValidArrowHour: () => getValidArrowHour,
@@ -794,10 +818,12 @@ __export(index_exports, {
794
818
  getValidMinuteOrSecond: () => getValidMinuteOrSecond,
795
819
  getValidNumber: () => getValidNumber,
796
820
  isMultiDayEvent: () => isMultiDayEvent,
821
+ isMultiDayEventAgenda: () => isMultiDayEventAgenda,
797
822
  isValid12Hour: () => isValid12Hour,
798
823
  isValidHour: () => isValidHour,
799
824
  isValidMinuteOrSecond: () => isValidMinuteOrSecond,
800
825
  niceCeil: () => niceCeil,
826
+ normalizeAttendDate: () => normalizeAttendDate,
801
827
  renderInsideBarLabel: () => renderInsideBarLabel,
802
828
  renderPillLabel: () => pillLabelRenderer_default,
803
829
  resolveChartMargins: () => resolveChartMargins,
@@ -808,12 +834,16 @@ __export(index_exports, {
808
834
  setMinutes: () => setMinutes,
809
835
  setSeconds: () => setSeconds,
810
836
  sortEvents: () => sortEvents,
837
+ sortEventsAgenda: () => sortEventsAgenda,
811
838
  toast: () => toast2,
812
839
  useCalendarDnd: () => useCalendarDnd,
840
+ useCalendarDndAgenda: () => useCalendarDndAgenda,
813
841
  useChartHighlights: () => useChartHighlights,
814
842
  useCurrentTimeIndicator: () => useCurrentTimeIndicator,
843
+ useCurrentTimeIndicatorAgenda: () => useCurrentTimeIndicatorAgenda,
815
844
  useDrag: () => useDrag,
816
845
  useEventVisibility: () => useEventVisibility,
846
+ useEventVisibilityAgenda: () => useEventVisibilityAgenda,
817
847
  useIsMobile: () => useIsMobile,
818
848
  useTheme: () => useTheme
819
849
  });
@@ -12387,7 +12417,7 @@ function AgendaView({
12387
12417
  onEventSelect,
12388
12418
  showUndatedEvents = false
12389
12419
  }) {
12390
- const isValidDate3 = (d) => {
12420
+ const isValidDate6 = (d) => {
12391
12421
  try {
12392
12422
  const t = d instanceof Date ? d.getTime() : new Date(String(d)).getTime();
12393
12423
  return !isNaN(t);
@@ -12396,11 +12426,11 @@ function AgendaView({
12396
12426
  }
12397
12427
  };
12398
12428
  const datedEvents = (0, import_react52.useMemo)(
12399
- () => events.filter((e) => isValidDate3(e.start) && isValidDate3(e.end)),
12429
+ () => events.filter((e) => isValidDate6(e.start) && isValidDate6(e.end)),
12400
12430
  [events]
12401
12431
  );
12402
12432
  const undatedEvents = (0, import_react52.useMemo)(
12403
- () => events.filter((e) => !(isValidDate3(e.start) && isValidDate3(e.end))),
12433
+ () => events.filter((e) => !(isValidDate6(e.start) && isValidDate6(e.end))),
12404
12434
  [events]
12405
12435
  );
12406
12436
  const days = (0, import_react52.useMemo)(() => {
@@ -15565,14 +15595,2248 @@ function debounce(func, wait) {
15565
15595
  };
15566
15596
  }
15567
15597
 
15598
+ // src/components/event-calendar-view/Agenda.tsx
15599
+ var import_date_fns16 = require("date-fns");
15600
+ var import_locale9 = require("date-fns/locale");
15601
+ var import_react73 = require("react");
15602
+ var import_react74 = require("@phosphor-icons/react");
15603
+ var import_tailwind_merge2 = require("tailwind-merge");
15604
+ var import_jsx_runtime86 = require("react/jsx-runtime");
15605
+ function Agenda({
15606
+ currentDate,
15607
+ events,
15608
+ onEventSelect,
15609
+ showUndatedEvents = true
15610
+ }) {
15611
+ const isValidDate6 = (d) => {
15612
+ try {
15613
+ const t = d instanceof Date ? d.getTime() : new Date(String(d)).getTime();
15614
+ return !isNaN(t);
15615
+ } catch {
15616
+ return false;
15617
+ }
15618
+ };
15619
+ const datedEvents = (0, import_react73.useMemo)(
15620
+ () => events.filter(
15621
+ (e) => isValidDate6(e.start) && isValidDate6(e.end) || isValidDate6(e.attend_date)
15622
+ ),
15623
+ [events]
15624
+ );
15625
+ const undatedEvents = (0, import_react73.useMemo)(
15626
+ () => events.filter(
15627
+ (e) => !(isValidDate6(e.start) && isValidDate6(e.end)) && !isValidDate6(e.attend_date)
15628
+ ),
15629
+ [events]
15630
+ );
15631
+ const days = (0, import_react73.useMemo)(() => {
15632
+ console.log("Agenda view updating with date:", currentDate.toISOString());
15633
+ return Array.from(
15634
+ { length: AgendaDaysToShowAgenda },
15635
+ (_, i) => (0, import_date_fns16.addDays)(new Date(currentDate), i)
15636
+ );
15637
+ }, [currentDate]);
15638
+ const handleEventClick = (event, e) => {
15639
+ e.stopPropagation();
15640
+ console.log("Agenda view event clicked:", event);
15641
+ if (onEventSelect) onEventSelect(event);
15642
+ };
15643
+ const hasEvents = days.some(
15644
+ (day) => getAgendaEventsForDayAgenda(datedEvents, day).length > 0
15645
+ );
15646
+ return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "border-border/70 border-t px-4", children: !hasEvents && !(showUndatedEvents && undatedEvents.length > 0) ? /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "flex min-h-[70svh] flex-col items-center justify-center py-16 text-center", children: [
15647
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_react74.CalendarIcon, { className: "mb-2 text-muted-foreground/50", size: 32 }),
15648
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("h3", { className: "font-medium text-lg", children: "Nenhum evento encontrado" }),
15649
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("p", { className: "text-muted-foreground", children: "N\xE3o h\xE1 eventos agendados para este per\xEDodo." })
15650
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
15651
+ days.map((day) => {
15652
+ const dayEvents = getAgendaEventsForDayAgenda(datedEvents, day);
15653
+ if (dayEvents.length === 0) return null;
15654
+ return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15655
+ "div",
15656
+ {
15657
+ className: (0, import_tailwind_merge2.twMerge)("relative my-12 border-border/70 border-t", (0, import_date_fns16.isToday)(day) ? "border-blue-200" : ""),
15658
+ children: [
15659
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15660
+ "span",
15661
+ {
15662
+ className: (0, import_tailwind_merge2.twMerge)("-top-3 absolute left-0 flex h-6 items-center bg-background pe-4 uppercase data-today:font-extrabold sm:pe-4 text-lg font-bold", (0, import_date_fns16.isToday)(day) ? "text-blue-500" : ""),
15663
+ "data-today": (0, import_date_fns16.isToday)(day) || void 0,
15664
+ children: (() => {
15665
+ const s = (0, import_date_fns16.format)(day, "d MMM, EEEE", { locale: import_locale9.ptBR });
15666
+ return s.split(" ").map((w) => w ? w[0].toUpperCase() + w.slice(1) : w).join(" ");
15667
+ })()
15668
+ }
15669
+ ),
15670
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "mt-6 space-y-2", children: dayEvents.map((event) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15671
+ EventItemAgenda,
15672
+ {
15673
+ event,
15674
+ onClick: onEventSelect ? (e) => handleEventClick(event, e) : void 0,
15675
+ view: "agenda",
15676
+ className: onEventSelect ? void 0 : "cursor-default hover:shadow-none hover:scale-100"
15677
+ },
15678
+ event.id
15679
+ )) })
15680
+ ]
15681
+ },
15682
+ day.toString()
15683
+ );
15684
+ }),
15685
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15686
+ UndatedEvents,
15687
+ {
15688
+ events,
15689
+ onEventSelect,
15690
+ show: showUndatedEvents,
15691
+ className: "my-12"
15692
+ }
15693
+ )
15694
+ ] }) });
15695
+ }
15696
+
15697
+ // src/components/event-calendar-view/CalendarDND.tsx
15698
+ var import_core4 = require("@dnd-kit/core");
15699
+ var import_date_fns17 = require("date-fns");
15700
+ var import_react76 = require("react");
15701
+
15702
+ // src/components/event-calendar-view/hooks.ts
15703
+ var import_react75 = require("react");
15704
+ var CalendarDndContext2 = (0, import_react75.createContext)({
15705
+ activeEvent: null,
15706
+ activeId: null,
15707
+ activeView: null,
15708
+ currentTime: null,
15709
+ dragHandlePosition: null,
15710
+ eventHeight: null,
15711
+ isMultiDay: false,
15712
+ multiDayWidth: null
15713
+ });
15714
+ var useCalendarDndAgenda = () => (0, import_react75.useContext)(CalendarDndContext2);
15715
+
15716
+ // src/components/event-calendar-view/CalendarDND.tsx
15717
+ var import_jsx_runtime87 = require("react/jsx-runtime");
15718
+ function CalendarDndProviderAgenda({
15719
+ children,
15720
+ onEventUpdate
15721
+ }) {
15722
+ const [activeEvent, setActiveEvent] = (0, import_react76.useState)(null);
15723
+ const [activeId, setActiveId] = (0, import_react76.useState)(null);
15724
+ const [activeView, setActiveView] = (0, import_react76.useState)(
15725
+ null
15726
+ );
15727
+ const [currentTime, setCurrentTime] = (0, import_react76.useState)(null);
15728
+ const [eventHeight, setEventHeight] = (0, import_react76.useState)(null);
15729
+ const [isMultiDay, setIsMultiDay] = (0, import_react76.useState)(false);
15730
+ const [multiDayWidth, setMultiDayWidth] = (0, import_react76.useState)(null);
15731
+ const [dragHandlePosition, setDragHandlePosition] = (0, import_react76.useState)(null);
15732
+ const eventDimensions = (0, import_react76.useRef)({ height: 0 });
15733
+ const sensors = (0, import_core4.useSensors)(
15734
+ (0, import_core4.useSensor)(import_core4.MouseSensor, {
15735
+ // Require the mouse to move by 5px before activating
15736
+ activationConstraint: {
15737
+ distance: 5
15738
+ }
15739
+ }),
15740
+ (0, import_core4.useSensor)(import_core4.TouchSensor, {
15741
+ // Press delay of 250ms, with tolerance of 5px of movement
15742
+ activationConstraint: {
15743
+ delay: 250,
15744
+ tolerance: 5
15745
+ }
15746
+ }),
15747
+ (0, import_core4.useSensor)(import_core4.PointerSensor, {
15748
+ // Require the pointer to move by 5px before activating
15749
+ activationConstraint: {
15750
+ distance: 5
15751
+ }
15752
+ })
15753
+ );
15754
+ const dndContextId = (0, import_react76.useId)();
15755
+ const handleDragStart = (event) => {
15756
+ const { active } = event;
15757
+ if (!active.data.current) {
15758
+ console.error("Missing data in drag start event", event);
15759
+ return;
15760
+ }
15761
+ const {
15762
+ event: calendarEvent,
15763
+ view,
15764
+ height,
15765
+ isMultiDay: eventIsMultiDay,
15766
+ multiDayWidth: eventMultiDayWidth,
15767
+ dragHandlePosition: eventDragHandlePosition
15768
+ } = active.data.current;
15769
+ setActiveEvent(calendarEvent);
15770
+ setActiveId(active.id);
15771
+ setActiveView(view);
15772
+ setCurrentTime(calendarEvent.start ? new Date(calendarEvent.start) : null);
15773
+ setIsMultiDay(eventIsMultiDay || false);
15774
+ setMultiDayWidth(eventMultiDayWidth || null);
15775
+ setDragHandlePosition(eventDragHandlePosition || null);
15776
+ if (height) {
15777
+ eventDimensions.current.height = height;
15778
+ setEventHeight(height);
15779
+ }
15780
+ };
15781
+ const handleDragOver = (event) => {
15782
+ const { over } = event;
15783
+ if (over && activeEvent && over.data.current) {
15784
+ const { date, time } = over.data.current;
15785
+ if (time !== void 0 && activeView !== "month") {
15786
+ const newTime = new Date(date);
15787
+ const hours = Math.floor(time);
15788
+ const fractionalHour = time - hours;
15789
+ let minutes = 0;
15790
+ if (fractionalHour < 0.125) minutes = 0;
15791
+ else if (fractionalHour < 0.375) minutes = 15;
15792
+ else if (fractionalHour < 0.625) minutes = 30;
15793
+ else minutes = 45;
15794
+ newTime.setHours(hours, minutes, 0, 0);
15795
+ if (!currentTime || newTime.getHours() !== currentTime.getHours() || newTime.getMinutes() !== currentTime.getMinutes() || newTime.getDate() !== currentTime.getDate() || newTime.getMonth() !== currentTime.getMonth() || newTime.getFullYear() !== currentTime.getFullYear()) {
15796
+ setCurrentTime(newTime);
15797
+ }
15798
+ } else if (activeView === "month") {
15799
+ const newTime = new Date(date);
15800
+ if (currentTime) {
15801
+ newTime.setHours(
15802
+ currentTime.getHours(),
15803
+ currentTime.getMinutes(),
15804
+ currentTime.getSeconds(),
15805
+ currentTime.getMilliseconds()
15806
+ );
15807
+ }
15808
+ if (!currentTime || newTime.getDate() !== currentTime.getDate() || newTime.getMonth() !== currentTime.getMonth() || newTime.getFullYear() !== currentTime.getFullYear()) {
15809
+ setCurrentTime(newTime);
15810
+ }
15811
+ }
15812
+ }
15813
+ };
15814
+ const handleDragEnd = (event) => {
15815
+ const { active, over } = event;
15816
+ if (!over || !activeEvent || !currentTime) {
15817
+ setActiveEvent(null);
15818
+ setActiveId(null);
15819
+ setActiveView(null);
15820
+ setCurrentTime(null);
15821
+ setEventHeight(null);
15822
+ setIsMultiDay(false);
15823
+ setMultiDayWidth(null);
15824
+ setDragHandlePosition(null);
15825
+ return;
15826
+ }
15827
+ try {
15828
+ if (!active.data.current || !over.data.current) {
15829
+ throw new Error("Missing data in drag event");
15830
+ }
15831
+ const activeData = active.data.current;
15832
+ const overData = over.data.current;
15833
+ if (!activeData.event || !overData.date) {
15834
+ throw new Error("Missing required event data");
15835
+ }
15836
+ const calendarEvent = activeData.event;
15837
+ const date = overData.date;
15838
+ const time = overData.time;
15839
+ const newStart = new Date(date);
15840
+ if (time !== void 0) {
15841
+ const hours = Math.floor(time);
15842
+ const fractionalHour = time - hours;
15843
+ let minutes = 0;
15844
+ if (fractionalHour < 0.125) minutes = 0;
15845
+ else if (fractionalHour < 0.375) minutes = 15;
15846
+ else if (fractionalHour < 0.625) minutes = 30;
15847
+ else minutes = 45;
15848
+ newStart.setHours(hours, minutes, 0, 0);
15849
+ } else {
15850
+ newStart.setHours(
15851
+ currentTime.getHours(),
15852
+ currentTime.getMinutes(),
15853
+ currentTime.getSeconds(),
15854
+ currentTime.getMilliseconds()
15855
+ );
15856
+ }
15857
+ if (!calendarEvent.start || !calendarEvent.end) {
15858
+ console.error("Cannot compute duration: event start or end is null", calendarEvent);
15859
+ return;
15860
+ }
15861
+ const originalStart = new Date(calendarEvent.start);
15862
+ const originalEnd = new Date(calendarEvent.end);
15863
+ const durationMinutes = (0, import_date_fns17.differenceInMinutes)(originalEnd, originalStart);
15864
+ const newEnd = (0, import_date_fns17.addMinutes)(newStart, durationMinutes);
15865
+ const hasStartTimeChanged = originalStart.getFullYear() !== newStart.getFullYear() || originalStart.getMonth() !== newStart.getMonth() || originalStart.getDate() !== newStart.getDate() || originalStart.getHours() !== newStart.getHours() || originalStart.getMinutes() !== newStart.getMinutes();
15866
+ if (hasStartTimeChanged) {
15867
+ onEventUpdate({
15868
+ ...calendarEvent,
15869
+ end: newEnd,
15870
+ start: newStart
15871
+ });
15872
+ }
15873
+ } catch (error) {
15874
+ console.error("Error in drag end handler:", error);
15875
+ } finally {
15876
+ setActiveEvent(null);
15877
+ setActiveId(null);
15878
+ setActiveView(null);
15879
+ setCurrentTime(null);
15880
+ setEventHeight(null);
15881
+ setIsMultiDay(false);
15882
+ setMultiDayWidth(null);
15883
+ setDragHandlePosition(null);
15884
+ }
15885
+ };
15886
+ return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15887
+ import_core4.DndContext,
15888
+ {
15889
+ id: dndContextId,
15890
+ onDragEnd: handleDragEnd,
15891
+ onDragOver: handleDragOver,
15892
+ onDragStart: handleDragStart,
15893
+ sensors,
15894
+ children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(
15895
+ CalendarDndContext2.Provider,
15896
+ {
15897
+ value: {
15898
+ activeEvent,
15899
+ activeId,
15900
+ activeView,
15901
+ currentTime,
15902
+ dragHandlePosition,
15903
+ eventHeight,
15904
+ isMultiDay,
15905
+ multiDayWidth
15906
+ },
15907
+ children: [
15908
+ children,
15909
+ /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_core4.DragOverlay, { adjustScale: false, dropAnimation: null, children: activeEvent && activeView && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15910
+ "div",
15911
+ {
15912
+ style: {
15913
+ height: eventHeight ? `${eventHeight}px` : "auto",
15914
+ width: isMultiDay && multiDayWidth ? `${multiDayWidth}%` : "100%"
15915
+ },
15916
+ children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15917
+ EventItemAgenda,
15918
+ {
15919
+ currentTime: currentTime || void 0,
15920
+ event: activeEvent,
15921
+ isDragging: true,
15922
+ isFirstDay: dragHandlePosition?.data?.isFirstDay !== false,
15923
+ isLastDay: dragHandlePosition?.data?.isLastDay !== false,
15924
+ showTime: activeView !== "month",
15925
+ view: activeView
15926
+ }
15927
+ )
15928
+ }
15929
+ ) })
15930
+ ]
15931
+ }
15932
+ )
15933
+ }
15934
+ );
15935
+ }
15936
+
15937
+ // src/components/event-calendar-view/constants.ts
15938
+ var EventHeightAgenda = 24;
15939
+ var EventGapAgenda = 4;
15940
+ var WeekCellsHeightAgenda = 64;
15941
+ var AgendaDaysToShowAgenda = 30;
15942
+ var StartHourAgenda = 0;
15943
+ var EndHourAgenda = 24;
15944
+ var DefaultStartHourAgenda = 9;
15945
+ var DefaultEndHourAgenda = 10;
15946
+
15947
+ // src/components/event-calendar-view/DayView.tsx
15948
+ var import_date_fns22 = require("date-fns");
15949
+ var import_react80 = require("react");
15950
+
15951
+ // src/components/event-calendar-view/utils.ts
15952
+ var import_date_fns18 = require("date-fns");
15953
+ var import_date_fns19 = require("date-fns");
15954
+ function getEventColorClassesAgenda(color) {
15955
+ const eventColor = color || "sky";
15956
+ switch (eventColor) {
15957
+ case "sky":
15958
+ return "bg-sky-200/50 hover:bg-sky-200/40 text-sky-950/80 dark:bg-sky-400/25 dark:hover:bg-sky-400/20 dark:text-sky-200 shadow-sky-700/8";
15959
+ case "amber":
15960
+ return "bg-amber-200/50 hover:bg-amber-200/40 text-amber-950/80 dark:bg-amber-400/25 dark:hover:bg-amber-400/20 dark:text-amber-200 shadow-amber-700/8";
15961
+ case "violet":
15962
+ return "bg-violet-200/50 hover:bg-violet-200/40 text-violet-950/80 dark:bg-violet-400/25 dark:hover:bg-violet-400/20 dark:text-violet-200 shadow-violet-700/8";
15963
+ case "rose":
15964
+ return "bg-rose-200/50 hover:bg-rose-200/40 text-rose-950/80 dark:bg-rose-400/25 dark:hover:bg-rose-400/20 dark:text-rose-200 shadow-rose-700/8";
15965
+ case "emerald":
15966
+ return "bg-emerald-200/50 hover:bg-emerald-200/40 text-emerald-950/80 dark:bg-emerald-400/25 dark:hover:bg-emerald-400/20 dark:text-emerald-200 shadow-emerald-700/8";
15967
+ case "orange":
15968
+ return "bg-orange-200/50 hover:bg-orange-200/40 text-orange-950/80 dark:bg-orange-400/25 dark:hover:bg-orange-400/20 dark:text-orange-200 shadow-orange-700/8";
15969
+ default:
15970
+ return "bg-sky-200/50 hover:bg-sky-200/40 text-sky-950/80 dark:bg-sky-400/25 dark:hover:bg-sky-400/20 dark:text-sky-200 shadow-sky-700/8";
15971
+ }
15972
+ }
15973
+ function getBorderRadiusClassesAgenda(isFirstDay, isLastDay) {
15974
+ if (isFirstDay && isLastDay) {
15975
+ return "rounded";
15976
+ }
15977
+ if (isFirstDay) {
15978
+ return "rounded-l rounded-r-none";
15979
+ }
15980
+ if (isLastDay) {
15981
+ return "rounded-r rounded-l-none";
15982
+ }
15983
+ return "rounded-none";
15984
+ }
15985
+ function isMultiDayEventAgenda(event) {
15986
+ const eventStart = isValidDate3(event.start) ? new Date(event.start) : void 0;
15987
+ const eventEnd = isValidDate3(event.end) ? new Date(event.end) : void 0;
15988
+ if (!eventStart || !eventEnd) return !!event.allDay;
15989
+ return event.allDay || eventStart.getDate() !== eventEnd.getDate();
15990
+ }
15991
+ function getEventsForDayAgenda(events, day) {
15992
+ return events.filter((event) => {
15993
+ const eventStart = isValidDate3(event.start) ? new Date(event.start) : isValidDate3(event.attend_date) ? normalizeAttendDate(event.attend_date) : void 0;
15994
+ return eventStart ? (0, import_date_fns18.isSameDay)(day, eventStart) : false;
15995
+ }).sort((a, b) => getEventStartTimestamp2(a) - getEventStartTimestamp2(b));
15996
+ }
15997
+ function sortEventsAgenda(events) {
15998
+ return [...events].sort((a, b) => {
15999
+ const aIsMultiDay = isMultiDayEventAgenda(a);
16000
+ const bIsMultiDay = isMultiDayEventAgenda(b);
16001
+ if (aIsMultiDay && !bIsMultiDay) return -1;
16002
+ if (!aIsMultiDay && bIsMultiDay) return 1;
16003
+ return getEventStartTimestamp2(a) - getEventStartTimestamp2(b);
16004
+ });
16005
+ }
16006
+ function getSpanningEventsForDayAgenda(events, day) {
16007
+ return events.filter((event) => {
16008
+ if (!isMultiDayEventAgenda(event)) return false;
16009
+ const eventStart = isValidDate3(event.start) ? new Date(event.start) : void 0;
16010
+ const eventEnd = isValidDate3(event.end) ? new Date(event.end) : void 0;
16011
+ if (!eventStart || !eventEnd) return false;
16012
+ return !(0, import_date_fns18.isSameDay)(day, eventStart) && ((0, import_date_fns18.isSameDay)(day, eventEnd) || day > eventStart && day < eventEnd);
16013
+ });
16014
+ }
16015
+ function getAllEventsForDayAgenda(events, day) {
16016
+ return events.filter((event) => {
16017
+ const eventStart = isValidDate3(event.start) ? new Date(event.start) : void 0;
16018
+ const eventEnd = isValidDate3(event.end) ? new Date(event.end) : void 0;
16019
+ if (!eventStart) return false;
16020
+ return (0, import_date_fns18.isSameDay)(day, eventStart) || (eventEnd ? (0, import_date_fns18.isSameDay)(day, eventEnd) : false) || (eventEnd ? day > eventStart && day < eventEnd : false);
16021
+ });
16022
+ }
16023
+ function getAgendaEventsForDayAgenda(events, day) {
16024
+ return events.filter((event) => {
16025
+ const eventStart = isValidDate3(event.start) ? new Date(event.start) : isValidDate3(event.attend_date) ? normalizeAttendDate(event.attend_date) : void 0;
16026
+ const eventEnd = isValidDate3(event.end) ? new Date(event.end) : isValidDate3(event.attend_date) ? (() => {
16027
+ const dt = normalizeAttendDate(event.attend_date);
16028
+ return dt ? (0, import_date_fns19.addHours)(dt, 1) : void 0;
16029
+ })() : void 0;
16030
+ if (!eventStart) return false;
16031
+ return (0, import_date_fns18.isSameDay)(day, eventStart) || (eventEnd ? (0, import_date_fns18.isSameDay)(day, eventEnd) : false) || (eventEnd ? day > eventStart && day < eventEnd : false);
16032
+ }).sort((a, b) => getEventStartTimestamp2(a) - getEventStartTimestamp2(b));
16033
+ }
16034
+ function isValidDate3(d) {
16035
+ try {
16036
+ const t = d instanceof Date ? d.getTime() : new Date(String(d)).getTime();
16037
+ return !isNaN(t);
16038
+ } catch {
16039
+ return false;
16040
+ }
16041
+ }
16042
+ function getEventStartTimestamp2(e) {
16043
+ if (isValidDate3(e.start)) return new Date(e.start).getTime();
16044
+ if (isValidDate3(e.attend_date))
16045
+ return normalizeAttendDate(e.attend_date).getTime();
16046
+ return Number.MAX_SAFE_INTEGER;
16047
+ }
16048
+ function normalizeAttendDate(d) {
16049
+ if (d === void 0 || d === null) return void 0;
16050
+ try {
16051
+ const dt = d instanceof Date ? d : new Date(String(d));
16052
+ if (isNaN(dt.getTime())) return void 0;
16053
+ if (dt.getHours() !== 0 || dt.getMinutes() !== 0 || dt.getSeconds() !== 0 || dt.getMilliseconds() !== 0) {
16054
+ return dt;
16055
+ }
16056
+ return new Date(dt.getFullYear(), dt.getMonth(), dt.getDate());
16057
+ } catch {
16058
+ return void 0;
16059
+ }
16060
+ }
16061
+ function addHoursToDateAgenda(date, hours) {
16062
+ const result = new Date(date);
16063
+ result.setHours(result.getHours() + hours);
16064
+ return result;
16065
+ }
16066
+
16067
+ // src/components/event-calendar-view/hooks/use-current-time-indicator.ts
16068
+ var import_date_fns20 = require("date-fns");
16069
+ var import_locale10 = require("date-fns/locale");
16070
+ var import_react77 = require("react");
16071
+ function useCurrentTimeIndicatorAgenda(currentDate, view) {
16072
+ const [currentTimePosition, setCurrentTimePosition] = (0, import_react77.useState)(0);
16073
+ const [currentTimeVisible, setCurrentTimeVisible] = (0, import_react77.useState)(false);
16074
+ (0, import_react77.useEffect)(() => {
16075
+ const calculateTimePosition = () => {
16076
+ const now = /* @__PURE__ */ new Date();
16077
+ const hours = now.getHours();
16078
+ const minutes = now.getMinutes();
16079
+ const totalMinutes = (hours - StartHourAgenda) * 60 + minutes;
16080
+ const dayStartMinutes = 0;
16081
+ const dayEndMinutes = (EndHourAgenda - StartHourAgenda) * 60;
16082
+ const position = (totalMinutes - dayStartMinutes) / (dayEndMinutes - dayStartMinutes) * 100;
16083
+ let isCurrentTimeVisible = false;
16084
+ if (view === "day") {
16085
+ isCurrentTimeVisible = (0, import_date_fns20.isSameDay)(now, currentDate);
16086
+ } else if (view === "week") {
16087
+ const startOfWeekDate = (0, import_date_fns20.startOfWeek)(currentDate, { locale: import_locale10.ptBR });
16088
+ const endOfWeekDate = (0, import_date_fns20.endOfWeek)(currentDate, { locale: import_locale10.ptBR });
16089
+ isCurrentTimeVisible = (0, import_date_fns20.isWithinInterval)(now, {
16090
+ end: endOfWeekDate,
16091
+ start: startOfWeekDate
16092
+ });
16093
+ }
16094
+ setCurrentTimePosition(position);
16095
+ setCurrentTimeVisible(isCurrentTimeVisible);
16096
+ };
16097
+ calculateTimePosition();
16098
+ const interval = setInterval(calculateTimePosition, 6e4);
16099
+ return () => clearInterval(interval);
16100
+ }, [currentDate, view]);
16101
+ return { currentTimePosition, currentTimeVisible };
16102
+ }
16103
+
16104
+ // src/components/event-calendar-view/EventItemAgenda.tsx
16105
+ var import_date_fns21 = require("date-fns");
16106
+ var import_react78 = require("react");
16107
+ var import_react79 = require("@phosphor-icons/react");
16108
+ var import_jsx_runtime88 = require("react/jsx-runtime");
16109
+ var formatTimeWithOptionalMinutes2 = (date) => {
16110
+ return (0, import_date_fns21.format)(date, "HH:mm");
16111
+ };
16112
+ var isValidDate4 = (d) => {
16113
+ try {
16114
+ const dt = d instanceof Date ? d : new Date(String(d));
16115
+ return !isNaN(dt.getTime());
16116
+ } catch {
16117
+ return false;
16118
+ }
16119
+ };
16120
+ function EventWrapper2({
16121
+ event,
16122
+ isFirstDay = true,
16123
+ isLastDay = true,
16124
+ isDragging,
16125
+ onClick,
16126
+ className,
16127
+ children,
16128
+ currentTime,
16129
+ dndListeners,
16130
+ dndAttributes,
16131
+ onMouseDown,
16132
+ onTouchStart,
16133
+ ariaLabel
16134
+ }) {
16135
+ const hasValidTimeForWrapper = isValidDate4(event.start) && isValidDate4(event.end) || isValidDate4(event.attend_date);
16136
+ const displayEnd = (() => {
16137
+ if (isValidDate4(event.start) && isValidDate4(event.end)) {
16138
+ return currentTime ? new Date(
16139
+ new Date(currentTime).getTime() + (new Date(event.end).getTime() - new Date(event.start).getTime())
16140
+ ) : new Date(event.end);
16141
+ }
16142
+ if (isValidDate4(event.attend_date)) {
16143
+ const start = normalizeAttendDate(event.attend_date);
16144
+ return start ? addHoursToDateAgenda(start, 1) : void 0;
16145
+ }
16146
+ return void 0;
16147
+ })();
16148
+ const isEventInPast = displayEnd ? (0, import_date_fns21.isPast)(displayEnd) : false;
16149
+ const colorClasses = hasValidTimeForWrapper ? getEventColorClassesAgenda(event.color) : "bg-gray-200/50 hover:bg-gray-200/40 text-gray-900/80 dark:bg-gray-700/25 dark:text-gray-200/90 shadow-none";
16150
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16151
+ "button",
16152
+ {
16153
+ className: cn(
16154
+ "flex w-full select-none overflow-hidden px-3 py-1 text-left font-medium outline-none transition-transform duration-150 ease-out backdrop-blur-sm focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:border-ring data-dragging:cursor-grabbing data-past-event:line-through data-dragging:shadow-lg sm:px-3 rounded-lg shadow-sm hover:shadow-md ",
16155
+ colorClasses,
16156
+ getBorderRadiusClassesAgenda(isFirstDay, isLastDay),
16157
+ className
16158
+ ),
16159
+ "data-dragging": isDragging || void 0,
16160
+ "data-past-event": isEventInPast || void 0,
16161
+ onClick,
16162
+ onMouseDown,
16163
+ onTouchStart,
16164
+ "aria-label": ariaLabel,
16165
+ type: "button",
16166
+ ...dndListeners,
16167
+ ...dndAttributes,
16168
+ children
16169
+ }
16170
+ );
16171
+ }
16172
+ function EventItemAgenda({
16173
+ event,
16174
+ view,
16175
+ onClick,
16176
+ showTime,
16177
+ currentTime,
16178
+ isFirstDay = true,
16179
+ isLastDay = true,
16180
+ children,
16181
+ className,
16182
+ dndListeners,
16183
+ dndAttributes,
16184
+ onMouseDown,
16185
+ onTouchStart,
16186
+ agendaOnly = false
16187
+ }) {
16188
+ const eventColor = event.color;
16189
+ const hasValidTime = isValidDate4(event.start) && isValidDate4(event.end) || isValidDate4(event.attend_date);
16190
+ const colorClasses = hasValidTime ? getEventColorClassesAgenda(eventColor) : "bg-gray-200/50 hover:bg-gray-200/40 text-gray-900/80 dark:bg-gray-700/25 dark:text-gray-200/90 shadow-none";
16191
+ const displayStart = (0, import_react78.useMemo)(() => {
16192
+ if (!hasValidTime) return void 0;
16193
+ if (isValidDate4(event.start))
16194
+ return currentTime || new Date(event.start);
16195
+ if (isValidDate4(event.attend_date))
16196
+ return currentTime || normalizeAttendDate(event.attend_date);
16197
+ return void 0;
16198
+ }, [currentTime, event.start, event.attend_date, hasValidTime]);
16199
+ const displayEnd = (0, import_react78.useMemo)(() => {
16200
+ if (!hasValidTime) return void 0;
16201
+ if (isValidDate4(event.end)) {
16202
+ return currentTime ? new Date(
16203
+ new Date(currentTime).getTime() + (new Date(event.end).getTime() - new Date(event.start).getTime())
16204
+ ) : new Date(event.end);
16205
+ }
16206
+ if (isValidDate4(event.attend_date)) {
16207
+ const start = normalizeAttendDate(event.attend_date);
16208
+ return start ? addHoursToDateAgenda(start, 1) : void 0;
16209
+ }
16210
+ return void 0;
16211
+ }, [currentTime, event.start, event.end, event.attend_date, hasValidTime]);
16212
+ const durationMinutes = (0, import_react78.useMemo)(() => {
16213
+ if (!hasValidTime || !displayStart || !displayEnd) return 0;
16214
+ return (0, import_date_fns21.differenceInMinutes)(displayEnd, displayStart);
16215
+ }, [displayStart, displayEnd, hasValidTime]);
16216
+ const getEventTime = () => {
16217
+ if (!hasValidTime) return "";
16218
+ if (event.allDay) return "All day";
16219
+ if (durationMinutes < 45) {
16220
+ return formatTimeWithOptionalMinutes2(displayStart);
16221
+ }
16222
+ return `${formatTimeWithOptionalMinutes2(
16223
+ displayStart
16224
+ )} - ${formatTimeWithOptionalMinutes2(displayEnd)}`;
16225
+ };
16226
+ let ariaLabel;
16227
+ if (!hasValidTime) {
16228
+ ariaLabel = event.title;
16229
+ } else if (event.allDay) {
16230
+ ariaLabel = `${event.title}, All day`;
16231
+ } else if (durationMinutes < 45) {
16232
+ ariaLabel = `${event.title}, ${formatTimeWithOptionalMinutes2(
16233
+ displayStart
16234
+ )}`;
16235
+ } else {
16236
+ ariaLabel = `${event.title}, ${formatTimeWithOptionalMinutes2(
16237
+ displayStart
16238
+ )} - ${formatTimeWithOptionalMinutes2(displayEnd)}`;
16239
+ }
16240
+ if (view === "month") {
16241
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16242
+ EventWrapper2,
16243
+ {
16244
+ className: cn(
16245
+ "mt-[var(--event-gap)] h-[var(--event-height)] items-center text-[10px] sm:text-xs",
16246
+ className
16247
+ ),
16248
+ currentTime,
16249
+ dndAttributes,
16250
+ dndListeners,
16251
+ event,
16252
+ ariaLabel,
16253
+ isFirstDay,
16254
+ isLastDay,
16255
+ onClick,
16256
+ children: children || /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("span", { className: "flex items-center gap-2 truncate", children: [
16257
+ !event.allDay && hasValidTime && displayStart && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "truncate font-normal opacity-80 sm:text-[11px] bg-white/10 px-2 py-0.5 rounded-full text-[11px]", children: formatTimeWithOptionalMinutes2(displayStart) }),
16258
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16259
+ "span",
16260
+ {
16261
+ className: cn(
16262
+ "truncate",
16263
+ agendaOnly ? "font-bold text-lg" : "font-medium"
16264
+ ),
16265
+ children: event.title
16266
+ }
16267
+ )
16268
+ ] })
16269
+ }
16270
+ );
16271
+ }
16272
+ if (view === "week" || view === "day") {
16273
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16274
+ EventWrapper2,
16275
+ {
16276
+ className: cn(
16277
+ "py-1",
16278
+ durationMinutes < 45 ? "items-center" : "flex-col",
16279
+ view === "week" ? "text-[10px] sm:text-xs" : "text-xs",
16280
+ className
16281
+ ),
16282
+ currentTime,
16283
+ dndAttributes,
16284
+ dndListeners,
16285
+ event,
16286
+ ariaLabel,
16287
+ isFirstDay,
16288
+ isLastDay,
16289
+ children: durationMinutes < 45 ? /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: "flex items-center justify-between w-full", children: [
16290
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: cn("truncate text-lg"), children: event.title }),
16291
+ showTime && hasValidTime && displayStart && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "ml-2 inline-block bg-white/10 px-2 py-0.5 rounded-full text-[11px] opacity-90", children: formatTimeWithOptionalMinutes2(displayStart) })
16292
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
16293
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: cn("truncate font-medium text-lg"), children: event.title }),
16294
+ showTime && hasValidTime && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "truncate font-normal opacity-70 sm:text-[15px]", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "inline-block bg-white/5 px-0.5 py-0.5 rounded-full", children: getEventTime() }) })
16295
+ ] })
16296
+ }
16297
+ );
16298
+ }
16299
+ if (!hasValidTime) {
16300
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
16301
+ "button",
16302
+ {
16303
+ className: cn(
16304
+ "flex w-full flex-col gap-2 rounded-lg p-3 text-left outline-none transition-shadow duration-150 ease-out hover:bg-white/3 focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:border-ring",
16305
+ getEventColorClassesAgenda(eventColor),
16306
+ className
16307
+ ),
16308
+ "aria-label": ariaLabel,
16309
+ onClick,
16310
+ onMouseDown,
16311
+ onTouchStart,
16312
+ type: "button",
16313
+ ...dndListeners,
16314
+ ...dndAttributes,
16315
+ children: [
16316
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: cn("font-medium", agendaOnly ? "text-lg" : "text-sm"), children: event.title }),
16317
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16318
+ "div",
16319
+ {
16320
+ className: cn(
16321
+ "opacity-70 flex items-center gap-2",
16322
+ agendaOnly ? "text-sm" : "text-xs"
16323
+ ),
16324
+ children: event.location && /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("span", { className: "opacity-80 flex items-center gap-1", children: [
16325
+ "-",
16326
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "truncate", children: event.location })
16327
+ ] })
16328
+ }
16329
+ ),
16330
+ event.description && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16331
+ "div",
16332
+ {
16333
+ className: cn(
16334
+ "my-1 opacity-90",
16335
+ agendaOnly ? "text-md" : "text-xs"
16336
+ ),
16337
+ style: {
16338
+ display: "-webkit-box",
16339
+ WebkitLineClamp: 2,
16340
+ WebkitBoxOrient: "vertical",
16341
+ overflow: "hidden"
16342
+ },
16343
+ children: event.description
16344
+ }
16345
+ )
16346
+ ]
16347
+ }
16348
+ );
16349
+ }
16350
+ return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
16351
+ "button",
16352
+ {
16353
+ className: cn(
16354
+ "flex w-full flex-col gap-2 rounded-lg p-3 text-left outline-none transition-shadow duration-150 ease-out hover:bg-white/3 focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:border-ring data-past-event:line-through data-past-event:opacity-90 border-2 border-border",
16355
+ colorClasses,
16356
+ className
16357
+ ),
16358
+ "data-past-event": (0, import_date_fns21.isPast)(displayEnd) || void 0,
16359
+ "aria-label": ariaLabel,
16360
+ onClick,
16361
+ onMouseDown,
16362
+ onTouchStart,
16363
+ type: "button",
16364
+ ...dndListeners,
16365
+ ...dndAttributes,
16366
+ children: [
16367
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: "flex w-full justify-between ", children: [
16368
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: cn("font-bold text-lg"), children: event.title }),
16369
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: cn("opacity-90 flex items-center gap-2 text-lg"), children: event.allDay ? /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { children: "Dia todo" }) : /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("span", { className: "uppercase font-semibold flex items-center gap-2", children: [
16370
+ formatTimeWithOptionalMinutes2(displayStart),
16371
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("span", { className: "opacity-70", children: "-" }),
16372
+ formatTimeWithOptionalMinutes2(displayEnd),
16373
+ /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_react79.ClockUserIcon, {})
16374
+ ] }) })
16375
+ ] }),
16376
+ event.description && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16377
+ "div",
16378
+ {
16379
+ className: cn("my-1 opacity-90 flex text-md"),
16380
+ style: {
16381
+ display: "-webkit-box",
16382
+ WebkitLineClamp: 2,
16383
+ WebkitBoxOrient: "vertical",
16384
+ overflow: "hidden"
16385
+ },
16386
+ children: event.description
16387
+ }
16388
+ )
16389
+ ]
16390
+ }
16391
+ );
16392
+ }
16393
+
16394
+ // src/components/event-calendar-view/DroppableCell.tsx
16395
+ var import_core5 = require("@dnd-kit/core");
16396
+ var import_jsx_runtime89 = require("react/jsx-runtime");
16397
+ function DroppableCellAgenda({
16398
+ id,
16399
+ date,
16400
+ time,
16401
+ children,
16402
+ className,
16403
+ onClick
16404
+ }) {
16405
+ const { activeEvent } = useCalendarDndAgenda();
16406
+ const { setNodeRef, isOver } = (0, import_core5.useDroppable)({
16407
+ data: {
16408
+ date,
16409
+ time
16410
+ },
16411
+ id
16412
+ });
16413
+ const formattedTime = time !== void 0 ? `${Math.floor(time)}:${Math.round((time - Math.floor(time)) * 60).toString().padStart(2, "0")}` : null;
16414
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16415
+ "div",
16416
+ {
16417
+ className: cn(
16418
+ "flex h-full flex-col overflow-hidden px-0.5 py-1 data-dragging:bg-accent sm:px-1",
16419
+ className
16420
+ ),
16421
+ "data-dragging": isOver && activeEvent ? true : void 0,
16422
+ onClick,
16423
+ ref: setNodeRef,
16424
+ title: formattedTime ? `${formattedTime}` : void 0,
16425
+ children
16426
+ }
16427
+ );
16428
+ }
16429
+
16430
+ // src/components/event-calendar-view/DayView.tsx
16431
+ var import_jsx_runtime90 = require("react/jsx-runtime");
16432
+ function DayViewAgenda({
16433
+ currentDate,
16434
+ events,
16435
+ onEventSelect,
16436
+ showUndatedEvents
16437
+ }) {
16438
+ const hours = (0, import_react80.useMemo)(() => {
16439
+ const dayStart = (0, import_date_fns22.startOfDay)(currentDate);
16440
+ return (0, import_date_fns22.eachHourOfInterval)({
16441
+ end: (0, import_date_fns22.addHours)(dayStart, EndHourAgenda - 1),
16442
+ start: (0, import_date_fns22.addHours)(dayStart, StartHourAgenda)
16443
+ });
16444
+ }, [currentDate]);
16445
+ const dayEvents = (0, import_react80.useMemo)(() => {
16446
+ const dayStart = (0, import_date_fns22.startOfDay)(currentDate);
16447
+ const dayEnd = (0, import_date_fns22.endOfDay)(currentDate);
16448
+ return events.map((event) => {
16449
+ let eventStart = event.start != null ? new Date(event.start) : void 0;
16450
+ let eventEnd = event.end != null ? new Date(event.end) : void 0;
16451
+ if ((!eventStart || !eventEnd) && event.attend_date) {
16452
+ try {
16453
+ const ad = new Date(event.attend_date);
16454
+ const hasTime = ad.getHours() !== 0 || ad.getMinutes() !== 0 || ad.getSeconds() !== 0 || ad.getMilliseconds() !== 0;
16455
+ if (hasTime) {
16456
+ if (!eventStart) eventStart = ad;
16457
+ if (!eventEnd) eventEnd = (0, import_date_fns22.addHours)(ad, 1);
16458
+ }
16459
+ } catch {
16460
+ }
16461
+ }
16462
+ return { event, eventStart, eventEnd };
16463
+ }).filter(({ eventStart, eventEnd }) => !!eventStart && !!eventEnd).filter(
16464
+ ({ eventStart, eventEnd }) => (0, import_date_fns22.areIntervalsOverlapping)(
16465
+ { start: eventStart, end: eventEnd },
16466
+ { start: dayStart, end: dayEnd }
16467
+ )
16468
+ ).map(({ event }) => event).sort((a, b) => {
16469
+ const aStart = a.start ? new Date(a.start).getTime() : a.attend_date ? new Date(a.attend_date).getTime() : 0;
16470
+ const bStart = b.start ? new Date(b.start).getTime() : b.attend_date ? new Date(b.attend_date).getTime() : 0;
16471
+ return aStart - bStart;
16472
+ });
16473
+ }, [currentDate, events]);
16474
+ const allDayEvents = (0, import_react80.useMemo)(() => {
16475
+ return dayEvents.filter((event) => {
16476
+ return event.allDay || isMultiDayEventAgenda(event);
16477
+ });
16478
+ }, [dayEvents]);
16479
+ const timeEvents = (0, import_react80.useMemo)(() => {
16480
+ return dayEvents.filter((event) => {
16481
+ return !event.allDay && !isMultiDayEventAgenda(event);
16482
+ });
16483
+ }, [dayEvents]);
16484
+ const positionedEvents = (0, import_react80.useMemo)(() => {
16485
+ const result = [];
16486
+ const dayStart = (0, import_date_fns22.startOfDay)(currentDate);
16487
+ const sortedEvents = [...timeEvents].sort((a, b) => {
16488
+ const aStart = new Date(a.start);
16489
+ const bStart = new Date(b.start);
16490
+ const aEnd = new Date(a.end);
16491
+ const bEnd = new Date(b.end);
16492
+ if (aStart < bStart) return -1;
16493
+ if (aStart > bStart) return 1;
16494
+ const aDuration = (0, import_date_fns22.differenceInMinutes)(aEnd, aStart);
16495
+ const bDuration = (0, import_date_fns22.differenceInMinutes)(bEnd, bStart);
16496
+ return bDuration - aDuration;
16497
+ });
16498
+ const columns = [];
16499
+ for (const event of sortedEvents) {
16500
+ let eventStart = event.start != null ? new Date(event.start) : void 0;
16501
+ let eventEnd = event.end != null ? new Date(event.end) : void 0;
16502
+ if ((!eventStart || !eventEnd) && event.attend_date) {
16503
+ try {
16504
+ const ad = new Date(event.attend_date);
16505
+ const hasTime = ad.getHours() !== 0 || ad.getMinutes() !== 0 || ad.getSeconds() !== 0 || ad.getMilliseconds() !== 0;
16506
+ if (hasTime) {
16507
+ if (!eventStart) eventStart = ad;
16508
+ if (!eventEnd) eventEnd = (0, import_date_fns22.addHours)(ad, 1);
16509
+ }
16510
+ } catch {
16511
+ }
16512
+ }
16513
+ if (!eventStart || !eventEnd) continue;
16514
+ const adjustedStart = (0, import_date_fns22.isSameDay)(currentDate, eventStart) ? eventStart : dayStart;
16515
+ const adjustedEnd = (0, import_date_fns22.isSameDay)(currentDate, eventEnd) ? eventEnd : (0, import_date_fns22.addHours)(dayStart, 24);
16516
+ const startHour = (0, import_date_fns22.getHours)(adjustedStart) + (0, import_date_fns22.getMinutes)(adjustedStart) / 60;
16517
+ const endHour = (0, import_date_fns22.getHours)(adjustedEnd) + (0, import_date_fns22.getMinutes)(adjustedEnd) / 60;
16518
+ const top = (startHour - StartHourAgenda) * WeekCellsHeightAgenda;
16519
+ const height = (endHour - startHour) * WeekCellsHeightAgenda;
16520
+ let columnIndex = 0;
16521
+ let placed = false;
16522
+ while (!placed) {
16523
+ const col = columns[columnIndex] || [];
16524
+ if (col.length === 0) {
16525
+ columns[columnIndex] = col;
16526
+ placed = true;
16527
+ } else {
16528
+ const overlaps = col.some(
16529
+ (c) => (0, import_date_fns22.areIntervalsOverlapping)(
16530
+ { end: adjustedEnd, start: adjustedStart },
16531
+ { end: c.end, start: c.start }
16532
+ )
16533
+ );
16534
+ if (!overlaps) {
16535
+ placed = true;
16536
+ } else {
16537
+ columnIndex++;
16538
+ }
16539
+ }
16540
+ }
16541
+ const currentColumn = columns[columnIndex] || [];
16542
+ columns[columnIndex] = currentColumn;
16543
+ currentColumn.push({ start: adjustedStart, end: adjustedEnd, event });
16544
+ const width = columnIndex === 0 ? 1 : 0.9;
16545
+ const left = columnIndex === 0 ? 0 : columnIndex * 0.1;
16546
+ result.push({
16547
+ event,
16548
+ height,
16549
+ left,
16550
+ top,
16551
+ width,
16552
+ zIndex: 10 + columnIndex
16553
+ });
16554
+ }
16555
+ return result;
16556
+ }, [currentDate, timeEvents]);
16557
+ const handleEventClick = (event, e) => {
16558
+ e.stopPropagation();
16559
+ onEventSelect(event);
16560
+ };
16561
+ const showAllDaySection = allDayEvents.length > 0;
16562
+ const { currentTimePosition, currentTimeVisible } = useCurrentTimeIndicatorAgenda(
16563
+ currentDate,
16564
+ "day"
16565
+ );
16566
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "contents", "data-slot": "day-view", children: [
16567
+ showAllDaySection && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "border-border/70 border-t bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "grid grid-cols-[3rem_1fr] sm:grid-cols-[4rem_1fr]", children: [
16568
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "absolute bottom-0 left-0 h-6 w-16 max-w-full pe-2 text-right text-[10px] text-muted-foreground/70 sm:pe-4 sm:text-xs", children: "All day" }) }),
16569
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "relative border-border/70 border-r p-1 last:border-r-0", children: allDayEvents.map((event) => {
16570
+ const eventStart = new Date(
16571
+ event.start ?? event.attend_date ?? event.end ?? Date.now()
16572
+ );
16573
+ const eventEnd = new Date(
16574
+ event.end ?? event.attend_date ?? event.start ?? Date.now()
16575
+ );
16576
+ const isFirstDay = (0, import_date_fns22.isSameDay)(currentDate, eventStart);
16577
+ const isLastDay = (0, import_date_fns22.isSameDay)(currentDate, eventEnd);
16578
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16579
+ EventItemAgenda,
16580
+ {
16581
+ event,
16582
+ isFirstDay,
16583
+ isLastDay,
16584
+ onClick: (e) => handleEventClick(event, e),
16585
+ view: "month",
16586
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { children: event.title })
16587
+ },
16588
+ `spanning-${event.id}`
16589
+ );
16590
+ }) })
16591
+ ] }) }),
16592
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "grid flex-1 grid-cols-[3rem_1fr] overflow-hidden border-border/70 border-t sm:grid-cols-[4rem_1fr]", children: [
16593
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { children: hours.map((hour, index) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16594
+ "div",
16595
+ {
16596
+ className: "relative h-[var(--week-cells-height)] border-border/70 border-b last:border-b-0",
16597
+ children: index > 0 && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "-top-3 absolute left-0 flex h-6 w-16 max-w-full items-center justify-end bg-background pe-2 text-[10px] text-muted-foreground/70 sm:pe-4 sm:text-xs", children: (0, import_date_fns22.format)(hour, "HH:mm") })
16598
+ },
16599
+ hour.toString()
16600
+ )) }),
16601
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "relative", children: [
16602
+ positionedEvents.map((positionedEvent) => {
16603
+ const evt = positionedEvent.event;
16604
+ const eventStart = new Date(
16605
+ evt.start ?? evt.attend_date ?? evt.end ?? Date.now()
16606
+ );
16607
+ const eventEnd = new Date(
16608
+ evt.end ?? evt.attend_date ?? evt.start ?? Date.now()
16609
+ );
16610
+ const isFirstDay = (0, import_date_fns22.isSameDay)(currentDate, eventStart);
16611
+ const isLastDay = (0, import_date_fns22.isSameDay)(currentDate, eventEnd);
16612
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16613
+ "div",
16614
+ {
16615
+ className: "absolute z-10 px-0.5",
16616
+ style: {
16617
+ height: `${positionedEvent.height}px`,
16618
+ left: `${positionedEvent.left * 100}%`,
16619
+ top: `${positionedEvent.top}px`,
16620
+ width: `${positionedEvent.width * 100}%`,
16621
+ zIndex: positionedEvent.zIndex
16622
+ },
16623
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16624
+ EventItemAgenda,
16625
+ {
16626
+ event: evt,
16627
+ view: "day",
16628
+ isFirstDay,
16629
+ isLastDay,
16630
+ onClick: (e) => handleEventClick(evt, e),
16631
+ showTime: true
16632
+ }
16633
+ )
16634
+ },
16635
+ positionedEvent.event.id
16636
+ );
16637
+ }),
16638
+ currentTimeVisible && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16639
+ "div",
16640
+ {
16641
+ className: "pointer-events-none absolute right-0 left-0 z-20",
16642
+ style: { top: `${currentTimePosition}%` },
16643
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "relative flex items-center", children: [
16644
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "-left-1 absolute h-2 w-2 rounded-full bg-primary" }),
16645
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "h-[2px] w-full bg-primary" })
16646
+ ] })
16647
+ }
16648
+ ),
16649
+ hours.map((hour) => {
16650
+ const hourValue = (0, import_date_fns22.getHours)(hour);
16651
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16652
+ "div",
16653
+ {
16654
+ className: "relative h-[var(--week-cells-height)] border-border/70 border-b last:border-b-0",
16655
+ children: [0, 1, 2, 3].map((quarter) => {
16656
+ const quarterHourTime = hourValue + quarter * 0.25;
16657
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16658
+ DroppableCellAgenda,
16659
+ {
16660
+ className: cn(
16661
+ "absolute h-[calc(var(--week-cells-height)/4)] w-full",
16662
+ quarter === 0 && "top-0",
16663
+ quarter === 1 && "top-[calc(var(--week-cells-height)/4)]",
16664
+ quarter === 2 && "top-[calc(var(--week-cells-height)/4*2)]",
16665
+ quarter === 3 && "top-[calc(var(--week-cells-height)/4*3)]"
16666
+ ),
16667
+ date: currentDate,
16668
+ id: `day-cell-${currentDate.toISOString()}-${quarterHourTime}`,
16669
+ onClick: () => {
16670
+ const startTime = new Date(currentDate);
16671
+ startTime.setHours(hourValue);
16672
+ startTime.setMinutes(quarter * 15);
16673
+ },
16674
+ time: quarterHourTime
16675
+ },
16676
+ `${hour.toString()}-${quarter}`
16677
+ );
16678
+ })
16679
+ },
16680
+ hour.toString()
16681
+ );
16682
+ })
16683
+ ] })
16684
+ ] }),
16685
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16686
+ UndatedEvents,
16687
+ {
16688
+ events,
16689
+ onEventSelect,
16690
+ show: showUndatedEvents
16691
+ }
16692
+ )
16693
+ ] });
16694
+ }
16695
+
16696
+ // src/components/event-calendar-view/EventAgenda.tsx
16697
+ var import_date_fns23 = require("date-fns");
16698
+ var import_locale11 = require("date-fns/locale");
16699
+ var import_react81 = require("react");
16700
+ var import_sonner4 = require("sonner");
16701
+ var import_react82 = require("@phosphor-icons/react");
16702
+ var import_jsx_runtime91 = require("react/jsx-runtime");
16703
+ function EventAgenda({
16704
+ events = [],
16705
+ onEventUpdate,
16706
+ className,
16707
+ initialView = "month",
16708
+ mode,
16709
+ initialDate
16710
+ }) {
16711
+ const [currentDate, setCurrentDate] = (0, import_react81.useState)(
16712
+ initialDate && new Date(initialDate) || /* @__PURE__ */ new Date()
16713
+ );
16714
+ const [view, setView] = (0, import_react81.useState)(initialView);
16715
+ const [isFading, setIsFading] = (0, import_react81.useState)(false);
16716
+ const FADE_DURATION = 220;
16717
+ const changeView = (0, import_react81.useCallback)(
16718
+ (next) => {
16719
+ if (mode === "agenda-only") return;
16720
+ if (next === view) return;
16721
+ setIsFading(true);
16722
+ window.setTimeout(() => {
16723
+ setView(next);
16724
+ requestAnimationFrame(() => setIsFading(false));
16725
+ }, FADE_DURATION);
16726
+ },
16727
+ [view, mode]
16728
+ );
16729
+ const [isPaging, setIsPaging] = (0, import_react81.useState)(false);
16730
+ const [pageDirection, setPageDirection] = (0, import_react81.useState)(
16731
+ null
16732
+ );
16733
+ const PAGE_DURATION = 200;
16734
+ const pageTransition = (0, import_react81.useCallback)(
16735
+ (applyDateChange, direction) => {
16736
+ setIsPaging(true);
16737
+ setPageDirection(direction);
16738
+ window.setTimeout(() => {
16739
+ applyDateChange();
16740
+ requestAnimationFrame(() => {
16741
+ setIsPaging(false);
16742
+ setPageDirection(null);
16743
+ });
16744
+ }, PAGE_DURATION);
16745
+ },
16746
+ []
16747
+ );
16748
+ const [isEventDialogOpen, setIsEventDialogOpen] = (0, import_react81.useState)(false);
16749
+ (0, import_react81.useEffect)(() => {
16750
+ const handleKeyDown = (e) => {
16751
+ if (isEventDialogOpen || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLElement && e.target.isContentEditable) {
16752
+ return;
16753
+ }
16754
+ if (mode === "agenda-only") return;
16755
+ switch (e.key.toLowerCase()) {
16756
+ case "m":
16757
+ changeView("month");
16758
+ break;
16759
+ case "w":
16760
+ case "s":
16761
+ changeView("week");
16762
+ break;
16763
+ case "d":
16764
+ changeView("day");
16765
+ break;
16766
+ case "a":
16767
+ changeView("agenda");
16768
+ break;
16769
+ }
16770
+ };
16771
+ window.addEventListener("keydown", handleKeyDown);
16772
+ return () => {
16773
+ window.removeEventListener("keydown", handleKeyDown);
16774
+ };
16775
+ }, [isEventDialogOpen, changeView, mode]);
16776
+ (0, import_react81.useEffect)(() => {
16777
+ if (mode === "agenda-only") setView("agenda");
16778
+ }, [mode]);
16779
+ const handlePrevious = () => {
16780
+ pageTransition(() => {
16781
+ if (view === "month") {
16782
+ setCurrentDate((0, import_date_fns23.subMonths)(currentDate, 1));
16783
+ } else if (view === "week") {
16784
+ setCurrentDate((0, import_date_fns23.subWeeks)(currentDate, 1));
16785
+ } else if (view === "day") {
16786
+ setCurrentDate((0, import_date_fns23.addDays)(currentDate, -1));
16787
+ } else if (view === "agenda") {
16788
+ setCurrentDate((0, import_date_fns23.addDays)(currentDate, -AgendaDaysToShowAgenda));
16789
+ }
16790
+ }, "right");
16791
+ };
16792
+ const handleNext = () => {
16793
+ pageTransition(() => {
16794
+ if (view === "month") {
16795
+ setCurrentDate((0, import_date_fns23.addMonths)(currentDate, 1));
16796
+ } else if (view === "week") {
16797
+ setCurrentDate((0, import_date_fns23.addWeeks)(currentDate, 1));
16798
+ } else if (view === "day") {
16799
+ setCurrentDate((0, import_date_fns23.addDays)(currentDate, 1));
16800
+ } else if (view === "agenda") {
16801
+ setCurrentDate((0, import_date_fns23.addDays)(currentDate, AgendaDaysToShowAgenda));
16802
+ }
16803
+ }, "left");
16804
+ };
16805
+ const handleToday = () => {
16806
+ setCurrentDate(/* @__PURE__ */ new Date());
16807
+ };
16808
+ const handleEventSelect = (event) => {
16809
+ console.log("Event selected:", event);
16810
+ setIsEventDialogOpen(true);
16811
+ };
16812
+ const handleEventUpdate = (updatedEvent) => {
16813
+ onEventUpdate?.(updatedEvent);
16814
+ const startDate = updatedEvent.start ?? /* @__PURE__ */ new Date();
16815
+ (0, import_sonner4.toast)(`Evento "${updatedEvent.title}" movido`, {
16816
+ description: (0, import_date_fns23.format)(startDate, "d 'de' MMMM 'de' yyyy", { locale: import_locale11.ptBR }),
16817
+ position: "bottom-left"
16818
+ });
16819
+ };
16820
+ const viewTitle = (0, import_react81.useMemo)(() => {
16821
+ const capitalize = (s) => s && s.length > 0 ? s.charAt(0).toUpperCase() + s.slice(1) : s;
16822
+ if (view === "month") {
16823
+ return capitalize((0, import_date_fns23.format)(currentDate, "MMMM yyyy", { locale: import_locale11.ptBR }));
16824
+ }
16825
+ if (view === "week") {
16826
+ const start = (0, import_date_fns23.startOfWeek)(currentDate, { weekStartsOn: 1 });
16827
+ const end = (0, import_date_fns23.endOfWeek)(currentDate, { weekStartsOn: 1 });
16828
+ if ((0, import_date_fns23.isSameMonth)(start, end)) {
16829
+ return capitalize((0, import_date_fns23.format)(start, "MMMM yyyy", { locale: import_locale11.ptBR }));
16830
+ }
16831
+ const s1 = capitalize((0, import_date_fns23.format)(start, "MMM", { locale: import_locale11.ptBR }));
16832
+ const s2 = capitalize((0, import_date_fns23.format)(end, "MMM yyyy", { locale: import_locale11.ptBR }));
16833
+ return `${s1} - ${s2}`;
16834
+ }
16835
+ if (view === "day") {
16836
+ const dayNum = (0, import_date_fns23.format)(currentDate, "d", { locale: import_locale11.ptBR });
16837
+ const month = capitalize((0, import_date_fns23.format)(currentDate, "MMMM", { locale: import_locale11.ptBR }));
16838
+ const year = (0, import_date_fns23.format)(currentDate, "yyyy", { locale: import_locale11.ptBR });
16839
+ const short = `${dayNum} de ${month} de ${year}`;
16840
+ return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
16841
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { "aria-hidden": "true", className: "min-[480px]:hidden", children: short }),
16842
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { "aria-hidden": "true", className: "max-[479px]:hidden min-md:hidden", children: short })
16843
+ ] });
16844
+ }
16845
+ if (view === "agenda") {
16846
+ const start = currentDate;
16847
+ const end = (0, import_date_fns23.addDays)(currentDate, AgendaDaysToShowAgenda - 1);
16848
+ if ((0, import_date_fns23.isSameMonth)(start, end)) {
16849
+ return capitalize((0, import_date_fns23.format)(start, "MMMM yyyy", { locale: import_locale11.ptBR }));
16850
+ }
16851
+ const s1 = capitalize((0, import_date_fns23.format)(start, "MMMM", { locale: import_locale11.ptBR }));
16852
+ const s2 = capitalize((0, import_date_fns23.format)(end, "MMMM yyyy", { locale: import_locale11.ptBR }));
16853
+ return `${s1} - ${s2}`;
16854
+ }
16855
+ return capitalize((0, import_date_fns23.format)(currentDate, "MMMM yyyy", { locale: import_locale11.ptBR }));
16856
+ }, [currentDate, view]);
16857
+ const calendarContent = /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
16858
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16859
+ "div",
16860
+ {
16861
+ className: cn(
16862
+ "flex items-center justify-between p-2 sm:p-4",
16863
+ className
16864
+ ),
16865
+ children: [
16866
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex items-center gap-1 sm:gap-4", children: [
16867
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16868
+ ButtonBase,
16869
+ {
16870
+ className: "max-[479px]:aspect-square max-[479px]:p-0!",
16871
+ onClick: handleToday,
16872
+ variant: "outline",
16873
+ children: [
16874
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16875
+ import_react82.CalendarIcon,
16876
+ {
16877
+ "aria-hidden": "true",
16878
+ className: "min-[480px]:hidden",
16879
+ size: 16
16880
+ }
16881
+ ),
16882
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "max-[479px]:sr-only", children: "Hoje" })
16883
+ ]
16884
+ }
16885
+ ),
16886
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex items-center sm:gap-2", children: [
16887
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16888
+ ButtonBase,
16889
+ {
16890
+ "aria-label": "Anterior",
16891
+ onClick: handlePrevious,
16892
+ size: "icon",
16893
+ variant: "ghost",
16894
+ children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.CaretLeftIcon, { "aria-hidden": "true", size: 16 })
16895
+ }
16896
+ ),
16897
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16898
+ ButtonBase,
16899
+ {
16900
+ "aria-label": "Pr\xF3ximo",
16901
+ onClick: handleNext,
16902
+ size: "icon",
16903
+ variant: "ghost",
16904
+ children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.CaretRightIcon, { "aria-hidden": "true", size: 16 })
16905
+ }
16906
+ )
16907
+ ] }),
16908
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("h2", { className: "font-semibold text-xl", children: viewTitle })
16909
+ ] }),
16910
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_jsx_runtime91.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(DropDownMenuBase, { children: [
16911
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DropDownMenuTriggerBase, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16912
+ ButtonBase,
16913
+ {
16914
+ className: "gap-2 px-3 py-1.5 max-[479px]:h-8",
16915
+ variant: "outline",
16916
+ children: [
16917
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("span", { className: "flex items-center gap-2", children: [
16918
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "hidden min-[480px]:inline-block", children: (() => {
16919
+ const labels = {
16920
+ month: "M\xEAs",
16921
+ week: "Semana",
16922
+ day: "Dia",
16923
+ agenda: "Agenda"
16924
+ };
16925
+ return labels[view] || view;
16926
+ })() }),
16927
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "min-[480px]:hidden", children: (() => {
16928
+ const labels = {
16929
+ month: "M",
16930
+ week: "S",
16931
+ day: "D",
16932
+ agenda: "A"
16933
+ };
16934
+ return labels[view] || view;
16935
+ })() })
16936
+ ] }),
16937
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16938
+ import_react82.CaretDownIcon,
16939
+ {
16940
+ "aria-hidden": "true",
16941
+ className: "-me-1 opacity-60",
16942
+ size: 16
16943
+ }
16944
+ )
16945
+ ]
16946
+ }
16947
+ ) }),
16948
+ mode === "agenda-only" ? null : /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16949
+ DropDownMenuContentBase,
16950
+ {
16951
+ align: "end",
16952
+ className: "min-w-32 rounded-md p-1",
16953
+ children: [
16954
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16955
+ DropDownMenuItemBase,
16956
+ {
16957
+ onClick: () => changeView("month"),
16958
+ className: cn(
16959
+ "flex items-center justify-between gap-2 px-3 py-2 rounded",
16960
+ view === "month"
16961
+ ),
16962
+ children: [
16963
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { children: " M\xEAs " }) }),
16964
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: view === "month" ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.Check, { "aria-hidden": true, className: "opacity-80", size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DropDownMenuShortcutBase, { children: "M" }) })
16965
+ ]
16966
+ }
16967
+ ),
16968
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16969
+ DropDownMenuItemBase,
16970
+ {
16971
+ onClick: () => changeView("week"),
16972
+ className: cn(
16973
+ "flex items-center justify-between gap-2 px-3 py-2 rounded",
16974
+ view === "week"
16975
+ ),
16976
+ children: [
16977
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: "Semana" }),
16978
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: view === "week" ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.Check, { "aria-hidden": true, className: "opacity-80", size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DropDownMenuShortcutBase, { children: "S" }) })
16979
+ ]
16980
+ }
16981
+ ),
16982
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16983
+ DropDownMenuItemBase,
16984
+ {
16985
+ onClick: () => changeView("day"),
16986
+ className: cn(
16987
+ "flex items-center justify-between gap-2 px-3 py-2 rounded",
16988
+ view === "day"
16989
+ ),
16990
+ children: [
16991
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: "Dia" }),
16992
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: view === "day" ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.Check, { "aria-hidden": true, className: "opacity-80", size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DropDownMenuShortcutBase, { children: "D" }) })
16993
+ ]
16994
+ }
16995
+ ),
16996
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16997
+ DropDownMenuItemBase,
16998
+ {
16999
+ onClick: () => changeView("agenda"),
17000
+ className: cn(
17001
+ "flex items-center justify-between gap-2 px-3 py-2 rounded",
17002
+ view === "agenda"
17003
+ ),
17004
+ children: [
17005
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: "Agenda" }),
17006
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "flex items-center gap-2", children: view === "agenda" ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_react82.Check, { "aria-hidden": true, className: "opacity-80", size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DropDownMenuShortcutBase, { children: "A" }) })
17007
+ ]
17008
+ }
17009
+ )
17010
+ ]
17011
+ }
17012
+ )
17013
+ ] }) }) })
17014
+ ]
17015
+ }
17016
+ ),
17017
+ /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
17018
+ "div",
17019
+ {
17020
+ className: cn(
17021
+ "flex flex-1 flex-col transition-all duration-200 ease-in-out",
17022
+ isFading ? "opacity-0 -translate-y-2 pointer-events-none" : isPaging ? pageDirection === "left" ? "-translate-x-4 opacity-0 pointer-events-none" : "translate-x-4 opacity-0 pointer-events-none" : "opacity-100 translate-y-0"
17023
+ ),
17024
+ "aria-live": "polite",
17025
+ children: [
17026
+ view === "month" && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17027
+ MonthViewAgenda,
17028
+ {
17029
+ currentDate,
17030
+ events,
17031
+ onEventSelect: handleEventSelect
17032
+ }
17033
+ ),
17034
+ view === "week" && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17035
+ WeekViewAgenda,
17036
+ {
17037
+ currentDate,
17038
+ events,
17039
+ onEventSelect: handleEventSelect
17040
+ }
17041
+ ),
17042
+ view === "day" && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17043
+ DayViewAgenda,
17044
+ {
17045
+ currentDate,
17046
+ events,
17047
+ onEventSelect: handleEventSelect
17048
+ }
17049
+ ),
17050
+ view === "agenda" && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17051
+ Agenda,
17052
+ {
17053
+ currentDate,
17054
+ events,
17055
+ onEventSelect: handleEventSelect
17056
+ }
17057
+ )
17058
+ ]
17059
+ }
17060
+ )
17061
+ ] });
17062
+ return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17063
+ "div",
17064
+ {
17065
+ className: "flex flex-col rounded-lg border has-data-[slot=month-view]:flex-1 px-6",
17066
+ style: {
17067
+ "--event-gap": `${EventGapAgenda}px`,
17068
+ "--event-height": `${EventHeightAgenda}px`,
17069
+ "--week-cells-height": `${WeekCellsHeightAgenda}px`
17070
+ },
17071
+ children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(CalendarDndProviderAgenda, { onEventUpdate: handleEventUpdate, children: calendarContent })
17072
+ }
17073
+ );
17074
+ }
17075
+
17076
+ // src/components/event-calendar-view/UndatedEvents.tsx
17077
+ var import_react83 = require("react");
17078
+ var import_jsx_runtime92 = require("react/jsx-runtime");
17079
+ var isValidDate5 = (d) => {
17080
+ try {
17081
+ const t = d instanceof Date ? d.getTime() : new Date(String(d)).getTime();
17082
+ return !isNaN(t);
17083
+ } catch {
17084
+ return false;
17085
+ }
17086
+ };
17087
+ function UndatedEvents({
17088
+ events,
17089
+ onEventSelect,
17090
+ className,
17091
+ title = "Data de Atendimento n\xE3o Prevista",
17092
+ show = true
17093
+ }) {
17094
+ const undatedEvents = (0, import_react83.useMemo)(
17095
+ () => events.filter(
17096
+ (e) => !(isValidDate5(e.start) && isValidDate5(e.end)) && !isValidDate5(e.attend_date)
17097
+ ),
17098
+ [events]
17099
+ );
17100
+ if (!show || undatedEvents.length === 0) return null;
17101
+ return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "relative border-border/70 border-t", children: [
17102
+ /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "-top-3 absolute left-0 flex h-6 items-center bg-background pe-4 uppercase sm:pe-4 text-lg", children: title }),
17103
+ /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "mt-6 space-y-2", children: undatedEvents.map((event) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17104
+ EventItemAgenda,
17105
+ {
17106
+ event,
17107
+ onClick: onEventSelect ? () => onEventSelect(event) : void 0,
17108
+ view: "agenda",
17109
+ agendaOnly: true,
17110
+ className: "cursor-default hover:shadow-none hover:scale-100 bg-gray-200/50 hover:bg-gray-200/40 text-gray-900/80 dark:bg-gray-700/25 dark:text-gray-200/90 shadow-none "
17111
+ },
17112
+ event.id
17113
+ )) })
17114
+ ] }) });
17115
+ }
17116
+
17117
+ // src/components/event-calendar-view/hooks/use-event-visibility.ts
17118
+ var import_react84 = require("react");
17119
+ function useEventVisibilityAgenda({
17120
+ eventHeight,
17121
+ eventGap
17122
+ }) {
17123
+ const contentRef = (0, import_react84.useRef)(null);
17124
+ const observerRef = (0, import_react84.useRef)(null);
17125
+ const [contentHeight, setContentHeight] = (0, import_react84.useState)(null);
17126
+ (0, import_react84.useLayoutEffect)(() => {
17127
+ if (!contentRef.current) return;
17128
+ const updateHeight = () => {
17129
+ if (contentRef.current) {
17130
+ setContentHeight(contentRef.current.clientHeight);
17131
+ }
17132
+ };
17133
+ updateHeight();
17134
+ if (!observerRef.current) {
17135
+ observerRef.current = new ResizeObserver(() => {
17136
+ updateHeight();
17137
+ });
17138
+ }
17139
+ observerRef.current.observe(contentRef.current);
17140
+ return () => {
17141
+ if (observerRef.current) {
17142
+ observerRef.current.disconnect();
17143
+ }
17144
+ };
17145
+ }, []);
17146
+ const getVisibleEventCount = (0, import_react84.useMemo)(() => {
17147
+ return (totalEvents) => {
17148
+ if (!contentHeight) return totalEvents;
17149
+ const maxEvents = Math.floor(contentHeight / (eventHeight + eventGap));
17150
+ if (totalEvents <= maxEvents) {
17151
+ return totalEvents;
17152
+ }
17153
+ return maxEvents > 0 ? maxEvents - 1 : 0;
17154
+ };
17155
+ }, [contentHeight, eventHeight, eventGap]);
17156
+ return {
17157
+ contentHeight,
17158
+ contentRef,
17159
+ getVisibleEventCount
17160
+ };
17161
+ }
17162
+
17163
+ // src/components/event-calendar-view/MonthView.tsx
17164
+ var import_date_fns24 = require("date-fns");
17165
+ var import_locale12 = require("date-fns/locale");
17166
+ var import_react85 = require("react");
17167
+ var import_tailwind_merge3 = require("tailwind-merge");
17168
+ var import_jsx_runtime93 = require("react/jsx-runtime");
17169
+ function MonthViewAgenda({
17170
+ currentDate,
17171
+ events,
17172
+ onEventSelect,
17173
+ showUndatedEvents
17174
+ }) {
17175
+ const days = (0, import_react85.useMemo)(() => {
17176
+ const monthStart = (0, import_date_fns24.startOfMonth)(currentDate);
17177
+ const monthEnd = (0, import_date_fns24.endOfMonth)(monthStart);
17178
+ const calendarStart = (0, import_date_fns24.startOfWeek)(monthStart, { weekStartsOn: 0 });
17179
+ const calendarEnd = (0, import_date_fns24.endOfWeek)(monthEnd, { weekStartsOn: 0 });
17180
+ return (0, import_date_fns24.eachDayOfInterval)({ end: calendarEnd, start: calendarStart });
17181
+ }, [currentDate]);
17182
+ const weekdays = (0, import_react85.useMemo)(() => {
17183
+ return Array.from({ length: 7 }).map((_, i) => {
17184
+ const date = (0, import_date_fns24.addDays)((0, import_date_fns24.startOfWeek)(/* @__PURE__ */ new Date(), { weekStartsOn: 0 }), i);
17185
+ const short = (0, import_date_fns24.format)(date, "EEE", { locale: import_locale12.ptBR });
17186
+ return short.charAt(0).toUpperCase() + short.slice(1);
17187
+ });
17188
+ }, []);
17189
+ const weeks = (0, import_react85.useMemo)(() => {
17190
+ const result = [];
17191
+ let week = [];
17192
+ for (let i = 0; i < days.length; i++) {
17193
+ week.push(days[i]);
17194
+ if (week.length === 7 || i === days.length - 1) {
17195
+ result.push(week);
17196
+ week = [];
17197
+ }
17198
+ }
17199
+ return result;
17200
+ }, [days]);
17201
+ const handleEventClick = (event, e) => {
17202
+ e.stopPropagation();
17203
+ onEventSelect(event);
17204
+ };
17205
+ const [isMounted, setIsMounted] = (0, import_react85.useState)(false);
17206
+ const { contentRef, getVisibleEventCount } = useEventVisibilityAgenda({
17207
+ eventGap: EventGapAgenda,
17208
+ eventHeight: EventHeightAgenda
17209
+ });
17210
+ (0, import_react85.useEffect)(() => {
17211
+ setIsMounted(true);
17212
+ }, []);
17213
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "contents", "data-slot": "month-view", children: [
17214
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "grid grid-cols-7 border-border/70 border-b", children: weekdays.map((day) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17215
+ "div",
17216
+ {
17217
+ className: "py-2 text-center text-muted-foreground/70 text-sm uppercase tracking-wide bg-muted/5",
17218
+ children: day
17219
+ },
17220
+ day
17221
+ )) }),
17222
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "grid flex-1 auto-rows-fr", children: weeks.map((week, weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17223
+ "div",
17224
+ {
17225
+ className: "grid grid-cols-7 [&:last-child>*]:border-b-0",
17226
+ children: week.map((day, dayIndex) => {
17227
+ if (!day) return null;
17228
+ const dayEvents = getEventsForDayAgenda(events, day);
17229
+ const spanningEvents = getSpanningEventsForDayAgenda(events, day);
17230
+ const isCurrentMonth = (0, import_date_fns24.isSameMonth)(day, currentDate);
17231
+ const cellId = `month-cell-${day.toISOString()}`;
17232
+ const allDayEvents = [...spanningEvents, ...dayEvents];
17233
+ const allEvents = getAllEventsForDayAgenda(events, day);
17234
+ const isReferenceCell = weekIndex === 0 && dayIndex === 0;
17235
+ const visibleCount = isMounted ? getVisibleEventCount(allDayEvents.length) : void 0;
17236
+ const hasMore = visibleCount !== void 0 && allDayEvents.length > visibleCount;
17237
+ const remainingCount = hasMore ? allDayEvents.length - visibleCount : 0;
17238
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17239
+ "div",
17240
+ {
17241
+ className: "group border-border/70 border-r border-b last:border-r-0 data-outside-cell:bg-muted/25 data-outside-cell:text-muted-foreground/70 hover:bg-muted/5 transition-colors p-2 ",
17242
+ "data-outside-cell": !isCurrentMonth || void 0,
17243
+ "data-today": (0, import_date_fns24.isToday)(day) || void 0,
17244
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17245
+ DroppableCellAgenda,
17246
+ {
17247
+ date: day,
17248
+ id: cellId,
17249
+ onClick: () => {
17250
+ const startTime = new Date(day);
17251
+ startTime.setHours(DefaultStartHourAgenda, 0, 0);
17252
+ },
17253
+ children: [
17254
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17255
+ "div",
17256
+ {
17257
+ className: (0, import_tailwind_merge3.twMerge)(
17258
+ `mt-1 inline-flex w-7 h-7 items-center justify-center rounded-full text-sm font-semibold text-muted-foreground`,
17259
+ (0, import_date_fns24.isToday)(day) ? "bg-blue-500 text-white" : ""
17260
+ ),
17261
+ children: (0, import_date_fns24.format)(day, "d")
17262
+ }
17263
+ ),
17264
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17265
+ "div",
17266
+ {
17267
+ className: "min-h-[calc((var(--event-height)+var(--event-gap))*2)] sm:min-h-[calc((var(--event-height)+var(--event-gap))*3)] lg:min-h-[calc((var(--event-height)+var(--event-gap))*4)] px-1 py-1",
17268
+ ref: isReferenceCell ? contentRef : null,
17269
+ children: [
17270
+ sortEventsAgenda(allDayEvents).map((event, index) => {
17271
+ const eventStart = new Date(
17272
+ event.start ?? event.attend_date ?? event.end ?? Date.now()
17273
+ );
17274
+ const eventEnd = new Date(
17275
+ event.end ?? event.attend_date ?? event.start ?? Date.now()
17276
+ );
17277
+ const isFirstDay = (0, import_date_fns24.isSameDay)(day, eventStart);
17278
+ const isLastDay = (0, import_date_fns24.isSameDay)(day, eventEnd);
17279
+ const isHidden = isMounted && visibleCount && index >= visibleCount;
17280
+ if (!visibleCount) return null;
17281
+ if (!isFirstDay) {
17282
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17283
+ "div",
17284
+ {
17285
+ "aria-hidden": isHidden ? "true" : void 0,
17286
+ className: "aria-hidden:hidden",
17287
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17288
+ EventItemAgenda,
17289
+ {
17290
+ event,
17291
+ isFirstDay,
17292
+ isLastDay,
17293
+ onClick: (e) => handleEventClick(event, e),
17294
+ view: "month",
17295
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { "aria-hidden": true, className: "invisible", children: [
17296
+ !event.allDay && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("span", { children: [
17297
+ (0, import_date_fns24.format)(eventStart, "HH:mm"),
17298
+ " "
17299
+ ] }),
17300
+ event.title
17301
+ ] })
17302
+ }
17303
+ )
17304
+ },
17305
+ `spanning-${event.id}-${day.toISOString().slice(0, 10)}`
17306
+ );
17307
+ }
17308
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17309
+ "div",
17310
+ {
17311
+ "aria-hidden": isHidden ? "true" : void 0,
17312
+ className: "aria-hidden:hidden",
17313
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17314
+ EventItemAgenda,
17315
+ {
17316
+ className: "cursor-default",
17317
+ event,
17318
+ isFirstDay,
17319
+ isLastDay,
17320
+ onClick: (e) => handleEventClick(event, e),
17321
+ view: "month",
17322
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("span", { className: "flex items-center gap-2 truncate", children: [
17323
+ !event.allDay && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "truncate font-normal opacity-80 sm:text-[11px] bg-white/10 px-2 py-0.5 rounded-full text-[11px]", children: (0, import_date_fns24.format)(eventStart, "HH:mm") }),
17324
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "truncate font-medium", children: event.title })
17325
+ ] })
17326
+ }
17327
+ )
17328
+ },
17329
+ event.id
17330
+ );
17331
+ }),
17332
+ hasMore && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(PopoverBase, { modal: true, children: [
17333
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(PopoverTriggerBase, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17334
+ "button",
17335
+ {
17336
+ className: "mt-[var(--event-gap)] flex h-[var(--event-height)] w-full select-none items-center overflow-hidden px-2 text-left text-[10px] text-muted-foreground outline-none backdrop-blur-md rounded-md transition hover:bg-muted/60 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 sm:text-xs",
17337
+ onClick: (e) => e.stopPropagation(),
17338
+ type: "button",
17339
+ "aria-label": `Show ${remainingCount} more events on ${(0, import_date_fns24.format)(
17340
+ day,
17341
+ "PPP",
17342
+ { locale: import_locale12.ptBR }
17343
+ )}`,
17344
+ children: [
17345
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("span", { className: "font-medium", children: [
17346
+ "+ ",
17347
+ remainingCount
17348
+ ] }),
17349
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "sr-only", children: " more" })
17350
+ ]
17351
+ }
17352
+ ) }),
17353
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17354
+ PopoverContentBase,
17355
+ {
17356
+ align: "center",
17357
+ className: "max-w-52 p-3",
17358
+ style: {
17359
+ "--event-height": `${EventHeightAgenda}px`
17360
+ },
17361
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "space-y-2", children: [
17362
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "font-medium text-sm", children: (0, import_date_fns24.format)(day, "EEE d", { locale: import_locale12.ptBR }) }),
17363
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "space-y-1", children: sortEventsAgenda(allEvents).map((event) => {
17364
+ const eventStart = new Date(
17365
+ event.start ?? event.end ?? Date.now()
17366
+ );
17367
+ const eventEnd = new Date(
17368
+ event.end ?? event.start ?? Date.now()
17369
+ );
17370
+ const isFirstDay = (0, import_date_fns24.isSameDay)(day, eventStart);
17371
+ const isLastDay = (0, import_date_fns24.isSameDay)(day, eventEnd);
17372
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17373
+ EventItemAgenda,
17374
+ {
17375
+ event,
17376
+ isFirstDay,
17377
+ isLastDay,
17378
+ onClick: (e) => handleEventClick(event, e),
17379
+ view: "month"
17380
+ },
17381
+ event.id
17382
+ );
17383
+ }) })
17384
+ ] })
17385
+ }
17386
+ )
17387
+ ] })
17388
+ ]
17389
+ }
17390
+ )
17391
+ ]
17392
+ }
17393
+ )
17394
+ },
17395
+ day.toString()
17396
+ );
17397
+ })
17398
+ },
17399
+ `week-${week}`
17400
+ )) }),
17401
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17402
+ UndatedEvents,
17403
+ {
17404
+ events,
17405
+ onEventSelect,
17406
+ className: "my-12",
17407
+ show: showUndatedEvents
17408
+ }
17409
+ )
17410
+ ] });
17411
+ }
17412
+
17413
+ // src/components/event-calendar-view/WeekView.tsx
17414
+ var import_date_fns26 = require("date-fns");
17415
+ var import_date_fns27 = require("date-fns");
17416
+ var import_locale13 = require("date-fns/locale");
17417
+ var import_react87 = require("react");
17418
+
17419
+ // src/components/event-calendar-view/DraggablaEvent.tsx
17420
+ var import_core6 = require("@dnd-kit/core");
17421
+ var import_utilities2 = require("@dnd-kit/utilities");
17422
+ var import_date_fns25 = require("date-fns");
17423
+ var import_react86 = require("react");
17424
+ var import_jsx_runtime94 = require("react/jsx-runtime");
17425
+ function DraggableEvent2({
17426
+ event,
17427
+ view,
17428
+ showTime,
17429
+ onClick,
17430
+ height,
17431
+ isMultiDay,
17432
+ multiDayWidth,
17433
+ isFirstDay = true,
17434
+ isLastDay = true,
17435
+ "aria-hidden": ariaHidden
17436
+ }) {
17437
+ const { activeId } = useCalendarDndAgenda();
17438
+ const elementRef = (0, import_react86.useRef)(null);
17439
+ const [dragHandlePosition, setDragHandlePosition] = (0, import_react86.useState)(null);
17440
+ const eventStart = new Date(event.start ?? Date.now());
17441
+ const eventEnd = new Date(event.end ?? Date.now());
17442
+ const isMultiDayEvent2 = isMultiDay || event.allDay || (0, import_date_fns25.differenceInDays)(eventEnd, eventStart) >= 1;
17443
+ const { attributes, listeners, setNodeRef, transform, isDragging } = (0, import_core6.useDraggable)({
17444
+ data: {
17445
+ dragHandlePosition,
17446
+ event,
17447
+ height: height || elementRef.current?.offsetHeight || null,
17448
+ isFirstDay,
17449
+ isLastDay,
17450
+ isMultiDay: isMultiDayEvent2,
17451
+ multiDayWidth,
17452
+ view
17453
+ },
17454
+ id: `${event.id}-${view}`
17455
+ });
17456
+ const handleMouseDown = (e) => {
17457
+ if (elementRef.current) {
17458
+ const rect = elementRef.current.getBoundingClientRect();
17459
+ setDragHandlePosition({
17460
+ x: e.clientX - rect.left,
17461
+ y: e.clientY - rect.top
17462
+ });
17463
+ }
17464
+ };
17465
+ if (isDragging || activeId === `${event.id}-${view}`) {
17466
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17467
+ "div",
17468
+ {
17469
+ className: "opacity-0",
17470
+ ref: setNodeRef,
17471
+ style: { height: height || "auto" }
17472
+ }
17473
+ );
17474
+ }
17475
+ const style = transform ? {
17476
+ height: height || "auto",
17477
+ transform: import_utilities2.CSS.Translate.toString(transform),
17478
+ width: isMultiDayEvent2 && multiDayWidth ? `${multiDayWidth}%` : void 0
17479
+ } : {
17480
+ height: height || "auto",
17481
+ width: isMultiDayEvent2 && multiDayWidth ? `${multiDayWidth}%` : void 0
17482
+ };
17483
+ const handleTouchStart = (e) => {
17484
+ if (elementRef.current) {
17485
+ const rect = elementRef.current.getBoundingClientRect();
17486
+ const touch = e.touches[0];
17487
+ if (touch) {
17488
+ setDragHandlePosition({
17489
+ x: touch.clientX - rect.left,
17490
+ y: touch.clientY - rect.top
17491
+ });
17492
+ }
17493
+ }
17494
+ };
17495
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17496
+ "div",
17497
+ {
17498
+ className: "touch-none",
17499
+ ref: (node) => {
17500
+ setNodeRef(node);
17501
+ if (elementRef) elementRef.current = node;
17502
+ },
17503
+ style,
17504
+ children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17505
+ EventItemAgenda,
17506
+ {
17507
+ "aria-hidden": ariaHidden,
17508
+ dndAttributes: attributes,
17509
+ dndListeners: listeners,
17510
+ event,
17511
+ isDragging,
17512
+ isFirstDay,
17513
+ isLastDay,
17514
+ onClick,
17515
+ onMouseDown: handleMouseDown,
17516
+ onTouchStart: handleTouchStart,
17517
+ showTime,
17518
+ view
17519
+ }
17520
+ )
17521
+ }
17522
+ );
17523
+ }
17524
+
17525
+ // src/components/event-calendar-view/WeekView.tsx
17526
+ var import_jsx_runtime95 = require("react/jsx-runtime");
17527
+ function WeekViewAgenda({
17528
+ currentDate,
17529
+ events,
17530
+ onEventSelect,
17531
+ onEventCreate
17532
+ }) {
17533
+ const days = (0, import_react87.useMemo)(() => {
17534
+ const weekStart2 = (0, import_date_fns26.startOfWeek)(currentDate, { weekStartsOn: 0 });
17535
+ const weekEnd = (0, import_date_fns26.endOfWeek)(currentDate, { weekStartsOn: 0 });
17536
+ return (0, import_date_fns26.eachDayOfInterval)({ end: weekEnd, start: weekStart2 });
17537
+ }, [currentDate]);
17538
+ const weekStart = (0, import_react87.useMemo)(
17539
+ () => (0, import_date_fns26.startOfWeek)(currentDate, { weekStartsOn: 0 }),
17540
+ [currentDate]
17541
+ );
17542
+ const hours = (0, import_react87.useMemo)(() => {
17543
+ const dayStart = (0, import_date_fns26.startOfDay)(currentDate);
17544
+ return (0, import_date_fns26.eachHourOfInterval)({
17545
+ end: (0, import_date_fns26.addHours)(dayStart, EndHour - 1),
17546
+ start: (0, import_date_fns26.addHours)(dayStart, StartHour)
17547
+ });
17548
+ }, [currentDate]);
17549
+ const allDayEvents = (0, import_react87.useMemo)(() => {
17550
+ return events.filter((event) => {
17551
+ return event.allDay || isMultiDayEventAgenda(event);
17552
+ }).filter((event) => {
17553
+ const eventStart = event.start ? new Date(event.start) : void 0;
17554
+ const eventEnd = event.end ? new Date(event.end) : void 0;
17555
+ return days.some((day) => {
17556
+ if (eventStart && (0, import_date_fns26.isSameDay)(day, eventStart)) return true;
17557
+ if (eventEnd && (0, import_date_fns26.isSameDay)(day, eventEnd)) return true;
17558
+ if (eventStart && eventEnd && day > eventStart && day < eventEnd) return true;
17559
+ return false;
17560
+ });
17561
+ });
17562
+ }, [events, days]);
17563
+ const processedDayEvents = (0, import_react87.useMemo)(() => {
17564
+ const result = days.map((day) => {
17565
+ const dayEventsWithIntervals = events.filter((event) => !event.allDay && !isMultiDayEventAgenda(event)).map((event) => {
17566
+ let eventStart = event.start != null ? new Date(event.start) : void 0;
17567
+ let eventEnd = event.end != null ? new Date(event.end) : void 0;
17568
+ if ((!eventStart || !eventEnd) && event.attend_date) {
17569
+ try {
17570
+ const ad = new Date(event.attend_date);
17571
+ const hasTime = ad.getHours() !== 0 || ad.getMinutes() !== 0 || ad.getSeconds() !== 0 || ad.getMilliseconds() !== 0;
17572
+ if (hasTime) {
17573
+ if (!eventStart) eventStart = ad;
17574
+ if (!eventEnd) eventEnd = (0, import_date_fns26.addHours)(ad, 1);
17575
+ }
17576
+ } catch {
17577
+ }
17578
+ }
17579
+ return { event, eventStart, eventEnd };
17580
+ }).filter(({ eventStart, eventEnd }) => !!eventStart && !!eventEnd).filter(({ eventStart, eventEnd }) => {
17581
+ const dayStart2 = (0, import_date_fns26.startOfDay)(day);
17582
+ const dayEnd = (0, import_date_fns27.endOfDay)(day);
17583
+ return (0, import_date_fns26.areIntervalsOverlapping)(
17584
+ { start: eventStart, end: eventEnd },
17585
+ { start: dayStart2, end: dayEnd }
17586
+ );
17587
+ });
17588
+ const sortedEvents = [...dayEventsWithIntervals].sort((a, b) => {
17589
+ const aStart = a.eventStart.getTime();
17590
+ const bStart = b.eventStart.getTime();
17591
+ if (aStart < bStart) return -1;
17592
+ if (aStart > bStart) return 1;
17593
+ const aDuration = (0, import_date_fns26.differenceInMinutes)(
17594
+ a.eventEnd,
17595
+ a.eventStart
17596
+ );
17597
+ const bDuration = (0, import_date_fns26.differenceInMinutes)(
17598
+ b.eventEnd,
17599
+ b.eventStart
17600
+ );
17601
+ return bDuration - aDuration;
17602
+ });
17603
+ const positionedEvents = [];
17604
+ const dayStart = (0, import_date_fns26.startOfDay)(day);
17605
+ const columns = [];
17606
+ for (const item of sortedEvents) {
17607
+ const event = item.event;
17608
+ const eventStart = item.eventStart;
17609
+ const eventEnd = item.eventEnd;
17610
+ const adjustedStart = (0, import_date_fns26.isSameDay)(day, eventStart) ? eventStart : dayStart;
17611
+ const adjustedEnd = (0, import_date_fns26.isSameDay)(day, eventEnd) ? eventEnd : (0, import_date_fns26.addHours)(dayStart, 24);
17612
+ const startHour = (0, import_date_fns26.getHours)(adjustedStart) + (0, import_date_fns26.getMinutes)(adjustedStart) / 60;
17613
+ const endHour = (0, import_date_fns26.getHours)(adjustedEnd) + (0, import_date_fns26.getMinutes)(adjustedEnd) / 60;
17614
+ const top = (startHour - StartHour) * WeekCellsHeightAgenda;
17615
+ const height = (endHour - startHour) * WeekCellsHeightAgenda;
17616
+ let columnIndex = 0;
17617
+ let placed = false;
17618
+ while (!placed) {
17619
+ const col = columns[columnIndex] || [];
17620
+ if (col.length === 0) {
17621
+ columns[columnIndex] = col;
17622
+ placed = true;
17623
+ } else {
17624
+ const overlaps = col.some(
17625
+ (c) => (0, import_date_fns26.areIntervalsOverlapping)(
17626
+ { end: adjustedEnd, start: adjustedStart },
17627
+ { end: c.end, start: c.start }
17628
+ )
17629
+ );
17630
+ if (!overlaps) {
17631
+ placed = true;
17632
+ } else {
17633
+ columnIndex++;
17634
+ }
17635
+ }
17636
+ }
17637
+ const currentColumn = columns[columnIndex] || [];
17638
+ columns[columnIndex] = currentColumn;
17639
+ currentColumn.push({ start: adjustedStart, end: adjustedEnd, event });
17640
+ const width = columnIndex === 0 ? 1 : 0.7;
17641
+ const left = columnIndex === 0 ? 0 : columnIndex * 0.3;
17642
+ positionedEvents.push({
17643
+ event,
17644
+ height,
17645
+ left,
17646
+ top,
17647
+ width,
17648
+ zIndex: 10 + columnIndex
17649
+ });
17650
+ }
17651
+ return positionedEvents;
17652
+ });
17653
+ return result;
17654
+ }, [days, events]);
17655
+ const handleEventClick = (event, e) => {
17656
+ e.stopPropagation();
17657
+ onEventSelect(event);
17658
+ };
17659
+ const showAllDaySection = allDayEvents.length > 0;
17660
+ const { currentTimePosition, currentTimeVisible } = useCurrentTimeIndicatorAgenda(
17661
+ currentDate,
17662
+ "week"
17663
+ );
17664
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "flex h-full flex-col", "data-slot": "week-view", children: [
17665
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "sticky top-0 z-30 grid grid-cols-8 border-border/70 border-b bg-background", children: [
17666
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "py-2 text-center text-muted-foreground/70 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "max-[479px]:sr-only", children: (0, import_date_fns26.format)(/* @__PURE__ */ new Date(), "O") }) }),
17667
+ days.map((day) => /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
17668
+ "div",
17669
+ {
17670
+ className: "py-2 text-center text-muted-foreground/70 text-sm data-today:font-medium data-today:text-foreground",
17671
+ "data-today": (0, import_date_fns26.isToday)(day) || void 0,
17672
+ children: [
17673
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("span", { "aria-hidden": "true", className: "sm:hidden", children: [
17674
+ (0, import_date_fns26.format)(day, "EEE", { locale: import_locale13.ptBR })[0],
17675
+ " ",
17676
+ (0, import_date_fns26.format)(day, "d", { locale: import_locale13.ptBR })
17677
+ ] }),
17678
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "max-sm:hidden", children: (0, import_date_fns26.format)(day, "EEE dd", { locale: import_locale13.ptBR }) })
17679
+ ]
17680
+ },
17681
+ day.toString()
17682
+ ))
17683
+ ] }),
17684
+ showAllDaySection && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "border-border/70 border-b bg-muted/50", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "grid grid-cols-8", children: [
17685
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "relative border-border/70 border-r", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "absolute bottom-0 left-0 h-6 w-16 max-w-full pe-2 text-right text-[10px] text-muted-foreground/70 sm:pe-4 sm:text-xs", children: "All day" }) }),
17686
+ days.map((day, dayIndex) => {
17687
+ const dayAllDayEvents = allDayEvents.filter((event) => {
17688
+ const eventStart = event.start ? new Date(event.start) : void 0;
17689
+ const eventEnd = event.end ? new Date(event.end) : void 0;
17690
+ if (!eventStart && !eventEnd) return false;
17691
+ return eventStart && (0, import_date_fns26.isSameDay)(day, eventStart) || eventStart && eventEnd && day > eventStart && day < eventEnd || eventEnd && (0, import_date_fns26.isSameDay)(day, eventEnd);
17692
+ });
17693
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17694
+ "div",
17695
+ {
17696
+ className: "relative border-border/70 border-r p-1 last:border-r-0",
17697
+ "data-today": (0, import_date_fns26.isToday)(day) || void 0,
17698
+ children: dayAllDayEvents.map((event) => {
17699
+ const eventStart = event.start ? new Date(event.start) : void 0;
17700
+ const eventEnd = event.end ? new Date(event.end) : void 0;
17701
+ const isFirstDay = eventStart ? (0, import_date_fns26.isSameDay)(day, eventStart) : false;
17702
+ const isLastDay = eventEnd ? (0, import_date_fns26.isSameDay)(day, eventEnd) : false;
17703
+ const isFirstVisibleDay = eventStart ? dayIndex === 0 && (0, import_date_fns26.isBefore)(eventStart, weekStart) : false;
17704
+ const shouldShowTitle = isFirstDay || isFirstVisibleDay;
17705
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17706
+ EventItemAgenda,
17707
+ {
17708
+ event,
17709
+ isFirstDay,
17710
+ isLastDay,
17711
+ onClick: (e) => handleEventClick(event, e),
17712
+ view: "month",
17713
+ children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17714
+ "div",
17715
+ {
17716
+ "aria-hidden": !shouldShowTitle,
17717
+ className: cn(
17718
+ "truncate",
17719
+ !shouldShowTitle && "invisible"
17720
+ ),
17721
+ children: event.title
17722
+ }
17723
+ )
17724
+ },
17725
+ `spanning-${event.id}`
17726
+ );
17727
+ })
17728
+ },
17729
+ day.toString()
17730
+ );
17731
+ })
17732
+ ] }) }),
17733
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "grid flex-1 grid-cols-8 overflow-hidden", children: [
17734
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "grid auto-cols-fr border-border/70 border-r", children: hours.map((hour, index) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17735
+ "div",
17736
+ {
17737
+ className: "relative min-h-[var(--week-cells-height)] border-border/70 border-b last:border-b-0",
17738
+ children: index > 0 && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "-top-3 absolute left-0 flex h-6 w-16 max-w-full items-center justify-end bg-background pe-2 text-[10px] text-muted-foreground/70 sm:pe-4 sm:text-xs", children: (0, import_date_fns26.format)(hour, "HH:mm") })
17739
+ },
17740
+ hour.toString()
17741
+ )) }),
17742
+ days.map((day, dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
17743
+ "div",
17744
+ {
17745
+ className: "relative grid auto-cols-fr border-border/70 border-r last:border-r-0",
17746
+ "data-today": (0, import_date_fns26.isToday)(day) || void 0,
17747
+ children: [
17748
+ (processedDayEvents[dayIndex] ?? []).map((positionedEvent) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17749
+ "div",
17750
+ {
17751
+ className: "absolute z-10 px-0.5",
17752
+ onClick: (e) => e.stopPropagation(),
17753
+ style: {
17754
+ height: `${positionedEvent.height}px`,
17755
+ left: `${positionedEvent.left * 100}%`,
17756
+ top: `${positionedEvent.top}px`,
17757
+ width: `${positionedEvent.width * 100}%`,
17758
+ zIndex: positionedEvent.zIndex
17759
+ },
17760
+ children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "size-full", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17761
+ DraggableEvent2,
17762
+ {
17763
+ event: positionedEvent.event,
17764
+ height: positionedEvent.height,
17765
+ onClick: (e) => handleEventClick(positionedEvent.event, e),
17766
+ showTime: true,
17767
+ view: "week"
17768
+ }
17769
+ ) })
17770
+ },
17771
+ positionedEvent.event.id
17772
+ )),
17773
+ currentTimeVisible && (0, import_date_fns26.isToday)(day) && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17774
+ "div",
17775
+ {
17776
+ className: "pointer-events-none absolute right-0 left-0 z-20",
17777
+ style: { top: `${currentTimePosition}%` },
17778
+ children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "relative flex items-center", children: [
17779
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "-left-1 absolute h-2 w-2 rounded-full bg-primary" }),
17780
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "h-[2px] w-full bg-primary" })
17781
+ ] })
17782
+ }
17783
+ ),
17784
+ hours.map((hour) => {
17785
+ const hourValue = (0, import_date_fns26.getHours)(hour);
17786
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17787
+ "div",
17788
+ {
17789
+ className: "relative min-h-[var(--week-cells-height)] border-border/70 border-b last:border-b-0",
17790
+ children: [0, 1, 2, 3].map((quarter) => {
17791
+ const quarterHourTime = hourValue + quarter * 0.25;
17792
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17793
+ DroppableCellAgenda,
17794
+ {
17795
+ className: cn(
17796
+ "absolute h-[calc(var(--week-cells-height)/4)] w-full",
17797
+ quarter === 0 && "top-0",
17798
+ quarter === 1 && "top-[calc(var(--week-cells-height)/4)]",
17799
+ quarter === 2 && "top-[calc(var(--week-cells-height)/4*2)]",
17800
+ quarter === 3 && "top-[calc(var(--week-cells-height)/4*)]"
17801
+ ),
17802
+ date: day,
17803
+ id: `week-cell-${day.toISOString()}-${quarterHourTime}`,
17804
+ onClick: () => {
17805
+ const startTime = new Date(day);
17806
+ startTime.setHours(hourValue);
17807
+ startTime.setMinutes(quarter * 15);
17808
+ if (onEventCreate) onEventCreate(startTime);
17809
+ },
17810
+ time: quarterHourTime
17811
+ },
17812
+ `${hour.toString()}-${quarter}`
17813
+ );
17814
+ })
17815
+ },
17816
+ hour.toString()
17817
+ );
17818
+ })
17819
+ ]
17820
+ },
17821
+ day.toString()
17822
+ ))
17823
+ ] })
17824
+ ] });
17825
+ }
17826
+
17827
+ // src/components/ui/data/Banner.tsx
17828
+ var import_react88 = require("@phosphor-icons/react");
17829
+ var import_react89 = __toESM(require("react"));
17830
+ var import_jsx_runtime96 = require("react/jsx-runtime");
17831
+
15568
17832
  // src/hooks/use-drag.tsx
15569
- var import_react73 = require("react");
17833
+ var import_react90 = require("react");
15570
17834
  var useDrag = (options = {}) => {
15571
- const [isDragging, setIsDragging] = (0, import_react73.useState)(null);
15572
- const [positions, setPositions] = (0, import_react73.useState)({});
15573
- const dragStartPos = (0, import_react73.useRef)(null);
15574
- const dragId = (0, import_react73.useRef)(null);
15575
- const handleMouseDown = (0, import_react73.useCallback)((id, e) => {
17835
+ const [isDragging, setIsDragging] = (0, import_react90.useState)(null);
17836
+ const [positions, setPositions] = (0, import_react90.useState)({});
17837
+ const dragStartPos = (0, import_react90.useRef)(null);
17838
+ const dragId = (0, import_react90.useRef)(null);
17839
+ const handleMouseDown = (0, import_react90.useCallback)((id, e) => {
15576
17840
  e.preventDefault();
15577
17841
  const currentPosition = positions[id] || { top: 0, left: 0 };
15578
17842
  dragStartPos.current = {
@@ -15585,7 +17849,7 @@ var useDrag = (options = {}) => {
15585
17849
  setIsDragging(id);
15586
17850
  options.onDragStart?.(id);
15587
17851
  }, [positions, options]);
15588
- const handleMouseMove = (0, import_react73.useCallback)((e) => {
17852
+ const handleMouseMove = (0, import_react90.useCallback)((e) => {
15589
17853
  if (!isDragging || !dragStartPos.current || !dragId.current) return;
15590
17854
  const deltaX = e.clientX - dragStartPos.current.x;
15591
17855
  const deltaY = e.clientY - dragStartPos.current.y;
@@ -15601,7 +17865,7 @@ var useDrag = (options = {}) => {
15601
17865
  }));
15602
17866
  options.onDrag?.(dragId.current, newPosition);
15603
17867
  }, [isDragging, options]);
15604
- const handleMouseUp = (0, import_react73.useCallback)(() => {
17868
+ const handleMouseUp = (0, import_react90.useCallback)(() => {
15605
17869
  if (dragId.current) {
15606
17870
  options.onDragEnd?.(dragId.current);
15607
17871
  }
@@ -15609,7 +17873,7 @@ var useDrag = (options = {}) => {
15609
17873
  dragStartPos.current = null;
15610
17874
  dragId.current = null;
15611
17875
  }, [options]);
15612
- (0, import_react73.useEffect)(() => {
17876
+ (0, import_react90.useEffect)(() => {
15613
17877
  if (isDragging) {
15614
17878
  document.addEventListener("mousemove", handleMouseMove);
15615
17879
  document.addEventListener("mouseup", handleMouseUp);
@@ -15621,16 +17885,16 @@ var useDrag = (options = {}) => {
15621
17885
  };
15622
17886
  }
15623
17887
  }, [isDragging, handleMouseMove, handleMouseUp]);
15624
- const setPosition = (0, import_react73.useCallback)((id, position) => {
17888
+ const setPosition = (0, import_react90.useCallback)((id, position) => {
15625
17889
  setPositions((prev) => ({
15626
17890
  ...prev,
15627
17891
  [id]: position
15628
17892
  }));
15629
17893
  }, []);
15630
- const getPosition = (0, import_react73.useCallback)((id) => {
17894
+ const getPosition = (0, import_react90.useCallback)((id) => {
15631
17895
  return positions[id] || { top: 0, left: 0 };
15632
17896
  }, [positions]);
15633
- const isElementDragging = (0, import_react73.useCallback)((id) => {
17897
+ const isElementDragging = (0, import_react90.useCallback)((id) => {
15634
17898
  return isDragging === id;
15635
17899
  }, [isDragging]);
15636
17900
  return {