UNPKG

rharuow-ds

Version:

Modern React Design System with 20 components and auto color system. Define only 2 colors (primary/secondary) and get automatic variations (hover, light, dark) with proper text contrast (WCAG AA). Includes: Table, Card, Button, Chip, Pagination, Input, Te

2,876 lines 97.5 kB
"use client";
import * as a from "react";
import n, { useState as se, useRef as ge, useEffect as ye, createContext as je, useCallback as xe, useContext as Ye, useId as Ue } from "react";
import { useFormContext as ie, useWatch as ce } from "react-hook-form";
import { createPortal as pe } from "react-dom";
function Re(e) {
  var r, t, o = "";
  if (typeof e == "string" || typeof e == "number") o += e;
  else if (typeof e == "object") if (Array.isArray(e)) {
    var s = e.length;
    for (r = 0; r < s; r++) e[r] && (t = Re(e[r])) && (o && (o += " "), o += t);
  } else for (t in e) e[t] && (o && (o += " "), o += t);
  return o;
}
function Ge() {
  for (var e, r, t = 0, o = "", s = arguments.length; t < s; t++) (e = arguments[t]) && (r = Re(e)) && (o && (o += " "), o += r);
  return o;
}
function l(...e) {
  return Ge(...e);
}
const wt = ({
  children: e,
  variant: r = "default",
  size: t = "md",
  className: o = "",
  ...s
}) => {
  const u = "rounded font-medium transition disabled:cursor-not-allowed disabled:opacity-50", c = {
    default: "bg-[var(--primary)] text-[var(--primary-text)] hover:bg-[var(--primary-hover)] disabled:hover:bg-[var(--primary)]",
    outline: "border border-[var(--primary)] text-[var(--primary)] hover:bg-[var(--primary-light)] disabled:hover:bg-white",
    secondary: "bg-[var(--secondary)] text-[var(--secondary-text)] hover:bg-[var(--secondary-hover)] disabled:hover:bg-[var(--secondary)]",
    icon: "inline-flex items-center justify-center bg-[var(--primary)] text-[var(--primary-text)] hover:bg-[var(--primary-hover)] disabled:hover:bg-[var(--primary)]"
  }, g = {
    xl: "px-8 py-4 text-xl",
    lg: "px-6 py-3 text-lg",
    md: "px-4 py-2 text-base",
    sm: "px-3 py-1.5 text-sm",
    xs: "px-2 py-1 text-xs"
  };
  return /* @__PURE__ */ n.createElement("button", { className: l(u, c[r], g[t], o), ...s }, e);
}, yt = ({
  label: e,
  active: r = !1,
  onChange: t,
  icon: o,
  disabled: s = !1,
  className: u = "",
  onClick: c,
  ...g
}) => {
  const m = (v) => {
    s || (t == null || t(!r), c == null || c(v));
  };
  return /* @__PURE__ */ n.createElement(
    "button",
    {
      type: "button",
      role: "switch",
      "aria-checked": r,
      "aria-label": e,
      disabled: s,
      onClick: m,
      className: l(
        // Base
        "inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-sm font-medium",
        "border transition-all duration-200 select-none cursor-pointer",
        "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-1",
        // Active state
        r ? "bg-[var(--primary)] text-[var(--chip-active-text)] border-[var(--primary)] hover:bg-[var(--primary-hover)] hover:border-[var(--primary-hover)]" : "bg-[var(--chip-inactive-bg)] text-[var(--chip-inactive-text)] border-[var(--chip-inactive-border)] hover:bg-[var(--chip-inactive-hover-bg)] hover:border-[var(--primary)]",
        // Disabled state
        s && "opacity-40 cursor-not-allowed pointer-events-none",
        u
      ),
      ...g
    },
    o && /* @__PURE__ */ n.createElement("span", { className: "flex items-center" }, o),
    e
  );
};
function Ke(e, r) {
  if (r <= 0) return [];
  let t = Math.max(1, e - 1), o = Math.min(r, t + 2);
  t = Math.max(1, o - 2);
  const s = [];
  for (let u = t; u <= o; u++) s.push(u);
  return o < r && (r - o > 1 && s.push("..."), s.push(r)), s;
}
const we = ({
  active: e = !1,
  disabled: r = !1,
  onClick: t,
  children: o,
  ...s
}) => /* @__PURE__ */ n.createElement(
  "button",
  {
    type: "button",
    onClick: t,
    disabled: r,
    className: l(
      "min-w-[2rem] h-8 px-2 rounded font-medium text-sm transition-all duration-150",
      "flex items-center justify-center select-none",
      "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-1",
      e ? "bg-[var(--primary)] text-[var(--pagination-active-text)] border border-[var(--primary)]" : "bg-[var(--pagination-item-bg)] text-[var(--pagination-item-text)] border border-[var(--pagination-item-border)] hover:bg-[var(--pagination-item-hover-bg)] hover:border-[var(--primary)] hover:text-[var(--primary)]",
      r && "opacity-40 cursor-not-allowed pointer-events-none"
    ),
    ...s
  },
  o
), qe = () => /* @__PURE__ */ n.createElement(
  "svg",
  {
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: "0 0 20 20",
    fill: "currentColor",
    width: 16,
    height: 16,
    "aria-hidden": "true"
  },
  /* @__PURE__ */ n.createElement(
    "path",
    {
      fillRule: "evenodd",
      d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",
      clipRule: "evenodd"
    }
  )
), Je = () => /* @__PURE__ */ n.createElement(
  "svg",
  {
    xmlns: "http://www.w3.org/2000/svg",
    viewBox: "0 0 20 20",
    fill: "currentColor",
    width: 16,
    height: 16,
    "aria-hidden": "true"
  },
  /* @__PURE__ */ n.createElement(
    "path",
    {
      fillRule: "evenodd",
      d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",
      clipRule: "evenodd"
    }
  )
), Et = ({
  totalPages: e,
  currentPage: r,
  onPageChange: t,
  disabled: o = !1,
  className: s = ""
}) => {
  if (e <= 0) return null;
  const u = r <= 1, c = r >= e, g = Ke(r, e);
  return /* @__PURE__ */ n.createElement(
    "nav",
    {
      role: "navigation",
      "aria-label": "Paginação",
      className: l("flex items-center gap-1", s)
    },
    !u && /* @__PURE__ */ n.createElement(
      we,
      {
        "aria-label": "Página anterior",
        disabled: o,
        onClick: () => t(r - 1)
      },
      /* @__PURE__ */ n.createElement(qe, null)
    ),
    g.map(
      (m, v) => m === "..." ? /* @__PURE__ */ n.createElement(
        "span",
        {
          key: `ellipsis-${v}`,
          className: "min-w-[2rem] h-8 flex items-center justify-center text-sm text-[var(--pagination-item-text)] select-none",
          "aria-hidden": "true"
        },
        "…"
      ) : /* @__PURE__ */ n.createElement(
        we,
        {
          key: m,
          active: m === r,
          disabled: o,
          "aria-label": m === r ? `Página atual, página ${m}` : `Ir para página ${m}`,
          "aria-current": m === r ? "page" : void 0,
          onClick: () => t(m)
        },
        m
      )
    ),
    !c && /* @__PURE__ */ n.createElement(
      we,
      {
        "aria-label": "Próxima página",
        disabled: o,
        onClick: () => t(r + 1)
      },
      /* @__PURE__ */ n.createElement(Je, null)
    )
  );
}, be = (e) => e.replace(/\D/g, ""), Qe = (e) => {
  const t = be(e).slice(0, 11);
  return t.length <= 3 ? t : t.length <= 6 ? `${t.slice(0, 3)}.${t.slice(3)}` : t.length <= 9 ? `${t.slice(0, 3)}.${t.slice(3, 6)}.${t.slice(6)}` : `${t.slice(0, 3)}.${t.slice(3, 6)}.${t.slice(6, 9)}-${t.slice(9, 11)}`;
}, Me = (e) => {
  const r = be(e);
  if (r.length !== 11 || /^(\d)\1{10}$/.test(r))
    return !1;
  let t = 0;
  for (let s = 0; s < 9; s++)
    t += parseInt(r.charAt(s)) * (10 - s);
  let o = t * 10 % 11;
  if ((o === 10 || o === 11) && (o = 0), o !== parseInt(r.charAt(9)))
    return !1;
  t = 0;
  for (let s = 0; s < 10; s++)
    t += parseInt(r.charAt(s)) * (11 - s);
  return o = t * 10 % 11, (o === 10 || o === 11) && (o = 0), o === parseInt(r.charAt(10));
}, Xe = (e) => {
  const t = be(e).slice(0, 8);
  return t.length <= 5 ? t : `${t.slice(0, 5)}-${t.slice(5)}`;
}, Le = (e) => {
  const r = be(e);
  return !(r.length !== 8 || r === "00000000");
}, Ee = "BRL", Ne = "pt-BR";
function Ce(e) {
  if (e == null || e === "")
    return null;
  if (typeof e == "number")
    return Number.isFinite(e) ? Number(e.toFixed(2)) : null;
  const r = e.replace(/\D/g, "");
  return r ? Number(r) / 100 : null;
}
function ve(e, r = Ee, t = Ne) {
  const o = Ce(e);
  return o === null ? "" : new Intl.NumberFormat(t, {
    style: "currency",
    currency: r,
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  }).format(o);
}
function Ze(e, r = "string", t = Ee, o = Ne) {
  const s = Ce(e);
  return s === null ? r === "number" ? void 0 : "" : r === "number" ? s : ve(s, t, o);
}
const et = a.forwardRef(
  ({
    name: e,
    className: r,
    type: t = "text",
    label: o,
    onFocus: s,
    onBlur: u,
    onChange: c,
    Icon: g,
    iconClassName: m,
    iconAction: v,
    containerClassName: f,
    cpf: d = !1,
    cep: i = !1,
    currency: C = !1,
    currencyCode: R = Ee,
    currencyLocale: S = Ne,
    currencyValueType: h = "string",
    value: E,
    defaultValue: M,
    ...I
  }, k) => {
    var q, Z, L;
    const [N, F] = a.useState(!1), [T, p] = a.useState(!1), [B, D] = a.useState(null), [A, J] = a.useState(null), j = ie(), U = j == null ? void 0 : j.control, _ = j == null ? void 0 : j.register, $ = U && e ? ce({ control: U, name: e }) : void 0, Q = E ?? $ ?? M ?? "", W = C ? ve(Q, R, S) : Q, P = ((L = (Z = (q = j == null ? void 0 : j.formState) == null ? void 0 : q.errors) == null ? void 0 : Z[e]) == null ? void 0 : L.message) || B || A, G = ["date", "datetime-local", "time", "month", "week"].includes(t), ee = N || !!W || G, X = C ? "text" : t === "password" ? T ? "text" : "password" : t, re = () => /* @__PURE__ */ a.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ a.createElement(
      "path",
      {
        d: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z",
        fill: "currentColor"
      }
    )), ne = () => /* @__PURE__ */ a.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ a.createElement(
      "path",
      {
        d: "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z",
        fill: "currentColor"
      }
    )), oe = () => {
      p(!T);
    }, ae = (y) => {
      C && (y.target.value = ve(
        y.target.value,
        R,
        S
      ));
    }, x = (y) => {
      if (d) {
        const b = y.target.value, O = Qe(b);
        y.target.value = O, O.length === 14 ? Me(O) ? D(null) : D("CPF inválido") : D(null);
      }
    }, z = (y) => {
      if (i) {
        const b = y.target.value, O = Xe(b);
        y.target.value = O, O.length === 9 ? Le(O) ? J(null) : J("CEP inválido") : J(null);
      }
    }, w = (y) => {
      C && ae(y), d && x(y), i && z(y), c && c(y);
    }, V = C ? {
      setValueAs: (y) => Ze(
        y,
        h,
        R,
        S
      ),
      validate: (y) => y == null || y === "" ? !0 : Ce(y) !== null || "Valor monetário inválido"
    } : d ? {
      validate: (y) => y ? y.length < 14 ? "CPF incompleto" : Me(y) ? !0 : "CPF inválido" : "CPF é obrigatório"
    } : i ? {
      validate: (y) => y ? y.length < 9 ? "CEP incompleto" : Le(y) ? !0 : "CEP inválido" : "CEP é obrigatório"
    } : void 0, K = C && E === void 0 && j || C && E !== void 0 ? W : E, te = C ? ve(
      M,
      R,
      S
    ) : M;
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", f) }, /* @__PURE__ */ a.createElement(
      "input",
      {
        id: I.id || e,
        type: X,
        className: l(
          "peer flex h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 pt-6 pb-2 text-sm placeholder-transparent transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50",
          t === "password" || g ? "pr-12" : "",
          // espaço extra para qualquer ícone (password ou customizado)
          P ? "border-red-500" : "",
          r
        ),
        onFocus: (y) => {
          F(!0), s && s(y);
        },
        maxLength: d ? 14 : i ? 9 : I.maxLength,
        inputMode: C ? "decimal" : d || i ? "numeric" : I.inputMode,
        ...j && e ? (() => {
          const y = _(e, V), b = y.onBlur, O = y.onChange;
          return {
            ...y,
            ref: (H) => {
              typeof k == "function" ? k(H) : k && (k.current = H), y.ref && y.ref(H);
            },
            onBlur: (H) => {
              F(!1), u && u(H), b && b(H);
            },
            onChange: (H) => {
              w(H), O && O(H);
            }
          };
        })() : {
          ref: k,
          onBlur: (y) => {
            F(!1), u && u(y);
          },
          onChange: w
        },
        value: K,
        defaultValue: K === void 0 ? te : void 0,
        ...I
      }
    ), o && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: I.id || e,
        style: ee ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none text-[var(--foreground)] transition-all duration-200",
          ee ? "text-xs p-1 rounded-full bg-white text-[var(--primary)]" : "text-sm"
        )
      },
      o
    ), t === "password" && !C && /* @__PURE__ */ a.createElement(
      "button",
      {
        type: "button",
        className: "absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 hover:text-[var(--primary)] transition-colors duration-200 focus:outline-none focus:text-[var(--primary)]",
        onClick: oe,
        "aria-label": T ? "Esconder senha" : "Mostrar senha",
        tabIndex: -1
      },
      T ? /* @__PURE__ */ a.createElement(ne, null) : /* @__PURE__ */ a.createElement(re, null)
    ), g && t !== "password" && /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute top-1/2 right-3 -translate-y-1/2 text-gray-400 cursor-pointer hover:text-[var(--primary)] transition-colors duration-200",
          m
        ),
        onClick: v
      },
      /* @__PURE__ */ a.createElement(g, null)
    ), P && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, P));
  }
);
et.displayName = "Input";
const tt = a.forwardRef(
  ({
    name: e,
    className: r,
    label: t,
    onBlur: o,
    onChange: s,
    containerClassName: u,
    value: c,
    defaultValue: g,
    ...m
  }, v) => {
    var I, k, N;
    const [f, d] = a.useState(!1), i = ie(), C = i == null ? void 0 : i.control, R = i == null ? void 0 : i.register, S = C && e ? ce({ control: C, name: e }) : void 0, h = c ?? S ?? g ?? "#000000", E = (N = (k = (I = i == null ? void 0 : i.formState) == null ? void 0 : I.errors) == null ? void 0 : k[e]) == null ? void 0 : N.message, M = f || !!h;
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", u) }, /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "flex h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 pt-6 pb-2 text-sm transition focus-within:outline-none focus-within:border-[var(--primary)]",
          E ? "border-red-500" : "",
          r
        )
      },
      /* @__PURE__ */ a.createElement("div", { className: "flex items-center gap-2 w-full" }, /* @__PURE__ */ a.createElement(
        "input",
        {
          id: m.id || e,
          type: "color",
          className: "h-6 w-8 cursor-pointer rounded border-0 bg-transparent p-0 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",
          ...i && e ? (() => {
            const F = R(e), T = F.onBlur, p = F.onChange;
            return {
              ...F,
              ref: (B) => {
                typeof v == "function" ? v(B) : v && (v.current = B), F.ref && F.ref(B);
              },
              onFocus: () => d(!0),
              onBlur: (B) => {
                d(!1), o && o(B), T && T(B);
              },
              onChange: (B) => {
                p && p(B), s && s(B);
              }
            };
          })() : {
            ref: v,
            value: c,
            defaultValue: c === void 0 ? g ?? "#000000" : void 0,
            onFocus: () => d(!0),
            onBlur: (F) => {
              d(!1), o && o(F);
            },
            onChange: s
          },
          ...m
        }
      ), /* @__PURE__ */ a.createElement("span", { className: "text-sm text-[var(--foreground)] font-mono select-none" }, String(h).toUpperCase()))
    ), t && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: m.id || e,
        style: M ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none text-[var(--foreground)] transition-all duration-200",
          M ? "text-xs p-1 rounded-full bg-white text-[var(--primary)]" : "text-sm"
        )
      },
      t
    ), E && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, E));
  }
);
tt.displayName = "ColorInput";
const rt = a.forwardRef(
  ({
    name: e,
    label: r,
    options: t,
    className: o,
    containerClassName: s,
    isClearable: u,
    searchable: c = !1,
    filterPlaceholder: g = "Digite para filtrar...",
    caseSensitive: m = !1,
    filterFunction: v,
    onFocus: f,
    onBlur: d,
    ...i
  }, C) => {
    var ae, x, z;
    const [R, S] = a.useState(!1), [h, E] = a.useState(!1), [M, I] = a.useState(""), [k, N] = a.useState({
      top: 0,
      left: 0,
      width: 0
    }), F = a.useRef(null), T = a.useRef(null), p = ie(), B = p == null ? void 0 : p.control, D = B && e ? ce({ control: B, name: e }) : void 0, A = i.value ?? D ?? "", J = (z = (x = (ae = p == null ? void 0 : p.formState) == null ? void 0 : ae.errors) == null ? void 0 : x[e]) == null ? void 0 : z.message, U = v || ((w, V) => {
      const K = m ? w.label : w.label.toLowerCase(), te = m ? V : V.toLowerCase();
      return K.includes(te);
    }), _ = M.trim() ? t.filter((w) => U(w, M.trim())) : t, $ = t.find((w) => w.value === A), Q = !!$, W = c && h ? M : ($ == null ? void 0 : $.label) || "", P = R || Q || h || c && !!M, Y = a.useCallback(() => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768, []), G = a.useCallback(() => {
      if (F.current && h) {
        const w = F.current.getBoundingClientRect(), V = Y(), K = window.innerHeight, te = window.innerWidth, q = 152;
        let Z = w.bottom + 4, L = w.left;
        if (V) {
          const y = K - w.bottom, b = w.top;
          y < q && b > q && (Z = w.top - q - 4);
          const O = 16, H = te - w.width - O;
          L = Math.min(Math.max(L, O), H);
        } else
          K - w.bottom < q && (Z = w.top - q - 4);
        N({
          top: Z,
          left: L,
          width: w.width
        });
      }
    }, [h, Y]);
    a.useEffect(() => {
      if (G(), h) {
        const w = () => G(), V = () => G();
        return window.addEventListener("resize", w), window.addEventListener("scroll", V, !0), () => {
          window.removeEventListener("resize", w), window.removeEventListener("scroll", V, !0);
        };
      }
    }, [h, G]), a.useEffect(() => {
      const w = (V) => {
        F.current && !F.current.contains(V.target) && (E(!1), S(!1));
      };
      return document.addEventListener("mousedown", w), () => {
        document.removeEventListener("mousedown", w);
      };
    }, []);
    const ee = () => {
      E((w) => !w), S(!0);
    }, X = (w) => {
      S(!0), f && f(w);
    }, re = (w) => {
      d && d(w);
    }, ne = (w) => {
      I(w.target.value);
    }, oe = (w) => {
      if (p && e && p.setValue(e, w), i.onChange) {
        const V = {
          target: { value: w }
        };
        i.onChange(V);
      }
      E(!1), S(!1), I("");
    };
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", s), ref: F }, /* @__PURE__ */ a.createElement(
      "div",
      {
        id: i.id || e,
        tabIndex: 0,
        role: "button",
        "aria-haspopup": "listbox",
        "aria-expanded": h,
        className: l(
          "peer flex items-center h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",
          o
        ),
        onClick: c ? void 0 : ee,
        onFocus: c ? void 0 : X,
        onBlur: c ? void 0 : re,
        ref: C
      },
      c ? /* @__PURE__ */ a.createElement(
        "input",
        {
          ref: T,
          type: "text",
          value: W,
          onChange: ne,
          onFocus: c ? (w) => {
            S(!0), E(!0), f && f(w);
          } : void 0,
          onBlur: c ? (w) => {
            d && d(w);
          } : void 0,
          placeholder: r ? "" : g || "Selecione...",
          className: l(
            "w-full bg-transparent border-none outline-none text-sm",
            !Q && !M && "text-gray-400"
          )
        }
      ) : /* @__PURE__ */ a.createElement("span", { className: l("block truncate", !Q && "text-gray-400") }, ($ == null ? void 0 : $.label) || !r && "Selecione..."),
      u && A && /* @__PURE__ */ a.createElement(
        "button",
        {
          type: "button",
          tabIndex: -1,
          "aria-label": "Limpar seleção",
          className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",
          onClick: (w) => {
            if (w.stopPropagation(), p && e && p.setValue(e, ""), i.onChange) {
              const V = {
                target: { value: "" }
              };
              i.onChange(V);
            }
            E(!1), S(!1);
          }
        },
        "✕"
      )
    ), r && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: i.id || e,
        style: P ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none transition-all text-[var(--foreground)] duration-200",
          P ? "text-xs p-1 rounded-full bg-[var(--input-bg)] text-[var(--primary)]" : "text-sm"
        )
      },
      r
    ), /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute left-0 w-full mt-1 rounded-md transition-all duration-200 overflow-hidden",
          "bg-[var(--select-dropdown-bg)] border-[var(--select-dropdown-border)] text-[var(--foreground)]",
          h ? "border max-h-36 opacity-100 scale-100" : "max-h-0 opacity-0 scale-95 pointer-events-none"
        ),
        style: {
          maxHeight: h ? "9.5rem" : "0",
          // 3 options * 2.5rem + padding
          overflowY: t.length > 3 ? "auto" : "hidden",
          position: "fixed",
          // Use fixed positioning to escape container overflow
          top: h ? `${k.top}px` : "auto",
          left: h ? `${k.left}px` : "auto",
          width: h ? `${k.width}px` : "auto",
          zIndex: 9999,
          boxShadow: h ? "var(--select-dropdown-shadow)" : "none"
        }
      },
      _.length === 0 ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, "Nenhuma opção encontrada") : _.map((w) => /* @__PURE__ */ a.createElement(
        "div",
        {
          key: w.value,
          className: l(
            "px-3 py-2 cursor-pointer text-sm transition-colors duration-150",
            "hover:bg-[var(--select-dropdown-hover)]",
            A === w.value && "bg-[var(--select-dropdown-selected)]"
          ),
          onMouseDown: () => oe(w.value)
        },
        w.label
      ))
    ), J && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, J));
  }
);
rt.displayName = "Select";
const at = a.forwardRef(
  ({
    name: e,
    className: r,
    label: t,
    onFocus: o,
    onBlur: s,
    Icon: u,
    iconClassName: c,
    iconAction: g,
    containerClassName: m,
    rows: v = 4,
    ...f
  }, d) => {
    var N, F, T;
    const [i, C] = a.useState(!1), R = ie(), S = R == null ? void 0 : R.control, h = R == null ? void 0 : R.register, E = S && e ? ce({ control: S, name: e }) : void 0, M = f.value ?? E ?? "", I = (T = (F = (N = R == null ? void 0 : R.formState) == null ? void 0 : N.errors) == null ? void 0 : F[e]) == null ? void 0 : T.message, k = i || !!M;
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", m) }, /* @__PURE__ */ a.createElement(
      "textarea",
      {
        id: f.id || e,
        rows: v,
        className: l(
          "peer flex min-h-[80px] w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 pt-6 pb-2 text-sm placeholder-transparent transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50 resize-vertical",
          u ? "pr-12" : "",
          // espaço extra para ícone customizado
          r
        ),
        onFocus: (p) => {
          C(!0), o && o(p);
        },
        ...R && e ? (() => {
          const p = h(e), B = p.onBlur;
          return {
            ...p,
            ref: (D) => {
              typeof d == "function" ? d(D) : d && (d.current = D), p.ref && p.ref(D);
            },
            onBlur: (D) => {
              C(!1), s && s(D), B && B(D);
            }
          };
        })() : {
          ref: d,
          onBlur: (p) => {
            C(!1), s && s(p);
          }
        },
        ...f
      }
    ), t && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: f.id || e,
        style: k ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none text-[var(--foreground)] transition-all duration-200",
          k ? "text-xs p-1 rounded-full bg-white text-[var(--primary)]" : "text-sm"
        )
      },
      t
    ), u && /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute top-3 right-3 text-gray-400 cursor-pointer hover:text-[var(--primary)] transition-colors duration-200",
          c
        ),
        onClick: g
      },
      /* @__PURE__ */ a.createElement(u, null)
    ), I && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, I));
  }
);
at.displayName = "Textarea";
const nt = a.forwardRef(
  ({
    name: e,
    label: r,
    loadOptions: t,
    className: o,
    containerClassName: s,
    isClearable: u,
    defaultOptions: c = !1,
    loadingMessage: g = "Carregando...",
    noOptionsMessage: m = "Nenhuma opção encontrada",
    searchable: v = !1,
    debounceMs: f = 300,
    onFocus: d,
    onBlur: i,
    ...C
  }, R) => {
    var te, q, Z;
    const [S, h] = a.useState(!1), [E, M] = a.useState(!1), [I, k] = a.useState([]), [N, F] = a.useState(!1), [T, p] = a.useState(""), [B, D] = a.useState(""), [A, J] = a.useState({
      top: 0,
      left: 0,
      width: 0
    }), j = a.useRef(null), U = a.useRef(null), _ = ie(), $ = _ == null ? void 0 : _.control, Q = $ && e ? ce({ control: $, name: e }) : void 0, W = C.value ?? Q ?? "", P = (Z = (q = (te = _ == null ? void 0 : _.formState) == null ? void 0 : te.errors) == null ? void 0 : q[e]) == null ? void 0 : Z.message, Y = I.find((L) => L.value === W), G = !!Y, ee = S || G || E, X = a.useCallback(() => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768, []), re = a.useCallback(() => {
      if (j.current && E) {
        const L = j.current.getBoundingClientRect(), y = X(), b = window.innerHeight, O = window.innerWidth, H = 152;
        let de = L.bottom + 4, le = L.left;
        if (y) {
          const ue = b - L.bottom, me = L.top;
          ue < H && me > H && (de = L.top - H - 4);
          const fe = 16, he = O - L.width - fe;
          le = Math.min(Math.max(le, fe), he);
        } else
          b - L.bottom < H && (de = L.top - H - 4);
        J({
          top: de,
          left: le,
          width: L.width
        });
      }
    }, [E, X]);
    a.useEffect(() => {
      if (re(), E) {
        const L = () => re(), y = () => re();
        return window.addEventListener("resize", L), window.addEventListener("scroll", y, !0), () => {
          window.removeEventListener("resize", L), window.removeEventListener("scroll", y, !0);
        };
      }
    }, [E, re]), a.useEffect(() => {
      const L = setTimeout(() => {
        D(T);
      }, f);
      return () => clearTimeout(L);
    }, [T, f]), a.useEffect(() => {
      (E || c && I.length === 0) && ne(v ? B : void 0);
    }, [B, E]), a.useEffect(() => {
      c === !0 ? ne() : Array.isArray(c) && k(c);
    }, []);
    const ne = async (L) => {
      try {
        F(!0);
        const y = await t(L);
        k(y);
      } catch (y) {
        console.error("Error loading options:", y), k([]);
      } finally {
        F(!1);
      }
    };
    a.useEffect(() => {
      const L = (y) => {
        j.current && !j.current.contains(y.target) && (M(!1), h(!1), p(""));
      };
      return document.addEventListener("mousedown", L), () => {
        document.removeEventListener("mousedown", L);
      };
    }, []);
    const oe = () => {
      E || (M(!0), h(!0), v && U.current && setTimeout(() => {
        var L;
        return (L = U.current) == null ? void 0 : L.focus();
      }, 0));
    }, ae = (L) => {
      h(!0), d && d(L);
    }, x = (L) => {
      i && i(L);
    }, z = (L) => {
      p(L.target.value);
    }, w = (L) => {
      if (_ && e && _.setValue(e, L), C.onChange) {
        const y = {
          target: { value: L }
        };
        C.onChange(y);
      }
      M(!1), h(!1), p("");
    }, V = (L) => {
      if (L.stopPropagation(), _ && e && _.setValue(e, ""), C.onChange) {
        const y = {
          target: { value: "" }
        };
        C.onChange(y);
      }
      M(!1), h(!1), p("");
    }, K = v && E ? T : (Y == null ? void 0 : Y.label) || "";
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", s), ref: j }, /* @__PURE__ */ a.createElement(
      "div",
      {
        id: C.id || e,
        tabIndex: v ? -1 : 0,
        role: "button",
        "aria-haspopup": "listbox",
        "aria-expanded": E,
        className: l(
          "peer flex items-center h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",
          o
        ),
        onClick: oe,
        onFocus: v ? void 0 : ae,
        onBlur: v ? void 0 : x,
        ref: R
      },
      v ? /* @__PURE__ */ a.createElement(
        "input",
        {
          ref: U,
          type: "text",
          value: K,
          onChange: z,
          onFocus: ae,
          onBlur: x,
          placeholder: r ? "" : "Selecione...",
          className: l(
            "w-full bg-transparent border-none outline-none text-sm",
            !G && !T && "text-gray-400"
          )
        }
      ) : /* @__PURE__ */ a.createElement("span", { className: l("block truncate", !G && "text-gray-400") }, (Y == null ? void 0 : Y.label) || !r && "Selecione..."),
      N && /* @__PURE__ */ a.createElement("div", { className: "absolute right-8 top-1/2 -translate-y-1/2" }, /* @__PURE__ */ a.createElement("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary)]" })),
      u && W && !N && /* @__PURE__ */ a.createElement(
        "button",
        {
          type: "button",
          tabIndex: -1,
          "aria-label": "Limpar seleção",
          className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",
          onClick: V
        },
        "✕"
      )
    ), r && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: C.id || e,
        style: ee ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none text-[var(--foreground)] transition-all duration-200",
          ee ? "text-xs p-1 rounded-full bg-[var(--input-bg)] text-[var(--primary)]" : "text-sm"
        )
      },
      r
    ), /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute left-0 w-full mt-1 rounded-md transition-all duration-200 overflow-hidden",
          "bg-[var(--select-dropdown-bg)] border-[var(--select-dropdown-border)] text-[var(--foreground)]",
          E ? "border max-h-36 opacity-100 scale-100" : "max-h-0 opacity-0 scale-95 pointer-events-none"
        ),
        style: {
          maxHeight: E ? "9.5rem" : "0",
          overflowY: I.length > 3 ? "auto" : "hidden",
          position: "fixed",
          // Use fixed positioning to escape container overflow
          top: E ? `${A.top}px` : "auto",
          left: E ? `${A.left}px` : "auto",
          width: E ? `${A.width}px` : "auto",
          zIndex: 9999,
          boxShadow: E ? "var(--select-dropdown-shadow)" : "none"
        }
      },
      N ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, g) : I.length === 0 ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, m) : I.map((L) => /* @__PURE__ */ a.createElement(
        "div",
        {
          key: L.value,
          className: l(
            "px-3 py-2 cursor-pointer text-sm transition-colors duration-150",
            "hover:bg-[var(--select-dropdown-hover)]",
            W === L.value && "bg-[var(--select-dropdown-selected)]"
          ),
          onMouseDown: () => w(L.value)
        },
        L.label
      ))
    ), P && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, P));
  }
);
nt.displayName = "AsyncSelect";
const ot = a.forwardRef(
  ({
    name: e,
    label: r,
    options: t,
    className: o,
    containerClassName: s,
    isClearable: u,
    searchable: c = !1,
    filterPlaceholder: g = "Digite para filtrar...",
    caseSensitive: m = !1,
    filterFunction: v,
    onFocus: f,
    onBlur: d,
    ...i
  }, C) => {
    var ne, oe, ae;
    const [R, S] = a.useState(!1), [h, E] = a.useState(!1), [M, I] = a.useState(""), [k, N] = a.useState({
      top: 0,
      left: 0,
      width: 0
    }), F = a.useRef(null), T = a.useRef(null), p = ie(), B = p == null ? void 0 : p.control, D = B && e ? ce({ control: B, name: e }) : void 0, A = i.value ?? D ?? [], J = (ae = (oe = (ne = p == null ? void 0 : p.formState) == null ? void 0 : ne.errors) == null ? void 0 : oe[e]) == null ? void 0 : ae.message, U = v || ((x, z) => {
      const w = m ? x.label : x.label.toLowerCase(), V = m ? z : z.toLowerCase();
      return w.includes(V);
    }), _ = M.trim() ? t.filter((x) => U(x, M.trim())) : t, $ = R || A && A.length > 0 || h || c && !!M, Q = a.useCallback(() => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768, []), W = a.useCallback(() => {
      if (F.current && h) {
        const x = F.current.getBoundingClientRect(), z = Q(), w = window.innerHeight, V = window.innerWidth, K = 152;
        let te = x.bottom + 4, q = x.left;
        if (z) {
          const Z = w - x.bottom, L = x.top;
          Z < K && L > K && (te = x.top - K - 4);
          const y = 16, b = V - x.width - y;
          q = Math.min(Math.max(q, y), b);
        } else
          w - x.bottom < K && (te = x.top - K - 4);
        N({
          top: te,
          left: q,
          width: x.width
        });
      }
    }, [h, Q]);
    a.useEffect(() => {
      if (W(), h) {
        const x = () => W(), z = () => W();
        return window.addEventListener("resize", x), window.addEventListener("scroll", z, !0), () => {
          window.removeEventListener("resize", x), window.removeEventListener("scroll", z, !0);
        };
      }
    }, [h, W]), a.useEffect(() => {
      const x = (z) => {
        F.current && !F.current.contains(z.target) && (E(!1), S(!1));
      };
      return document.addEventListener("mousedown", x), () => {
        document.removeEventListener("mousedown", x);
      };
    }, []);
    const P = () => {
      E((x) => !x), S(!0);
    }, Y = (x) => {
      S(!0), f && f(x);
    }, G = (x) => {
      d && d(x);
    }, ee = (x) => {
      var w;
      let z;
      A.includes(x) ? z = A.filter((V) => V !== x) : z = [...A, x], p && e && p.setValue(e, z), i.onChange && ((w = i.onChange) == null || w.call(i, {
        target: { value: z }
      })), S(!0);
    }, X = (x) => {
      var z;
      x.stopPropagation(), p && e && p.setValue(e, []), i.onChange && ((z = i.onChange) == null || z.call(i, {
        target: { value: [] }
      })), E(!1), S(!1);
    }, re = (x) => {
      I(x.target.value);
    };
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", s), ref: F }, /* @__PURE__ */ a.createElement(
      "div",
      {
        id: i.id || e,
        tabIndex: 0,
        role: "button",
        "aria-haspopup": "listbox",
        "aria-expanded": h,
        className: l(
          "peer flex items-center h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 py-3 text-sm transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",
          o
        ),
        onClick: c ? void 0 : P,
        onFocus: c ? void 0 : Y,
        onBlur: c ? void 0 : G,
        ref: C
      },
      /* @__PURE__ */ a.createElement(
        "div",
        {
          className: "flex flex-nowrap gap-1 items-center min-h-[1.5rem] w-full overflow-x-auto",
          style: { scrollbarWidth: "none" }
        },
        A && A.length > 0 ? t.filter((x) => A.includes(x.value)).map((x) => /* @__PURE__ */ a.createElement(
          "span",
          {
            key: x.value,
            className: "flex items-center border border-blue-200 bg-blue-50 text-blue-700 rounded-2xl px-3 py-1 text-xs shadow-sm mr-1 gap-2",
            style: { maxWidth: "140px" }
          },
          /* @__PURE__ */ a.createElement("span", { className: "truncate", title: x.label }, x.label),
          /* @__PURE__ */ a.createElement(
            "button",
            {
              type: "button",
              className: "ml-1 text-[var(--primary)] hover:text-red-500 focus:outline-none w-4 h-4 flex items-center justify-center rounded-full transition-colors duration-150",
              "aria-label": `Remover ${x.label}`,
              tabIndex: -1,
              onClick: (z) => {
                z.stopPropagation();
                const w = A.filter((V) => V !== x.value);
                p && e && p.setValue(e, w), i.onChange && i.onChange({
                  target: { value: w }
                });
              }
            },
            /* @__PURE__ */ a.createElement(
              "svg",
              {
                width: "12",
                height: "12",
                viewBox: "0 0 12 12",
                fill: "none",
                xmlns: "http://www.w3.org/2000/svg"
              },
              /* @__PURE__ */ a.createElement(
                "path",
                {
                  d: "M3 3L9 9M9 3L3 9",
                  stroke: "currentColor",
                  strokeWidth: "1.5",
                  strokeLinecap: "round"
                }
              )
            )
          )
        )) : !r && !c && /* @__PURE__ */ a.createElement("span", { className: "text-gray-400 text-sm" }, "Selecione..."),
        c && /* @__PURE__ */ a.createElement(
          "input",
          {
            ref: T,
            type: "text",
            value: M,
            onChange: re,
            onFocus: (x) => {
              S(!0), E(!0), f && f(x);
            },
            onBlur: (x) => {
              d && d(x);
            },
            placeholder: r ? A && A.length > 0 ? "" : g : g || "Selecione...",
            className: "flex-1 bg-transparent border-none outline-none text-sm min-w-[100px]"
          }
        )
      ),
      u && A && A.length > 0 && /* @__PURE__ */ a.createElement(
        "button",
        {
          type: "button",
          tabIndex: -1,
          "aria-label": "Limpar seleção",
          className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",
          onClick: X
        },
        "✕"
      )
    ), r && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: i.id || e,
        style: $ ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text text-[var(--foreground)] select-none transition-all duration-200",
          $ ? "text-xs p-1 rounded-full bg-[var(--input-bg)] text-[var(--primary)]" : "text-sm"
        )
      },
      r
    ), /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute left-0 w-full mt-1 rounded-md transition-all duration-200 overflow-hidden",
          "bg-[var(--select-dropdown-bg)] border-[var(--select-dropdown-border)] text-[var(--foreground)]",
          h ? "border max-h-36 opacity-100 scale-100" : "max-h-0 opacity-0 scale-95 pointer-events-none"
        ),
        style: {
          maxHeight: h ? "9.5rem" : "0",
          overflowY: t.length > 3 ? "auto" : "hidden",
          position: "fixed",
          // Use fixed positioning to escape container overflow
          top: h ? `${k.top}px` : "auto",
          left: h ? `${k.left}px` : "auto",
          width: h ? `${k.width}px` : "auto",
          zIndex: 9999,
          boxShadow: h ? "var(--select-dropdown-shadow)" : "none"
        }
      },
      _.length === 0 ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, "Nenhuma opção encontrada") : _.map((x) => /* @__PURE__ */ a.createElement(
        "div",
        {
          key: x.value,
          className: l(
            "px-3 py-2 cursor-pointer text-sm flex items-center gap-2 transition-colors duration-150",
            "hover:bg-[var(--select-dropdown-hover)]",
            A.includes(x.value) && "bg-[var(--select-dropdown-selected)] font-semibold"
          ),
          onMouseDown: () => ee(x.value)
        },
        /* @__PURE__ */ a.createElement(
          "input",
          {
            type: "checkbox",
            checked: A.includes(x.value),
            readOnly: !0,
            className: "accent-blue-500"
          }
        ),
        x.label
      ))
    ), J && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, J));
  }
);
ot.displayName = "MultiSelect";
const st = a.forwardRef(
  ({
    name: e,
    label: r,
    loadOptions: t,
    className: o,
    containerClassName: s,
    isClearable: u,
    defaultOptions: c = !1,
    loadingMessage: g = "Carregando...",
    noOptionsMessage: m = "Nenhuma opção encontrada",
    searchable: v = !1,
    debounceMs: f = 300,
    maxSelectedDisplay: d = 3,
    onFocus: i,
    onBlur: C,
    ...R
  }, S) => {
    var Z, L, y;
    const [h, E] = a.useState(!1), [M, I] = a.useState(!1), [k, N] = a.useState([]), [F, T] = a.useState(!1), [p, B] = a.useState(""), [D, A] = a.useState(""), [J, j] = a.useState({
      top: 0,
      left: 0,
      width: 0
    }), U = a.useRef(null), _ = a.useRef(null), $ = ie(), Q = $ == null ? void 0 : $.control, W = Q && e ? ce({ control: Q, name: e }) : void 0, P = R.value ?? W ?? [], Y = (y = (L = (Z = $ == null ? void 0 : $.formState) == null ? void 0 : Z.errors) == null ? void 0 : L[e]) == null ? void 0 : y.message, G = h || P && P.length > 0 || M, ee = a.useCallback(() => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768, []), X = a.useCallback(() => {
      if (U.current && M) {
        const b = U.current.getBoundingClientRect(), O = ee(), H = window.innerHeight, de = window.innerWidth, le = 152;
        let ue = b.bottom + 4, me = b.left;
        if (O) {
          const fe = H - b.bottom, he = b.top;
          fe < le && he > le && (ue = b.top - le - 4);
          const Se = 16, _e = de - b.width - Se;
          me = Math.min(Math.max(me, Se), _e);
        } else
          H - b.bottom < le && (ue = b.top - le - 4);
        j({
          top: ue,
          left: me,
          width: b.width
        });
      }
    }, [M, ee]);
    a.useEffect(() => {
      if (X(), M) {
        const b = () => X(), O = () => X();
        return window.addEventListener("resize", b), window.addEventListener("scroll", O, !0), () => {
          window.removeEventListener("resize", b), window.removeEventListener("scroll", O, !0);
        };
      }
    }, [M, X]), a.useEffect(() => {
      const b = setTimeout(() => {
        A(p);
      }, f);
      return () => clearTimeout(b);
    }, [p, f]), a.useEffect(() => {
      (M || c && k.length === 0) && re(v ? D : void 0);
    }, [D, M]), a.useEffect(() => {
      c === !0 ? re() : Array.isArray(c) && N(c);
    }, []);
    const re = async (b) => {
      try {
        T(!0);
        const O = await t(b);
        N(O);
      } catch (O) {
        console.error("Error loading options:", O), N([]);
      } finally {
        T(!1);
      }
    };
    a.useEffect(() => {
      const b = (O) => {
        U.current && !U.current.contains(O.target) && (I(!1), E(!1), B(""));
      };
      return document.addEventListener("mousedown", b), () => {
        document.removeEventListener("mousedown", b);
      };
    }, []);
    const ne = () => {
      M || (I(!0), E(!0), v && _.current && setTimeout(() => {
        var b;
        return (b = _.current) == null ? void 0 : b.focus();
      }, 0));
    }, oe = (b) => {
      E(!0), i && i(b);
    }, ae = (b) => {
      C && C(b);
    }, x = (b) => {
      B(b.target.value);
    }, z = (b) => {
      let O;
      P.includes(b) ? O = P.filter((H) => H !== b) : O = [...P, b], $ && e && $.setValue(e, O), R.onChange && R.onChange({
        target: { value: O }
      }), E(!0);
    }, w = (b, O) => {
      O.stopPropagation();
      const H = P.filter((de) => de !== b);
      $ && e && $.setValue(e, H), R.onChange && R.onChange({
        target: { value: H }
      });
    }, V = (b) => {
      b.stopPropagation(), $ && e && $.setValue(e, []), R.onChange && R.onChange({
        target: { value: [] }
      }), I(!1), E(!1), B("");
    }, K = k.filter((b) => P.includes(b.value)), te = K.slice(0, d), q = K.length - d;
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", s), ref: U }, /* @__PURE__ */ a.createElement(
      "div",
      {
        id: R.id || e,
        tabIndex: v ? -1 : 0,
        role: "button",
        "aria-haspopup": "listbox",
        "aria-expanded": M,
        className: l(
          "peer flex items-center min-h-12 w-full border border-[var(--primary)] rounded-md bg-[var(--input-bg)] text-[var(--foreground)] px-3 py-2 text-sm transition focus:outline-none focus:border-[var(--primary)] disabled:cursor-not-allowed disabled:opacity-50 appearance-none cursor-pointer relative",
          o
        ),
        onClick: ne,
        onFocus: v ? void 0 : oe,
        onBlur: v ? void 0 : ae,
        ref: S
      },
      /* @__PURE__ */ a.createElement("div", { className: "flex flex-wrap gap-1 items-center min-h-[1.5rem] w-full" }, te.map((b) => /* @__PURE__ */ a.createElement(
        "span",
        {
          key: b.value,
          className: "flex items-center border border-blue-200 bg-blue-50 text-blue-700 rounded-2xl px-3 py-1 text-xs shadow-sm gap-2",
          style: { maxWidth: "140px" }
        },
        /* @__PURE__ */ a.createElement("span", { className: "truncate", title: b.label }, b.label),
        /* @__PURE__ */ a.createElement(
          "button",
          {
            type: "button",
            className: "ml-1 text-[var(--primary)] hover:text-red-500 focus:outline-none w-4 h-4 flex items-center justify-center rounded-full transition-colors duration-150",
            "aria-label": `Remover ${b.label}`,
            tabIndex: -1,
            onClick: (O) => w(b.value, O)
          },
          /* @__PURE__ */ a.createElement(
            "svg",
            {
              width: "12",
              height: "12",
              viewBox: "0 0 12 12",
              fill: "none",
              xmlns: "http://www.w3.org/2000/svg"
            },
            /* @__PURE__ */ a.createElement(
              "path",
              {
                d: "M3 3L9 9M9 3L3 9",
                stroke: "currentColor",
                strokeWidth: "1.5",
                strokeLinecap: "round"
              }
            )
          )
        )
      )), q > 0 && /* @__PURE__ */ a.createElement("span", { className: "flex items-center border border-gray-200 bg-gray-100 text-gray-600 rounded-2xl px-3 py-1 text-xs" }, "+", q, " mais"), v ? /* @__PURE__ */ a.createElement(
        "input",
        {
          ref: _,
          type: "text",
          value: p,
          onChange: x,
          onFocus: oe,
          onBlur: ae,
          placeholder: P.length === 0 && !r ? "Selecione..." : "",
          className: "flex-1 min-w-[120px] bg-transparent border-none outline-none text-sm"
        }
      ) : P.length === 0 && !r && /* @__PURE__ */ a.createElement("span", { className: "text-gray-400 text-sm" }, "Selecione...")),
      F && /* @__PURE__ */ a.createElement("div", { className: "absolute right-8 top-1/2 -translate-y-1/2" }, /* @__PURE__ */ a.createElement("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-[var(--primary)]" })),
      u && P && P.length > 0 && !F && /* @__PURE__ */ a.createElement(
        "button",
        {
          type: "button",
          tabIndex: -1,
          "aria-label": "Limpar seleção",
          className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-red-500 bg-transparent p-1 rounded-full focus:outline-none",
          onClick: V
        },
        "✕"
      )
    ), r && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: R.id || e,
        style: G ? { top: "-14px", transform: "scale(0.9)", transformOrigin: "0 0" } : { top: "14px", transform: "scale(1)", transformOrigin: "0 0" },
        className: l(
          "absolute left-3 z-10 cursor-text select-none transition-all duration-200 text-[var(--foreground)]",
          G ? "text-xs p-1 rounded-full bg-[var(--input-bg)] text-[var(--primary)]" : "text-sm"
        )
      },
      r
    ), /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "absolute left-0 w-full mt-1 rounded-md transition-all duration-200 overflow-hidden",
          "bg-[var(--select-dropdown-bg)] border-[var(--select-dropdown-border)] text-[var(--foreground)]",
          M ? "border max-h-36 opacity-100 scale-100" : "max-h-0 opacity-0 scale-95 pointer-events-none"
        ),
        style: {
          maxHeight: M ? "9.5rem" : "0",
          overflowY: k.length > 3 ? "auto" : "hidden",
          position: "fixed",
          // Use fixed positioning to escape container overflow
          top: M ? `${J.top}px` : "auto",
          left: M ? `${J.left}px` : "auto",
          width: M ? `${J.width}px` : "auto",
          zIndex: 9999,
          boxShadow: M ? "var(--select-dropdown-shadow)" : "none"
        }
      },
      F ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, g) : k.length === 0 ? /* @__PURE__ */ a.createElement("div", { className: "px-3 py-2 text-sm text-gray-500 text-center" }, m) : k.map((b) => /* @__PURE__ */ a.createElement(
        "div",
        {
          key: b.value,
          className: l(
            "px-3 py-2 cursor-pointer text-sm flex items-center gap-2 transition-colors duration-150",
            "hover:bg-[var(--select-dropdown-hover)]",
            P.includes(b.value) && "bg-[var(--select-dropdown-selected)] font-semibold"
          ),
          onMouseDown: () => z(b.value)
        },
        /* @__PURE__ */ a.createElement(
          "input",
          {
            type: "checkbox",
            checked: P.includes(b.value),
            readOnly: !0,
            className: "accent-blue-500"
          }
        ),
        b.label
      ))
    ), Y && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, Y));
  }
);
st.displayName = "MultiAsyncSelect";
const lt = {
  sm: "h-10 text-sm px-3",
  md: "h-12 text-base px-4",
  lg: "h-16 text-lg px-6"
}, it = a.forwardRef(
  ({
    name: e,
    label: r,
    options: t,
    className: o,
    containerClassName: s,
    optionClassName: u,
    direction: c = "row",
    size: g = "md",
    onFocus: m,
    onBlur: v,
    ...f
  }, d) => {
    var M, I, k;
    const i = ie(), C = i == null ? void 0 : i.control, R = C && e ? ce({ control: C, name: e }) : void 0, S = f.value ?? R ?? "", h = (k = (I = (M = i == null ? void 0 : i.formState) == null ? void 0 : M.errors) == null ? void 0 : I[e]) == null ? void 0 : k.message, E = (N) => {
      i && e && i.setValue(e, N), f.onChange && f.onChange({ target: { value: N } });
    };
    return /* @__PURE__ */ a.createElement("div", { className: l("relative", s), ref: d }, r && /* @__PURE__ */ a.createElement(
      "label",
      {
        htmlFor: e,
        className: l(
          "absolute left-3 z-10 origin-[0] cursor-text select-none text-sm transition-all duration-200",
          "top-0 scale-90 -translate-y-1 text-xs text-[var(--primary)] p-1 rounded-full"
        )
      },
      r
    ), /* @__PURE__ */ a.createElement(
      "div",
      {
        className: l(
          "flex gap-2 w-full pt-6",
          // espaço para label flutuante
          c === "row" ? "flex-row" : "flex-col",
          o
        ),
        "aria-label": r,
        tabIndex: -1,
        onFocus: m,
        onBlur: v
      },
      t.map((N) => /* @__PURE__ */ a.createElement(
        "button",
        {
          key: N.value,
          type: "button",
          className: l(
            "relative flex items-center justify-center border rounded-lg transition-all duration-200 shadow-sm px-4 focus:outline-none focus:ring-2 focus:ring-[var(--primary-light)]",
            lt[g],
            S === N.value ? "border-[var(--primary)] bg-[var(--primary-light)] text-[var(--primary)] ring-2 ring-[var(--primary-light)] shadow-md transform scale-[1.02]" : "border-gray-200 bg-white text-[var(--primary)] hover:border-[var(--primary)] hover:bg-[var(--primary-light)] hover:text-[var(--primary)] hover:shadow-md",
            u
          ),
          "aria-pressed": S === N.value,
          "data-selected": S === N.value,
          tabIndex: 0,
          onClick: () => E(N.value),
          onKeyDown: (F) => {
            (F.key === "Enter" || F.key === " ") && (F.preventDefault(), E(N.value));
          }
        },
        N.icon && /* @__PURE__ */ a.createElement("span", { className: "mr-2 text-lg flex items-center" }, N.icon),
        /* @__PURE__ */ a.createElement("span", { className: "truncate font-medium" }, N.label)
      ))
    ), h && /* @__PURE__ */ a.createElement("span", { className: "text-red-500 text-xs mt-1 block" }, h));
  }
);
it.displayName = "RadioGroup";
const Fe = n.forwardRef(
  ({ children: e, className: r, as: t = "div", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "px-2 py-1 sm:px-4 sm:py-2 lg:px-6 lg:py-4 border-b",
        "bg-[var(--card-header-bg)]",
        "border-[var(--card-header-border)]",
        "text-[var(--foreground)]",
        r
      ),
      ...o
    },
    e
  )
);
Fe.displayName = "CardHeader";
const Be = n.forwardRef(
  ({ children: e, className: r, as: t = "div", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "px-2 py-1 sm:px-4 sm:py-2 lg:px-6 lg:py-4",
        "flex-1",
        // Para ocupar o espaço disponível
        "bg-[var(--card-body-bg)]",
        "text-[var(--foreground)]",
        r
      ),
      ...o
    },
    e
  )
);
Be.displayName = "CardBody";
const Ie = n.forwardRef(
  ({ children: e, className: r, as: t = "div", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "px-6 py-4 border-t",
        "bg-[var(--card-footer-bg)]",
        "border-[var(--card-footer-border)]",
        "text-[var(--foreground)]",
        r
      ),
      ...o
    },
    e
  )
);
Ie.displayName = "CardFooter";
const ct = n.forwardRef(
  ({
    children: e,
    className: r,
    variant: t = "default",
    size: o = "md",
    padding: s = "none",
    // none pois cada seção tem seu próprio padding
    rounded: u = "lg",
    constrainWidth: c = !1,
    // Por padrão, não aplicar max-width
    allowOverflow: g = !1,
    // Por padrão, aplicar overflow hidden para interface limpa
    ...m
  }, v) => {
    const f = {
      default: "bg-[var(--card-bg)] border border-[var(--card-border)] shadow-[var(--card-shadow-sm)]",
      outlined: "bg-[var(--card-bg)] border-2 border-[var(--primary)]",
      elevated: "bg-[var(--card-bg)] border border-[var(--card-border)] shadow-[var(--card-shadow-lg)]",
      flat: "bg-[var(--card-bg)] border-0",
      primary: "bg-[var(--primary-light)] border-2 border-[var(--primary)] shadow-[var(--card-shadow-sm)]",
      secondary: "bg-[var(--secondary-light)] border-2 border-[var(--secondary)] shadow-[var(--card-shadow-sm)]"
    }, d = {
      sm: "max-w-sm",
      md: "max-w-md",
      lg: "max-w-lg"
    }, i = {
      none: "",
      sm: "p-3",
      md: "p-4",
      lg: "p-6"
    }, C = {
      none: "rounded-none",
      sm: "rounded-sm",
      md: "rounded-md",
      lg: "rounded-lg",
      xl: "rounded-xl"
    };
    return /* @__PURE__ */ n.createElement(
      "div",
      {
        ref: v,
        className: l(
          "flex flex-col",
          // Flex column para organizar header, body, footer
          !g && "overflow-hidden",
          // Overflow hidden por padrão para bordas limpas
          f[t],
          c && d[o],
          // Aplicar max-width apenas se constrainWidth for true
          i[s],
          C[u],
          r
        ),
        ...m
      },
      e
    );
  }
), Nt = Object.assign(ct, {
  Header: Fe,
  Body: Be,
  Footer: Ie
}), Te = n.forwardRef(
  ({
    children: e,
    className: r,
    variant: t = "default",
    size: o = "md",
    responsive: s = !1,
    stickyHeader: u = !1,
    ...c
  }, g) => {
    const m = l(
      // Base styles
      "w-full border-collapse bg-[var(--table-bg)] text-[var(--foreground)]",
      // Variant styles
      {
        "border border-[var(--table-border)]": t === "bordered"
      },
      // Size styles
      {
        "text-sm": o === "sm",
        "text-base": o === "md",
        "text-lg": o === "lg"
      },
      r
    ), v = l(
      {
        "overflow-x-auto": s,
        "max-h-96 overflow-y-auto": u
      }
    ), f = /* @__PURE__ */ n.createElement(
      "table",
      {
        ref: g,
        className: m,
        ...c
      },
      e
    );
    return s || u ? /* @__PURE__ */ n.createElement("div", { className: v }, f) : f;
  }
), Ae = n.forwardRef(
  ({ children: e, className: r, as: t = "thead", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "border-b border-[var(--table-border)] bg-[var(--table-header-bg)]",
        {
          "sticky top-0 z-10": t === "thead"
        },
        r
      ),
      ...o
    },
    e
  )
), Oe = n.forwardRef(
  ({ children: e, className: r, as: t = "tbody", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "[&_tr:nth-child(odd)]:bg-[var(--table-row-odd)]",
        "[&_tr:nth-child(even)]:bg-[var(--table-row-even)]",
        r
      ),
      ...o
    },
    e
  )
), $e = n.forwardRef(
  ({ children: e, className: r, as: t = "tfoot", ...o }, s) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: s,
      className: l(
        "border-t border-[var(--table-border)] bg-[var(--table-header-bg)] font-medium",
        r
      ),
      ...o
    },
    e
  )
), Pe = n.forwardRef(
  ({ children: e, className: r, variant: t = "default", ...o }, s) => /* @__PURE__ */ n.createElement(
    "tr",
    {
      ref: s,
      className: l(
        "border-b border-[var(--table-border)] transition-colors",
        {
          "hover:bg-[var(--table-row-hover)]": t === "hover",
          "bg-[var(--table-row-selected)]": t === "selected"
        },
        r
      ),
      ...o
    },
    e
  )
), ze = n.forwardRef(
  ({
    children: e,
    className: r,
    as: t = "td",
    align: o = "left",
    scope: s,
    colSpan: u,
    rowSpan: c,
    ...g
  }, m) => /* @__PURE__ */ n.createElement(
    t,
    {
      ref: m,
      scope: t === "th" ? s : void 0,
      colSpan: u,
      rowSpan: c,
      className: l(
        "px-4 py-3 text-left",
        {
          "font-semibold": t === "th",
          "text-sm": t === "td",
          "text-center": o === "center",
          "text-right": o === "right"
        },
        r
      ),
      ...g
    },
    e
  )
);
Te.displayName = "Table";
Ae.displayName = "TableHeader";
Oe.displayName = "TableBody";
$e.displayName = "TableFooter";
Pe.displayName = "TableRow";
ze.displayName = "TableCell";
const Ct = Object.assign(Te, {
  Header: Ae,
  Body: Oe,
  Footer: $e,
  Row: Pe,
  Cell: ze
}), kt = ({
  content: e,
  children: r,
  position: t = "top",
  className: o = "",
  disabled: s = !1,
  maxWidth: u
}) => {
  const [c, g] = se(!1), [m, v] = se(t), [f, d] = se({}), i = ge(null), C = ge(null);
  ye(() => {
    if (!c || !C.current) return;
    const N = C.current.getBoundingClientRect();
    let F = t, T = 0, p = 0;
    switch (t) {
      case "top":
        T = N.top - 8, p = N.left + N.width / 2;
        break;
      case "bottom":
        T = N.bottom + 8, p = N.left + N.width / 2;
        break;
      case "left":
        T = N.top + N.height / 2, p = N.left - 8;
        break;
      case "right":
        T = N.top + N.height / 2, p = N.right + 8;
        break;
    }
    if (i.current) {
      const B = i.current.getBoundingClientRect(), D = window.innerWidth, A = window.innerHeight;
      t === "top" && N.top < B.height + 16 ? (F = "bottom", T = N.bottom + 8) : t === "bottom" && N.bottom + B.height + 16 > A ? (F = "top", T = N.top - 8) : t === "left" && N.left < B.width + 16 ? (F = "right", p = N.right + 8) : t === "right" && N.right + B.width + 16 > D && (F = "left", p = N.left - 8);
    }
    v(F), d({
      position: "fixed",
      top: `${T}px`,
      left: `${p}px`,
      zIndex: 9999,
      ...u !== void 0 ? { maxWidth: typeof u == "number" ? `${u}px` : u } : {}
    });
  }, [c, t, u]);
  const R = () => {
    s || g(!0);
  }, S = () => {
    g(!1);
  }, h = () => {
    s || g(!0);
  }, E = () => {
    g(!1);
  }, M = () => {
    const k = "pointer-events-none";
    switch (m) {
      case "top":
        return `${k} transform -translate-x-1/2 -translate-y-full`;
      case "bottom":
        return `${k} transform -translate-x-1/2`;
      case "left":
        return `${k} transform -translate-x-full -translate-y-1/2`;
      case "right":
        return `${k} transform -translate-y-1/2`;
      default:
        return `${k} transform -translate-x-1/2 -translate-y-full`;
    }
  }, I = () => {
    const k = "absolute w-2 h-2 bg-[var(--tooltip-bg)] transform rotate-45";
    switch (m) {
      case "top":
        return `${k} top-full left-1/2 -translate-x-1/2 -translate-y-1/2`;
      case "bottom":
        return `${k} bottom-full left-1/2 -translate-x-1/2 translate-y-1/2`;
      case "left":
        return `${k} left-full top-1/2 -translate-y-1/2 -translate-x-1/2`;
      case "right":
        return `${k} right-full top-1/2 -translate-y-1/2 translate-x-1/2`;
      default:
        return `${k} top-full left-1/2 -translate-x-1/2 -translate-y-1/2`;
    }
  };
  return s || !e ? /* @__PURE__ */ n.createElement(n.Fragment, null, r) : /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
    "div",
    {
      className: "relative inline-block",
      ref: C,
      onMouseEnter: R,
      onMouseLeave: S,
      onFocus: h,
      onBlur: E
    },
    r
  ), c && typeof document < "u" && pe(
    /* @__PURE__ */ n.createElement(
      "div",
      {
        ref: i,
        style: f,
        className: l(
          M(),
          `px-2 py-1 text-sm rounded ${u !== void 0 ? "whitespace-normal" : "whitespace-nowrap"}`,
          "bg-[var(--tooltip-bg)] text-white",
          "shadow-[var(--tooltip-shadow,0_10px_15px_-3px_rgb(0_0_0_/_0.1),_0_4px_6px_-4px_rgb(0_0_0_/_0.1))]",
          "transition-opacity duration-200 ease-in-out",
          o
        ),
        role: "tooltip",
        "aria-hidden": !c
      },
      e,
      /* @__PURE__ */ n.createElement("div", { className: I() })
    ),
    document.body
  ));
}, dt = ({
  open: e,
  onClose: r,
  side: t = "right",
  size: o = "md",
  closeOnOverlayClick: s = !0,
  children: u,
  className: c = "",
  ...g
}) => {
  const m = typeof document < "u" ? document.body : null, v = o === "sm" ? "w-64" : o === "md" ? "w-96" : o === "lg" ? "w-[36rem]" : void 0, f = typeof o == "string" && !["sm", "md", "lg"].includes(o) ? { width: o } : void 0, d = /* @__PURE__ */ n.createElement(
    "div",
    {
      "aria-hidden": !e,
      className: l(
        "fixed inset-0 z-50 flex",
        e ? "pointer-events-auto" : "pointer-events-none"
      )
    },
    /* @__PURE__ */ n.createElement(
      "div",
      {
        className: l(
          "absolute inset-0 bg-black/40 transition-opacity duration-200",
          e ? "opacity-100" : "opacity-0"
        ),
        onMouseDown: (i) => {
          s && i.target === i.currentTarget && r();
        }
      }
    ),
    /* @__PURE__ */ n.createElement(
      "div",
      {
        className: l(
          "relative h-full",
          t === "right" ? "ml-auto" : "mr-auto",
          // ensure the sheet doesn't shrink
          "flex-shrink-0"
        ),
        style: f
      },
      /* @__PURE__ */ n.createElement(
        "aside",
        {
          role: "dialog",
          "aria-modal": !0,
          className: l(
            "h-full bg-[var(--aside-bg)] shadow-xl border-l border-gray-100 overflow-auto transition-transform duration-300",
            t === "right" ? e ? "translate-x-0" : "translate-x-full" : e ? "translate-x-0" : "-translate-x-full",
            v,
            c
          ),
          style: f,
          ...g
        },
        u
      )
    )
  );
  return m ? pe(d, m) : null;
};
dt.displayName = "AsideSheet";
const St = ({
  open: e,
  side: r = "left",
  size: t = "md",
  children: o,
  className: s = "",
  ...u
}) => {
  const c = t === "sm" ? "w-64" : t === "md" ? "w-72" : t === "lg" ? "w-96" : void 0, g = typeof t == "string" && !["sm", "md", "lg"].includes(t) ? { width: t } : void 0;
  return /* @__PURE__ */ n.createElement(
    "aside",
    {
      role: "navigation",
      "aria-expanded": e,
      className: l(
        // Only visible/usable on md+ screens
        "hidden md:flex md:flex-col",
        "fixed top-0 h-full z-40",
        "bg-[var(--sidebar-bg,var(--aside-bg,#ffffff))]",
        "shadow-lg border-gray-200 overflow-y-auto",
        "transition-transform duration-300 ease-in-out",
        // Positioning and slide direction
        r === "left" ? l("left-0 border-r", e ? "translate-x-0" : "-translate-x-full") : l("right-0 border-l", e ? "translate-x-0" : "translate-x-full"),
        c,
        s
      ),
      style: g,
      ...u
    },
    o
  );
}, Mt = ({
  avatar: e = !1,
  value: r,
  onUpload: t,
  onRemove: o,
  accept: s = "image/*",
  maxSize: u,
  placeholder: c = "Selecionar imagem",
  loading: g = !1,
  size: m = "md",
  label: v,
  error: f,
  disabled: d,
  className: i,
  ...C
}) => {
  const [R, S] = se(null), [h, E] = se(""), [M, I] = se(!1), k = ge(null), N = !!r, F = !!R, T = N || F, p = g || M, B = {
    sm: e ? "w-16 h-16" : "w-24 h-16",
    md: e ? "w-24 h-24" : "w-32 h-24",
    lg: e ? "w-32 h-32" : "w-40 h-32"
  }, A = c || (e ? "Adicionar foto" : "Selecionar imagem"), J = (W) => {
    var G;
    const P = (G = W.target.files) == null ? void 0 : G[0];
    if (!P) return;
    if (u && P.size > u) {
      alert(`Arquivo muito grande. Tamanho máximo: ${(u / 1024 / 1024).toFixed(1)}MB`);
      return;
    }
    const Y = new FileReader();
    Y.onload = (ee) => {
      var X;
      E((X = ee.target) == null ? void 0 : X.result), S(P);
    }, Y.readAsDataURL(P);
  }, j = async () => {
    if (!(!R || !t))
      try {
        I(!0);
        const W = await t(R);
        S(null), E(""), k.current && (k.current.value = "");
      } catch (W) {
        console.error("Erro ao fazer upload:", W), alert("Erro ao fazer upload da imagem");
      } finally {
        I(!1);
      }
  }, U = () => {
    S(null), E(""), k.current && (k.current.value = "");
  }, _ = async () => {
    try {
      o && await o(r), S(null), E(""), k.current && (k.current.value = "");
    } catch (W) {
      console.error("Erro ao remover imagem:", W), alert("Erro ao remover imagem");
    }
  }, $ = () => {
    var W;
    d || p || (W = k.current) == null || W.click();
  }, Q = h || r;
  return /* @__PURE__ */ n.createElement("div", { className: l("flex flex-col space-y-2", i) }, v && /* @__PURE__ */ n.createElement("label", { className: "text-sm font-medium text-gray-700" }, v), /* @__PURE__ */ n.createElement("div", { className: "relative flex flex-col items-center" }, /* @__PURE__ */ n.createElement(
    "input",
    {
      ref: k,
      type: "file",
      accept: s,
      onChange: J,
      disabled: d || p,
      className: "hidden",
      ...C
    }
  ), /* @__PURE__ */ n.createElement(
    "div",
    {
      onClick: $,
      className: l(
        // Base styles
        "relative border-2 border-dashed border-gray-300 transition-colors cursor-pointer",
        "hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",
        // Shape
        e ? "rounded-full" : "rounded-lg",
        // Size
        B[m],
        // States
        d && "opacity-50 cursor-not-allowed",
        p && "cursor-wait",
        f && "border-red-300",
        // Background
        !T && "bg-gray-50 hover:bg-gray-100",
        T && "border-solid border-gray-200"
      )
    },
    T ? (
      // Preview da imagem
      /* @__PURE__ */ n.createElement(
        "img",
        {
          src: Q,
          alt: "Preview",
          className: l(
            "w-full h-full object-cover",
            e ? "rounded-full" : "rounded-lg"
          )
        }
      )
    ) : (
      // Estado vazio
      /* @__PURE__ */ n.createElement("div", { className: "flex flex-col items-center justify-center h-full text-gray-500 text-sm" }, e ? (
        // Ícone de usuário para avatar
        /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
          "svg",
          {
            className: "w-8 h-8 mb-1",
            fill: "none",
            stroke: "currentColor",
            viewBox: "0 0 24 24"
          },
          /* @__PURE__ */ n.createElement(
            "path",
            {
              strokeLinecap: "round",
              strokeLinejoin: "round",
              strokeWidth: 1.5,
              d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
            }
          )
        ), /* @__PURE__ */ n.createElement("span", { className: "text-center px-2 text-xs" }, A))
      ) : (
        // Ícone de adicionar imagem genérica
        /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
          "svg",
          {
            className: "w-6 h-6 mb-1",
            fill: "none",
            stroke: "currentColor",
            viewBox: "0 0 24 24"
          },
          /* @__PURE__ */ n.createElement(
            "path",
            {
              strokeLinecap: "round",
              strokeLinejoin: "round",
              strokeWidth: 2,
              d: "M12 6v6m0 0v6m0-6h6m-6 0H6"
            }
          )
        ), /* @__PURE__ */ n.createElement("span", { className: "text-center px-2" }, A))
      ))
    ),
    p && /* @__PURE__ */ n.createElement("div", { className: l(
      "absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center",
      e ? "rounded-full" : "rounded-lg"
    ) }, /* @__PURE__ */ n.createElement("div", { className: "w-6 h-6 border-2 border-white border-t-transparent rounded-full animate-spin" }))
  ), T && !p && /* @__PURE__ */ n.createElement("div", { className: "flex justify-center space-x-2 mt-3" }, F ? (
    // Ações para arquivo selecionado (não salvo ainda)
    /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
      "button",
      {
        onClick: j,
        disabled: !t,
        className: "px-3 py-1 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
      },
      "Confirmar"
    ), /* @__PURE__ */ n.createElement(
      "button",
      {
        onClick: U,
        className: "px-3 py-1 bg-gray-600 text-white text-sm rounded hover:bg-gray-700"
      },
      "Cancelar"
    ))
  ) : (
    // Ações para imagem já salva
    /* @__PURE__ */ n.createElement(
      "button",
      {
        onClick: _,
        disabled: !o,
        className: "px-3 py-1 bg-red-600 text-white text-sm rounded hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed"
      },
      "Remover"
    )
  ))), f && /* @__PURE__ */ n.createElement("p", { className: "text-sm text-red-600" }, f), u && !T && /* @__PURE__ */ n.createElement("p", { className: "text-xs text-gray-500" }, "Tamanho máximo: ", (u / 1024 / 1024).toFixed(1), "MB"), e && !T && /* @__PURE__ */ n.createElement("p", { className: "text-xs text-gray-500 text-center" }, "Use uma foto com seu rosto centralizado e bem visível"));
}, Ve = n.createContext(null), ut = () => {
  const e = n.useContext(Ve);
  if (!e)
    throw new Error("AccordionItem must be used within an Accordion");
  return e;
};
let We = 0;
const De = ({
  title: e,
  children: r,
  defaultOpen: t = !1,
  disabled: o = !1,
  className: s,
  headerClassName: u,
  contentClassName: c,
  icon: g
}) => {
  const { openItems: m, toggleItem: v, variant: f } = ut(), [d] = se(() => We++), i = m.has(d), C = ge(null), [R, S] = se(t ? void 0 : 0);
  ye(() => {
    if (i) {
      const I = C.current;
      I && S(I.scrollHeight);
    } else
      S(0);
  }, [i]);
  const h = () => {
    o || v(d);
  }, M = {
    default: {
      item: "border-b border-[var(--accordion-border)] last:border-b-0",
      header: "",
      content: ""
    },
    bordered: {
      item: "border border-[var(--accordion-border)] rounded-md mb-2",
      header: "border-b border-[var(--accordion-border)]",
      content: ""
    },
    separated: {
      item: "border border-[var(--accordion-border)] rounded-md mb-3 shadow-sm",
      header: "",
      content: ""
    }
  }[f];
  return /* @__PURE__ */ n.createElement("div", { className: l(M.item, s) }, /* @__PURE__ */ n.createElement(
    "button",
    {
      type: "button",
      onClick: h,
      disabled: o,
      "aria-expanded": i,
      className: l(
        "w-full flex items-center justify-between px-4 py-3 text-left transition-colors",
        "bg-[var(--accordion-header-bg)]",
        "hover:bg-[var(--accordion-header-hover,rgba(0,0,0,0.05))]",
        "text-[var(--foreground)]",
        "font-medium",
        o && "opacity-50 cursor-not-allowed",
        i && f !== "default" && M.header,
        u
      )
    },
    /* @__PURE__ */ n.createElement("span", { className: "flex items-center gap-2" }, g && /* @__PURE__ */ n.createElement("span", { className: "flex-shrink-0" }, g), e),
    /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: l(
          "w-5 h-5 transition-transform duration-200 flex-shrink-0",
          "text-[var(--accordion-icon)]",
          i && "rotate-180"
        ),
        fill: "none",
        strokeWidth: "2",
        stroke: "currentColor",
        viewBox: "0 0 24 24"
      },
      /* @__PURE__ */ n.createElement("path", { d: "M19 9l-7 7-7-7" })
    )
  ), /* @__PURE__ */ n.createElement(
    "div",
    {
      style: {
        height: R,
        overflow: "hidden",
        transition: "height 0.3s ease-in-out"
      }
    },
    /* @__PURE__ */ n.createElement(
      "div",
      {
        ref: C,
        className: l(
          "px-4 py-3",
          "text-[var(--foreground)]",
          "bg-[var(--accordion-content-bg)]",
          c
        )
      },
      r
    )
  ));
};
De.displayName = "AccordionItem";
const mt = ({
  children: e,
  type: r = "single",
  className: t,
  variant: o = "default",
  collapsible: s = !0
}) => {
  const [u, c] = se(/* @__PURE__ */ new Set());
  ye(() => {
    We = 0;
    const m = n.Children.toArray(e), v = /* @__PURE__ */ new Set();
    if (m.forEach((f, d) => {
      n.isValidElement(f) && f.props.defaultOpen && v.add(d);
    }), r === "single" && v.size > 1) {
      const f = Array.from(v)[0];
      c(/* @__PURE__ */ new Set([f]));
    } else
      c(v);
  }, []);
  const g = (m) => {
    c((v) => {
      const f = new Set(v);
      return r === "single" ? f.has(m) ? s && f.clear() : (f.clear(), f.add(m)) : f.has(m) ? f.delete(m) : f.add(m), f;
    });
  };
  return /* @__PURE__ */ n.createElement(
    Ve.Provider,
    {
      value: { type: r, openItems: u, toggleItem: g, collapsible: s, variant: o }
    },
    /* @__PURE__ */ n.createElement("div", { className: l("w-full", t) }, e)
  );
};
mt.Item = De;
const ke = ({
  open: e,
  onClose: r,
  size: t = "md",
  variant: o = "default",
  closeOnOverlayClick: s = !0,
  closeOnEscape: u = !0,
  showCloseButton: c = !0,
  children: g,
  className: m = "",
  ...v
}) => {
  const f = typeof document < "u" ? document.body : null;
  n.useEffect(() => {
    if (!e || !u) return;
    const S = (h) => {
      h.key === "Escape" && r();
    };
    return document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
  }, [e, u, r]), n.useEffect(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
    document.body.style.overflow = "";
  }), [e]);
  const d = {
    sm: "max-w-sm",
    md: "max-w-md",
    lg: "max-w-lg",
    xl: "max-w-xl",
    full: "max-w-full mx-4"
  }, i = {
    default: "bg-[var(--bg-modal)] text-gray-900",
    primary: "bg-[var(--primary)] text-[var(--primary-text)]",
    secondary: "bg-[var(--secondary)] text-[var(--secondary-text)]"
  }, C = {
    default: "text-gray-400 hover:text-gray-600",
    primary: "text-[var(--primary-text)] hover:opacity-80",
    secondary: "text-[var(--secondary-text)] hover:opacity-80"
  };
  if (!f || !e) return null;
  const R = /* @__PURE__ */ n.createElement(
    "div",
    {
      className: l(
        "fixed inset-0 z-50 flex items-center justify-center p-4",
        e ? "pointer-events-auto" : "pointer-events-none"
      )
    },
    /* @__PURE__ */ n.createElement(
      "div",
      {
        className: l(
          "absolute inset-0 bg-black/50 transition-opacity duration-200",
          e ? "opacity-100" : "opacity-0"
        ),
        onClick: (S) => {
          s && S.target === S.currentTarget && r();
        }
      }
    ),
    /* @__PURE__ */ n.createElement(
      "div",
      {
        role: "dialog",
        "aria-modal": !0,
        className: l(
          "relative rounded-lg shadow-xl w-full transition-opacity duration-200",
          d[t],
          i[o],
          e ? "opacity-100" : "opacity-0",
          m
        ),
        ...v
      },
      c && /* @__PURE__ */ n.createElement(
        "button",
        {
          onClick: r,
          className: l(
            "absolute top-4 right-4 transition-colors",
            C[o]
          ),
          "aria-label": "Fechar modal"
        },
        /* @__PURE__ */ n.createElement(
          "svg",
          {
            xmlns: "http://www.w3.org/2000/svg",
            className: "h-6 w-6",
            fill: "none",
            viewBox: "0 0 24 24",
            stroke: "currentColor"
          },
          /* @__PURE__ */ n.createElement(
            "path",
            {
              strokeLinecap: "round",
              strokeLinejoin: "round",
              strokeWidth: 2,
              d: "M6 18L18 6M6 6l12 12"
            }
          )
        )
      ),
      /* @__PURE__ */ n.createElement("div", { className: "p-6" }, g)
    )
  );
  return pe(R, f);
};
ke.Header = function({
  children: r,
  className: t = "",
  ...o
}) {
  return /* @__PURE__ */ n.createElement("div", { className: l("mb-4 pr-8", t), ...o }, r);
};
ke.Body = function({
  children: r,
  className: t = "",
  ...o
}) {
  return /* @__PURE__ */ n.createElement("div", { className: l("mb-4", t), ...o }, r);
};
ke.Footer = function({
  children: r,
  className: t = "",
  ...o
}) {
  return /* @__PURE__ */ n.createElement(
    "div",
    {
      className: l("flex justify-end gap-2 mt-6 pt-4 border-t border-gray-200", t),
      ...o
    },
    r
  );
};
const He = je(null), Lt = ({
  children: e,
  position: r = "top-right",
  maxToasts: t = 5
}) => {
  const [o, s] = se([]), u = xe(
    (m) => {
      const v = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, f = { ...m, id: v };
      if (s((d) => [...d, f].slice(-t)), m.duration !== 0) {
        const d = m.duration || 5e3;
        setTimeout(() => {
          var i;
          c(v), (i = m.onClose) == null || i.call(m);
        }, d);
      }
      return v;
    },
    [t]
  ), c = xe((m) => {
    s((v) => v.filter((f) => f.id !== m));
  }, []), g = xe(() => {
    s([]);
  }, []);
  return /* @__PURE__ */ n.createElement(He.Provider, { value: { toasts: o, addToast: u, removeToast: c, clearAll: g } }, e, /* @__PURE__ */ n.createElement(pt, { toasts: o, position: r, onClose: c }));
}, ft = () => {
  const e = Ye(He);
  if (!e)
    throw new Error("useToaster must be used within ToasterProvider");
  return e;
}, Rt = () => {
  const { addToast: e } = ft();
  return {
    toast: (r, t) => e({ message: r, ...t }),
    success: (r, t) => e({ message: r, variant: "success", duration: t }),
    error: (r, t) => e({ message: r, variant: "error", duration: t }),
    warning: (r, t) => e({ message: r, variant: "warning", duration: t }),
    info: (r, t) => e({ message: r, variant: "info", duration: t })
  };
}, pt = ({
  toasts: e,
  position: r,
  onClose: t
}) => {
  const o = typeof document < "u" ? document.body : null;
  if (!o || e.length === 0) return null;
  const s = {
    "top-left": "top-4 left-4 items-start",
    "top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
    "top-right": "top-4 right-4 items-end",
    "bottom-left": "bottom-4 left-4 items-start",
    "bottom-center": "bottom-4 left-1/2 -translate-x-1/2 items-center",
    "bottom-right": "bottom-4 right-4 items-end"
  }, u = /* @__PURE__ */ n.createElement(
    "div",
    {
      className: l(
        "fixed z-[100] flex flex-col gap-2 pointer-events-none",
        s[r]
      ),
      style: { maxWidth: "calc(100vw - 2rem)" }
    },
    e.map((c) => /* @__PURE__ */ n.createElement(vt, { key: c.id, toast: c, onClose: t }))
  );
  return pe(u, o);
}, vt = ({ toast: e, onClose: r }) => {
  const [t, o] = se(!1), s = () => {
    o(!0), setTimeout(() => {
      var m;
      r(e.id), (m = e.onClose) == null || m.call(e);
    }, 200);
  }, u = {
    success: "bg-green-50 text-green-800 border-green-200",
    error: "bg-red-50 text-red-800 border-red-200",
    warning: "bg-yellow-50 text-yellow-800 border-yellow-200",
    info: "bg-blue-50 text-blue-800 border-blue-200",
    default: "bg-white text-gray-800 border-gray-200"
  }, c = {
    success: /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: "w-5 h-5 text-green-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor"
      },
      /* @__PURE__ */ n.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
        }
      )
    ),
    error: /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: "w-5 h-5 text-red-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor"
      },
      /* @__PURE__ */ n.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
        }
      )
    ),
    warning: /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: "w-5 h-5 text-yellow-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor"
      },
      /* @__PURE__ */ n.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
        }
      )
    ),
    info: /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: "w-5 h-5 text-blue-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor"
      },
      /* @__PURE__ */ n.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
        }
      )
    ),
    default: /* @__PURE__ */ n.createElement(
      "svg",
      {
        className: "w-5 h-5 text-gray-600",
        fill: "none",
        viewBox: "0 0 24 24",
        stroke: "currentColor"
      },
      /* @__PURE__ */ n.createElement(
        "path",
        {
          strokeLinecap: "round",
          strokeLinejoin: "round",
          strokeWidth: 2,
          d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
        }
      )
    )
  }, g = e.variant || "default";
  return /* @__PURE__ */ n.createElement(
    "div",
    {
      role: "alert",
      className: l(
        "pointer-events-auto flex items-start gap-3 px-4 py-3 rounded-lg border shadow-lg min-w-[300px] max-w-[500px]",
        "transition-all duration-200 ease-in-out",
        t ? "opacity-0 scale-95 translate-x-4" : "opacity-100 scale-100 translate-x-0",
        u[g]
      )
    },
    /* @__PURE__ */ n.createElement("div", { className: "flex-shrink-0 mt-0.5" }, c[g]),
    /* @__PURE__ */ n.createElement("p", { className: "flex-1 text-sm font-medium leading-relaxed" }, e.message),
    /* @__PURE__ */ n.createElement(
      "button",
      {
        onClick: s,
        className: "flex-shrink-0 text-current opacity-60 hover:opacity-100 transition-opacity",
        "aria-label": "Fechar notificação"
      },
      /* @__PURE__ */ n.createElement(
        "svg",
        {
          className: "w-4 h-4",
          fill: "none",
          viewBox: "0 0 24 24",
          stroke: "currentColor"
        },
        /* @__PURE__ */ n.createElement(
          "path",
          {
            strokeLinecap: "round",
            strokeLinejoin: "round",
            strokeWidth: 2,
            d: "M6 18L18 6M6 6l12 12"
          }
        )
      )
    )
  );
}, Ft = ({
  checked: e = !1,
  onChange: r,
  label: t,
  labelPosition: o = "right",
  size: s = "md",
  disabled: u = !1,
  className: c = "",
  onClick: g,
  id: m,
  ...v
}) => {
  const f = Ue(), d = m ?? f, i = (M) => {
    u || (r == null || r(!e), g == null || g(M));
  }, C = {
    sm: "w-8 h-4",
    md: "w-11 h-6",
    lg: "w-14 h-8"
  }, R = {
    sm: "w-3 h-3",
    md: "w-4 h-4",
    lg: "w-6 h-6"
  }, S = {
    sm: e ? "translate-x-4" : "translate-x-0.5",
    md: e ? "translate-x-6" : "translate-x-1",
    lg: e ? "translate-x-7" : "translate-x-1"
  }, h = {
    sm: "text-xs",
    md: "text-sm",
    lg: "text-base"
  }, E = /* @__PURE__ */ n.createElement(
    "button",
    {
      type: "button",
      role: "switch",
      "aria-checked": e,
      id: d,
      disabled: u,
      onClick: i,
      className: l(
        "relative inline-flex items-center rounded-full shrink-0 transition-colors duration-200",
        "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-2",
        C[s],
        e ? "bg-[var(--primary)]" : "bg-[var(--chip-inactive-border,#d1d5db)]",
        u && "opacity-40 cursor-not-allowed",
        !u && "cursor-pointer",
        c
      ),
      ...v
    },
    /* @__PURE__ */ n.createElement(
      "span",
      {
        className: l(
          "inline-block rounded-full bg-white text-[var(--primary)] shadow transition-transform duration-200",
          R[s],
          S[s]
        )
      }
    )
  );
  return t ? /* @__PURE__ */ n.createElement(
    "label",
    {
      htmlFor: d,
      className: l(
        "inline-flex items-center gap-2 select-none",
        u ? "opacity-40 cursor-not-allowed" : "cursor-pointer"
      )
    },
    o === "left" && /* @__PURE__ */ n.createElement("span", { className: l("text-[var(--foreground,#111827)]", h[s]) }, t),
    E,
    o === "right" && /* @__PURE__ */ n.createElement("span", { className: l("text-[var(--foreground,#111827)]", h[s]) }, t)
  ) : E;
}, Bt = ({
  items: e,
  value: r,
  defaultValue: t,
  onValueChange: o,
  className: s = "",
  ...u
}) => {
  const c = n.useMemo(
    () => {
      var d;
      return (d = e.find((i) => !i.disabled)) == null ? void 0 : d.id;
    },
    [e]
  ), [g, m] = n.useState(
    t ?? c
  );
  n.useEffect(() => {
    r === void 0 && (e.some((d) => d.id === g && !d.disabled) || m(c));
  }, [e, g, c, r]);
  const v = r ?? g, f = (d) => {
    r === void 0 && m(d), o == null || o(d);
  };
  return /* @__PURE__ */ n.createElement(
    "nav",
    {
      role: "tablist",
      "aria-label": "Bottom navigation",
      className: l(
        "md:hidden fixed inset-x-0 bottom-0 z-40",
        "border-t border-gray-200",
        "bg-[var(--bottom-tab-bg,var(--sidebar-bg,var(--aside-bg,#ffffff)))]",
        "shadow-[0_-8px_20px_rgba(0,0,0,0.08)]",
        "pb-[max(0.5rem,env(safe-area-inset-bottom))]",
        s
      ),
      ...u
    },
    /* @__PURE__ */ n.createElement(
      "div",
      {
        className: "mx-auto grid max-w-3xl gap-1 px-2 pt-2",
        style: { gridTemplateColumns: `repeat(${Math.max(e.length, 1)}, minmax(0, 1fr))` }
      },
      e.map((d) => {
        const i = d.id === v;
        return /* @__PURE__ */ n.createElement(
          "button",
          {
            key: d.id,
            role: "tab",
            type: "button",
            "aria-selected": i,
            "aria-disabled": d.disabled,
            disabled: d.disabled,
            onClick: () => {
              d.disabled || f(d.id);
            },
            className: l(
              "relative flex min-h-[3.25rem] w-full flex-col items-center justify-center gap-1 rounded-xl px-1 py-2 text-xs font-medium transition",
              "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--primary)] focus-visible:ring-offset-1",
              i ? "bg-[var(--primary-light)] text-[var(--primary)]" : "text-[var(--text-muted)] hover:bg-black/5",
              d.disabled && "cursor-not-allowed opacity-50"
            )
          },
          d.icon ? /* @__PURE__ */ n.createElement("span", { className: "text-base leading-none", "aria-hidden": !0 }, d.icon) : null,
          /* @__PURE__ */ n.createElement("span", { className: "truncate" }, d.label),
          d.badge ? /* @__PURE__ */ n.createElement("span", { className: "absolute right-2 top-1 text-[10px] leading-none" }, d.badge) : null
        );
      })
    )
  );
}, gt = ({
  open: e,
  onClose: r,
  size: t = "md",
  closeOnOverlayClick: o = !0,
  closeOnEscape: s = !0,
  lockBodyScroll: u = !0,
  closeOnDragDown: c = !0,
  dragCloseThreshold: g = 100,
  children: m,
  className: v = "",
  ...f
}) => {
  const d = typeof document < "u" ? document.body : null, [i, C] = n.useState(0), [R, S] = n.useState(!1), h = n.useRef(null);
  n.useEffect(() => {
    if (!e || !s) return;
    const p = (B) => {
      B.key === "Escape" && r();
    };
    return document.addEventListener("keydown", p), () => document.removeEventListener("keydown", p);
  }, [e, s, r]), n.useEffect(() => {
    if (u)
      return e ? (document.body.style.overflow = "hidden", () => {
        document.body.style.overflow = "";
      }) : (document.body.style.overflow = "", () => {
        document.body.style.overflow = "";
      });
  }, [e, u]), n.useEffect(() => {
    e || (C(0), S(!1), h.current = null);
  }, [e]);
  const E = t === "sm" ? "max-h-[40vh]" : t === "md" ? "max-h-[60vh]" : t === "lg" ? "max-h-[80vh]" : t === "full" ? "max-h-[calc(100dvh-1rem)]" : void 0, I = {
    ...(typeof t == "string" && !["sm", "md", "lg", "full"].includes(t) ? { maxHeight: t } : void 0) ?? {},
    ...e && i > 0 ? { transform: `translateY(${i}px)` } : {}
  }, k = (p) => {
    var B;
    !c || !e || (h.current = ((B = p.touches[0]) == null ? void 0 : B.clientY) ?? null, S(!0));
  }, N = (p) => {
    var A;
    if (!c || !R || h.current === null) return;
    const D = (((A = p.touches[0]) == null ? void 0 : A.clientY) ?? h.current) - h.current;
    if (D <= 0) {
      C(0);
      return;
    }
    C(D);
  }, F = () => {
    if (c) {
      if (S(!1), h.current = null, i >= g) {
        C(0), r();
        return;
      }
      C(0);
    }
  }, T = /* @__PURE__ */ n.createElement(
    "div",
    {
      "aria-hidden": !e,
      className: l(
        "md:hidden fixed inset-0 z-50 flex items-end",
        e ? "pointer-events-auto" : "pointer-events-none"
      )
    },
    /* @__PURE__ */ n.createElement(
      "div",
      {
        className: l(
          "absolute inset-0 bg-black/40 transition-opacity duration-200",
          e ? "opacity-100" : "opacity-0"
        ),
        onMouseDown: (p) => {
          o && p.target === p.currentTarget && r();
        }
      }
    ),
    /* @__PURE__ */ n.createElement(
      "div",
      {
        role: "dialog",
        "aria-modal": !0,
        className: l(
          "relative w-full overflow-auto rounded-t-2xl border-t border-gray-200",
          "bg-[var(--bottom-sheet-bg,var(--aside-bg,#ffffff))] shadow-2xl",
          R ? "transition-none" : "transition-transform duration-300 ease-out",
          e ? "translate-y-0" : "translate-y-full",
          E,
          v
        ),
        style: I,
        ...f
      },
      /* @__PURE__ */ n.createElement(
        "div",
        {
          className: "sticky top-0 z-10 flex justify-center bg-inherit pb-1 pt-2 touch-none",
          onTouchStart: k,
          onTouchMove: N,
          onTouchEnd: F,
          onTouchCancel: F
        },
        /* @__PURE__ */ n.createElement("div", { className: "h-1.5 w-12 rounded-full bg-black/20" })
      ),
      m
    )
  );
  return d ? pe(T, d) : null;
};
gt.displayName = "BottomSheet";
export {
  mt as Accordion,
  De as AccordionItem,
  dt as AsideSheet,
  nt as AsyncSelect,
  gt as BottomSheet,
  Bt as BottomTabNavigator,
  wt as Button,
  Nt as Card,
  Be as CardBody,
  Ie as CardFooter,
  Fe as CardHeader,
  yt as Chip,
  tt as ColorInput,
  Mt as ImageInput,
  et as Input,
  ke as Modal,
  st as MultiAsyncSelect,
  ot as MultiSelect,
  Et as Pagination,
  it as RadioGroup,
  rt as Select,
  St as Sidebar,
  Ft as Switch,
  Ct as Table,
  Oe as TableBody,
  ze as TableCell,
  $e as TableFooter,
  Ae as TableHeader,
  Pe as TableRow,
  at as Textarea,
  Lt as ToasterProvider,
  kt as Tooltip,
  Rt as useToast,
  ft as useToaster
};