@j3m-quantum/ui 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as React22 from 'react';
1
+ import * as React27 from 'react';
2
2
  import { useMemo } from 'react';
3
3
  import { Slot } from '@radix-ui/react-slot';
4
4
  import { cva } from 'class-variance-authority';
@@ -7,7 +7,7 @@ import { twMerge } from 'tailwind-merge';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
9
9
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
10
- import { SearchIcon, CheckIcon, CircleIcon, ChevronDownIcon, ChevronUpIcon, ChevronRightIcon, ChevronLeftIcon, ArrowLeft, ArrowRight, Check, Loader2Icon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon, ChevronRight, MoreHorizontal, MoreHorizontalIcon, XIcon, GripVerticalIcon, PanelLeftIcon, ArrowDown, ArrowUp, ChevronsUpDown, EyeOff, ChevronsLeft, ChevronLeft, ChevronsRight, Settings2, FolderIcon, ShareIcon, TrashIcon, ChevronsUpDownIcon, SparklesIcon, BadgeCheckIcon, CreditCardIcon, BellIcon, LogOutIcon, X, Flag, Factory, Truck, MessageSquare, ChevronDown, Plus, Send, MessageSquarePlus, AlertTriangle, CheckCircle, Calendar as Calendar$1, User, Clock, CalendarX2, List, Columns, Grid2x2, Grid3x3, CalendarRange, Settings, Info, Moon, ArrowUpDown, CheckCircle2, XCircle, Package } from 'lucide-react';
10
+ import { SearchIcon, CheckIcon, CircleIcon, ChevronDownIcon, ChevronUpIcon, ChevronRightIcon, ChevronLeftIcon, ArrowLeft, ArrowRight, Check, Loader2Icon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon, ChevronRight, MoreHorizontal, MoreHorizontalIcon, XIcon, GripVerticalIcon, PanelLeftIcon, ArrowDown, ArrowUp, ChevronsUpDown, EyeOff, ChevronsLeft, ChevronLeft, ChevronsRight, Settings2, FolderIcon, ShareIcon, TrashIcon, ChevronsUpDownIcon, SparklesIcon, BadgeCheckIcon, CreditCardIcon, BellIcon, LogOutIcon, X, Flag, Factory, Truck, MessageSquare, ChevronDown, Plus, Send, MessageSquarePlus, AlertTriangle, CheckCircle, Calendar as Calendar$1, MapPin, Package, User, Clock, CalendarX2, List, Columns, Grid2x2, Grid3x3, CalendarRange, Settings, Info, Moon, ArrowUpDown, CheckCircle2, XCircle } from 'lucide-react';
11
11
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
12
12
  import * as SwitchPrimitive from '@radix-ui/react-switch';
13
13
  import * as SliderPrimitive from '@radix-ui/react-slider';
@@ -41,14 +41,14 @@ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
41
41
  import * as ResizablePrimitive from 'react-resizable-panels';
42
42
  import { useReactTable, getPaginationRowModel, getFilteredRowModel, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
43
43
  export { flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
44
- import { subMonths, subYears, subWeeks, subDays, addMonths, addYears, addWeeks, addDays, format, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfYear, endOfYear, isSameMonth, isSameWeek, isSameDay, isSameYear, isWithinInterval, parseISO, differenceInMinutes, eachDayOfInterval, differenceInDays, startOfDay, setMinutes, setHours, eachHourOfInterval, endOfDay, getHours, getMinutes, addMinutes, isToday, areIntervalsOverlapping } from 'date-fns';
44
+ import { addDays, isToday, subMonths, subYears, subWeeks, subDays, addMonths, addYears, addWeeks, format, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfYear, endOfYear, isSameMonth, isSameWeek, isSameDay, isSameYear, isWithinInterval, parseISO, differenceInMinutes, eachDayOfInterval, differenceInDays, startOfDay, setMinutes, setHours, eachHourOfInterval, endOfDay, getHours, getMinutes, addMinutes, areIntervalsOverlapping } from 'date-fns';
45
45
  export { areIntervalsOverlapping, format, getDay, isSameDay, isSameMonth, isToday, parseISO } from 'date-fns';
46
46
 
47
47
  // src/hooks/use-mobile.ts
48
48
  var MOBILE_BREAKPOINT = 768;
49
49
  function useIsMobile() {
50
- const [isMobile, setIsMobile] = React22.useState(void 0);
51
- React22.useEffect(() => {
50
+ const [isMobile, setIsMobile] = React27.useState(void 0);
51
+ React27.useEffect(() => {
52
52
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
53
53
  const onChange = () => {
54
54
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
@@ -89,7 +89,7 @@ var buttonVariants = cva(
89
89
  }
90
90
  }
91
91
  );
92
- var Button = React22.forwardRef(
92
+ var Button = React27.forwardRef(
93
93
  ({ className, variant, size, asChild = false, ...props }, ref) => {
94
94
  const Comp = asChild ? Slot : "button";
95
95
  return /* @__PURE__ */ jsx(
@@ -453,7 +453,7 @@ function Slider({
453
453
  max = 100,
454
454
  ...props
455
455
  }) {
456
- const _values = React22.useMemo(
456
+ const _values = React27.useMemo(
457
457
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
458
458
  [value, defaultValue, min, max]
459
459
  );
@@ -739,7 +739,7 @@ function Toggle({
739
739
  }
740
740
  );
741
741
  }
742
- var ToggleGroupContext = React22.createContext({
742
+ var ToggleGroupContext = React27.createContext({
743
743
  size: "default",
744
744
  variant: "default",
745
745
  spacing: 0
@@ -776,7 +776,7 @@ function ToggleGroupItem({
776
776
  size,
777
777
  ...props
778
778
  }) {
779
- const context = React22.useContext(ToggleGroupContext);
779
+ const context = React27.useContext(ToggleGroupContext);
780
780
  return /* @__PURE__ */ jsx(
781
781
  ToggleGroupPrimitive.Item,
782
782
  {
@@ -806,7 +806,7 @@ function ThemeSwitch({
806
806
  className,
807
807
  size = "default"
808
808
  }) {
809
- const [isChecked, setIsChecked] = React22.useState(defaultChecked);
809
+ const [isChecked, setIsChecked] = React27.useState(defaultChecked);
810
810
  const isControlled = checked !== void 0;
811
811
  const currentChecked = isControlled ? checked : isChecked;
812
812
  const handleClick = () => {
@@ -1226,7 +1226,7 @@ function Label2({
1226
1226
  );
1227
1227
  }
1228
1228
  var Form = FormProvider;
1229
- var FormFieldContext = React22.createContext(
1229
+ var FormFieldContext = React27.createContext(
1230
1230
  {}
1231
1231
  );
1232
1232
  var FormField = ({
@@ -1235,8 +1235,8 @@ var FormField = ({
1235
1235
  return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
1236
1236
  };
1237
1237
  var useFormField = () => {
1238
- const fieldContext = React22.useContext(FormFieldContext);
1239
- const itemContext = React22.useContext(FormItemContext);
1238
+ const fieldContext = React27.useContext(FormFieldContext);
1239
+ const itemContext = React27.useContext(FormItemContext);
1240
1240
  const { getFieldState } = useFormContext();
1241
1241
  const formState = useFormState({ name: fieldContext.name });
1242
1242
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -1253,11 +1253,11 @@ var useFormField = () => {
1253
1253
  ...fieldState
1254
1254
  };
1255
1255
  };
1256
- var FormItemContext = React22.createContext(
1256
+ var FormItemContext = React27.createContext(
1257
1257
  {}
1258
1258
  );
1259
1259
  function FormItem({ className, ...props }) {
1260
- const id = React22.useId();
1260
+ const id = React27.useId();
1261
1261
  return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx(
1262
1262
  "div",
1263
1263
  {
@@ -2359,8 +2359,8 @@ function CalendarDayButton({
2359
2359
  modifiers,
2360
2360
  ...props
2361
2361
  }) {
2362
- const ref = React22.useRef(null);
2363
- React22.useEffect(() => {
2362
+ const ref = React27.useRef(null);
2363
+ React27.useEffect(() => {
2364
2364
  if (modifiers.focused) ref.current?.focus();
2365
2365
  }, [modifiers.focused]);
2366
2366
  return /* @__PURE__ */ jsx(
@@ -2381,9 +2381,9 @@ function CalendarDayButton({
2381
2381
  }
2382
2382
  );
2383
2383
  }
2384
- var CarouselContext = React22.createContext(null);
2384
+ var CarouselContext = React27.createContext(null);
2385
2385
  function useCarousel() {
2386
- const context = React22.useContext(CarouselContext);
2386
+ const context = React27.useContext(CarouselContext);
2387
2387
  if (!context) {
2388
2388
  throw new Error("useCarousel must be used within a <Carousel />");
2389
2389
  }
@@ -2405,20 +2405,20 @@ function Carousel({
2405
2405
  },
2406
2406
  plugins
2407
2407
  );
2408
- const [canScrollPrev, setCanScrollPrev] = React22.useState(false);
2409
- const [canScrollNext, setCanScrollNext] = React22.useState(false);
2410
- const onSelect = React22.useCallback((api2) => {
2408
+ const [canScrollPrev, setCanScrollPrev] = React27.useState(false);
2409
+ const [canScrollNext, setCanScrollNext] = React27.useState(false);
2410
+ const onSelect = React27.useCallback((api2) => {
2411
2411
  if (!api2) return;
2412
2412
  setCanScrollPrev(api2.canScrollPrev());
2413
2413
  setCanScrollNext(api2.canScrollNext());
2414
2414
  }, []);
2415
- const scrollPrev = React22.useCallback(() => {
2415
+ const scrollPrev = React27.useCallback(() => {
2416
2416
  api?.scrollPrev();
2417
2417
  }, [api]);
2418
- const scrollNext = React22.useCallback(() => {
2418
+ const scrollNext = React27.useCallback(() => {
2419
2419
  api?.scrollNext();
2420
2420
  }, [api]);
2421
- const handleKeyDown = React22.useCallback(
2421
+ const handleKeyDown = React27.useCallback(
2422
2422
  (event) => {
2423
2423
  if (event.key === "ArrowLeft") {
2424
2424
  event.preventDefault();
@@ -2430,11 +2430,11 @@ function Carousel({
2430
2430
  },
2431
2431
  [scrollPrev, scrollNext]
2432
2432
  );
2433
- React22.useEffect(() => {
2433
+ React27.useEffect(() => {
2434
2434
  if (!api || !setApi) return;
2435
2435
  setApi(api);
2436
2436
  }, [api, setApi]);
2437
- React22.useEffect(() => {
2437
+ React27.useEffect(() => {
2438
2438
  if (!api) return;
2439
2439
  onSelect(api);
2440
2440
  api.on("reInit", onSelect);
@@ -2567,9 +2567,9 @@ function CarouselNext({
2567
2567
  );
2568
2568
  }
2569
2569
  var THEMES = { light: "", dark: ".dark" };
2570
- var ChartContext = React22.createContext(null);
2570
+ var ChartContext = React27.createContext(null);
2571
2571
  function useChart() {
2572
- const context = React22.useContext(ChartContext);
2572
+ const context = React27.useContext(ChartContext);
2573
2573
  if (!context) {
2574
2574
  throw new Error("useChart must be used within a <ChartContainer />");
2575
2575
  }
@@ -2582,7 +2582,7 @@ function ChartContainer({
2582
2582
  config,
2583
2583
  ...props
2584
2584
  }) {
2585
- const uniqueId = React22.useId();
2585
+ const uniqueId = React27.useId();
2586
2586
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
2587
2587
  return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
2588
2588
  "div",
@@ -2643,7 +2643,7 @@ function ChartTooltipContent({
2643
2643
  labelKey
2644
2644
  }) {
2645
2645
  const { config } = useChart();
2646
- const tooltipLabel = React22.useMemo(() => {
2646
+ const tooltipLabel = React27.useMemo(() => {
2647
2647
  if (hideLabel || !payload?.length) {
2648
2648
  return null;
2649
2649
  }
@@ -3445,8 +3445,8 @@ function TooltipContent({
3445
3445
  ) });
3446
3446
  }
3447
3447
  function useDetectTheme() {
3448
- const [theme, setTheme] = React22.useState("light");
3449
- React22.useEffect(() => {
3448
+ const [theme, setTheme] = React27.useState("light");
3449
+ React27.useEffect(() => {
3450
3450
  const isDark = document.documentElement.classList.contains("dark");
3451
3451
  setTheme(isDark ? "dark" : "light");
3452
3452
  const observer = new MutationObserver((mutations) => {
@@ -4095,7 +4095,7 @@ function CommandShortcut({
4095
4095
  }
4096
4096
  );
4097
4097
  }
4098
- var SearchTrigger = React22.forwardRef(
4098
+ var SearchTrigger = React27.forwardRef(
4099
4099
  ({
4100
4100
  className,
4101
4101
  placeholder = "Search...",
@@ -4131,7 +4131,7 @@ var SearchTrigger = React22.forwardRef(
4131
4131
  );
4132
4132
  SearchTrigger.displayName = "SearchTrigger";
4133
4133
  function useSearchShortcut(onOpen, key = "k") {
4134
- React22.useEffect(() => {
4134
+ React27.useEffect(() => {
4135
4135
  const down = (e) => {
4136
4136
  if (e.key.toLowerCase() === key.toLowerCase() && (e.metaKey || e.ctrlKey)) {
4137
4137
  e.preventDefault();
@@ -5106,9 +5106,9 @@ var SIDEBAR_WIDTH = "16rem";
5106
5106
  var SIDEBAR_WIDTH_MOBILE = "18rem";
5107
5107
  var SIDEBAR_WIDTH_ICON = "3rem";
5108
5108
  var SIDEBAR_KEYBOARD_SHORTCUT = "b";
5109
- var SidebarContext = React22.createContext(null);
5109
+ var SidebarContext = React27.createContext(null);
5110
5110
  function useSidebar() {
5111
- const context = React22.useContext(SidebarContext);
5111
+ const context = React27.useContext(SidebarContext);
5112
5112
  if (!context) {
5113
5113
  throw new Error("useSidebar must be used within a SidebarProvider.");
5114
5114
  }
@@ -5124,10 +5124,10 @@ function SidebarProvider({
5124
5124
  ...props
5125
5125
  }) {
5126
5126
  const isMobile = useIsMobile();
5127
- const [openMobile, setOpenMobile] = React22.useState(false);
5128
- const [_open, _setOpen] = React22.useState(defaultOpen);
5127
+ const [openMobile, setOpenMobile] = React27.useState(false);
5128
+ const [_open, _setOpen] = React27.useState(defaultOpen);
5129
5129
  const open = openProp ?? _open;
5130
- const setOpen = React22.useCallback(
5130
+ const setOpen = React27.useCallback(
5131
5131
  (value) => {
5132
5132
  const openState = typeof value === "function" ? value(open) : value;
5133
5133
  if (setOpenProp) {
@@ -5139,10 +5139,10 @@ function SidebarProvider({
5139
5139
  },
5140
5140
  [setOpenProp, open]
5141
5141
  );
5142
- const toggleSidebar = React22.useCallback(() => {
5142
+ const toggleSidebar = React27.useCallback(() => {
5143
5143
  return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
5144
5144
  }, [isMobile, setOpen, setOpenMobile]);
5145
- React22.useEffect(() => {
5145
+ React27.useEffect(() => {
5146
5146
  const handleKeyDown = (event) => {
5147
5147
  if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
5148
5148
  event.preventDefault();
@@ -5153,7 +5153,7 @@ function SidebarProvider({
5153
5153
  return () => window.removeEventListener("keydown", handleKeyDown);
5154
5154
  }, [toggleSidebar]);
5155
5155
  const state = open ? "expanded" : "collapsed";
5156
- const contextValue = React22.useMemo(
5156
+ const contextValue = React27.useMemo(
5157
5157
  () => ({
5158
5158
  state,
5159
5159
  open,
@@ -5611,7 +5611,7 @@ function SidebarMenuSkeleton({
5611
5611
  showIcon = false,
5612
5612
  ...props
5613
5613
  }) {
5614
- const width = React22.useMemo(() => {
5614
+ const width = React27.useMemo(() => {
5615
5615
  return `${Math.floor(Math.random() * 40) + 50}%`;
5616
5616
  }, []);
5617
5617
  return /* @__PURE__ */ jsxs(
@@ -5754,7 +5754,7 @@ var sectionVariants = cva(
5754
5754
  }
5755
5755
  );
5756
5756
  var isGlassVariant = (variant) => variant?.startsWith("glass-") ?? false;
5757
- var Section = React22.forwardRef(
5757
+ var Section = React27.forwardRef(
5758
5758
  ({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx(
5759
5759
  "section",
5760
5760
  {
@@ -5766,7 +5766,7 @@ var Section = React22.forwardRef(
5766
5766
  )
5767
5767
  );
5768
5768
  Section.displayName = "Section";
5769
- var SectionHeader = React22.forwardRef(
5769
+ var SectionHeader = React27.forwardRef(
5770
5770
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5771
5771
  "div",
5772
5772
  {
@@ -5781,7 +5781,7 @@ var SectionHeader = React22.forwardRef(
5781
5781
  )
5782
5782
  );
5783
5783
  SectionHeader.displayName = "SectionHeader";
5784
- var SectionTitle = React22.forwardRef(
5784
+ var SectionTitle = React27.forwardRef(
5785
5785
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5786
5786
  "h2",
5787
5787
  {
@@ -5795,7 +5795,7 @@ var SectionTitle = React22.forwardRef(
5795
5795
  )
5796
5796
  );
5797
5797
  SectionTitle.displayName = "SectionTitle";
5798
- var SectionDescription = React22.forwardRef(
5798
+ var SectionDescription = React27.forwardRef(
5799
5799
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5800
5800
  "p",
5801
5801
  {
@@ -5809,7 +5809,7 @@ var SectionDescription = React22.forwardRef(
5809
5809
  )
5810
5810
  );
5811
5811
  SectionDescription.displayName = "SectionDescription";
5812
- var SectionContent = React22.forwardRef(
5812
+ var SectionContent = React27.forwardRef(
5813
5813
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5814
5814
  "div",
5815
5815
  {
@@ -5823,7 +5823,7 @@ var SectionContent = React22.forwardRef(
5823
5823
  )
5824
5824
  );
5825
5825
  SectionContent.displayName = "SectionContent";
5826
- var SectionFooter = React22.forwardRef(
5826
+ var SectionFooter = React27.forwardRef(
5827
5827
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5828
5828
  "div",
5829
5829
  {
@@ -6048,7 +6048,7 @@ function SiteHeader({
6048
6048
  children: /* @__PURE__ */ jsxs("div", { className: "flex h-[var(--header-height,3.5rem)] w-full items-center gap-[var(--j3m-spacing-s)] px-[var(--j3m-spacing-m)]", children: [
6049
6049
  trigger,
6050
6050
  trigger && /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mr-[var(--j3m-spacing-s)] h-4" }),
6051
- /* @__PURE__ */ jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxs(React22.Fragment, { children: [
6051
+ /* @__PURE__ */ jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxs(React27.Fragment, { children: [
6052
6052
  index > 0 && /* @__PURE__ */ jsx(BreadcrumbSeparator, {}),
6053
6053
  /* @__PURE__ */ jsx(BreadcrumbItem, { children: item.href ? /* @__PURE__ */ jsx(BreadcrumbLink, { href: item.href, children: item.label }) : /* @__PURE__ */ jsx(BreadcrumbPage, { children: item.label }) })
6054
6054
  ] }, index)) }) }),
@@ -6655,11 +6655,11 @@ function PlanningWeekCommentPopover({
6655
6655
  open,
6656
6656
  onOpenChange
6657
6657
  }) {
6658
- const [newCommentText, setNewCommentText] = React22.useState("");
6659
- const [selectedLocationId, setSelectedLocationId] = React22.useState("");
6660
- const [viewCommentsOpen, setViewCommentsOpen] = React22.useState(true);
6661
- const [showAddForm, setShowAddForm] = React22.useState(false);
6662
- const selectedLocation = React22.useMemo(() => {
6658
+ const [newCommentText, setNewCommentText] = React27.useState("");
6659
+ const [selectedLocationId, setSelectedLocationId] = React27.useState("");
6660
+ const [viewCommentsOpen, setViewCommentsOpen] = React27.useState(true);
6661
+ const [showAddForm, setShowAddForm] = React27.useState(false);
6662
+ const selectedLocation = React27.useMemo(() => {
6663
6663
  return locationOptions.find((opt) => opt.id === selectedLocationId);
6664
6664
  }, [locationOptions, selectedLocationId]);
6665
6665
  const handleSubmit = () => {
@@ -6703,8 +6703,8 @@ function PlanningWeekCommentPopover({
6703
6703
  minute: "2-digit"
6704
6704
  }).format(date);
6705
6705
  };
6706
- const prevOpenRef = React22.useRef(open);
6707
- React22.useEffect(() => {
6706
+ const prevOpenRef = React27.useRef(open);
6707
+ React27.useEffect(() => {
6708
6708
  const wasOpen = prevOpenRef.current;
6709
6709
  prevOpenRef.current = open;
6710
6710
  if (wasOpen && !open) {
@@ -6727,7 +6727,7 @@ function PlanningWeekCommentPopover({
6727
6727
  /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
6728
6728
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
6729
6729
  ] }),
6730
- /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
6730
+ /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
6731
6731
  /* @__PURE__ */ jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
6732
6732
  /* @__PURE__ */ jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
6733
6733
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium", children: [
@@ -7058,22 +7058,22 @@ function PlanningTable({
7058
7058
  stickySupplierColumn = true,
7059
7059
  maxHeight = "600px"
7060
7060
  } = config;
7061
- const weeks = React22.useMemo(
7061
+ const weeks = React27.useMemo(
7062
7062
  () => generateWeeks(startDate, weekCount),
7063
7063
  [startDate, weekCount]
7064
7064
  );
7065
- const currentWeekKey = React22.useMemo(() => {
7065
+ const currentWeekKey = React27.useMemo(() => {
7066
7066
  const currentWeek = weeks.find((w) => w.isCurrentWeek);
7067
7067
  return currentWeek ? getWeekKey(currentWeek.startDate) : null;
7068
7068
  }, [weeks]);
7069
- const columns = React22.useMemo(
7069
+ const columns = React27.useMemo(
7070
7070
  () => generateColumns(weeks, config, suppliers),
7071
7071
  [weeks, config, suppliers]
7072
7072
  );
7073
- const [sorting, setSorting] = React22.useState([]);
7074
- const [columnFilters, setColumnFilters] = React22.useState([]);
7075
- const [columnVisibility, setColumnVisibility] = React22.useState({});
7076
- const [rowSelection, setRowSelection] = React22.useState({});
7073
+ const [sorting, setSorting] = React27.useState([]);
7074
+ const [columnFilters, setColumnFilters] = React27.useState([]);
7075
+ const [columnVisibility, setColumnVisibility] = React27.useState({});
7076
+ const [rowSelection, setRowSelection] = React27.useState({});
7077
7077
  const table = useReactTable({
7078
7078
  data: suppliers,
7079
7079
  columns,
@@ -7280,10 +7280,10 @@ function DeliveryCommentPopover({
7280
7280
  onAddComment,
7281
7281
  deliveryLabel
7282
7282
  }) {
7283
- const [open, setOpen] = React22.useState(false);
7284
- const [newCommentText, setNewCommentText] = React22.useState("");
7285
- const [viewCommentsOpen, setViewCommentsOpen] = React22.useState(true);
7286
- const [showAddForm, setShowAddForm] = React22.useState(false);
7283
+ const [open, setOpen] = React27.useState(false);
7284
+ const [newCommentText, setNewCommentText] = React27.useState("");
7285
+ const [viewCommentsOpen, setViewCommentsOpen] = React27.useState(true);
7286
+ const [showAddForm, setShowAddForm] = React27.useState(false);
7287
7287
  const handleSubmit = () => {
7288
7288
  if (newCommentText.trim() && onAddComment) {
7289
7289
  onAddComment(newCommentText.trim());
@@ -7310,8 +7310,8 @@ function DeliveryCommentPopover({
7310
7310
  minute: "2-digit"
7311
7311
  }).format(date);
7312
7312
  };
7313
- const prevOpenRef = React22.useRef(open);
7314
- React22.useEffect(() => {
7313
+ const prevOpenRef = React27.useRef(open);
7314
+ React27.useEffect(() => {
7315
7315
  const wasOpen = prevOpenRef.current;
7316
7316
  prevOpenRef.current = open;
7317
7317
  if (wasOpen && !open) {
@@ -7333,7 +7333,7 @@ function DeliveryCommentPopover({
7333
7333
  /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
7334
7334
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: deliveryLabel })
7335
7335
  ] }),
7336
- /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
7336
+ /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
7337
7337
  /* @__PURE__ */ jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
7338
7338
  /* @__PURE__ */ jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
7339
7339
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium", children: [
@@ -7423,8 +7423,8 @@ function ProductionCommentSection({
7423
7423
  comments = [],
7424
7424
  onAddComment
7425
7425
  }) {
7426
- const [showAddForm, setShowAddForm] = React22.useState(false);
7427
- const [newComment, setNewComment] = React22.useState("");
7426
+ const [showAddForm, setShowAddForm] = React27.useState(false);
7427
+ const [newComment, setNewComment] = React27.useState("");
7428
7428
  const handleSubmit = () => {
7429
7429
  if (newComment.trim() && onAddComment) {
7430
7430
  onAddComment(newComment.trim());
@@ -7580,7 +7580,7 @@ function DeliveryDetailsView({
7580
7580
  onAddComment
7581
7581
  }) {
7582
7582
  const elements = delivery.elements ?? [];
7583
- const categorizedElements = React22.useMemo(() => {
7583
+ const categorizedElements = React27.useMemo(() => {
7584
7584
  const sent = [];
7585
7585
  const notSent = [];
7586
7586
  const moved = [];
@@ -7948,15 +7948,15 @@ function WeekDetailDialog({
7948
7948
  }) {
7949
7949
  const production = data?.production;
7950
7950
  const initialProduced = production?.produced ?? 0;
7951
- const [producedValue, setProducedValue] = React22.useState(initialProduced.toString());
7952
- const [hasChanges, setHasChanges] = React22.useState(false);
7953
- const [selectedDelivery, setSelectedDelivery] = React22.useState(null);
7954
- React22.useEffect(() => {
7951
+ const [producedValue, setProducedValue] = React27.useState(initialProduced.toString());
7952
+ const [hasChanges, setHasChanges] = React27.useState(false);
7953
+ const [selectedDelivery, setSelectedDelivery] = React27.useState(null);
7954
+ React27.useEffect(() => {
7955
7955
  const newProduced = data?.production?.produced ?? 0;
7956
7956
  setProducedValue(newProduced.toString());
7957
7957
  setHasChanges(false);
7958
7958
  }, [data]);
7959
- React22.useEffect(() => {
7959
+ React27.useEffect(() => {
7960
7960
  if (!open) {
7961
7961
  setSelectedDelivery(null);
7962
7962
  }
@@ -8178,13 +8178,13 @@ function CalibrationWeekCell({
8178
8178
  onAddClick,
8179
8179
  ...props
8180
8180
  }) {
8181
- const inputRef = React22.useRef(null);
8182
- const [localValue, setLocalValue] = React22.useState(
8181
+ const inputRef = React27.useRef(null);
8182
+ const [localValue, setLocalValue] = React27.useState(
8183
8183
  data.entered !== null ? String(data.entered) : ""
8184
8184
  );
8185
- const [isHovered, setIsHovered] = React22.useState(false);
8186
- const [isEditing, setIsEditing] = React22.useState(false);
8187
- React22.useEffect(() => {
8185
+ const [isHovered, setIsHovered] = React27.useState(false);
8186
+ const [isEditing, setIsEditing] = React27.useState(false);
8187
+ React27.useEffect(() => {
8188
8188
  setLocalValue(data.entered !== null ? String(data.entered) : "");
8189
8189
  }, [data.entered]);
8190
8190
  const unitLabel = formatCalibrationUnit(unit);
@@ -8370,11 +8370,11 @@ function CommentPopover({
8370
8370
  open,
8371
8371
  onOpenChange
8372
8372
  }) {
8373
- const [newCommentText, setNewCommentText] = React22.useState("");
8374
- const [selectedPrefixId, setSelectedPrefixId] = React22.useState("");
8375
- const [viewCommentsOpen, setViewCommentsOpen] = React22.useState(true);
8376
- const [showAddForm, setShowAddForm] = React22.useState(false);
8377
- const selectedPrefixName = React22.useMemo(() => {
8373
+ const [newCommentText, setNewCommentText] = React27.useState("");
8374
+ const [selectedPrefixId, setSelectedPrefixId] = React27.useState("");
8375
+ const [viewCommentsOpen, setViewCommentsOpen] = React27.useState(true);
8376
+ const [showAddForm, setShowAddForm] = React27.useState(false);
8377
+ const selectedPrefixName = React27.useMemo(() => {
8378
8378
  const prefix = availablePrefixes.find((p) => p.id === selectedPrefixId);
8379
8379
  return prefix?.name ?? "";
8380
8380
  }, [availablePrefixes, selectedPrefixId]);
@@ -8406,8 +8406,8 @@ function CommentPopover({
8406
8406
  minute: "2-digit"
8407
8407
  }).format(date);
8408
8408
  };
8409
- const prevOpenRef = React22.useRef(open);
8410
- React22.useEffect(() => {
8409
+ const prevOpenRef = React27.useRef(open);
8410
+ React27.useEffect(() => {
8411
8411
  const wasOpen = prevOpenRef.current;
8412
8412
  prevOpenRef.current = open;
8413
8413
  if (wasOpen && !open) {
@@ -8430,7 +8430,7 @@ function CommentPopover({
8430
8430
  /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
8431
8431
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
8432
8432
  ] }),
8433
- /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
8433
+ /* @__PURE__ */ jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
8434
8434
  /* @__PURE__ */ jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
8435
8435
  /* @__PURE__ */ jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(
8436
8436
  Button,
@@ -8636,7 +8636,7 @@ function CalibrationTable({
8636
8636
  onAddComment,
8637
8637
  onAddEarlierWeek
8638
8638
  } = config;
8639
- const calculatedStartDate = React22.useMemo(() => {
8639
+ const calculatedStartDate = React27.useMemo(() => {
8640
8640
  if (startDate) return startDate;
8641
8641
  let earliest = null;
8642
8642
  for (const prefix of prefixes) {
@@ -8657,31 +8657,31 @@ function CalibrationTable({
8657
8657
  }
8658
8658
  return earliest ?? /* @__PURE__ */ new Date();
8659
8659
  }, [startDate, prefixes]);
8660
- const [additionalWeeks, setAdditionalWeeks] = React22.useState(0);
8661
- const weeks = React22.useMemo(() => {
8660
+ const [additionalWeeks, setAdditionalWeeks] = React27.useState(0);
8661
+ const weeks = React27.useMemo(() => {
8662
8662
  const start = new Date(calculatedStartDate);
8663
8663
  start.setDate(start.getDate() - additionalWeeks * 7);
8664
8664
  return generateWeeks(start, weekCount + additionalWeeks);
8665
8665
  }, [calculatedStartDate, weekCount, additionalWeeks]);
8666
- React22.useMemo(() => {
8666
+ React27.useMemo(() => {
8667
8667
  const currentWeek = weeks.find((w) => w.isCurrentWeek);
8668
8668
  return currentWeek ? getWeekKey(currentWeek.startDate) : null;
8669
8669
  }, [weeks]);
8670
- const [currentPage, setCurrentPage] = React22.useState(0);
8671
- const [pageSize, setPageSize] = React22.useState(defaultPageSize);
8672
- const [searchQuery, setSearchQuery] = React22.useState("");
8673
- const filteredPrefixes = React22.useMemo(() => {
8670
+ const [currentPage, setCurrentPage] = React27.useState(0);
8671
+ const [pageSize, setPageSize] = React27.useState(defaultPageSize);
8672
+ const [searchQuery, setSearchQuery] = React27.useState("");
8673
+ const filteredPrefixes = React27.useMemo(() => {
8674
8674
  if (!searchQuery) return prefixes;
8675
8675
  const query = searchQuery.toLowerCase();
8676
8676
  return prefixes.filter(
8677
8677
  (p) => p.name.toLowerCase().includes(query) || p.typeCode.toLowerCase().includes(query)
8678
8678
  );
8679
8679
  }, [prefixes, searchQuery]);
8680
- const paginatedPrefixes = React22.useMemo(() => {
8680
+ const paginatedPrefixes = React27.useMemo(() => {
8681
8681
  const start = currentPage * pageSize;
8682
8682
  return filteredPrefixes.slice(start, start + pageSize);
8683
8683
  }, [filteredPrefixes, currentPage, pageSize]);
8684
- React22.useMemo(
8684
+ React27.useMemo(
8685
8685
  () => canSubmitCalibration(prefixes),
8686
8686
  [prefixes]
8687
8687
  );
@@ -8705,7 +8705,7 @@ function CalibrationTable({
8705
8705
  }
8706
8706
  return allComments;
8707
8707
  };
8708
- const availablePrefixes = React22.useMemo(
8708
+ const availablePrefixes = React27.useMemo(
8709
8709
  () => prefixes.map((p) => ({ id: p.id, name: p.name })),
8710
8710
  [prefixes]
8711
8711
  );
@@ -8942,14 +8942,14 @@ function CommentDialog({
8942
8942
  open,
8943
8943
  onOpenChange
8944
8944
  }) {
8945
- const [selectedPrefixId, setSelectedPrefixId] = React22.useState("");
8946
- const [selectedWeekKey, setSelectedWeekKey] = React22.useState("");
8947
- const [commentText, setCommentText] = React22.useState("");
8948
- const currentWeek = React22.useMemo(
8945
+ const [selectedPrefixId, setSelectedPrefixId] = React27.useState("");
8946
+ const [selectedWeekKey, setSelectedWeekKey] = React27.useState("");
8947
+ const [commentText, setCommentText] = React27.useState("");
8948
+ const currentWeek = React27.useMemo(
8949
8949
  () => weeks.find((w) => w.isCurrentWeek),
8950
8950
  [weeks]
8951
8951
  );
8952
- React22.useEffect(() => {
8952
+ React27.useEffect(() => {
8953
8953
  if (open) {
8954
8954
  setSelectedPrefixId(prefixes[0]?.id ?? "");
8955
8955
  setSelectedWeekKey(currentWeek ? getWeekKey(currentWeek.startDate) : weeks[0] ? getWeekKey(weeks[0].startDate) : "");
@@ -9120,6 +9120,1315 @@ function SubmitCalibrationBar({
9120
9120
  );
9121
9121
  }
9122
9122
 
9123
+ // src/blocks/supplier-weekly-loading/types.ts
9124
+ function getLoadingElementStatusLabel(status) {
9125
+ switch (status) {
9126
+ case "loaded":
9127
+ return "Loaded";
9128
+ case "missing":
9129
+ return "Missing";
9130
+ case "moved":
9131
+ return "Moved to another delivery";
9132
+ case "addon":
9133
+ return "Add-on";
9134
+ default:
9135
+ return status;
9136
+ }
9137
+ }
9138
+ function getLoadingDeliveryStatusLabel(status) {
9139
+ switch (status) {
9140
+ case "planned":
9141
+ return "Planned";
9142
+ case "in_progress":
9143
+ return "In Progress";
9144
+ case "loaded":
9145
+ return "Loaded";
9146
+ case "shipped":
9147
+ return "Shipped";
9148
+ case "delivered":
9149
+ return "Delivered";
9150
+ case "cancelled":
9151
+ return "Cancelled";
9152
+ default:
9153
+ return status;
9154
+ }
9155
+ }
9156
+ function getDeliveryVisualState(delivery) {
9157
+ if (delivery.status === "shipped" || delivery.status === "delivered") {
9158
+ return "sent";
9159
+ }
9160
+ if (delivery.isReadyToUnload) {
9161
+ return "ready";
9162
+ }
9163
+ return "normal";
9164
+ }
9165
+ function getLoadingISOWeek(date) {
9166
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
9167
+ const dayNum = d.getUTCDay() || 7;
9168
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
9169
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
9170
+ return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
9171
+ }
9172
+ function getLoadingWeekKey(date) {
9173
+ const year = date.getFullYear();
9174
+ const weekNumber = getLoadingISOWeek(date);
9175
+ return `${year}-W${weekNumber.toString().padStart(2, "0")}`;
9176
+ }
9177
+ function generateLoadingWeek(date) {
9178
+ const monday = new Date(date);
9179
+ const day = monday.getDay();
9180
+ const diff = monday.getDate() - day + (day === 0 ? -6 : 1);
9181
+ monday.setDate(diff);
9182
+ monday.setHours(0, 0, 0, 0);
9183
+ const friday = new Date(monday);
9184
+ friday.setDate(monday.getDate() + 4);
9185
+ const today = /* @__PURE__ */ new Date();
9186
+ today.setHours(0, 0, 0, 0);
9187
+ const isCurrentWeek = monday <= today && today <= friday;
9188
+ const formatDate2 = (d) => {
9189
+ return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
9190
+ };
9191
+ return {
9192
+ weekKey: getLoadingWeekKey(monday),
9193
+ label: `W${getLoadingISOWeek(monday).toString().padStart(2, "0")}`,
9194
+ startDate: monday,
9195
+ endDate: friday,
9196
+ dateRange: `${formatDate2(monday)} - ${formatDate2(friday)}`,
9197
+ isCurrentWeek
9198
+ };
9199
+ }
9200
+ function groupDeliveriesByDay(deliveries) {
9201
+ const grouped = /* @__PURE__ */ new Map();
9202
+ for (let i = 1; i <= 5; i++) {
9203
+ grouped.set(i, []);
9204
+ }
9205
+ for (const delivery of deliveries) {
9206
+ const dayOfWeek = delivery.date.getDay();
9207
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9208
+ const dayDeliveries = grouped.get(dayOfWeek) ?? [];
9209
+ dayDeliveries.push(delivery);
9210
+ grouped.set(dayOfWeek, dayDeliveries);
9211
+ }
9212
+ }
9213
+ return grouped;
9214
+ }
9215
+ function getDayLabel(dayOfWeek) {
9216
+ const labels = {
9217
+ 1: "Monday",
9218
+ 2: "Tuesday",
9219
+ 3: "Wednesday",
9220
+ 4: "Thursday",
9221
+ 5: "Friday"
9222
+ };
9223
+ return labels[dayOfWeek] ?? "";
9224
+ }
9225
+ function getShortDayLabel(dayOfWeek) {
9226
+ const labels = {
9227
+ 1: "Mon",
9228
+ 2: "Tue",
9229
+ 3: "Wed",
9230
+ 4: "Thu",
9231
+ 5: "Fri"
9232
+ };
9233
+ return labels[dayOfWeek] ?? "";
9234
+ }
9235
+ function extractPrefixes(deliveries) {
9236
+ const prefixMap = /* @__PURE__ */ new Map();
9237
+ for (const delivery of deliveries) {
9238
+ const prefixCode = delivery.prefixScope ?? "GENERAL";
9239
+ if (!prefixMap.has(prefixCode)) {
9240
+ prefixMap.set(prefixCode, {
9241
+ id: prefixCode,
9242
+ name: prefixCode === "GENERAL" ? "General" : prefixCode,
9243
+ typeCode: prefixCode,
9244
+ supplierId: delivery.supplierId,
9245
+ supplierName: delivery.supplierName,
9246
+ totalDeliveries: 0,
9247
+ sentDeliveries: 0,
9248
+ hasRisk: false
9249
+ });
9250
+ }
9251
+ const prefix = prefixMap.get(prefixCode);
9252
+ prefix.totalDeliveries += 1;
9253
+ if (delivery.status === "shipped" || delivery.status === "delivered") {
9254
+ prefix.sentDeliveries += 1;
9255
+ }
9256
+ if (delivery.hasProductionRisk) {
9257
+ prefix.hasRisk = true;
9258
+ }
9259
+ }
9260
+ return Array.from(prefixMap.values());
9261
+ }
9262
+ function groupDeliveriesByPrefixAndDay(deliveries) {
9263
+ const grouped = /* @__PURE__ */ new Map();
9264
+ for (const delivery of deliveries) {
9265
+ const prefixCode = delivery.prefixScope ?? "GENERAL";
9266
+ const dayOfWeek = delivery.date.getDay();
9267
+ if (dayOfWeek < 1 || dayOfWeek > 5) continue;
9268
+ if (!grouped.has(prefixCode)) {
9269
+ const dayMap2 = /* @__PURE__ */ new Map();
9270
+ for (let i = 1; i <= 5; i++) {
9271
+ dayMap2.set(i, []);
9272
+ }
9273
+ grouped.set(prefixCode, dayMap2);
9274
+ }
9275
+ const dayMap = grouped.get(prefixCode);
9276
+ const dayDeliveries = dayMap.get(dayOfWeek) ?? [];
9277
+ dayDeliveries.push(delivery);
9278
+ dayMap.set(dayOfWeek, dayDeliveries);
9279
+ }
9280
+ return grouped;
9281
+ }
9282
+ function getLeftStrokeStyles(state, hasRisk, isHovered) {
9283
+ if (hasRisk) {
9284
+ return {
9285
+ stroke: "border-l-[3px] border-l-red-500",
9286
+ content: "text-foreground",
9287
+ progressBg: "bg-red-500",
9288
+ iconColor: "text-red-600 dark:text-red-400"
9289
+ };
9290
+ }
9291
+ switch (state) {
9292
+ case "sent":
9293
+ return {
9294
+ stroke: "border-l-[3px] border-l-green-500/50",
9295
+ content: "text-muted-foreground/60",
9296
+ progressBg: "bg-green-500",
9297
+ iconColor: "text-green-600 dark:text-green-400"
9298
+ };
9299
+ case "ready":
9300
+ return {
9301
+ stroke: "border-l-[3px] border-l-green-500",
9302
+ content: "text-foreground",
9303
+ progressBg: "bg-green-500",
9304
+ iconColor: "text-green-600 dark:text-green-400"
9305
+ };
9306
+ default:
9307
+ return {
9308
+ stroke: isHovered ? "border-l-[3px] border-l-primary/50" : "border-l-[3px] border-l-border",
9309
+ content: "text-foreground",
9310
+ progressBg: "bg-primary",
9311
+ iconColor: "text-muted-foreground"
9312
+ };
9313
+ }
9314
+ }
9315
+ function DeliveryBadge({
9316
+ delivery,
9317
+ onClick,
9318
+ className
9319
+ }) {
9320
+ const [isHovered, setIsHovered] = React27.useState(false);
9321
+ const hasComments = delivery.comments.length > 0;
9322
+ const visualState = getDeliveryVisualState(delivery);
9323
+ const styles = getLeftStrokeStyles(visualState, delivery.hasProductionRisk ?? false, isHovered);
9324
+ const prefixTitle = React27.useMemo(() => {
9325
+ const prefixSet = /* @__PURE__ */ new Set();
9326
+ if (delivery.elements && delivery.elements.length > 0) {
9327
+ for (const element of delivery.elements) {
9328
+ if (element.prefix) {
9329
+ prefixSet.add(element.prefix);
9330
+ }
9331
+ }
9332
+ }
9333
+ if (prefixSet.size === 0 && delivery.prefixScope) {
9334
+ prefixSet.add(delivery.prefixScope);
9335
+ }
9336
+ const prefixes = Array.from(prefixSet);
9337
+ if (prefixes.length === 0) {
9338
+ return delivery.label;
9339
+ }
9340
+ if (prefixes.length > 3) {
9341
+ return `${prefixes.slice(0, 3).join(" \xB7 ")} \xB7 +${prefixes.length - 3}`;
9342
+ }
9343
+ return prefixes.join(" \xB7 ");
9344
+ }, [delivery]);
9345
+ const productionProgress = React27.useMemo(() => {
9346
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0 && delivery.totalTons > 0) {
9347
+ return Math.min(delivery.producedTons / delivery.totalTons * 100, 100);
9348
+ }
9349
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
9350
+ return Math.min(delivery.producedCount / delivery.totalCount * 100, 100);
9351
+ }
9352
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
9353
+ return Math.min(delivery.loadedCount / delivery.totalCount * 100, 100);
9354
+ }
9355
+ return 0;
9356
+ }, [delivery]);
9357
+ const productionDisplay = React27.useMemo(() => {
9358
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
9359
+ return `${delivery.producedTons}/${delivery.totalTons}t`;
9360
+ }
9361
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
9362
+ return `${delivery.producedCount}/${delivery.totalCount}`;
9363
+ }
9364
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
9365
+ return `${delivery.loadedCount}/${delivery.totalCount}`;
9366
+ }
9367
+ return null;
9368
+ }, [delivery]);
9369
+ const handleClick = (e) => {
9370
+ e.stopPropagation();
9371
+ onClick?.();
9372
+ };
9373
+ const handleKeyDown = (e) => {
9374
+ if (e.key === "Enter" || e.key === " ") {
9375
+ e.preventDefault();
9376
+ e.stopPropagation();
9377
+ onClick?.();
9378
+ }
9379
+ };
9380
+ return /* @__PURE__ */ jsxs(
9381
+ "button",
9382
+ {
9383
+ type: "button",
9384
+ onClick: handleClick,
9385
+ onKeyDown: handleKeyDown,
9386
+ onMouseEnter: () => setIsHovered(true),
9387
+ onMouseLeave: () => setIsHovered(false),
9388
+ className: cn(
9389
+ // Position relative for comment dot
9390
+ "relative",
9391
+ // Full-width in cell, 90° corners
9392
+ "w-full rounded-none",
9393
+ // Sizing using Quantum tokens:
9394
+ // - h-[80px] card height
9395
+ // - px-6 = 24px horizontal (j3m.spacing.l)
9396
+ // - py-4 = 16px vertical (j3m.spacing.m)
9397
+ "h-[80px] px-6 py-4",
9398
+ // Layout
9399
+ "flex items-center",
9400
+ // Card base: white background, complete border
9401
+ "bg-background border border-border",
9402
+ // Left stroke for status
9403
+ styles.stroke,
9404
+ // Interactive states
9405
+ "cursor-pointer transition-all duration-200 ease-out",
9406
+ "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
9407
+ "active:translate-y-0 active:shadow-sm",
9408
+ // Focus state
9409
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
9410
+ // Greyed out for sent state
9411
+ visualState === "sent" && "opacity-60",
9412
+ className
9413
+ ),
9414
+ children: [
9415
+ hasComments && /* @__PURE__ */ jsx(
9416
+ "span",
9417
+ {
9418
+ className: "absolute -top-1 -right-1 h-3 w-3 rounded-full bg-primary ring-2 ring-background",
9419
+ "aria-label": "Has comments"
9420
+ }
9421
+ ),
9422
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center gap-3 min-w-0 flex-1 overflow-hidden", children: [
9423
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 overflow-hidden", children: [
9424
+ /* @__PURE__ */ jsx("span", { className: cn("text-sm font-semibold truncate", styles.content), children: prefixTitle }),
9425
+ visualState === "sent" && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
9426
+ delivery.hasProductionRisk && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
9427
+ delivery.supplierName && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground truncate ml-auto", children: delivery.supplierName })
9428
+ ] }),
9429
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9430
+ /* @__PURE__ */ jsx(Factory, { className: cn("h-3.5 w-3.5 shrink-0", styles.iconColor) }),
9431
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-1.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsx(
9432
+ "div",
9433
+ {
9434
+ className: cn("h-full rounded-full transition-all", styles.progressBg),
9435
+ style: { width: `${productionProgress}%` }
9436
+ }
9437
+ ) }),
9438
+ productionDisplay && /* @__PURE__ */ jsx("span", { className: cn(
9439
+ "text-xs tabular-nums font-medium shrink-0",
9440
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
9441
+ ), children: productionDisplay })
9442
+ ] })
9443
+ ] })
9444
+ ]
9445
+ }
9446
+ );
9447
+ }
9448
+ function WeeklyLoadingView({
9449
+ week,
9450
+ deliveries,
9451
+ onDeliveryClick,
9452
+ onWeekChange,
9453
+ onDayCommentClick,
9454
+ showNavigation = true,
9455
+ className
9456
+ }) {
9457
+ const weekDays = React27.useMemo(() => {
9458
+ const days = [];
9459
+ for (let i = 0; i < 5; i++) {
9460
+ const date = addDays(week.startDate, i);
9461
+ days.push({
9462
+ date,
9463
+ dayOfWeek: i + 1,
9464
+ isToday: isToday(date)
9465
+ });
9466
+ }
9467
+ return days;
9468
+ }, [week.startDate]);
9469
+ const deliveriesByDay = React27.useMemo(() => {
9470
+ const grouped = /* @__PURE__ */ new Map();
9471
+ for (let i = 1; i <= 5; i++) {
9472
+ grouped.set(i, []);
9473
+ }
9474
+ for (const delivery of deliveries) {
9475
+ const dayOfWeek = delivery.date.getDay();
9476
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9477
+ const dayDeliveries = grouped.get(dayOfWeek) ?? [];
9478
+ dayDeliveries.push(delivery);
9479
+ grouped.set(dayOfWeek, dayDeliveries);
9480
+ }
9481
+ }
9482
+ return grouped;
9483
+ }, [deliveries]);
9484
+ const commentCountByDay = React27.useMemo(() => {
9485
+ const counts = /* @__PURE__ */ new Map();
9486
+ for (let i = 1; i <= 5; i++) {
9487
+ counts.set(i, 0);
9488
+ }
9489
+ for (const delivery of deliveries) {
9490
+ const dayOfWeek = delivery.date.getDay();
9491
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9492
+ const current = counts.get(dayOfWeek) ?? 0;
9493
+ counts.set(dayOfWeek, current + delivery.comments.length);
9494
+ }
9495
+ }
9496
+ return counts;
9497
+ }, [deliveries]);
9498
+ const totalDeliveries = deliveries.length;
9499
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col", className), children: [
9500
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 border-b border-border p-4 lg:flex-row lg:items-center lg:justify-between", children: [
9501
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
9502
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9503
+ /* @__PURE__ */ jsx("span", { className: cn(
9504
+ "text-2xl font-bold tabular-nums",
9505
+ week.isCurrentWeek && "text-primary"
9506
+ ), children: week.label }),
9507
+ week.isCurrentWeek && /* @__PURE__ */ jsxs("span", { className: "relative flex h-2.5 w-2.5", children: [
9508
+ /* @__PURE__ */ jsx("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75" }),
9509
+ /* @__PURE__ */ jsx("span", { className: "relative inline-flex rounded-full h-2.5 w-2.5 bg-primary" })
9510
+ ] })
9511
+ ] }),
9512
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
9513
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: week.dateRange }),
9514
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
9515
+ totalDeliveries,
9516
+ " ",
9517
+ totalDeliveries === 1 ? "delivery" : "deliveries"
9518
+ ] })
9519
+ ] })
9520
+ ] }),
9521
+ showNavigation && onWeekChange && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9522
+ /* @__PURE__ */ jsxs(
9523
+ Button,
9524
+ {
9525
+ variant: "outline",
9526
+ size: "icon",
9527
+ className: "h-8 w-8",
9528
+ onClick: () => onWeekChange("prev"),
9529
+ children: [
9530
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
9531
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Previous week" })
9532
+ ]
9533
+ }
9534
+ ),
9535
+ /* @__PURE__ */ jsx(
9536
+ Button,
9537
+ {
9538
+ variant: "outline",
9539
+ size: "sm",
9540
+ onClick: () => {
9541
+ },
9542
+ children: "Today"
9543
+ }
9544
+ ),
9545
+ /* @__PURE__ */ jsxs(
9546
+ Button,
9547
+ {
9548
+ variant: "outline",
9549
+ size: "icon",
9550
+ className: "h-8 w-8",
9551
+ onClick: () => onWeekChange("next"),
9552
+ children: [
9553
+ /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }),
9554
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Next week" })
9555
+ ]
9556
+ }
9557
+ )
9558
+ ] })
9559
+ ] }),
9560
+ /* @__PURE__ */ jsxs(ScrollArea, { className: "flex-1", children: [
9561
+ /* @__PURE__ */ jsxs("div", { className: "hidden sm:block", children: [
9562
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-5 border-b border-border bg-muted/30", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9563
+ const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9564
+ return /* @__PURE__ */ jsxs(
9565
+ "div",
9566
+ {
9567
+ className: cn(
9568
+ // Relative for positioning comment button
9569
+ "relative",
9570
+ // Compact padding: py-2 px-3 (j3m.spacing.xs / j3m.spacing.s)
9571
+ "flex items-center justify-center gap-2 py-2 px-3",
9572
+ dayIsToday && "bg-primary/5"
9573
+ ),
9574
+ children: [
9575
+ /* @__PURE__ */ jsx("span", { className: cn(
9576
+ "text-xs font-medium uppercase tracking-wide",
9577
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9578
+ ), children: getShortDayLabel(dayOfWeek) }),
9579
+ /* @__PURE__ */ jsx("span", { className: cn(
9580
+ "text-base font-semibold tabular-nums",
9581
+ dayIsToday ? "text-primary" : "text-foreground"
9582
+ ), children: date.getDate() }),
9583
+ /* @__PURE__ */ jsxs(
9584
+ Button,
9585
+ {
9586
+ variant: "ghost",
9587
+ size: "icon",
9588
+ className: cn(
9589
+ "absolute top-1 right-1 h-7 w-7",
9590
+ dayCommentCount > 0 && "text-primary"
9591
+ ),
9592
+ onClick: (e) => {
9593
+ e.stopPropagation();
9594
+ onDayCommentClick?.(dayOfWeek, date);
9595
+ },
9596
+ children: [
9597
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
9598
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-4 w-4" }),
9599
+ dayCommentCount > 0 && /* @__PURE__ */ jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9600
+ ] }),
9601
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: dayCommentCount > 0 ? `${dayCommentCount} comments on ${getShortDayLabel(dayOfWeek)}` : `Add comment for ${getShortDayLabel(dayOfWeek)}` })
9602
+ ]
9603
+ }
9604
+ )
9605
+ ]
9606
+ },
9607
+ dayOfWeek
9608
+ );
9609
+ }) }),
9610
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-5", children: weekDays.map(({ dayOfWeek, isToday: dayIsToday }) => {
9611
+ const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9612
+ return /* @__PURE__ */ jsx(
9613
+ "div",
9614
+ {
9615
+ className: cn(
9616
+ // Column padding: p-3 = 12px (j3m.spacing.s)
9617
+ "flex flex-col p-3",
9618
+ dayIsToday && "bg-primary/5"
9619
+ ),
9620
+ children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsx(
9621
+ DeliveryBadge,
9622
+ {
9623
+ delivery,
9624
+ onClick: () => onDeliveryClick?.(delivery)
9625
+ },
9626
+ delivery.id
9627
+ )) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-6 text-sm text-muted-foreground/40", children: "\u2014" }) })
9628
+ },
9629
+ dayOfWeek
9630
+ );
9631
+ }) })
9632
+ ] }),
9633
+ /* @__PURE__ */ jsx("div", { className: "sm:hidden divide-y divide-border", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9634
+ const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9635
+ const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9636
+ return /* @__PURE__ */ jsxs(
9637
+ "div",
9638
+ {
9639
+ className: cn(
9640
+ dayIsToday && "bg-primary/5"
9641
+ ),
9642
+ children: [
9643
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
9644
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9645
+ /* @__PURE__ */ jsx("span", { className: cn(
9646
+ "text-xs font-medium uppercase",
9647
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9648
+ ), children: getShortDayLabel(dayOfWeek) }),
9649
+ /* @__PURE__ */ jsx("span", { className: cn(
9650
+ "text-base font-semibold tabular-nums",
9651
+ dayIsToday ? "text-primary" : "text-foreground"
9652
+ ), children: date.getDate() }),
9653
+ dayIsToday && /* @__PURE__ */ jsx("span", { className: "text-xs text-primary font-medium", children: "Today" })
9654
+ ] }),
9655
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9656
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
9657
+ dayDeliveries.length,
9658
+ " ",
9659
+ dayDeliveries.length === 1 ? "delivery" : "deliveries"
9660
+ ] }),
9661
+ /* @__PURE__ */ jsxs(
9662
+ Button,
9663
+ {
9664
+ variant: "ghost",
9665
+ size: "icon",
9666
+ className: cn(
9667
+ "h-7 w-7",
9668
+ dayCommentCount > 0 && "text-primary"
9669
+ ),
9670
+ onClick: (e) => {
9671
+ e.stopPropagation();
9672
+ onDayCommentClick?.(dayOfWeek, date);
9673
+ },
9674
+ children: [
9675
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
9676
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-4 w-4" }),
9677
+ dayCommentCount > 0 && /* @__PURE__ */ jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9678
+ ] }),
9679
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Comments" })
9680
+ ]
9681
+ }
9682
+ )
9683
+ ] })
9684
+ ] }),
9685
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 p-3 pt-0", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsx(
9686
+ DeliveryBadge,
9687
+ {
9688
+ delivery,
9689
+ onClick: () => onDeliveryClick?.(delivery)
9690
+ },
9691
+ delivery.id
9692
+ )) : /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground/40 py-4 text-center", children: "\u2014" }) })
9693
+ ]
9694
+ },
9695
+ dayOfWeek
9696
+ );
9697
+ }) })
9698
+ ] })
9699
+ ] });
9700
+ }
9701
+ function getStatusBadgeVariant2(status) {
9702
+ switch (status) {
9703
+ case "shipped":
9704
+ case "delivered":
9705
+ return "default";
9706
+ case "loaded":
9707
+ case "in_progress":
9708
+ return "secondary";
9709
+ case "cancelled":
9710
+ return "destructive";
9711
+ case "planned":
9712
+ default:
9713
+ return "outline";
9714
+ }
9715
+ }
9716
+ function getStatusBadgeClasses2(status) {
9717
+ switch (status) {
9718
+ case "shipped":
9719
+ case "delivered":
9720
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
9721
+ case "loaded":
9722
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
9723
+ case "in_progress":
9724
+ return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
9725
+ case "cancelled":
9726
+ return "";
9727
+ case "planned":
9728
+ default:
9729
+ return "border-muted-foreground/50 text-muted-foreground";
9730
+ }
9731
+ }
9732
+ function getElementStatusBadgeClasses(status) {
9733
+ switch (status) {
9734
+ case "loaded":
9735
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
9736
+ case "missing":
9737
+ return "border-muted-foreground/50 text-muted-foreground bg-muted/50";
9738
+ case "moved":
9739
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
9740
+ case "addon":
9741
+ return "border-purple-500 text-purple-600 bg-purple-50 dark:bg-purple-950/50";
9742
+ default:
9743
+ return "border-muted-foreground/50 text-muted-foreground";
9744
+ }
9745
+ }
9746
+ function getElementRowBg(status) {
9747
+ switch (status) {
9748
+ case "loaded":
9749
+ return "bg-green-50/30 dark:bg-green-950/10";
9750
+ case "missing":
9751
+ return "bg-muted/30";
9752
+ case "moved":
9753
+ return "bg-blue-50/30 dark:bg-blue-950/10";
9754
+ case "addon":
9755
+ return "bg-purple-50/30 dark:bg-purple-950/10";
9756
+ default:
9757
+ return "";
9758
+ }
9759
+ }
9760
+ function AddCommentDialog({
9761
+ open,
9762
+ onOpenChange,
9763
+ delivery,
9764
+ weekId,
9765
+ onAddComment
9766
+ }) {
9767
+ const [commentText, setCommentText] = React27.useState("");
9768
+ const handleSubmit = () => {
9769
+ if (commentText.trim() && onAddComment) {
9770
+ onAddComment({
9771
+ author: "Current User",
9772
+ // Would come from auth context in real app
9773
+ text: commentText.trim(),
9774
+ context: "pre_unloading",
9775
+ weekId,
9776
+ deliveryId: delivery.id,
9777
+ supplierId: delivery.supplierId,
9778
+ supplierName: delivery.supplierName,
9779
+ prefixId: delivery.prefixScope,
9780
+ prefixName: delivery.prefixScope
9781
+ });
9782
+ setCommentText("");
9783
+ onOpenChange(false);
9784
+ }
9785
+ };
9786
+ const handleKeyDown = (e) => {
9787
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
9788
+ e.preventDefault();
9789
+ handleSubmit();
9790
+ }
9791
+ };
9792
+ React27.useEffect(() => {
9793
+ if (!open) {
9794
+ setCommentText("");
9795
+ }
9796
+ }, [open]);
9797
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-md", children: [
9798
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
9799
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Add pre-unloading note" }),
9800
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
9801
+ "Add a note for ",
9802
+ /* @__PURE__ */ jsx("strong", { children: delivery.label }),
9803
+ " (",
9804
+ delivery.supplierName,
9805
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`,
9806
+ ")."
9807
+ ] })
9808
+ ] }),
9809
+ /* @__PURE__ */ jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
9810
+ /* @__PURE__ */ jsx(Label2, { htmlFor: "comment-text", className: "text-sm font-medium", children: "Note" }),
9811
+ /* @__PURE__ */ jsx(
9812
+ Textarea,
9813
+ {
9814
+ id: "comment-text",
9815
+ placeholder: "Add a note before unloading...",
9816
+ value: commentText,
9817
+ onChange: (e) => setCommentText(e.target.value),
9818
+ onKeyDown: handleKeyDown,
9819
+ className: "min-h-[120px] text-base resize-none",
9820
+ autoFocus: true
9821
+ }
9822
+ ),
9823
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "\u2318+Enter to save" })
9824
+ ] }) }),
9825
+ /* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
9826
+ /* @__PURE__ */ jsx(
9827
+ Button,
9828
+ {
9829
+ variant: "ghost",
9830
+ onClick: () => onOpenChange(false),
9831
+ children: "Cancel"
9832
+ }
9833
+ ),
9834
+ /* @__PURE__ */ jsxs(
9835
+ Button,
9836
+ {
9837
+ onClick: handleSubmit,
9838
+ disabled: !commentText.trim(),
9839
+ className: "gap-1.5",
9840
+ children: [
9841
+ /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" }),
9842
+ "Save note"
9843
+ ]
9844
+ }
9845
+ )
9846
+ ] })
9847
+ ] }) });
9848
+ }
9849
+ function CommentsSection({
9850
+ comments,
9851
+ delivery,
9852
+ weekId,
9853
+ onAddComment
9854
+ }) {
9855
+ const [viewCommentsOpen, setViewCommentsOpen] = React27.useState(true);
9856
+ const [addDialogOpen, setAddDialogOpen] = React27.useState(false);
9857
+ const formatDate2 = (date) => {
9858
+ return new Intl.DateTimeFormat("en-US", {
9859
+ month: "short",
9860
+ day: "numeric",
9861
+ hour: "numeric",
9862
+ minute: "2-digit"
9863
+ }).format(date);
9864
+ };
9865
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9866
+ /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
9867
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9868
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9869
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-4 w-4 text-muted-foreground" }),
9870
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: "Notes before unloading" }),
9871
+ comments.length > 0 && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-[10px] h-5", children: comments.length })
9872
+ ] }),
9873
+ /* @__PURE__ */ jsxs(
9874
+ Button,
9875
+ {
9876
+ variant: "outline",
9877
+ size: "sm",
9878
+ className: "gap-1.5 h-9",
9879
+ onClick: () => setAddDialogOpen(true),
9880
+ children: [
9881
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
9882
+ "Add note"
9883
+ ]
9884
+ }
9885
+ )
9886
+ ] }),
9887
+ comments.length > 0 ? /* @__PURE__ */ jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
9888
+ /* @__PURE__ */ jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
9889
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: viewCommentsOpen ? "Hide comments" : "Show comments" }),
9890
+ /* @__PURE__ */ jsx(ChevronDown, { className: cn(
9891
+ "h-4 w-4 transition-transform duration-200",
9892
+ viewCommentsOpen && "rotate-180"
9893
+ ) })
9894
+ ] }) }),
9895
+ /* @__PURE__ */ jsx(CollapsibleContent2, { className: "space-y-2 pt-2", children: comments.map((comment) => /* @__PURE__ */ jsxs("div", { className: "rounded-lg bg-muted/50 p-3 space-y-1", children: [
9896
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9897
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9898
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: comment.author }),
9899
+ comment.supplierName && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-[9px] px-1.5 py-0 h-4", children: comment.prefixName ? `${comment.supplierName} - ${comment.prefixName}` : comment.supplierName })
9900
+ ] }),
9901
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", children: formatDate2(comment.createdAt) })
9902
+ ] }),
9903
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: comment.text })
9904
+ ] }, comment.id)) })
9905
+ ] }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground", children: "No pre-unloading notes yet. Add notes before confirming the load." })
9906
+ ] }),
9907
+ /* @__PURE__ */ jsx(
9908
+ AddCommentDialog,
9909
+ {
9910
+ open: addDialogOpen,
9911
+ onOpenChange: setAddDialogOpen,
9912
+ delivery,
9913
+ weekId,
9914
+ onAddComment
9915
+ }
9916
+ )
9917
+ ] });
9918
+ }
9919
+ function getDeliveryHeaderStyles(state, hasRisk) {
9920
+ if (hasRisk) {
9921
+ return {
9922
+ iconBg: "bg-red-100 dark:bg-red-950/50",
9923
+ iconColor: "text-red-600 dark:text-red-400"
9924
+ };
9925
+ }
9926
+ switch (state) {
9927
+ case "sent":
9928
+ return {
9929
+ iconBg: "bg-green-100 dark:bg-green-950/50",
9930
+ iconColor: "text-green-600 dark:text-green-400"
9931
+ };
9932
+ case "ready":
9933
+ return {
9934
+ iconBg: "bg-green-100 dark:bg-green-950/50",
9935
+ iconColor: "text-green-600 dark:text-green-400"
9936
+ };
9937
+ default:
9938
+ return {
9939
+ iconBg: "bg-muted",
9940
+ iconColor: "text-muted-foreground"
9941
+ };
9942
+ }
9943
+ }
9944
+ function DeliveryDetailPage({
9945
+ delivery,
9946
+ week,
9947
+ suppliers,
9948
+ userRole,
9949
+ currentSupplierId,
9950
+ onBack,
9951
+ onAddComment,
9952
+ onConfirmLoad
9953
+ }) {
9954
+ const visualState = getDeliveryVisualState(delivery);
9955
+ const headerStyles = getDeliveryHeaderStyles(visualState, delivery.hasProductionRisk ?? false);
9956
+ const loadedCount = delivery.loadedCount ?? delivery.elements.filter((e) => e.status === "loaded").length;
9957
+ const totalCount = delivery.totalCount ?? delivery.elements.length;
9958
+ const loadedPercent = totalCount > 0 ? Math.round(loadedCount / totalCount * 100) : 0;
9959
+ const producedCount = delivery.producedCount ?? loadedCount;
9960
+ const producedPercent = totalCount > 0 ? Math.round(producedCount / totalCount * 100) : 0;
9961
+ const elementsByStatus = React27.useMemo(() => {
9962
+ const loaded = delivery.elements.filter((e) => e.status === "loaded");
9963
+ const missing = delivery.elements.filter((e) => e.status === "missing");
9964
+ const moved = delivery.elements.filter((e) => e.status === "moved");
9965
+ const addons = delivery.elements.filter((e) => e.status === "addon");
9966
+ return { loaded, missing, moved, addons };
9967
+ }, [delivery.elements]);
9968
+ const preUnloadingComments = delivery.comments.filter((c) => c.context === "pre_unloading");
9969
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
9970
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 px-4 py-3 border-b bg-background sticky top-0 z-10", children: /* @__PURE__ */ jsxs(
9971
+ Button,
9972
+ {
9973
+ variant: "ghost",
9974
+ size: "sm",
9975
+ className: "gap-1 -ml-2",
9976
+ onClick: onBack,
9977
+ children: [
9978
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
9979
+ "Back"
9980
+ ]
9981
+ }
9982
+ ) }),
9983
+ /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsxs("div", { className: "px-4 pb-6 space-y-6", children: [
9984
+ /* @__PURE__ */ jsxs("section", { className: "pt-4 space-y-4", children: [
9985
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
9986
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
9987
+ /* @__PURE__ */ jsx("div", { className: cn(
9988
+ "flex items-center justify-center h-12 w-12 rounded-xl shrink-0",
9989
+ headerStyles.iconBg
9990
+ ), children: /* @__PURE__ */ jsx(Truck, { className: cn("h-6 w-6", headerStyles.iconColor) }) }),
9991
+ /* @__PURE__ */ jsxs("div", { children: [
9992
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9993
+ /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: delivery.label }),
9994
+ visualState === "sent" && /* @__PURE__ */ jsx(Check, { className: "h-5 w-5 text-green-600 dark:text-green-400" }),
9995
+ delivery.hasProductionRisk && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-5 w-5 text-red-500" })
9996
+ ] }),
9997
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
9998
+ delivery.supplierName,
9999
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
10000
+ ] })
10001
+ ] })
10002
+ ] }),
10003
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-1.5", children: [
10004
+ /* @__PURE__ */ jsx(
10005
+ Badge,
10006
+ {
10007
+ variant: getStatusBadgeVariant2(delivery.status),
10008
+ className: cn("shrink-0", getStatusBadgeClasses2(delivery.status)),
10009
+ children: getLoadingDeliveryStatusLabel(delivery.status)
10010
+ }
10011
+ ),
10012
+ delivery.isReadyToUnload && /* @__PURE__ */ jsx(
10013
+ Badge,
10014
+ {
10015
+ variant: "outline",
10016
+ className: "bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
10017
+ children: "Ready to unload"
10018
+ }
10019
+ )
10020
+ ] })
10021
+ ] }),
10022
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border-l-2 border-l-red-500 bg-red-50/50 dark:bg-red-950/30 p-3", children: [
10023
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10024
+ /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-red-600 dark:text-red-400 shrink-0" }),
10025
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-red-700 dark:text-red-400", children: "Production delay risk" })
10026
+ ] }),
10027
+ delivery.riskReason && /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600 dark:text-red-400 mt-1 ml-6", children: delivery.riskReason })
10028
+ ] }),
10029
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4 text-sm text-muted-foreground", children: [
10030
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
10031
+ /* @__PURE__ */ jsx(Calendar$1, { className: "h-4 w-4" }),
10032
+ /* @__PURE__ */ jsx("span", { children: delivery.date.toLocaleDateString("en-US", {
10033
+ weekday: "short",
10034
+ month: "short",
10035
+ day: "numeric"
10036
+ }) })
10037
+ ] }),
10038
+ delivery.destination && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
10039
+ /* @__PURE__ */ jsx(MapPin, { className: "h-4 w-4" }),
10040
+ /* @__PURE__ */ jsx("span", { children: delivery.destination })
10041
+ ] })
10042
+ ] }),
10043
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg bg-muted/50 p-4 space-y-3", children: [
10044
+ (delivery.producedCount !== void 0 || delivery.producedTons !== void 0) && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10045
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
10046
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Production" }),
10047
+ /* @__PURE__ */ jsxs("span", { className: cn(
10048
+ "text-sm font-semibold tabular-nums",
10049
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : ""
10050
+ ), children: [
10051
+ delivery.producedTons !== void 0 && delivery.totalTons !== void 0 ? `${delivery.producedTons} / ${delivery.totalTons} tons` : `Produced ${producedCount} / ${totalCount}`,
10052
+ delivery.isReadyToUnload && " \u2713"
10053
+ ] })
10054
+ ] }),
10055
+ /* @__PURE__ */ jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsx(
10056
+ "div",
10057
+ {
10058
+ className: cn(
10059
+ "h-full rounded-full transition-all",
10060
+ delivery.isReadyToUnload ? "bg-green-500" : delivery.hasProductionRisk ? "bg-red-500" : "bg-amber-500"
10061
+ ),
10062
+ style: { width: `${producedPercent}%` }
10063
+ }
10064
+ ) })
10065
+ ] }),
10066
+ /* @__PURE__ */ jsx(Separator, { className: "my-2" }),
10067
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10068
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
10069
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Loading Progress" }),
10070
+ /* @__PURE__ */ jsxs("span", { className: "text-sm font-semibold tabular-nums", children: [
10071
+ "Loaded ",
10072
+ loadedCount,
10073
+ " / ",
10074
+ totalCount
10075
+ ] })
10076
+ ] }),
10077
+ /* @__PURE__ */ jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsx(
10078
+ "div",
10079
+ {
10080
+ className: cn(
10081
+ "h-full rounded-full transition-all",
10082
+ loadedPercent === 100 ? "bg-green-500" : "bg-primary"
10083
+ ),
10084
+ style: { width: `${loadedPercent}%` }
10085
+ }
10086
+ ) }),
10087
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-wrap text-xs", children: [
10088
+ elementsByStatus.loaded.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-green-600 dark:text-green-400", children: [
10089
+ elementsByStatus.loaded.length,
10090
+ " Loaded"
10091
+ ] }),
10092
+ elementsByStatus.missing.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
10093
+ elementsByStatus.missing.length,
10094
+ " Missing"
10095
+ ] }),
10096
+ elementsByStatus.moved.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-blue-600 dark:text-blue-400", children: [
10097
+ elementsByStatus.moved.length,
10098
+ " Moved"
10099
+ ] }),
10100
+ elementsByStatus.addons.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-purple-600 dark:text-purple-400", children: [
10101
+ elementsByStatus.addons.length,
10102
+ " Add-on"
10103
+ ] })
10104
+ ] })
10105
+ ] })
10106
+ ] })
10107
+ ] }),
10108
+ delivery.elements.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
10109
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10110
+ /* @__PURE__ */ jsx(Package, { className: "h-4 w-4 text-muted-foreground" }),
10111
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: "Elements to Unload" }),
10112
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
10113
+ delivery.elements.length,
10114
+ " total"
10115
+ ] })
10116
+ ] }),
10117
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ jsxs(Table, { children: [
10118
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { className: "bg-sidebar hover:bg-sidebar", children: [
10119
+ /* @__PURE__ */ jsx(TableHead, { className: "font-semibold", children: "Prefix" }),
10120
+ /* @__PURE__ */ jsx(TableHead, { className: "font-semibold", children: "Type" }),
10121
+ /* @__PURE__ */ jsx(TableHead, { className: "font-semibold text-right", children: "Weight" }),
10122
+ /* @__PURE__ */ jsx(TableHead, { className: "font-semibold text-right", children: "Size (m\xB2)" }),
10123
+ /* @__PURE__ */ jsx(TableHead, { className: "font-semibold text-center", children: "Status" })
10124
+ ] }) }),
10125
+ /* @__PURE__ */ jsx(TableBody, { children: delivery.elements.map((element) => /* @__PURE__ */ jsxs(
10126
+ TableRow,
10127
+ {
10128
+ className: getElementRowBg(element.status),
10129
+ children: [
10130
+ /* @__PURE__ */ jsx(TableCell, { className: "font-medium", children: element.prefix }),
10131
+ /* @__PURE__ */ jsx(TableCell, { children: element.type }),
10132
+ /* @__PURE__ */ jsx(TableCell, { className: "text-right tabular-nums", children: element.weight ? /* @__PURE__ */ jsxs("span", { children: [
10133
+ element.weight,
10134
+ " ",
10135
+ element.weightUnit || "kg"
10136
+ ] }) : "\u2014" }),
10137
+ /* @__PURE__ */ jsx(TableCell, { className: "text-right tabular-nums", children: element.sizeSqm ?? "\u2014" }),
10138
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1", children: [
10139
+ /* @__PURE__ */ jsx(
10140
+ Badge,
10141
+ {
10142
+ variant: "outline",
10143
+ className: cn(
10144
+ "text-[10px] h-5",
10145
+ getElementStatusBadgeClasses(element.status)
10146
+ ),
10147
+ children: getLoadingElementStatusLabel(element.status)
10148
+ }
10149
+ ),
10150
+ element.status === "moved" && element.actualDeliveryLabel && /* @__PURE__ */ jsxs("span", { className: "text-[9px] text-blue-600 dark:text-blue-400", children: [
10151
+ "\u2192 ",
10152
+ element.actualDeliveryLabel
10153
+ ] }),
10154
+ element.status === "addon" && element.originalDeliveryLabel && /* @__PURE__ */ jsxs("span", { className: "text-[9px] text-purple-600 dark:text-purple-400", children: [
10155
+ "from ",
10156
+ element.originalDeliveryLabel
10157
+ ] })
10158
+ ] }) })
10159
+ ]
10160
+ },
10161
+ element.id
10162
+ )) })
10163
+ ] }) })
10164
+ ] }),
10165
+ /* @__PURE__ */ jsx(
10166
+ CommentsSection,
10167
+ {
10168
+ comments: preUnloadingComments,
10169
+ delivery,
10170
+ weekId: week.weekKey,
10171
+ onAddComment
10172
+ }
10173
+ ),
10174
+ onConfirmLoad && /* @__PURE__ */ jsxs("section", { className: "pt-4", children: [
10175
+ /* @__PURE__ */ jsx(
10176
+ Button,
10177
+ {
10178
+ className: "w-full h-12 text-base",
10179
+ onClick: () => onConfirmLoad(delivery.id),
10180
+ children: "Start Loading"
10181
+ }
10182
+ ),
10183
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground text-center mt-2", children: "Comments are saved independently." })
10184
+ ] })
10185
+ ] }) })
10186
+ ] });
10187
+ }
10188
+ function SupplierWeeklyLoading({
10189
+ week,
10190
+ deliveries,
10191
+ suppliers,
10192
+ userRole,
10193
+ currentSupplierId,
10194
+ onDeliveryClick,
10195
+ onBack,
10196
+ onAddComment,
10197
+ onConfirmLoad,
10198
+ onWeekChange,
10199
+ showNavigation = true,
10200
+ bordered = true,
10201
+ className
10202
+ }) {
10203
+ const [selectedDelivery, setSelectedDelivery] = React27.useState(null);
10204
+ const [sheetOpen, setSheetOpen] = React27.useState(false);
10205
+ const handleDeliveryClick = (delivery) => {
10206
+ setSelectedDelivery(delivery);
10207
+ setSheetOpen(true);
10208
+ onDeliveryClick?.(delivery);
10209
+ };
10210
+ const handleSheetClose = () => {
10211
+ setSheetOpen(false);
10212
+ setTimeout(() => setSelectedDelivery(null), 200);
10213
+ onBack?.();
10214
+ };
10215
+ const Wrapper = bordered ? Card : "div";
10216
+ const Content14 = bordered ? CardContent : "div";
10217
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
10218
+ /* @__PURE__ */ jsx(
10219
+ Wrapper,
10220
+ {
10221
+ className: cn(
10222
+ "flex flex-col overflow-hidden",
10223
+ // Removed fixed min-height - content-driven sizing
10224
+ !bordered && "border border-border bg-card rounded-lg",
10225
+ className
10226
+ ),
10227
+ children: /* @__PURE__ */ jsx(Content14, { className: cn("flex-1 overflow-hidden p-0", !bordered && ""), children: /* @__PURE__ */ jsx(
10228
+ WeeklyLoadingView,
10229
+ {
10230
+ week,
10231
+ deliveries,
10232
+ onDeliveryClick: handleDeliveryClick,
10233
+ onWeekChange,
10234
+ showNavigation
10235
+ }
10236
+ ) })
10237
+ }
10238
+ ),
10239
+ /* @__PURE__ */ jsx(Sheet, { open: sheetOpen, onOpenChange: (open) => !open && handleSheetClose(), children: /* @__PURE__ */ jsxs(
10240
+ SheetContent,
10241
+ {
10242
+ side: "right",
10243
+ className: "w-full sm:max-w-lg p-0 overflow-hidden",
10244
+ children: [
10245
+ /* @__PURE__ */ jsx(SheetHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(SheetTitle, { children: selectedDelivery?.label ?? "Delivery Details" }) }),
10246
+ selectedDelivery && /* @__PURE__ */ jsx(
10247
+ DeliveryDetailPage,
10248
+ {
10249
+ delivery: selectedDelivery,
10250
+ week,
10251
+ suppliers,
10252
+ userRole,
10253
+ currentSupplierId,
10254
+ onBack: handleSheetClose,
10255
+ onAddComment,
10256
+ onConfirmLoad
10257
+ }
10258
+ )
10259
+ ]
10260
+ }
10261
+ ) })
10262
+ ] });
10263
+ }
10264
+ function getStatusBadgeVariant3(status) {
10265
+ switch (status) {
10266
+ case "shipped":
10267
+ case "delivered":
10268
+ return "default";
10269
+ case "loaded":
10270
+ case "in_progress":
10271
+ return "secondary";
10272
+ case "cancelled":
10273
+ return "destructive";
10274
+ case "planned":
10275
+ default:
10276
+ return "outline";
10277
+ }
10278
+ }
10279
+ function getStatusBadgeClasses3(status) {
10280
+ switch (status) {
10281
+ case "shipped":
10282
+ case "delivered":
10283
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
10284
+ case "loaded":
10285
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
10286
+ case "in_progress":
10287
+ return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
10288
+ case "cancelled":
10289
+ return "";
10290
+ case "planned":
10291
+ default:
10292
+ return "border-muted-foreground/50 text-muted-foreground";
10293
+ }
10294
+ }
10295
+ function getLeftStrokeStyles2(state, hasRisk, isHovered) {
10296
+ if (hasRisk) {
10297
+ return {
10298
+ stroke: "border-l-2 border-l-red-500",
10299
+ iconColor: "text-muted-foreground"
10300
+ };
10301
+ }
10302
+ switch (state) {
10303
+ case "sent":
10304
+ return {
10305
+ stroke: "border-l-2 border-l-green-500/50",
10306
+ iconColor: "text-muted-foreground/40"
10307
+ };
10308
+ case "ready":
10309
+ return {
10310
+ stroke: "border-l-2 border-l-green-500",
10311
+ iconColor: "text-muted-foreground"
10312
+ };
10313
+ default:
10314
+ return {
10315
+ stroke: isHovered ? "border-l-2 border-l-border" : "border-l-2 border-l-transparent",
10316
+ iconColor: "text-muted-foreground"
10317
+ };
10318
+ }
10319
+ }
10320
+ function DeliveryCard({
10321
+ delivery,
10322
+ onTap,
10323
+ className
10324
+ }) {
10325
+ const [isHovered, setIsHovered] = React27.useState(false);
10326
+ const hasComments = delivery.comments.length > 0;
10327
+ const visualState = getDeliveryVisualState(delivery);
10328
+ const styles = getLeftStrokeStyles2(visualState, delivery.hasProductionRisk ?? false, isHovered);
10329
+ const productionDisplay = React27.useMemo(() => {
10330
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
10331
+ return `${delivery.producedTons} / ${delivery.totalTons}t produced`;
10332
+ }
10333
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
10334
+ return `${delivery.producedCount} / ${delivery.totalCount} produced`;
10335
+ }
10336
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
10337
+ return `Loaded ${delivery.loadedCount} / ${delivery.totalCount}`;
10338
+ }
10339
+ return null;
10340
+ }, [delivery]);
10341
+ const handleClick = () => {
10342
+ onTap?.();
10343
+ };
10344
+ const handleKeyDown = (e) => {
10345
+ if (e.key === "Enter" || e.key === " ") {
10346
+ e.preventDefault();
10347
+ onTap?.();
10348
+ }
10349
+ };
10350
+ return /* @__PURE__ */ jsx(
10351
+ "div",
10352
+ {
10353
+ role: "button",
10354
+ tabIndex: 0,
10355
+ onClick: handleClick,
10356
+ onKeyDown: handleKeyDown,
10357
+ onMouseEnter: () => setIsHovered(true),
10358
+ onMouseLeave: () => setIsHovered(false),
10359
+ className: cn(
10360
+ // Full-width, 90° corners (j3m.radius.none)
10361
+ "w-full rounded-none",
10362
+ // Touch-friendly sizing - 56px min-height for iPad
10363
+ "min-h-[56px] p-4",
10364
+ // Card styling: white background, standard border
10365
+ "bg-background border border-border",
10366
+ // Left stroke for status (j3m.stroke.m = 2px)
10367
+ styles.stroke,
10368
+ // Hover/tap state - lift effect like Calibration
10369
+ "cursor-pointer transition-all duration-200 ease-out",
10370
+ "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
10371
+ "active:translate-y-0 active:shadow-sm",
10372
+ // Focus state
10373
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
10374
+ // Greyed out for sent state
10375
+ visualState === "sent" && "opacity-60",
10376
+ className
10377
+ ),
10378
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
10379
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 min-w-0 flex-1", children: [
10380
+ /* @__PURE__ */ jsx("div", { className: cn(
10381
+ "flex items-center justify-center h-10 w-10 rounded-md shrink-0 bg-muted/50"
10382
+ ), children: /* @__PURE__ */ jsx(Truck, { className: cn("h-5 w-5", styles.iconColor) }) }),
10383
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
10384
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
10385
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold truncate", children: delivery.label }),
10386
+ visualState === "sent" && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
10387
+ visualState === "ready" && /* @__PURE__ */ jsx(
10388
+ Badge,
10389
+ {
10390
+ variant: "outline",
10391
+ className: "text-[9px] px-1.5 py-0 h-4 bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
10392
+ children: "Ready"
10393
+ }
10394
+ ),
10395
+ delivery.hasProductionRisk && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
10396
+ hasComments && /* @__PURE__ */ jsxs("div", { className: "relative shrink-0", children: [
10397
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-3.5 w-3.5 text-muted-foreground" }),
10398
+ /* @__PURE__ */ jsx("span", { className: "absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary" })
10399
+ ] })
10400
+ ] }),
10401
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground truncate", children: [
10402
+ delivery.supplierName,
10403
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
10404
+ ] }),
10405
+ productionDisplay && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs", children: [
10406
+ /* @__PURE__ */ jsx(Package, { className: "h-3 w-3 text-muted-foreground" }),
10407
+ /* @__PURE__ */ jsxs("span", { className: cn(
10408
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400 font-medium" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
10409
+ ), children: [
10410
+ delivery.isReadyToUnload ? "\u2713 " : "",
10411
+ productionDisplay
10412
+ ] })
10413
+ ] })
10414
+ ] })
10415
+ ] }),
10416
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [
10417
+ /* @__PURE__ */ jsx(
10418
+ Badge,
10419
+ {
10420
+ variant: getStatusBadgeVariant3(delivery.status),
10421
+ className: cn("text-[10px] h-5", getStatusBadgeClasses3(delivery.status)),
10422
+ children: getLoadingDeliveryStatusLabel(delivery.status)
10423
+ }
10424
+ ),
10425
+ /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
10426
+ ] })
10427
+ ] })
10428
+ }
10429
+ );
10430
+ }
10431
+
9123
10432
  // src/components/event-calendar/types.ts
9124
10433
  var DEFAULT_WORKING_HOURS = {
9125
10434
  0: { from: 0, to: 0 },
@@ -9182,7 +10491,7 @@ var BADGE_VARIANT_LABELS = {
9182
10491
  colored: "Colored",
9183
10492
  mixed: "Mixed"
9184
10493
  };
9185
- var CalendarContext = React22.createContext(null);
10494
+ var CalendarContext = React27.createContext(null);
9186
10495
  function EventCalendarProvider({
9187
10496
  children,
9188
10497
  events: initialEvents = [],
@@ -9197,38 +10506,38 @@ function EventCalendarProvider({
9197
10506
  onEventUpdate,
9198
10507
  onEventDelete
9199
10508
  }) {
9200
- const [selectedDate, setSelectedDate] = React22.useState(defaultDate);
9201
- const [selectedUserId, setSelectedUserId] = React22.useState(defaultUserId);
9202
- const [events, setEventsState] = React22.useState(initialEvents);
9203
- const [users] = React22.useState(initialUsers);
9204
- const [badgeVariant, setBadgeVariant] = React22.useState(defaultBadgeVariant);
9205
- const [view, setView] = React22.useState(defaultView);
9206
- const [workingHours, setWorkingHours] = React22.useState(defaultWorkingHours);
9207
- const [visibleHours, setVisibleHours] = React22.useState(defaultVisibleHours);
9208
- React22.useEffect(() => {
10509
+ const [selectedDate, setSelectedDate] = React27.useState(defaultDate);
10510
+ const [selectedUserId, setSelectedUserId] = React27.useState(defaultUserId);
10511
+ const [events, setEventsState] = React27.useState(initialEvents);
10512
+ const [users] = React27.useState(initialUsers);
10513
+ const [badgeVariant, setBadgeVariant] = React27.useState(defaultBadgeVariant);
10514
+ const [view, setView] = React27.useState(defaultView);
10515
+ const [workingHours, setWorkingHours] = React27.useState(defaultWorkingHours);
10516
+ const [visibleHours, setVisibleHours] = React27.useState(defaultVisibleHours);
10517
+ React27.useEffect(() => {
9209
10518
  setEventsState(initialEvents);
9210
10519
  }, [initialEvents]);
9211
- const setEvents = React22.useCallback((newEvents) => {
10520
+ const setEvents = React27.useCallback((newEvents) => {
9212
10521
  setEventsState(newEvents);
9213
10522
  }, []);
9214
- const addEvent = React22.useCallback((event) => {
10523
+ const addEvent = React27.useCallback((event) => {
9215
10524
  setEventsState((prev) => [...prev, event]);
9216
10525
  onEventAdd?.(event);
9217
10526
  }, [onEventAdd]);
9218
- const updateEvent = React22.useCallback((event) => {
10527
+ const updateEvent = React27.useCallback((event) => {
9219
10528
  setEventsState(
9220
10529
  (prev) => prev.map((e) => e.id === event.id ? event : e)
9221
10530
  );
9222
10531
  onEventUpdate?.(event);
9223
10532
  }, [onEventUpdate]);
9224
- const deleteEvent = React22.useCallback((eventId) => {
10533
+ const deleteEvent = React27.useCallback((eventId) => {
9225
10534
  setEventsState((prev) => prev.filter((e) => e.id !== eventId));
9226
10535
  onEventDelete?.(eventId);
9227
10536
  }, [onEventDelete]);
9228
- const goToToday = React22.useCallback(() => {
10537
+ const goToToday = React27.useCallback(() => {
9229
10538
  setSelectedDate(/* @__PURE__ */ new Date());
9230
10539
  }, []);
9231
- const goToPrevious = React22.useCallback(() => {
10540
+ const goToPrevious = React27.useCallback(() => {
9232
10541
  setSelectedDate((current) => {
9233
10542
  switch (view) {
9234
10543
  case "day":
@@ -9246,7 +10555,7 @@ function EventCalendarProvider({
9246
10555
  }
9247
10556
  });
9248
10557
  }, [view]);
9249
- const goToNext = React22.useCallback(() => {
10558
+ const goToNext = React27.useCallback(() => {
9250
10559
  setSelectedDate((current) => {
9251
10560
  switch (view) {
9252
10561
  case "day":
@@ -9264,7 +10573,7 @@ function EventCalendarProvider({
9264
10573
  }
9265
10574
  });
9266
10575
  }, [view]);
9267
- const contextValue = React22.useMemo(
10576
+ const contextValue = React27.useMemo(
9268
10577
  () => ({
9269
10578
  // State
9270
10579
  selectedDate,
@@ -9311,7 +10620,7 @@ function EventCalendarProvider({
9311
10620
  return /* @__PURE__ */ jsx(CalendarContext.Provider, { value: contextValue, children });
9312
10621
  }
9313
10622
  function useEventCalendar() {
9314
- const context = React22.useContext(CalendarContext);
10623
+ const context = React27.useContext(CalendarContext);
9315
10624
  if (!context) {
9316
10625
  throw new Error("useEventCalendar must be used within an EventCalendarProvider");
9317
10626
  }
@@ -9319,14 +10628,14 @@ function useEventCalendar() {
9319
10628
  }
9320
10629
  function useFilteredEvents() {
9321
10630
  const { events, selectedUserId } = useEventCalendar();
9322
- return React22.useMemo(() => {
10631
+ return React27.useMemo(() => {
9323
10632
  if (!selectedUserId) return events;
9324
10633
  return events.filter((event) => event.user.id === selectedUserId);
9325
10634
  }, [events, selectedUserId]);
9326
10635
  }
9327
10636
  function useEventsInRange(startDate, endDate) {
9328
10637
  const filteredEvents = useFilteredEvents();
9329
- return React22.useMemo(() => {
10638
+ return React27.useMemo(() => {
9330
10639
  return filteredEvents.filter((event) => {
9331
10640
  const eventStart = new Date(event.startDate);
9332
10641
  const eventEnd = new Date(event.endDate);
@@ -9884,8 +11193,8 @@ function MoreEvents({ count, onClick, className }) {
9884
11193
  );
9885
11194
  }
9886
11195
  function TimeIndicator({ className }) {
9887
- const [now, setNow] = React22.useState(/* @__PURE__ */ new Date());
9888
- React22.useEffect(() => {
11196
+ const [now, setNow] = React27.useState(/* @__PURE__ */ new Date());
11197
+ React27.useEffect(() => {
9889
11198
  const interval = setInterval(() => setNow(/* @__PURE__ */ new Date()), 6e4);
9890
11199
  return () => clearInterval(interval);
9891
11200
  }, []);
@@ -9922,24 +11231,24 @@ function DateBadge({ date, className }) {
9922
11231
  }
9923
11232
  );
9924
11233
  }
9925
- var DragContext = React22.createContext(null);
11234
+ var DragContext = React27.createContext(null);
9926
11235
  function DragProvider({
9927
11236
  children,
9928
11237
  snapMinutes = 15,
9929
11238
  onDragStart,
9930
11239
  onDragEnd
9931
11240
  }) {
9932
- const [draggedEvent, setDraggedEventState] = React22.useState(null);
9933
- const [isDragging, setIsDragging] = React22.useState(false);
11241
+ const [draggedEvent, setDraggedEventState] = React27.useState(null);
11242
+ const [isDragging, setIsDragging] = React27.useState(false);
9934
11243
  const { updateEvent } = useEventCalendar();
9935
- const setDraggedEvent = React22.useCallback((event) => {
11244
+ const setDraggedEvent = React27.useCallback((event) => {
9936
11245
  setDraggedEventState(event);
9937
11246
  setIsDragging(!!event);
9938
11247
  if (event) {
9939
11248
  onDragStart?.(event);
9940
11249
  }
9941
11250
  }, [onDragStart]);
9942
- const handleDrop = React22.useCallback((newStartDate) => {
11251
+ const handleDrop = React27.useCallback((newStartDate) => {
9943
11252
  if (!draggedEvent) return;
9944
11253
  const snappedDate = snapToInterval(newStartDate, snapMinutes);
9945
11254
  const { startDate, endDate } = calculateDropDates(draggedEvent, snappedDate);
@@ -9952,7 +11261,7 @@ function DragProvider({
9952
11261
  onDragEnd?.(updatedEvent, new Date(startDate), new Date(endDate));
9953
11262
  setDraggedEvent(null);
9954
11263
  }, [draggedEvent, snapMinutes, updateEvent, onDragEnd, setDraggedEvent]);
9955
- const contextValue = React22.useMemo(
11264
+ const contextValue = React27.useMemo(
9956
11265
  () => ({
9957
11266
  draggedEvent,
9958
11267
  setDraggedEvent,
@@ -9963,7 +11272,7 @@ function DragProvider({
9963
11272
  return /* @__PURE__ */ jsx(DragContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(DragDropHandler, { onDrop: handleDrop, children }) });
9964
11273
  }
9965
11274
  function useDrag() {
9966
- const context = React22.useContext(DragContext);
11275
+ const context = React27.useContext(DragContext);
9967
11276
  if (!context) {
9968
11277
  throw new Error("useDrag must be used within a DragProvider");
9969
11278
  }
@@ -10008,7 +11317,7 @@ function DroppableZone({
10008
11317
  }) {
10009
11318
  const { draggedEvent, setDraggedEvent } = useDrag();
10010
11319
  const { updateEvent } = useEventCalendar();
10011
- const [isOver, setIsOver] = React22.useState(false);
11320
+ const [isOver, setIsOver] = React27.useState(false);
10012
11321
  const handleDragOver = (e) => {
10013
11322
  e.preventDefault();
10014
11323
  e.dataTransfer.dropEffect = "move";
@@ -10046,23 +11355,23 @@ function DroppableZone({
10046
11355
  function useDroppable({ date, hour, minute = 0, onDrop }) {
10047
11356
  const { draggedEvent, setDraggedEvent } = useDrag();
10048
11357
  const { updateEvent } = useEventCalendar();
10049
- const [isOver, setIsOver] = React22.useState(false);
10050
- const dropTargetDate = React22.useMemo(() => {
11358
+ const [isOver, setIsOver] = React27.useState(false);
11359
+ const dropTargetDate = React27.useMemo(() => {
10051
11360
  const targetDate = new Date(date);
10052
11361
  if (hour !== void 0) {
10053
11362
  targetDate.setHours(hour, minute, 0, 0);
10054
11363
  }
10055
11364
  return targetDate;
10056
11365
  }, [date, hour, minute]);
10057
- const handleDragOver = React22.useCallback((e) => {
11366
+ const handleDragOver = React27.useCallback((e) => {
10058
11367
  e.preventDefault();
10059
11368
  e.dataTransfer.dropEffect = "move";
10060
11369
  if (!isOver) setIsOver(true);
10061
11370
  }, [isOver]);
10062
- const handleDragLeave = React22.useCallback(() => {
11371
+ const handleDragLeave = React27.useCallback(() => {
10063
11372
  setIsOver(false);
10064
11373
  }, []);
10065
- const handleDrop = React22.useCallback((e) => {
11374
+ const handleDrop = React27.useCallback((e) => {
10066
11375
  e.preventDefault();
10067
11376
  setIsOver(false);
10068
11377
  if (!draggedEvent) return;
@@ -10089,13 +11398,13 @@ function useDroppable({ date, hour, minute = 0, onDrop }) {
10089
11398
  function useDraggable(event, disabled = false) {
10090
11399
  const { setDraggedEvent, draggedEvent } = useDrag();
10091
11400
  const isDragged = draggedEvent?.id === event.id;
10092
- const handleDragStart = React22.useCallback((e) => {
11401
+ const handleDragStart = React27.useCallback((e) => {
10093
11402
  if (disabled) return;
10094
11403
  e.dataTransfer.effectAllowed = "move";
10095
11404
  e.dataTransfer.setData("text/plain", event.id);
10096
11405
  setDraggedEvent(event);
10097
11406
  }, [disabled, event, setDraggedEvent]);
10098
- const handleDragEnd = React22.useCallback(() => {
11407
+ const handleDragEnd = React27.useCallback(() => {
10099
11408
  setDraggedEvent(null);
10100
11409
  }, [setDraggedEvent]);
10101
11410
  return {
@@ -10136,15 +11445,15 @@ function MonthView({
10136
11445
  }) {
10137
11446
  const { selectedDate, badgeVariant, setSelectedDate, setView } = useEventCalendar();
10138
11447
  const filteredEvents = useFilteredEvents();
10139
- const { singleDayEvents, multiDayEvents } = React22.useMemo(
11448
+ const { singleDayEvents, multiDayEvents } = React27.useMemo(
10140
11449
  () => splitEventsByDuration(filteredEvents),
10141
11450
  [filteredEvents]
10142
11451
  );
10143
- const cells = React22.useMemo(
11452
+ const cells = React27.useMemo(
10144
11453
  () => getCalendarCells(selectedDate),
10145
11454
  [selectedDate]
10146
11455
  );
10147
- const eventPositions = React22.useMemo(
11456
+ const eventPositions = React27.useMemo(
10148
11457
  () => calculateMonthEventPositions(multiDayEvents, singleDayEvents, selectedDate),
10149
11458
  [multiDayEvents, singleDayEvents, selectedDate]
10150
11459
  );
@@ -10326,7 +11635,7 @@ function WeekView({
10326
11635
  visibleHours
10327
11636
  } = useEventCalendar();
10328
11637
  const filteredEvents = useFilteredEvents();
10329
- const { singleDayEvents, multiDayEvents } = React22.useMemo(
11638
+ const { singleDayEvents, multiDayEvents } = React27.useMemo(
10330
11639
  () => splitEventsByDuration(filteredEvents),
10331
11640
  [filteredEvents]
10332
11641
  );
@@ -10532,8 +11841,8 @@ function CalendarTimeline({
10532
11841
  firstVisibleHour,
10533
11842
  lastVisibleHour
10534
11843
  }) {
10535
- const [currentTime, setCurrentTime] = React22.useState(/* @__PURE__ */ new Date());
10536
- React22.useEffect(() => {
11844
+ const [currentTime, setCurrentTime] = React27.useState(/* @__PURE__ */ new Date());
11845
+ React27.useEffect(() => {
10537
11846
  const interval = setInterval(() => {
10538
11847
  setCurrentTime(/* @__PURE__ */ new Date());
10539
11848
  }, 6e4);
@@ -10616,7 +11925,7 @@ function DayView({
10616
11925
  visibleHours
10617
11926
  } = useEventCalendar();
10618
11927
  const filteredEvents = useFilteredEvents();
10619
- const { singleDayEvents, multiDayEvents } = React22.useMemo(
11928
+ const { singleDayEvents, multiDayEvents } = React27.useMemo(
10620
11929
  () => splitEventsByDuration(filteredEvents),
10621
11930
  [filteredEvents]
10622
11931
  );
@@ -10624,7 +11933,7 @@ function DayView({
10624
11933
  visibleHours,
10625
11934
  singleDayEvents
10626
11935
  );
10627
- const currentEvents = React22.useMemo(() => {
11936
+ const currentEvents = React27.useMemo(() => {
10628
11937
  if (!isToday(selectedDate)) return [];
10629
11938
  return getCurrentEvents(singleDayEvents);
10630
11939
  }, [singleDayEvents, selectedDate]);
@@ -10848,8 +12157,8 @@ function CalendarTimeline2({
10848
12157
  firstVisibleHour,
10849
12158
  lastVisibleHour
10850
12159
  }) {
10851
- const [currentTime, setCurrentTime] = React22.useState(/* @__PURE__ */ new Date());
10852
- React22.useEffect(() => {
12160
+ const [currentTime, setCurrentTime] = React27.useState(/* @__PURE__ */ new Date());
12161
+ React27.useEffect(() => {
10853
12162
  const interval = setInterval(() => {
10854
12163
  setCurrentTime(/* @__PURE__ */ new Date());
10855
12164
  }, 6e4);
@@ -10883,7 +12192,7 @@ function YearView({
10883
12192
  }) {
10884
12193
  const { selectedDate, setSelectedDate, setView } = useEventCalendar();
10885
12194
  const filteredEvents = useFilteredEvents();
10886
- const months = React22.useMemo(() => {
12195
+ const months = React27.useMemo(() => {
10887
12196
  const yearStart = startOfYear(selectedDate);
10888
12197
  return Array.from({ length: 12 }, (_, i) => addMonths(yearStart, i));
10889
12198
  }, [selectedDate]);
@@ -11006,11 +12315,11 @@ function AgendaView({
11006
12315
  }) {
11007
12316
  const { selectedDate, setSelectedDate, setView } = useEventCalendar();
11008
12317
  const filteredEvents = useFilteredEvents();
11009
- const { singleDayEvents, multiDayEvents } = React22.useMemo(
12318
+ const { singleDayEvents, multiDayEvents } = React27.useMemo(
11010
12319
  () => splitEventsByDuration(filteredEvents),
11011
12320
  [filteredEvents]
11012
12321
  );
11013
- const eventsByDay = React22.useMemo(() => {
12322
+ const eventsByDay = React27.useMemo(() => {
11014
12323
  const allDates = /* @__PURE__ */ new Map();
11015
12324
  singleDayEvents.forEach((event) => {
11016
12325
  const eventDate = parseISO(event.startDate);
@@ -11475,16 +12784,16 @@ function EventDialog({
11475
12784
  defaultUserId
11476
12785
  }) {
11477
12786
  const { addEvent, updateEvent, deleteEvent, users } = useEventCalendar();
11478
- const [title, setTitle] = React22.useState("");
11479
- const [description, setDescription] = React22.useState("");
11480
- const [startDate, setStartDate] = React22.useState("");
11481
- const [startTime, setStartTime] = React22.useState("");
11482
- const [endDate, setEndDate] = React22.useState("");
11483
- const [endTime, setEndTime] = React22.useState("");
11484
- const [color, setColor] = React22.useState("blue");
11485
- const [userId, setUserId] = React22.useState("");
11486
- const [isSubmitting, setIsSubmitting] = React22.useState(false);
11487
- React22.useEffect(() => {
12787
+ const [title, setTitle] = React27.useState("");
12788
+ const [description, setDescription] = React27.useState("");
12789
+ const [startDate, setStartDate] = React27.useState("");
12790
+ const [startTime, setStartTime] = React27.useState("");
12791
+ const [endDate, setEndDate] = React27.useState("");
12792
+ const [endTime, setEndTime] = React27.useState("");
12793
+ const [color, setColor] = React27.useState("blue");
12794
+ const [userId, setUserId] = React27.useState("");
12795
+ const [isSubmitting, setIsSubmitting] = React27.useState(false);
12796
+ React27.useEffect(() => {
11488
12797
  if (open) {
11489
12798
  if (mode === "edit" && event) {
11490
12799
  const start = parseISO(event.startDate);
@@ -11707,7 +13016,7 @@ function QuickAddEvent({
11707
13016
  onOpenDialog,
11708
13017
  onClose
11709
13018
  }) {
11710
- const [title, setTitle] = React22.useState("");
13019
+ const [title, setTitle] = React27.useState("");
11711
13020
  const { users } = useEventCalendar();
11712
13021
  const handleSubmit = (e) => {
11713
13022
  e.preventDefault();
@@ -11774,8 +13083,8 @@ var HOUR_OPTIONS = Array.from({ length: 25 }, (_, i) => {
11774
13083
  });
11775
13084
  function ChangeVisibleHoursInput() {
11776
13085
  const { visibleHours, setVisibleHours } = useEventCalendar();
11777
- const [from, setFrom] = React22.useState(visibleHours.from);
11778
- const [to, setTo] = React22.useState(visibleHours.to);
13086
+ const [from, setFrom] = React27.useState(visibleHours.from);
13087
+ const [to, setTo] = React27.useState(visibleHours.to);
11779
13088
  const handleApply = () => {
11780
13089
  const toHour = to === 0 ? 24 : to;
11781
13090
  setVisibleHours({ from, to: toHour });
@@ -11821,7 +13130,7 @@ var HOUR_OPTIONS2 = Array.from({ length: 25 }, (_, i) => {
11821
13130
  });
11822
13131
  function ChangeWorkingHoursInput() {
11823
13132
  const { workingHours, setWorkingHours } = useEventCalendar();
11824
- const [localWorkingHours, setLocalWorkingHours] = React22.useState({
13133
+ const [localWorkingHours, setLocalWorkingHours] = React27.useState({
11825
13134
  ...workingHours
11826
13135
  });
11827
13136
  const handleToggleDay = (dayId) => {
@@ -11970,8 +13279,8 @@ function CalendarSettingsButton({
11970
13279
  );
11971
13280
  }
11972
13281
  function useMediaQuery(query) {
11973
- const [matches, setMatches] = React22.useState(false);
11974
- React22.useEffect(() => {
13282
+ const [matches, setMatches] = React27.useState(false);
13283
+ React27.useEffect(() => {
11975
13284
  const media = window.matchMedia(query);
11976
13285
  setMatches(media.matches);
11977
13286
  const listener = (event) => {
@@ -12023,11 +13332,11 @@ function BigCalendarInner({
12023
13332
  maxEventsPerDay
12024
13333
  }) {
12025
13334
  const { view, setView } = useEventCalendar();
12026
- const [dialogOpen, setDialogOpen] = React22.useState(false);
12027
- const [settingsDialogOpen, setSettingsDialogOpen] = React22.useState(false);
12028
- const [selectedEvent, setSelectedEvent] = React22.useState(null);
12029
- const [dialogMode, setDialogMode] = React22.useState("add");
12030
- const [defaultDate, setDefaultDate] = React22.useState(/* @__PURE__ */ new Date());
13335
+ const [dialogOpen, setDialogOpen] = React27.useState(false);
13336
+ const [settingsDialogOpen, setSettingsDialogOpen] = React27.useState(false);
13337
+ const [selectedEvent, setSelectedEvent] = React27.useState(null);
13338
+ const [dialogMode, setDialogMode] = React27.useState("add");
13339
+ const [defaultDate, setDefaultDate] = React27.useState(/* @__PURE__ */ new Date());
12031
13340
  const isMobile = useMediaQuery("(max-width: 768px)");
12032
13341
  const isCompact = compact === "auto" ? isMobile : compact;
12033
13342
  const handleAddClick = () => {
@@ -12186,6 +13495,6 @@ function CalendarView({
12186
13495
  }
12187
13496
  }
12188
13497
 
12189
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AgendaView, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarFallback, AvatarImage, BADGE_VARIANT_LABELS, Badge, BigCalendar, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarContext, CalendarDayButton, CalendarHeader, CalendarHeaderCompact, CalendarSettingsButton, CalendarSettingsContent, CalendarSettingsDialog, CalibrationTable, CalibrationWeekCell, CalibrationWeekHeader, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChangeBadgeVariantInput, ChangeVisibleHoursInput, ChangeWorkingHoursInput, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CircularProgress, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CommentButton, CommentDialog, CommentPopover, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DEFAULT_VISIBLE_HOURS, DEFAULT_WORKING_HOURS, DataTableColumnHeader, DataTablePagination, DataTableViewOptions, DateBadge, DayView, DeliveryIndicator, DeliveryIndicators, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DragContext, DragProvider, DraggableEvent, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DroppableZone, EVENT_COLORS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, EventBadge, EventCalendarProvider, EventDialog, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Item6 as Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label2 as Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MonthView, MoreEvents, NativeSelect, NativeSelectOptGroup, NativeSelectOption, NavMain, NavProjects, NavSecondary, NavUser, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NetBadge, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PlanningTable, PlanningTableToolbar, PlanningWeekCommentPopover, PlayerCanvas, PlayerCanvasActionButton, PlayerCanvasControls, PlayerCanvasDivider, PlayerCanvasInfo, PlayerCanvasLabel, PlayerCanvasPlayButton, PlayerCanvasProgress, PlayerCanvasSkipButton, PlayerCanvasTitle, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, QuickAddEvent, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, RowHeaderCell, ScrollArea, ScrollBar, SearchForm, SearchTrigger, Section, SectionContent, SectionDescription, SectionFooter, SectionHeader, SectionTitle, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SiteHeader, Skeleton, Slider, Spinner, SubmitCalibrationBar, SupplierCell, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeSwitch, TimeIndicator, Toaster, Toggle, ToggleGroup, ToggleGroupItem, ToolBarCanvas, ToolBarCanvasButton, ToolBarCanvasDivider, ToolBarCanvasGroup, Tooltip2 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserAvatarsDropdown, VIEW_LABELS, WeekCell, WeekDetailDialog, WeekHeader, WeekView, YearView, badgeVariants, buttonGroupVariants, buttonVariants, calculateCalibrationCells, calculateDropDates, calculateMonthEventPositions, canSubmitCalibration, cardVariants, createDefaultEvent, deliveryIndicatorVariants, formatCalibrationUnit, formatDateRange2 as formatDateRange, formatProductionUnit, formatTime, generateColumns, generateEventId, generateLocationOptions, generateWeekColumns, generateWeeks, getCalendarCells, getCommentLocationLabel, getCurrentEvents, getDayHours, getElementShipmentStatus, getEventBlockStyle, getEventDuration, getEventDurationMinutes, getEventsCount, getEventsForDate, getEventsInRange, getHeaderLabel, getISOWeek, getMonthCellEvents, getMonthDays, getShipmentStatusLabel, getSupplierColumn, getTimeHeight, getTimePosition, getViewDateRange, getVisibleHours, getWeekDayNames, getWeekDays, getWeekKey, getYearMonths, groupEvents, isMultiDayEvent, isWorkingHour, navigateDate, navigationMenuTriggerStyle, playerCanvasPlayButtonVariants, playerCanvasSkipButtonVariants, rangeText, sectionVariants, snapToInterval, sortEvents, splitEventsByDuration, toggleVariants, toolBarCanvasButtonVariants, useDrag, useDraggable, useDroppable, useEventCalendar, useEventsInRange, useFilteredEvents, useFormField, useIsMobile, useSearchShortcut, useSidebar };
13498
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AgendaView, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarFallback, AvatarImage, BADGE_VARIANT_LABELS, Badge, BigCalendar, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarContext, CalendarDayButton, CalendarHeader, CalendarHeaderCompact, CalendarSettingsButton, CalendarSettingsContent, CalendarSettingsDialog, CalibrationTable, CalibrationWeekCell, CalibrationWeekHeader, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChangeBadgeVariantInput, ChangeVisibleHoursInput, ChangeWorkingHoursInput, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CircularProgress, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CommentButton, CommentDialog, CommentPopover, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DEFAULT_VISIBLE_HOURS, DEFAULT_WORKING_HOURS, DataTableColumnHeader, DataTablePagination, DataTableViewOptions, DateBadge, DayView, DeliveryBadge, DeliveryCard, DeliveryDetailPage, DeliveryIndicator, DeliveryIndicators, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DragContext, DragProvider, DraggableEvent, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DroppableZone, EVENT_COLORS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, EventBadge, EventCalendarProvider, EventDialog, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Item6 as Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label2 as Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MonthView, MoreEvents, NativeSelect, NativeSelectOptGroup, NativeSelectOption, NavMain, NavProjects, NavSecondary, NavUser, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NetBadge, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PlanningTable, PlanningTableToolbar, PlanningWeekCommentPopover, PlayerCanvas, PlayerCanvasActionButton, PlayerCanvasControls, PlayerCanvasDivider, PlayerCanvasInfo, PlayerCanvasLabel, PlayerCanvasPlayButton, PlayerCanvasProgress, PlayerCanvasSkipButton, PlayerCanvasTitle, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, QuickAddEvent, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, RowHeaderCell, ScrollArea, ScrollBar, SearchForm, SearchTrigger, Section, SectionContent, SectionDescription, SectionFooter, SectionHeader, SectionTitle, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SiteHeader, Skeleton, Slider, Spinner, SubmitCalibrationBar, SupplierCell, SupplierWeeklyLoading, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeSwitch, TimeIndicator, Toaster, Toggle, ToggleGroup, ToggleGroupItem, ToolBarCanvas, ToolBarCanvasButton, ToolBarCanvasDivider, ToolBarCanvasGroup, Tooltip2 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserAvatarsDropdown, VIEW_LABELS, WeekCell, WeekDetailDialog, WeekHeader, WeekView, WeeklyLoadingView, YearView, badgeVariants, buttonGroupVariants, buttonVariants, calculateCalibrationCells, calculateDropDates, calculateMonthEventPositions, canSubmitCalibration, cardVariants, createDefaultEvent, deliveryIndicatorVariants, extractPrefixes, formatCalibrationUnit, formatDateRange2 as formatDateRange, formatProductionUnit, formatTime, generateColumns, generateEventId, generateLoadingWeek, generateLocationOptions, generateWeekColumns, generateWeeks, getCalendarCells, getCommentLocationLabel, getCurrentEvents, getDayHours, getDayLabel, getDeliveryVisualState, getElementShipmentStatus, getEventBlockStyle, getEventDuration, getEventDurationMinutes, getEventsCount, getEventsForDate, getEventsInRange, getHeaderLabel, getISOWeek, getLoadingDeliveryStatusLabel, getLoadingElementStatusLabel, getLoadingISOWeek, getLoadingWeekKey, getMonthCellEvents, getMonthDays, getShipmentStatusLabel, getShortDayLabel, getSupplierColumn, getTimeHeight, getTimePosition, getViewDateRange, getVisibleHours, getWeekDayNames, getWeekDays, getWeekKey, getYearMonths, groupDeliveriesByDay, groupDeliveriesByPrefixAndDay, groupEvents, isMultiDayEvent, isWorkingHour, navigateDate, navigationMenuTriggerStyle, playerCanvasPlayButtonVariants, playerCanvasSkipButtonVariants, rangeText, sectionVariants, snapToInterval, sortEvents, splitEventsByDuration, toggleVariants, toolBarCanvasButtonVariants, useDrag, useDraggable, useDroppable, useEventCalendar, useEventsInRange, useFilteredEvents, useFormField, useIsMobile, useSearchShortcut, useSidebar };
12190
13499
  //# sourceMappingURL=index.js.map
12191
13500
  //# sourceMappingURL=index.js.map