import { cva } from 'class-variance-authority';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';

// src/primitives/loading/loading.tsx
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function Skeleton({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn("animate-pulse rounded-md border border-foreground/[0.06] bg-muted", className),
      ...props
    }
  );
}
var loadingVariants = cva("flex w-full", {
  variants: {
    variant: {
      list: "flex-col gap-[var(--space-3,0.75rem)]",
      card: "flex-col gap-[var(--space-2,0.5rem)] rounded-md border border-border bg-card p-[var(--space-4,1rem)]",
      stack: "flex-col gap-[var(--space-4,1rem)]"
    }
  },
  defaultVariants: { variant: "list" }
});
function Loading({
  className,
  variant = "list",
  rows = 3,
  label = "Loading\u2026",
  ref,
  ...props
}) {
  return /* @__PURE__ */ jsxs(
    "div",
    {
      ref,
      role: "status",
      "aria-live": "polite",
      className: cn(loadingVariants({ variant }), className),
      ...props,
      children: [
        /* @__PURE__ */ jsx("span", { className: "sr-only", children: label }),
        Array.from({ length: rows }, (_, i) => (
          // `variant` can be `null` per CVA's VariantProps shape — the
          // destructured default only catches undefined. The fallback
          // here narrows to the LoadingRow's "list" | "card" | "stack"
          // signature.
          /* @__PURE__ */ jsx(LoadingRow, { variant: variant ?? "list" }, i)
        ))
      ]
    }
  );
}
function LoadingRow({ variant }) {
  if (variant === "card") {
    return /* @__PURE__ */ jsxs(Fragment, { children: [
      /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }),
      /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-full" }),
      /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-5/6" })
    ] });
  }
  if (variant === "stack") {
    return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[var(--space-3,0.75rem)]", children: [
      /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-10 shrink-0 rounded-full" }),
      /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-[var(--space-2,0.5rem)]", children: [
        /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/3" }),
        /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-2/3" })
      ] })
    ] });
  }
  return /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" });
}

export { Loading, loadingVariants };
//# sourceMappingURL=loading.js.map
//# sourceMappingURL=loading.js.map