"use client";

// src/components/ui/export-drawer.tsx
import * as React10 from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";

// src/lib/dev-log.ts
function devLog(...args) {
  if (process.env.NODE_ENV === "development") {
    console.log(...args);
  }
}

// src/components/ui/button.tsx
import * as React from "react";
import { cva } from "class-variance-authority";
import { Slot } from "radix-ui";

// src/lib/utils.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}

// src/components/ui/button.tsx
import { jsx } from "react/jsx-runtime";
var buttonVariants = cva(
  "group/button inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/80",
        outline: "border-input bg-background hover:bg-interactive-hover hover:text-interactive-hover-foreground aria-expanded:bg-interactive-hover aria-expanded:text-interactive-hover-foreground dark:bg-input/15 dark:hover:bg-input/25",
        secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
        ghost: "hover:bg-interactive-hover hover:text-interactive-hover-foreground aria-expanded:bg-interactive-hover aria-expanded:text-interactive-hover-foreground dark:hover:bg-interactive-hover-subtle",
        destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
        link: "text-primary underline-offset-4 hover:underline"
      },
      size: {
        default: "h-9 gap-1.5 px-3 has-data-[icon=inline-end]:pe-2.5 has-data-[icon=inline-start]:ps-2.5",
        xs: "h-6 gap-1 px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
        sm: "h-8 gap-1 px-3 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2 [&_svg:not([class*='size-'])]:size-3.5",
        lg: "h-10 gap-1.5 px-4 has-data-[icon=inline-end]:pe-3.5 has-data-[icon=inline-start]:ps-3.5",
        icon: "size-9",
        "icon-xs": "size-6 in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
        "icon-sm": "size-8 in-data-[slot=button-group]:rounded-lg",
        "icon-lg": "size-10"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
);
var Button = React.forwardRef(({ className, variant = "default", size = "default", asChild = false, ...props }, ref) => {
  const Comp = asChild ? Slot.Root : "button";
  return /* @__PURE__ */ jsx(
    Comp,
    {
      ref,
      "data-slot": "button",
      "data-variant": variant,
      "data-size": size,
      className: cn(buttonVariants({ variant, size }), className),
      ...props
    }
  );
});
Button.displayName = "Button";

// src/components/ui/checkbox.tsx
import * as React3 from "react";
import { cva as cva2 } from "class-variance-authority";
import { Checkbox as CheckboxPrimitive } from "radix-ui";

// src/components/ui/label.tsx
import * as React2 from "react";
import { Label as LabelPrimitive } from "radix-ui";
import { jsx as jsx2 } from "react/jsx-runtime";
var Label = React2.forwardRef(function Label2({ className, ...props }, ref) {
  return /* @__PURE__ */ jsx2(
    LabelPrimitive.Root,
    {
      ref,
      "data-slot": "label",
      className: cn(
        "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
        className
      ),
      ...props
    }
  );
});

// src/components/ui/checkbox.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
var checkboxVariants = cva2(
  [
    "peer relative box-border flex shrink-0 items-center justify-center self-center rounded-[4px] border border-input",
    "outline-none transition-[color,box-shadow,transform,background-color,border-color] duration-150",
    "motion-reduce:transition-none",
    "group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2",
    "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
    "disabled:cursor-not-allowed disabled:opacity-50",
    "aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary",
    "dark:bg-input/15 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40"
  ].join(" "),
  {
    variants: {
      variant: {
        default: [
          "data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary",
          "data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:data-[state=indeterminate]:bg-primary dark:data-[state=indeterminate]:text-primary-foreground"
        ].join(" "),
        outline: [
          "bg-background",
          "data-[state=checked]:border-primary data-[state=checked]:bg-background data-[state=checked]:text-primary data-[state=checked]:ring-2 data-[state=checked]:ring-primary/25",
          "data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-background data-[state=indeterminate]:text-primary data-[state=indeterminate]:ring-2 data-[state=indeterminate]:ring-primary/25"
        ].join(" "),
        secondary: [
          "data-[state=checked]:border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-foreground",
          "data-[state=indeterminate]:border-secondary data-[state=indeterminate]:bg-secondary data-[state=indeterminate]:text-secondary-foreground"
        ].join(" "),
        success: [
          "data-[state=checked]:border-chart-2 data-[state=checked]:bg-chart-2 data-[state=checked]:text-primary-foreground",
          "data-[state=indeterminate]:border-chart-2 data-[state=indeterminate]:bg-chart-2 data-[state=indeterminate]:text-primary-foreground"
        ].join(" "),
        destructive: [
          "data-[state=checked]:border-destructive data-[state=checked]:bg-destructive data-[state=checked]:text-destructive-foreground",
          "data-[state=indeterminate]:border-destructive data-[state=indeterminate]:bg-destructive data-[state=indeterminate]:text-destructive-foreground"
        ].join(" "),
        warning: [
          "data-[state=checked]:border-amber-500 data-[state=checked]:bg-amber-500 data-[state=checked]:text-amber-950",
          "data-[state=indeterminate]:border-amber-500 data-[state=indeterminate]:bg-amber-500 data-[state=indeterminate]:text-amber-950"
        ].join(" "),
        muted: [
          "data-[state=checked]:border-muted-foreground/50 data-[state=checked]:bg-muted data-[state=checked]:text-foreground",
          "data-[state=indeterminate]:border-muted-foreground/50 data-[state=indeterminate]:bg-muted data-[state=indeterminate]:text-foreground"
        ].join(" ")
      },
      size: {
        sm: "size-3.5 max-h-3.5 max-w-3.5 min-h-3.5 min-w-3.5 rounded-[3px] [&_[data-slot=checkbox-indicator]_i]:text-[10px]",
        default: "size-4 max-h-4 max-w-4 min-h-4 min-w-4 [&_[data-slot=checkbox-indicator]_i]:text-xs",
        lg: "size-5 max-h-5 max-w-5 min-h-5 min-w-5 rounded-[5px] [&_[data-slot=checkbox-indicator]_i]:text-sm"
      },
      motion: {
        none: "",
        pop: [
          "motion-safe:active:scale-95",
          "data-[state=checked]:motion-safe:scale-[1.04] data-[state=indeterminate]:motion-safe:scale-[1.04]"
        ].join(" "),
        glow: [
          "data-[state=checked]:shadow-[0_0_0_3px] data-[state=checked]:shadow-primary/35",
          "data-[state=indeterminate]:shadow-[0_0_0_3px] data-[state=indeterminate]:shadow-primary/35"
        ].join(" "),
        "pop-glow": [
          "motion-safe:active:scale-95",
          "data-[state=checked]:motion-safe:scale-[1.04] data-[state=indeterminate]:motion-safe:scale-[1.04]",
          "data-[state=checked]:shadow-[0_0_0_3px] data-[state=checked]:shadow-primary/35",
          "data-[state=indeterminate]:shadow-[0_0_0_3px] data-[state=indeterminate]:shadow-primary/35"
        ].join(" ")
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default",
      motion: "none"
    }
  }
);
var checkboxIndicatorVariants = cva2("grid place-content-center text-current", {
  variants: {
    motion: {
      none: "transition-none",
      pop: "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-150",
      glow: "",
      "pop-glow": "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-150"
    }
  },
  defaultVariants: {
    motion: "none"
  }
});
var Checkbox = React3.forwardRef(
  function Checkbox2({ className, variant, size, motion, checked, ...props }, ref) {
    const m = motion ?? "none";
    return /* @__PURE__ */ jsx3(
      CheckboxPrimitive.Root,
      {
        ref,
        "data-slot": "checkbox",
        "data-variant": variant ?? "default",
        "data-motion": m,
        checked,
        className: cn(checkboxVariants({ variant, size, motion: m }), className),
        ...props,
        children: /* @__PURE__ */ jsx3(
          CheckboxPrimitive.Indicator,
          {
            "data-slot": "checkbox-indicator",
            className: checkboxIndicatorVariants({ motion: m }),
            children: checked === "indeterminate" ? /* @__PURE__ */ jsx3("i", { className: "fa-solid fa-minus text-current", "aria-hidden": "true" }) : /* @__PURE__ */ jsx3("i", { className: "fa-solid fa-check text-current", "aria-hidden": "true" })
          }
        )
      }
    );
  }
);

// src/components/ui/tooltip.tsx
import { Tooltip as TooltipPrimitive } from "radix-ui";
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
function Tooltip({
  ...props
}) {
  return /* @__PURE__ */ jsx4(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
}
function TooltipTrigger({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx4(
    TooltipPrimitive.Trigger,
    {
      "data-slot": "tooltip-trigger",
      suppressHydrationWarning: true,
      className: cn("cursor-pointer", className),
      ...props
    }
  );
}
function TooltipContent({
  className,
  sideOffset = 0,
  children,
  ...props
}) {
  return /* @__PURE__ */ jsx4(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
    TooltipPrimitive.Content,
    {
      "data-slot": "tooltip-content",
      sideOffset,
      className: cn(
        "z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-end-2 data-[side=right]:slide-in-from-start-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
        className
      ),
      ...props,
      children: [
        children,
        /* @__PURE__ */ jsx4(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
      ]
    }
  ) });
}

// src/components/ui/tip.tsx
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
function Tip({ label, children, side = "top" }) {
  return /* @__PURE__ */ jsxs2(Tooltip, { children: [
    /* @__PURE__ */ jsx5(TooltipTrigger, { asChild: true, children }),
    /* @__PURE__ */ jsx5(TooltipContent, { side, className: "flex flex-wrap items-center gap-1.5", children: label })
  ] });
}

// src/components/ui/kbd.tsx
import { jsx as jsx6 } from "react/jsx-runtime";
function Kbd({
  className,
  variant = "tile",
  "aria-hidden": ariaHidden,
  ...props
}) {
  const hidden = ariaHidden ?? (variant === "bare" ? true : void 0);
  return /* @__PURE__ */ jsx6(
    "kbd",
    {
      "data-slot": "kbd",
      "data-variant": variant,
      "aria-hidden": hidden,
      className: cn(
        "pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 px-1 font-sans text-xs font-medium",
        variant === "tile" && "bg-muted text-muted-foreground rounded-sm border",
        variant === "bare" && "text-current/70 px-0",
        className
      ),
      ...props
    }
  );
}
function KbdGroup({ className, ...props }) {
  return /* @__PURE__ */ jsx6(
    "div",
    {
      "data-slot": "kbd-group",
      className: cn("inline-flex items-center gap-1", className),
      ...props
    }
  );
}

// src/components/ui/dropdown-menu.tsx
import * as React4 from "react";
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
function Shortcut({
  keys,
  onInvoke,
  disabled
}) {
  useShortcut(keys, onInvoke, disabled);
  return null;
}
function useShortcut(keys, onInvoke, disabled) {
  const ref = React4.useRef(onInvoke);
  React4.useEffect(() => {
    ref.current = onInvoke;
  }, [onInvoke]);
  React4.useEffect(() => {
    if (disabled) return;
    const parsed = parseShortcut(keys);
    if (!parsed) return;
    function handler(e) {
      if (!matchesShortcut(e, parsed)) return;
      const t = e.target;
      if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable)) return;
      if (t && (parsed.key === "enter" || parsed.key === " ")) {
        const role = t.getAttribute("role");
        if (t.tagName === "BUTTON" || t.tagName === "A" || t.tagName === "SELECT" || role === "button" || role === "link" || role === "menuitem" || role === "tab" || role === "option" || role === "checkbox" || role === "radio" || role === "switch" || t.closest('[role="button"], [role="link"], [role="menuitem"], [role="tab"], [role="option"]'))
          return;
      }
      const openDialog = document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]');
      if (openDialog && (!t || !openDialog.contains(t))) return;
      e.preventDefault();
      e.stopPropagation();
      ref.current(e);
    }
    window.addEventListener("keydown", handler);
    return () => window.removeEventListener("keydown", handler);
  }, [keys, disabled]);
}
function mapKey(raw) {
  const p = raw.toLowerCase();
  if (raw === "\u232B") return "backspace";
  if (raw === "\u2326") return "delete";
  if (raw === "\u23CE" || p === "enter" || p === "return") return "enter";
  if (raw === "\u2423" || p === "space") return " ";
  if (p === "esc" || p === "escape") return "escape";
  if (p === "tab") return "tab";
  if (p === "up" || raw === "\u2191") return "arrowup";
  if (p === "down" || raw === "\u2193") return "arrowdown";
  if (p === "left" || raw === "\u2190") return "arrowleft";
  if (p === "right" || raw === "\u2192") return "arrowright";
  return p;
}
function parseShortcut(input) {
  let s = input.trim();
  if (!s) return null;
  const out = { meta: false, ctrl: false, shift: false, alt: false, key: "" };
  while (s.length) {
    const c = s[0];
    if (c === "\u2318") {
      out.meta = true;
      s = s.slice(1);
    } else if (c === "\u2303") {
      out.ctrl = true;
      s = s.slice(1);
    } else if (c === "\u21E7") {
      out.shift = true;
      s = s.slice(1);
    } else if (c === "\u2325") {
      out.alt = true;
      s = s.slice(1);
    } else break;
  }
  if (!s) return null;
  if (/[+\s]/.test(s)) {
    for (const raw of s.split(/[+\s]+/).filter(Boolean)) {
      const p = raw.toLowerCase();
      if (raw === "\u2318" || p === "cmd" || p === "meta" || p === "command") out.meta = true;
      else if (raw === "\u2303" || p === "ctrl" || p === "control") out.ctrl = true;
      else if (raw === "\u21E7" || p === "shift") out.shift = true;
      else if (raw === "\u2325" || p === "alt" || p === "opt" || p === "option") out.alt = true;
      else out.key = mapKey(raw);
    }
  } else {
    out.key = mapKey(s);
  }
  return out.key ? out : null;
}
function matchesShortcut(e, s) {
  if (e.metaKey !== s.meta) return false;
  if (e.ctrlKey !== s.ctrl) return false;
  if (e.altKey !== s.alt) return false;
  if (e.shiftKey !== s.shift) return false;
  return e.key.toLowerCase() === s.key;
}

// src/components/ui/radio-group.tsx
import * as React5 from "react";
import { cva as cva3 } from "class-variance-authority";
import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
import { jsx as jsx8 } from "react/jsx-runtime";
var radioGroupItemVariants = cva3(
  [
    "group/radio-group-item peer relative flex shrink-0 aspect-square rounded-full border border-input",
    "outline-none transition-[color,box-shadow,transform,background-color,border-color] duration-150",
    "motion-reduce:transition-none",
    "group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2",
    "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
    "disabled:cursor-not-allowed disabled:opacity-50",
    "aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:data-[state=checked]:border-primary",
    "dark:bg-input/15 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40"
  ].join(" "),
  {
    variants: {
      variant: {
        default: [
          "data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary"
        ].join(" "),
        outline: [
          "bg-background",
          "data-[state=checked]:border-primary data-[state=checked]:bg-background data-[state=checked]:text-primary data-[state=checked]:ring-2 data-[state=checked]:ring-primary/25"
        ].join(" "),
        secondary: [
          "data-[state=checked]:border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-foreground"
        ].join(" "),
        success: [
          "data-[state=checked]:border-chart-2 data-[state=checked]:bg-chart-2 data-[state=checked]:text-primary-foreground"
        ].join(" "),
        destructive: [
          "data-[state=checked]:border-destructive data-[state=checked]:bg-destructive data-[state=checked]:text-destructive-foreground"
        ].join(" "),
        warning: [
          "data-[state=checked]:border-amber-500 data-[state=checked]:bg-amber-500 data-[state=checked]:text-amber-950"
        ].join(" "),
        muted: [
          "data-[state=checked]:border-muted-foreground/50 data-[state=checked]:bg-muted data-[state=checked]:text-foreground"
        ].join(" ")
      },
      size: {
        sm: "size-3.5 min-h-3.5 min-w-3.5 max-h-3.5 max-w-3.5",
        default: "size-4 min-h-4 min-w-4 max-h-4 max-w-4",
        lg: "size-5 min-h-5 min-w-5 max-h-5 max-w-5"
      },
      motion: {
        none: "",
        pop: [
          "motion-safe:active:scale-95",
          "data-[state=checked]:motion-safe:scale-[1.04]"
        ].join(" "),
        glow: "data-[state=checked]:shadow-[0_0_0_3px] data-[state=checked]:shadow-primary/35",
        "pop-glow": [
          "motion-safe:active:scale-95",
          "data-[state=checked]:motion-safe:scale-[1.04]",
          "data-[state=checked]:shadow-[0_0_0_3px] data-[state=checked]:shadow-primary/35"
        ].join(" ")
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default",
      motion: "none"
    }
  }
);
var radioIndicatorDotVariants = cva3(
  "pointer-events-none absolute top-1/2 start-1/2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full",
  {
    variants: {
      variant: {
        default: "bg-primary-foreground",
        outline: "bg-primary",
        secondary: "bg-secondary-foreground",
        success: "bg-primary-foreground",
        destructive: "bg-destructive-foreground",
        warning: "bg-amber-950",
        muted: "bg-foreground"
      },
      size: {
        sm: "size-1.5",
        default: "size-2",
        lg: "size-2.5"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
);
var radioIndicatorWrapperVariants = cva3("relative flex size-full items-center justify-center", {
  variants: {
    motion: {
      none: "",
      pop: "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-150",
      glow: "",
      "pop-glow": "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:zoom-in-95 motion-safe:duration-150"
    }
  },
  defaultVariants: { motion: "none" }
});
var RadioGroupItemChromeContext = React5.createContext({});
function RadioGroup({
  className,
  itemVariant,
  itemSize,
  itemMotion,
  ...props
}) {
  const ctx = React5.useMemo(
    () => ({ itemVariant, itemSize, itemMotion }),
    [itemVariant, itemSize, itemMotion]
  );
  return /* @__PURE__ */ jsx8(RadioGroupItemChromeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx8(
    RadioGroupPrimitive.Root,
    {
      "data-slot": "radio-group",
      className: cn("grid w-full gap-2", className),
      ...props
    }
  ) });
}
var RadioGroupItem = React5.forwardRef(function RadioGroupItem2({ className, variant: variantProp, size: sizeProp, motion: motionProp, ...props }, ref) {
  const ctx = React5.useContext(RadioGroupItemChromeContext);
  const variant = variantProp ?? ctx.itemVariant;
  const size = sizeProp ?? ctx.itemSize;
  const motion = motionProp ?? ctx.itemMotion ?? "none";
  const vResolved = variant ?? "default";
  const sResolved = size ?? "default";
  return /* @__PURE__ */ jsx8(
    RadioGroupPrimitive.Item,
    {
      ref,
      "data-slot": "radio-group-item",
      "data-variant": vResolved,
      "data-motion": motion,
      className: cn(radioGroupItemVariants({ variant, size, motion }), className),
      ...props,
      children: /* @__PURE__ */ jsx8(
        RadioGroupPrimitive.Indicator,
        {
          "data-slot": "radio-group-indicator",
          className: radioIndicatorWrapperVariants({ motion }),
          children: /* @__PURE__ */ jsx8("span", { className: radioIndicatorDotVariants({ variant: vResolved, size: sResolved }) })
        }
      )
    }
  );
});
function RadioGroupLabel({ className, ...props }) {
  return /* @__PURE__ */ jsx8(
    Label,
    {
      "data-slot": "radio-group-label",
      className: cn(
        "inline-flex min-h-11 cursor-pointer select-none items-center gap-2 py-1 -my-1 text-sm font-medium leading-snug",
        "peer-disabled:cursor-not-allowed peer-disabled:opacity-60",
        className
      ),
      ...props
    }
  );
}

// src/components/ui/selection-tile-grid.tsx
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
function selectionTileClassNames(selected) {
  return cn(
    "flex aspect-square flex-col items-center justify-center gap-1.5 rounded-lg border px-2 py-3 text-xs leading-tight transition-colors",
    "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
    selected ? "border-brand bg-brand/5 text-foreground font-medium shadow-sm" : "border-border bg-background text-muted-foreground hover:border-border/80 hover:text-interactive-hover-foreground"
  );
}
function selectionTilePreviewClassNames(selected) {
  return cn(
    "relative box-border flex aspect-square w-full max-w-full flex-col rounded-lg border p-1 transition-colors",
    selected ? "border-brand bg-brand/5 shadow-sm" : "border-border bg-background hover:border-border/80"
  );
}
function SelectionTileGraphic({
  option,
  selected
}) {
  if (option.leading != null) {
    return /* @__PURE__ */ jsx9("span", { className: "flex h-full min-h-0 w-full min-w-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:block [&_svg]:h-full [&_svg]:w-auto [&_svg]:max-h-full [&_svg]:max-w-full [&_svg]:object-contain [&_svg]:object-center", children: option.leading });
  }
  if (option.icon) {
    return /* @__PURE__ */ jsx9(
      "i",
      {
        className: cn(
          "fa-light shrink-0 text-[18px] leading-none",
          option.icon,
          selected && "text-brand"
        ),
        "aria-hidden": "true"
      }
    );
  }
  return null;
}
function SelectionTileLabelText({
  option
}) {
  return /* @__PURE__ */ jsx9("span", { className: "text-center leading-tight", children: option.label });
}
function SelectionTileCaptionBelow({
  option,
  selected,
  ariaHidden = false
}) {
  return /* @__PURE__ */ jsx9(
    "span",
    {
      className: cn(
        "max-w-full px-0.5 text-center text-xs leading-tight",
        selected ? "font-medium text-foreground" : "text-muted-foreground"
      ),
      ...ariaHidden ? { "aria-hidden": true } : {},
      children: option.label
    }
  );
}
function SelectionTileGrid({
  sectionLabel,
  options,
  columns = 4,
  value,
  onValueChange,
  interaction,
  idPrefix = "tile",
  className,
  labelPlacement = "inside",
  itemVariant,
  itemSize,
  itemMotion
}) {
  const gridClass = cn(
    "gap-2",
    columns === 2 && "grid grid-cols-2",
    columns === 3 && "grid grid-cols-3",
    columns === 4 && "grid grid-cols-4"
  );
  if (interaction === "radio") {
    return /* @__PURE__ */ jsxs4("div", { className, children: [
      sectionLabel ? /* @__PURE__ */ jsx9("p", { className: "mb-2 text-xs font-medium text-muted-foreground", children: sectionLabel }) : null,
      /* @__PURE__ */ jsx9(
        RadioGroup,
        {
          value,
          onValueChange: (v) => onValueChange(v),
          className: gridClass,
          itemVariant,
          itemSize,
          itemMotion,
          children: options.map((opt) => {
            const selected = value === opt.value;
            const id = `${idPrefix}-${opt.value}`;
            if (labelPlacement === "below") {
              return /* @__PURE__ */ jsxs4(
                Label,
                {
                  htmlFor: id,
                  className: cn(
                    "flex min-w-0 cursor-pointer flex-col items-center gap-1.5 rounded-lg focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background"
                  ),
                  children: [
                    /* @__PURE__ */ jsxs4("span", { className: cn("flex w-full justify-center", selectionTilePreviewClassNames(selected)), children: [
                      /* @__PURE__ */ jsx9(RadioGroupItem, { value: opt.value, id, className: "sr-only" }),
                      /* @__PURE__ */ jsx9("span", { className: "flex min-h-0 w-full min-w-0 flex-1 items-center justify-center", children: /* @__PURE__ */ jsx9(SelectionTileGraphic, { option: opt, selected }) })
                    ] }),
                    /* @__PURE__ */ jsx9(SelectionTileCaptionBelow, { option: opt, selected })
                  ]
                },
                opt.value
              );
            }
            return /* @__PURE__ */ jsxs4(
              Label,
              {
                htmlFor: id,
                className: cn(
                  "cursor-pointer rounded-lg focus-within:rounded-lg focus-within:ring-2 focus-within:ring-ring focus-within:outline-none",
                  selectionTileClassNames(selected)
                ),
                children: [
                  /* @__PURE__ */ jsx9(RadioGroupItem, { value: opt.value, id, className: "sr-only" }),
                  /* @__PURE__ */ jsx9(SelectionTileGraphic, { option: opt, selected }),
                  /* @__PURE__ */ jsx9(SelectionTileLabelText, { option: opt })
                ]
              },
              opt.value
            );
          })
        }
      )
    ] });
  }
  return /* @__PURE__ */ jsxs4("div", { className, children: [
    sectionLabel ? /* @__PURE__ */ jsx9("p", { className: "mb-2 text-xs font-medium text-muted-foreground", children: sectionLabel }) : null,
    /* @__PURE__ */ jsx9("div", { className: gridClass, children: options.map((opt) => {
      const selected = value === opt.value;
      if (labelPlacement === "below") {
        return /* @__PURE__ */ jsxs4(
          "button",
          {
            type: "button",
            "aria-label": opt.label,
            "aria-pressed": selected,
            onClick: () => onValueChange(opt.value),
            className: "flex min-w-0 flex-col items-center gap-1.5 rounded-lg border-0 bg-transparent p-0 text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
            children: [
              /* @__PURE__ */ jsx9("span", { className: cn("flex w-full justify-center", selectionTilePreviewClassNames(selected)), children: /* @__PURE__ */ jsx9("span", { className: "flex min-h-0 w-full min-w-0 flex-1 items-center justify-center", children: /* @__PURE__ */ jsx9(SelectionTileGraphic, { option: opt, selected }) }) }),
              /* @__PURE__ */ jsx9(SelectionTileCaptionBelow, { option: opt, selected, ariaHidden: true })
            ]
          },
          opt.value
        );
      }
      return /* @__PURE__ */ jsxs4(
        "button",
        {
          type: "button",
          "aria-label": opt.label,
          "aria-pressed": selected,
          onClick: () => onValueChange(opt.value),
          className: selectionTileClassNames(selected),
          children: [
            /* @__PURE__ */ jsx9(SelectionTileGraphic, { option: opt, selected }),
            /* @__PURE__ */ jsx9(SelectionTileLabelText, { option: opt })
          ]
        },
        opt.value
      );
    }) })
  ] });
}

// src/components/ui/calendar.tsx
import * as React6 from "react";
import {
  ChevronDownIcon,
  ChevronLeftIcon,
  ChevronRightIcon
} from "lucide-react";
import {
  DayPicker,
  getDefaultClassNames
} from "react-day-picker";
import { jsx as jsx10 } from "react/jsx-runtime";
function Calendar({
  className,
  classNames,
  showOutsideDays = true,
  captionLayout = "label",
  buttonVariant = "ghost",
  formatters,
  components,
  ...props
}) {
  const defaultClassNames = getDefaultClassNames();
  return /* @__PURE__ */ jsx10(
    DayPicker,
    {
      showOutsideDays,
      className: cn(
        "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
        String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
        String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
        className
      ),
      captionLayout,
      formatters: {
        formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
        ...formatters
      },
      classNames: {
        root: cn("w-fit", defaultClassNames.root),
        months: cn(
          "relative flex flex-col gap-4 md:flex-row",
          defaultClassNames.months
        ),
        month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
        nav: cn(
          "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
          defaultClassNames.nav
        ),
        button_previous: cn(
          buttonVariants({ variant: buttonVariant }),
          "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
          defaultClassNames.button_previous
        ),
        button_next: cn(
          buttonVariants({ variant: buttonVariant }),
          "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
          defaultClassNames.button_next
        ),
        month_caption: cn(
          "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
          defaultClassNames.month_caption
        ),
        dropdowns: cn(
          "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
          defaultClassNames.dropdowns
        ),
        dropdown_root: cn(
          "relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
          defaultClassNames.dropdown_root
        ),
        dropdown: cn(
          "absolute inset-0 bg-popover opacity-0",
          defaultClassNames.dropdown
        ),
        caption_label: cn(
          "font-medium select-none",
          captionLayout === "label" ? "text-sm" : "flex h-8 items-center gap-1 rounded-md pe-1 ps-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
          defaultClassNames.caption_label
        ),
        table: "w-full border-collapse",
        weekdays: cn("flex", defaultClassNames.weekdays),
        weekday: cn(
          "flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
          defaultClassNames.weekday
        ),
        week: cn("mt-2 flex w-full", defaultClassNames.week),
        week_number_header: cn(
          "w-(--cell-size) select-none",
          defaultClassNames.week_number_header
        ),
        week_number: cn(
          "text-[0.8rem] text-muted-foreground select-none",
          defaultClassNames.week_number
        ),
        day: cn(
          "group/day relative aspect-square size-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
          props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md" : "[&:first-child[data-selected=true]_button]:rounded-l-md",
          defaultClassNames.day
        ),
        range_start: cn(
          "rounded-l-md bg-accent",
          defaultClassNames.range_start
        ),
        range_middle: cn("rounded-none", defaultClassNames.range_middle),
        range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
        today: cn(
          "rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
          defaultClassNames.today
        ),
        outside: cn(
          "text-muted-foreground aria-selected:text-muted-foreground",
          defaultClassNames.outside
        ),
        disabled: cn(
          "text-muted-foreground opacity-50",
          defaultClassNames.disabled
        ),
        hidden: cn("invisible", defaultClassNames.hidden),
        ...classNames
      },
      components: {
        Root: ({ className: className2, rootRef, ...props2 }) => {
          return /* @__PURE__ */ jsx10(
            "div",
            {
              "data-slot": "calendar",
              ref: rootRef,
              className: cn(className2),
              ...props2
            }
          );
        },
        Chevron: ({ className: className2, orientation, ...props2 }) => {
          if (orientation === "left") {
            return /* @__PURE__ */ jsx10(ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
          }
          if (orientation === "right") {
            return /* @__PURE__ */ jsx10(
              ChevronRightIcon,
              {
                className: cn("size-4", className2),
                ...props2
              }
            );
          }
          return /* @__PURE__ */ jsx10(ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
        },
        DayButton: CalendarDayButton,
        WeekNumber: ({ children, ...props2 }) => {
          return /* @__PURE__ */ jsx10("td", { ...props2, children: /* @__PURE__ */ jsx10("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
        },
        ...components
      },
      ...props
    }
  );
}
function CalendarDayButton({
  className,
  day,
  modifiers,
  ...props
}) {
  const defaultClassNames = getDefaultClassNames();
  const focusRef = React6.useCallback(
    (node) => {
      if (modifiers.focused) node?.focus();
    },
    [modifiers.focused]
  );
  return /* @__PURE__ */ jsx10(
    Button,
    {
      ref: focusRef,
      variant: "ghost",
      size: "icon",
      "data-day": day.date.toLocaleDateString(),
      "data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
      "data-range-start": modifiers.range_start,
      "data-range-end": modifiers.range_end,
      "data-range-middle": modifiers.range_middle,
      className: cn(
        "flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
        defaultClassNames.day,
        className
      ),
      ...props
    }
  );
}

// src/components/ui/input-group.tsx
import { cva as cva4 } from "class-variance-authority";

// src/components/ui/input.tsx
import * as React7 from "react";
import { jsx as jsx11 } from "react/jsx-runtime";
var Input = React7.forwardRef(
  function Input2({ className, type, ...props }, ref) {
    return /* @__PURE__ */ jsx11(
      "input",
      {
        ref,
        type,
        "data-slot": "input",
        className: cn(
          "h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
          className
        ),
        ...props
      }
    );
  }
);

// src/components/ui/input-group.tsx
import { jsx as jsx12 } from "react/jsx-runtime";
function InputGroup({ className, ...props }) {
  return /* @__PURE__ */ jsx12(
    "div",
    {
      "data-slot": "input-group",
      role: "group",
      className: cn(
        "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-md border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
        className
      ),
      ...props
    }
  );
}
var inputGroupAddonVariants = cva4(
  "flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
  {
    variants: {
      align: {
        "inline-start": "order-first ps-2 has-[>button]:ms-[-0.3rem] has-[>kbd]:ms-[-0.15rem]",
        "inline-end": "order-last pe-2 has-[>button]:me-[-0.3rem] has-[>kbd]:me-[-0.15rem]",
        "block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
        "block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
      }
    },
    defaultVariants: {
      align: "inline-start"
    }
  }
);
function InputGroupAddon({
  className,
  align = "inline-start",
  ...props
}) {
  return /* @__PURE__ */ jsx12(
    "div",
    {
      role: "group",
      "data-slot": "input-group-addon",
      "data-align": align,
      className: cn(inputGroupAddonVariants({ align }), className),
      onClick: (e) => {
        if (e.target.closest("button")) {
          return;
        }
        e.currentTarget.parentElement?.querySelector("input")?.focus();
      },
      onKeyDown: (e) => {
        if (e.key !== "Enter" && e.key !== " ") return;
        if (e.target.closest("button")) return;
        e.preventDefault();
        e.currentTarget.parentElement?.querySelector("input")?.focus();
      },
      ...props
    }
  );
}
var inputGroupButtonVariants = cva4(
  "flex items-center gap-2 text-sm shadow-none",
  {
    variants: {
      size: {
        xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
        sm: "",
        "icon-xs": "size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
        "icon-sm": "size-8 p-0 has-[>svg]:p-0"
      }
    },
    defaultVariants: {
      size: "xs"
    }
  }
);
function InputGroupButton({
  className,
  type = "button",
  variant = "ghost",
  size = "xs",
  ...props
}) {
  return /* @__PURE__ */ jsx12(
    Button,
    {
      type,
      "data-size": size,
      variant,
      className: cn(inputGroupButtonVariants({ size }), className),
      ...props
    }
  );
}

// src/components/ui/input-mask.tsx
import * as React8 from "react";
import {
  useMaskInput,
  withMask,
  useHookFormMask,
  withHookFormMask,
  useTanStackFormMask,
  withTanStackFormMask
} from "use-mask-input";

// src/lib/compose-refs.ts
function composeRefs(...refs) {
  return (node) => {
    for (const ref of refs) {
      if (ref == null) continue;
      if (typeof ref === "function") {
        ref(node);
      } else {
        ;
        ref.current = node;
      }
    }
  };
}

// src/components/ui/input-mask.tsx
import { jsx as jsx13 } from "react/jsx-runtime";
var exxatInputMaskDefaults = {
  placeholder: "_",
  showMaskOnHover: false
};
var exxatMaskPatterns = {
  /** US NANP 10-digit display */
  phoneUS: "(999) 999-9999",
  /** US ZIP or ZIP+4 */
  zipUS: "99999[-9999]",
  /** Calendar-style date (validate separately). */
  dateMDY: "99/99/9999",
  /** Studio input-mask-01 style — UK-style plate-ish token; adjust per product. */
  customReference: "AA99 AAA"
};
var MaskedInput = React8.forwardRef(function MaskedInput2({ mask, maskOptions, className, type = "text", ...props }, ref) {
  const maskRef = useMaskInput({
    mask,
    options: { ...exxatInputMaskDefaults, ...maskOptions }
  });
  return /* @__PURE__ */ jsx13(
    Input,
    {
      ref: composeRefs(ref, maskRef),
      type,
      className: cn(className),
      ...props
    }
  );
});

// src/components/ui/popover.tsx
import { Popover as PopoverPrimitive } from "radix-ui";
import { jsx as jsx14 } from "react/jsx-runtime";
function Popover({ ...props }) {
  return /* @__PURE__ */ jsx14(PopoverPrimitive.Root, { ...props });
}
function PopoverTrigger({ className, ...props }) {
  return /* @__PURE__ */ jsx14(PopoverPrimitive.Trigger, { className: cn("cursor-pointer", className), ...props });
}
function PopoverContent({
  className,
  align = "start",
  sideOffset = 4,
  ...props
}) {
  return /* @__PURE__ */ jsx14(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx14(
    PopoverPrimitive.Content,
    {
      "data-slot": "popover-content",
      align,
      sideOffset,
      className: cn(
        "z-50 rounded-lg border border-border bg-popover shadow-md outline-none",
        "data-[state=open]:animate-in data-[state=closed]:animate-out",
        "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
        "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
        "data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",
        "data-[side=left]:slide-in-from-end-2 data-[side=right]:slide-in-from-start-2",
        className
      ),
      ...props
    }
  ) });
}

// src/components/ui/date-picker-field.tsx
import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
var DATE_PICKER_ICON_CLASS = "fa-light fa-calendar";
function parseMdyToLocalDate(raw) {
  const match = raw.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
  if (!match) return void 0;
  const month = Number(match[1]);
  const day = Number(match[2]);
  const year = Number(match[3]);
  if (month < 1 || month > 12 || day < 1 || day > 31) return void 0;
  const date = new Date(year, month - 1, day, 12, 0, 0, 0);
  if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) return void 0;
  return date;
}
function formatLocalDateToMdy(date) {
  const month = String(date.getMonth() + 1).padStart(2, "0");
  const day = String(date.getDate()).padStart(2, "0");
  const year = String(date.getFullYear());
  return `${month}/${day}/${year}`;
}
function DateTextInputField({
  value,
  onValueChange,
  "aria-label": ariaLabel,
  id,
  placeholder = "MM/DD/YYYY",
  className,
  inputClassName,
  autoFocus,
  disabled,
  fromYear = 2020,
  toYear = 2032,
  iconButtonVariant = "ghost",
  popoverAlign = "end",
  popoverClassName
}) {
  return /* @__PURE__ */ jsxs5(InputGroup, { className, children: [
    /* @__PURE__ */ jsx15(
      MaskedInput,
      {
        "data-slot": "input-group-control",
        id,
        mask: exxatMaskPatterns.dateMDY,
        "aria-label": ariaLabel,
        placeholder,
        value,
        onChange: (event) => onValueChange(event.target.value),
        className: cn(
          "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
          inputClassName
        ),
        autoFocus,
        disabled
      }
    ),
    /* @__PURE__ */ jsx15(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsxs5(Popover, { children: [
      /* @__PURE__ */ jsx15(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx15(
        InputGroupButton,
        {
          type: "button",
          variant: iconButtonVariant,
          size: "icon-xs",
          disabled,
          "aria-label": `${ariaLabel} pick date`,
          children: /* @__PURE__ */ jsx15("i", { className: DATE_PICKER_ICON_CLASS, "aria-hidden": "true" })
        }
      ) }),
      /* @__PURE__ */ jsx15(
        PopoverContent,
        {
          className: cn("z-[80] w-auto p-0", popoverClassName),
          align: popoverAlign,
          sideOffset: 6,
          children: /* @__PURE__ */ jsx15(
            Calendar,
            {
              mode: "single",
              selected: parseMdyToLocalDate(value),
              onSelect: (next) => onValueChange(next ? formatLocalDateToMdy(next) : ""),
              initialFocus: true,
              fromYear,
              toYear,
              captionLayout: "dropdown"
            }
          )
        }
      )
    ] }) })
  ] });
}

// src/components/data-table/filter-text-value-input.tsx
import { jsx as jsx16 } from "react/jsx-runtime";
var MASK_BY_KIND = {
  phone: exxatMaskPatterns.phoneUS,
  zip: exxatMaskPatterns.zipUS,
  dateMDY: exxatMaskPatterns.dateMDY
};
function FilterTextValueInput({
  id,
  mask,
  value,
  onValueChange,
  "aria-label": ariaLabel,
  placeholder,
  className,
  autoFocus
}) {
  if (mask === "dateMDY") {
    return /* @__PURE__ */ jsx16(
      DateTextInputField,
      {
        id,
        value,
        onValueChange,
        "aria-label": ariaLabel,
        placeholder,
        inputClassName: className,
        autoFocus,
        iconButtonVariant: "ghost",
        popoverAlign: "end"
      }
    );
  }
  if (mask) {
    return /* @__PURE__ */ jsx16(
      MaskedInput,
      {
        id,
        mask: MASK_BY_KIND[mask],
        "aria-label": ariaLabel,
        placeholder,
        value,
        onChange: (e) => onValueChange(e.target.value),
        className,
        autoFocus
      }
    );
  }
  return /* @__PURE__ */ jsx16(
    Input,
    {
      id,
      type: "text",
      "aria-label": ariaLabel,
      placeholder,
      value,
      onChange: (e) => onValueChange(e.target.value),
      className,
      autoFocus
    }
  );
}

// src/components/ui/sheet.tsx
import { Dialog as SheetPrimitive } from "radix-ui";
import { jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
function Sheet({ ...props }) {
  return /* @__PURE__ */ jsx17(SheetPrimitive.Root, { "data-slot": "sheet", ...props });
}
function SheetPortal({
  ...props
}) {
  return /* @__PURE__ */ jsx17(SheetPrimitive.Portal, { "data-slot": "sheet-portal", ...props });
}
function SheetOverlay({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx17(
    SheetPrimitive.Overlay,
    {
      "data-slot": "sheet-overlay",
      className: cn(
        "fixed inset-0 z-50 bg-overlay duration-300 ease-out supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
        className
      ),
      ...props
    }
  );
}
function SheetContent({
  className,
  children,
  side = "right",
  showCloseButton = true,
  showOverlay = true,
  ...props
}) {
  return /* @__PURE__ */ jsxs6(SheetPortal, { children: [
    showOverlay && /* @__PURE__ */ jsx17(SheetOverlay, {}),
    /* @__PURE__ */ jsxs6(
      SheetPrimitive.Content,
      {
        "data-slot": "sheet-content",
        "data-side": side,
        className: cn(
          "fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg outline-none duration-300 ease-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:start-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=right]:inset-y-0 data-[side=right]:end-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-6 data-[side=left]:data-open:slide-in-from-start-6 data-[side=right]:data-open:slide-in-from-end-6 data-[side=top]:data-open:slide-in-from-top-6 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-6 data-[side=left]:data-closed:slide-out-to-start-6 data-[side=right]:data-closed:slide-out-to-end-6 data-[side=top]:data-closed:slide-out-to-top-6",
          className
        ),
        ...props,
        children: [
          children,
          showCloseButton && /* @__PURE__ */ jsx17(SheetPrimitive.Close, { "data-slot": "sheet-close", asChild: true, children: /* @__PURE__ */ jsxs6(
            Button,
            {
              variant: "ghost",
              className: "absolute top-3 end-3",
              size: "icon-sm",
              children: [
                /* @__PURE__ */ jsx17("i", { className: "fa-light fa-xmark", "aria-hidden": "true" }),
                /* @__PURE__ */ jsx17("span", { className: "sr-only", children: "Close" })
              ]
            }
          ) })
        ]
      }
    )
  ] });
}
function SheetTitle({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx17(
    SheetPrimitive.Title,
    {
      "data-slot": "sheet-title",
      className: cn(
        "text-base font-medium text-foreground",
        className
      ),
      ...props
    }
  );
}

// src/components/ui/form.tsx
import * as React9 from "react";
import { Slot as Slot2 } from "radix-ui";
import {
  Controller,
  FormProvider,
  useFormContext
} from "react-hook-form";
import { jsx as jsx18 } from "react/jsx-runtime";
var Form = FormProvider;
var FormFieldContext = React9.createContext(
  {}
);
function FormField({ ...props }) {
  const fieldContextValue = React9.useMemo(
    () => ({ name: props.name }),
    [props.name]
  );
  return /* @__PURE__ */ jsx18(FormFieldContext.Provider, { value: fieldContextValue, children: /* @__PURE__ */ jsx18(Controller, { ...props }) });
}
function useFormField() {
  const fieldContext = React9.useContext(FormFieldContext);
  const itemContext = React9.useContext(FormItemContext);
  const { getFieldState, formState } = useFormContext();
  const fieldState = getFieldState(fieldContext.name, formState);
  if (!fieldContext) throw new Error("useFormField must be used inside <FormField>");
  const { id } = itemContext;
  return {
    id,
    name: fieldContext.name,
    formItemId: `${id}-form-item`,
    formDescriptionId: `${id}-form-item-description`,
    formMessageId: `${id}-form-item-message`,
    ...fieldState
  };
}
var FormItemContext = React9.createContext({});
function FormItem({ className, ...props }) {
  const id = React9.useId();
  const itemContextValue = React9.useMemo(() => ({ id }), [id]);
  return /* @__PURE__ */ jsx18(FormItemContext.Provider, { value: itemContextValue, children: /* @__PURE__ */ jsx18("div", { "data-slot": "form-item", className: cn("flex flex-col gap-1.5", className), ...props }) });
}
function FormLabel({ className, ...props }) {
  const { error, formItemId } = useFormField();
  return /* @__PURE__ */ jsx18(
    Label,
    {
      "data-slot": "form-label",
      "data-error": !!error,
      className: cn("data-[error=true]:text-destructive", className),
      htmlFor: formItemId,
      ...props
    }
  );
}
function FormControl({ ...props }) {
  const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
  return /* @__PURE__ */ jsx18(
    Slot2.Root,
    {
      "data-slot": "form-control",
      id: formItemId,
      "aria-describedby": !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`,
      "aria-invalid": !!error,
      ...props
    }
  );
}
function FormDescription({ className, ...props }) {
  const { formDescriptionId } = useFormField();
  return /* @__PURE__ */ jsx18(
    "p",
    {
      "data-slot": "form-description",
      id: formDescriptionId,
      className: cn("text-muted-foreground text-sm", className),
      ...props
    }
  );
}
function FormMessage({ className, children, ...props }) {
  const { error, formMessageId } = useFormField();
  const body = error ? String(error?.message ?? "") : children;
  if (!body) return null;
  return /* @__PURE__ */ jsx18(
    "p",
    {
      "data-slot": "form-message",
      id: formMessageId,
      className: cn("text-destructive text-sm", className),
      ...props,
      children: body
    }
  );
}

// src/components/ui/export-drawer.tsx
import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
function parseMdyToDate(raw) {
  if (!raw?.trim()) return void 0;
  const m = raw.trim().match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
  if (!m) return void 0;
  const month = Number(m[1]);
  const day = Number(m[2]);
  const year = Number(m[3]);
  if (month < 1 || month > 12 || day < 1 || day > 31) return void 0;
  const d = new Date(year, month - 1, day, 12, 0, 0, 0);
  if (d.getFullYear() !== year || d.getMonth() !== month - 1 || d.getDate() !== day) return void 0;
  return d;
}
var EXPORT_FORMAT_OPTIONS = [
  { value: "csv", label: "CSV", icon: "fa-file-csv" },
  { value: "excel", label: "Excel", icon: "fa-file-excel" },
  { value: "pdf", label: "PDF", icon: "fa-file-pdf" }
];
var exportSchema = z.object({
  format: z.enum(["csv", "excel", "pdf"]),
  columns: z.enum(["all", "visible"]),
  dateFrom: z.string().optional(),
  dateTo: z.string().optional(),
  includeFilters: z.boolean()
}).superRefine((data, ctx) => {
  const from = parseMdyToDate(data.dateFrom);
  const to = parseMdyToDate(data.dateTo);
  if (data.dateFrom?.trim() && !from) {
    ctx.addIssue({ code: "custom", message: "Enter a valid from date", path: ["dateFrom"] });
  }
  if (data.dateTo?.trim() && !to) {
    ctx.addIssue({ code: "custom", message: "Enter a valid to date", path: ["dateTo"] });
  }
  if (from && to && to < from) {
    ctx.addIssue({ code: "custom", message: "End date must be after start date", path: ["dateTo"] });
  }
});
function ExportDrawer({
  open,
  onOpenChange,
  totalRows = 0,
  visibleColumns
}) {
  const form = useForm({
    resolver: zodResolver(exportSchema),
    defaultValues: {
      format: "csv",
      columns: "visible",
      dateFrom: "",
      dateTo: "",
      includeFilters: true
    }
  });
  const [isExporting, setIsExporting] = React10.useState(false);
  async function onSubmit(values) {
    setIsExporting(true);
    await new Promise((r) => setTimeout(r, 1200));
    devLog("Export:", {
      ...values,
      dateFrom: parseMdyToDate(values.dateFrom)?.toISOString(),
      dateTo: parseMdyToDate(values.dateTo)?.toISOString()
    });
    setIsExporting(false);
    onOpenChange(false);
    form.reset();
  }
  return /* @__PURE__ */ jsx19(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsxs7(
    SheetContent,
    {
      "data-slot": "export-drawer",
      side: "right",
      showCloseButton: false,
      showOverlay: false,
      className: "z-[80] w-80 sm:max-w-80 p-0 gap-0 flex flex-col border border-border shadow-xl rounded-xl overflow-hidden",
      style: { top: "0.5rem", bottom: "0.5rem", right: "0.5rem", height: "calc(100vh - 1rem)" },
      children: [
        /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between gap-3 px-4 pt-5 pb-3", children: [
          /* @__PURE__ */ jsx19(SheetTitle, { className: "text-base font-semibold leading-tight", children: "Export data" }),
          /* @__PURE__ */ jsx19(Tip, { label: "Close", side: "bottom", children: /* @__PURE__ */ jsx19(
            Button,
            {
              type: "button",
              variant: "ghost",
              size: "icon-sm",
              "aria-label": "Close",
              onClick: () => onOpenChange(false),
              children: /* @__PURE__ */ jsx19("i", { className: "fa-light fa-xmark text-[13px]", "aria-hidden": "true" })
            }
          ) })
        ] }),
        /* @__PURE__ */ jsxs7("p", { className: "px-4 pb-3 text-sm text-muted-foreground -mt-1", children: [
          totalRows,
          " record",
          totalRows !== 1 ? "s" : "",
          " available for export."
        ] }),
        /* @__PURE__ */ jsx19(Form, { ...form, children: /* @__PURE__ */ jsx19(
          "form",
          {
            id: "export-form",
            onSubmit: form.handleSubmit(onSubmit),
            className: "flex-1 overflow-y-auto",
            children: /* @__PURE__ */ jsxs7("div", { className: "px-4 pb-4 space-y-5", children: [
              /* @__PURE__ */ jsx19(
                FormField,
                {
                  control: form.control,
                  name: "format",
                  render: ({ field }) => /* @__PURE__ */ jsxs7(FormItem, { children: [
                    /* @__PURE__ */ jsx19(FormControl, { children: /* @__PURE__ */ jsx19(
                      SelectionTileGrid,
                      {
                        sectionLabel: "File format",
                        options: EXPORT_FORMAT_OPTIONS,
                        columns: 3,
                        value: field.value,
                        onValueChange: field.onChange,
                        interaction: "radio",
                        idPrefix: "export-fmt",
                        itemVariant: "outline",
                        itemMotion: "pop"
                      }
                    ) }),
                    /* @__PURE__ */ jsx19(FormMessage, {})
                  ] })
                }
              ),
              /* @__PURE__ */ jsxs7("fieldset", { className: "space-y-2", children: [
                /* @__PURE__ */ jsxs7("legend", { className: "text-sm font-medium leading-none mb-2", children: [
                  "Date range",
                  " ",
                  /* @__PURE__ */ jsx19("span", { className: "text-muted-foreground font-normal", children: "(optional)" })
                ] }),
                /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-2 gap-3", children: [
                  /* @__PURE__ */ jsx19(
                    FormField,
                    {
                      control: form.control,
                      name: "dateFrom",
                      render: ({ field }) => /* @__PURE__ */ jsxs7(FormItem, { className: "gap-1", children: [
                        /* @__PURE__ */ jsx19(FormLabel, { htmlFor: "export-date-from", className: "text-xs text-muted-foreground", children: "From" }),
                        /* @__PURE__ */ jsx19(FormControl, { children: /* @__PURE__ */ jsx19(
                          FilterTextValueInput,
                          {
                            id: "export-date-from",
                            mask: "dateMDY",
                            "aria-label": "Export from date (optional)",
                            placeholder: "MM/DD/YYYY",
                            value: field.value ?? "",
                            onValueChange: field.onChange,
                            className: "h-8 text-sm"
                          }
                        ) }),
                        /* @__PURE__ */ jsx19(FormDescription, { className: "text-[11px]", children: "MM/DD/YYYY" }),
                        /* @__PURE__ */ jsx19(FormMessage, {})
                      ] })
                    }
                  ),
                  /* @__PURE__ */ jsx19(
                    FormField,
                    {
                      control: form.control,
                      name: "dateTo",
                      render: ({ field }) => /* @__PURE__ */ jsxs7(FormItem, { className: "gap-1", children: [
                        /* @__PURE__ */ jsx19(FormLabel, { htmlFor: "export-date-to", className: "text-xs text-muted-foreground", children: "To" }),
                        /* @__PURE__ */ jsx19(FormControl, { children: /* @__PURE__ */ jsx19(
                          FilterTextValueInput,
                          {
                            id: "export-date-to",
                            mask: "dateMDY",
                            "aria-label": "Export to date (optional)",
                            placeholder: "MM/DD/YYYY",
                            value: field.value ?? "",
                            onValueChange: field.onChange,
                            className: "h-8 text-sm"
                          }
                        ) }),
                        /* @__PURE__ */ jsx19(FormDescription, { className: "text-[11px]", children: "MM/DD/YYYY" }),
                        /* @__PURE__ */ jsx19(FormMessage, {})
                      ] })
                    }
                  )
                ] })
              ] }),
              /* @__PURE__ */ jsx19(
                FormField,
                {
                  control: form.control,
                  name: "columns",
                  render: ({ field }) => /* @__PURE__ */ jsxs7(FormItem, { children: [
                    /* @__PURE__ */ jsx19(FormLabel, { className: "text-sm font-medium", children: "Columns" }),
                    /* @__PURE__ */ jsx19(FormControl, { children: /* @__PURE__ */ jsx19(
                      RadioGroup,
                      {
                        value: field.value,
                        onValueChange: field.onChange,
                        className: "space-y-1.5 mt-1",
                        itemVariant: "outline",
                        itemMotion: "pop",
                        children: [
                          { value: "all", label: "All columns", sub: null },
                          { value: "visible", label: "Visible columns only", sub: visibleColumns !== void 0 ? `${visibleColumns} columns` : null }
                        ].map((opt) => /* @__PURE__ */ jsxs7(
                          "div",
                          {
                            className: "flex items-center gap-2.5 rounded-lg border border-border px-3 py-2.5 transition-colors hover:bg-interactive-hover has-[[data-state=checked]]:border-brand has-[[data-state=checked]]:bg-brand/10 cursor-pointer",
                            children: [
                              /* @__PURE__ */ jsx19(RadioGroupItem, { value: opt.value, id: `col-${opt.value}` }),
                              /* @__PURE__ */ jsxs7(
                                RadioGroupLabel,
                                {
                                  htmlFor: `col-${opt.value}`,
                                  className: "min-h-0 flex-1 cursor-pointer py-0 text-sm font-normal leading-none",
                                  children: [
                                    opt.label,
                                    opt.sub && /* @__PURE__ */ jsxs7("span", { className: "text-muted-foreground ms-1.5 font-normal", children: [
                                      "(",
                                      opt.sub,
                                      ")"
                                    ] })
                                  ]
                                }
                              )
                            ]
                          },
                          opt.value
                        ))
                      }
                    ) }),
                    /* @__PURE__ */ jsx19(FormMessage, {})
                  ] })
                }
              ),
              /* @__PURE__ */ jsx19(
                FormField,
                {
                  control: form.control,
                  name: "includeFilters",
                  render: ({ field }) => /* @__PURE__ */ jsxs7(FormItem, { children: [
                    /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-3 rounded-lg border border-border px-3 py-2.5 transition-colors hover:bg-interactive-hover has-[[data-state=checked]]:border-primary", children: [
                      /* @__PURE__ */ jsx19(FormControl, { children: /* @__PURE__ */ jsx19(
                        Checkbox,
                        {
                          id: "include-filters",
                          checked: field.value,
                          onCheckedChange: field.onChange,
                          className: "mt-0.5 shrink-0"
                        }
                      ) }),
                      /* @__PURE__ */ jsxs7("div", { className: "min-w-0", children: [
                        /* @__PURE__ */ jsx19(Label, { htmlFor: "include-filters", className: "text-sm cursor-pointer font-medium leading-none", children: "Apply active filters" }),
                        /* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground mt-1", children: "Export only rows matching current filters" })
                      ] })
                    ] }),
                    /* @__PURE__ */ jsx19(FormMessage, {})
                  ] })
                }
              )
            ] })
          }
        ) }),
        /* @__PURE__ */ jsx19(Shortcut, { keys: "Enter", disabled: isExporting, onInvoke: () => form.handleSubmit(onSubmit)() }),
        /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 px-4 py-3 border-t border-border", children: [
          /* @__PURE__ */ jsxs7(
            Button,
            {
              type: "button",
              variant: "outline",
              className: "flex-1",
              onClick: () => onOpenChange(false),
              children: [
                "Cancel",
                /* @__PURE__ */ jsx19(KbdGroup, { className: "ms-1.5", children: /* @__PURE__ */ jsx19(Kbd, { variant: "bare", children: "Esc" }) })
              ]
            }
          ),
          /* @__PURE__ */ jsx19(
            Button,
            {
              type: "submit",
              form: "export-form",
              className: "flex-1",
              disabled: isExporting,
              children: isExporting ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
                /* @__PURE__ */ jsx19("i", { className: "fa-light fa-spinner-third fa-spin text-[13px]", "aria-hidden": "true" }),
                "Exporting\u2026"
              ] }) : /* @__PURE__ */ jsxs7(Fragment2, { children: [
                /* @__PURE__ */ jsx19("i", { className: "fa-light fa-arrow-down-to-line text-[13px]", "aria-hidden": "true" }),
                "Export",
                /* @__PURE__ */ jsx19(KbdGroup, { className: "ms-1.5", children: /* @__PURE__ */ jsx19(Kbd, { variant: "bare", children: "\u23CE" }) })
              ] })
            }
          )
        ] })
      ]
    }
  ) });
}
export {
  ExportDrawer
};
//# sourceMappingURL=export-drawer.js.map