"use client";
import { Loader2, AlertCircle, ImageUp, MoreHorizontal, Trash2, X } from 'lucide-react';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function FileUploadCard(_a) {
  var _b = _a, {
    className,
    fileName = "thumbnail.png",
    fileSize = "1.5 MB",
    thumbnailSrc,
    state = "uploaded",
    size = "lg",
    onRemove,
    onRetry,
    onReplace,
    removeVariant = "close"
  } = _b, props = __objRest(_b, [
    "className",
    "fileName",
    "fileSize",
    "thumbnailSrc",
    "state",
    "size",
    "onRemove",
    "onRetry",
    "onReplace",
    "removeVariant"
  ]);
  return /* @__PURE__ */ jsxs(
    "div",
    __spreadProps(__spreadValues({
      "data-slot": "file-upload-card",
      "data-state": state,
      "data-size": size,
      "aria-busy": state === "uploading" || void 0,
      className: cn(
        "relative flex items-center gap-2 overflow-clip rounded-[6px] border bg-card pl-2 pr-4 py-2 shadow-[0px_1px_2px_0px_rgba(0,0,0,0.05)]",
        "border-border",
        state === "failed" && "border-destructive/30",
        className
      )
    }, props), {
      children: [
        /* @__PURE__ */ jsx(
          "div",
          {
            className: cn(
              "shrink-0 overflow-hidden rounded-[var(--radius-xs)]",
              "border border-border shadow-sm",
              size === "sm" ? "size-6" : "size-10"
            ),
            children: thumbnailSrc ? (
              /* eslint-disable-next-line @next/next/no-img-element */
              /* @__PURE__ */ jsx(
                "img",
                {
                  src: thumbnailSrc,
                  alt: "",
                  className: "size-full object-cover"
                }
              )
            ) : /* @__PURE__ */ jsx("div", { className: "size-full bg-muted" })
          }
        ),
        size === "lg" ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
          /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium leading-5 text-foreground", children: fileName }),
          /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-xs leading-4", children: [
            /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: fileSize }),
            /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", "aria-hidden": true, children: "|" }),
            /* @__PURE__ */ jsxs(
              "span",
              {
                className: cn(
                  state === "uploaded" && "text-primary",
                  state === "uploading" && "text-primary",
                  state === "failed" && "text-destructive"
                ),
                children: [
                  state === "uploaded" && "Uploaded",
                  state === "uploading" && "Uploading\u2026",
                  state === "failed" && "Error"
                ]
              }
            )
          ] })
        ] }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium leading-5 text-foreground", children: fileName }),
        /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
          state === "uploading" && /* @__PURE__ */ jsx(
            Loader2,
            {
              className: "size-4 shrink-0 animate-spin text-muted-foreground",
              "aria-label": "Uploading"
            }
          ),
          size === "sm" && state === "failed" && /* @__PURE__ */ jsx(AlertCircle, { className: "size-4 text-destructive", "aria-label": "Upload failed" }),
          state === "uploaded" && /* @__PURE__ */ jsx(Fragment, { children: onReplace ? /* @__PURE__ */ jsx(
            "button",
            {
              type: "button",
              onClick: onReplace,
              className: "inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
              "aria-label": "Replace image",
              children: /* @__PURE__ */ jsx(ImageUp, { className: "size-4" })
            }
          ) : /* @__PURE__ */ jsx(
            "button",
            {
              type: "button",
              className: "inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
              "aria-label": "More options",
              children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" })
            }
          ) }),
          /* @__PURE__ */ jsx(
            "button",
            {
              type: "button",
              onClick: state === "failed" ? onRetry != null ? onRetry : onRemove : onRemove,
              className: "inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
              "aria-label": state === "failed" ? "Retry or remove" : removeVariant === "delete" ? "Delete" : "Remove file",
              children: removeVariant === "delete" ? /* @__PURE__ */ jsx(Trash2, { className: "size-4" }) : /* @__PURE__ */ jsx(X, { className: "size-4" })
            }
          )
        ] })
      ]
    })
  );
}

export { FileUploadCard };
//# sourceMappingURL=file-upload-card.js.map
//# sourceMappingURL=file-upload-card.js.map