"use client";
import Image from 'next/image';
import { cva } from 'class-variance-authority';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { Checkbox as Checkbox$1 } from '@base-ui/react/checkbox';
import { MinusIcon, CheckIcon } from 'lucide-react';
import { jsx, jsxs } from 'react/jsx-runtime';
import { Avatar as Avatar$1 } from '@base-ui/react/avatar';

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 Checkbox(_a) {
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
  return /* @__PURE__ */ jsx(
    Checkbox$1.Root,
    __spreadProps(__spreadValues({
      "data-slot": "checkbox",
      className: cn(
        "group/checkbox relative inline-flex size-6 shrink-0 cursor-pointer items-center justify-center outline-none touch-manipulation",
        "focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
        className
      )
    }, props), {
      children: /* @__PURE__ */ jsx(
        "span",
        {
          "aria-hidden": true,
          className: cn(
            "relative flex size-4 shrink-0 items-center justify-center overflow-hidden rounded-[4px] border border-input bg-background transition-colors outline-none",
            "dark:bg-input/30",
            "group-focus-visible/checkbox:ring-4 group-focus-visible/checkbox:ring-ring/50 group-focus-visible/checkbox:ring-offset-1 group-focus-visible/checkbox:ring-offset-background",
            "group-focus-visible/checkbox:border-ring",
            "group-disabled/checkbox:cursor-not-allowed group-disabled/checkbox:opacity-50",
            "group-aria-invalid/checkbox:border-destructive group-aria-invalid/checkbox:ring-3 group-aria-invalid/checkbox:ring-destructive/20",
            "group-aria-invalid/checkbox:group-data-checked/checkbox:border-primary",
            "dark:group-aria-invalid/checkbox:border-destructive/50 dark:group-aria-invalid/checkbox:ring-destructive/40",
            "group-data-unchecked/checkbox:group-hover/checkbox:border-input-hover group-data-unchecked/checkbox:group-hover/checkbox:bg-accent/50",
            "dark:group-data-unchecked/checkbox:group-hover/checkbox:border-input-hover dark:group-data-unchecked/checkbox:group-hover/checkbox:bg-accent/30",
            "group-disabled/checkbox:group-hover/checkbox:border-input group-disabled/checkbox:group-hover/checkbox:bg-transparent",
            "group-data-checked/checkbox:border-primary group-data-checked/checkbox:bg-primary group-data-checked/checkbox:text-primary-foreground",
            "group-data-checked/checkbox:group-hover/checkbox:border-[var(--primary-hover)] group-data-checked/checkbox:group-hover/checkbox:bg-[var(--primary-hover)]",
            "dark:group-data-checked/checkbox:bg-primary",
            "group-data-indeterminate/checkbox:border-primary group-data-indeterminate/checkbox:bg-primary group-data-indeterminate/checkbox:text-primary-foreground",
            "group-data-indeterminate/checkbox:group-hover/checkbox:border-[var(--primary-hover)] group-data-indeterminate/checkbox:group-hover/checkbox:bg-[var(--primary-hover)]",
            "dark:group-data-indeterminate/checkbox:bg-primary"
          ),
          children: /* @__PURE__ */ jsx(
            Checkbox$1.Indicator,
            {
              "data-slot": "checkbox-indicator",
              keepMounted: true,
              className: "absolute inset-0 flex items-center justify-center leading-none text-current transition-none",
              render: (indicatorProps, state) => /* @__PURE__ */ jsx(
                "span",
                __spreadProps(__spreadValues({}, indicatorProps), {
                  className: cn(
                    indicatorProps.className,
                    "flex size-full items-center justify-center"
                  ),
                  children: state.indeterminate ? /* @__PURE__ */ jsx(
                    MinusIcon,
                    {
                      className: "block size-2.5",
                      strokeWidth: 2.25,
                      "aria-hidden": true
                    }
                  ) : state.checked ? /* @__PURE__ */ jsx(
                    CheckIcon,
                    {
                      className: "block size-2.5",
                      strokeWidth: 2.25,
                      "aria-hidden": true
                    }
                  ) : null
                })
              )
            }
          )
        }
      )
    })
  );
}
function Avatar(_a) {
  var _b = _a, {
    className,
    size = "default"
  } = _b, props = __objRest(_b, [
    "className",
    "size"
  ]);
  return /* @__PURE__ */ jsx(
    Avatar$1.Root,
    __spreadValues({
      "data-slot": "avatar",
      "data-size": size,
      className: cn(
        "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
        className
      )
    }, props)
  );
}
function AvatarImage(_a) {
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
  return /* @__PURE__ */ jsx(
    Avatar$1.Image,
    __spreadValues({
      "data-slot": "avatar-image",
      className: cn(
        "aspect-square size-full rounded-full object-cover",
        className
      )
    }, props)
  );
}
function AvatarFallback(_a) {
  var _b = _a, {
    className
  } = _b, props = __objRest(_b, [
    "className"
  ]);
  return /* @__PURE__ */ jsx(
    Avatar$1.Fallback,
    __spreadValues({
      "data-slot": "avatar-fallback",
      className: cn(
        "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
        className
      )
    }, props)
  );
}
var tableSlotCellVariants = cva(
  "relative flex items-center min-h-8 min-w-9",
  {
    variants: {
      variant: {
        default: "gap-2 px-3",
        media: "gap-3 px-3",
        avatar: "gap-2 px-3",
        badge: "gap-1 px-3",
        progress: "gap-2 px-3",
        checkbox: "justify-center",
        icon: "justify-center",
        number: "justify-center px-3",
        empty: ""
      },
      state: {
        default: "",
        selected: "rounded-[var(--radius-2xs,2px)] border border-[var(--theme-stroke-accent,#437dfc)] bg-background",
        failed: "rounded-[var(--radius-2xs,2px)] border border-destructive bg-background"
      }
    },
    defaultVariants: {
      variant: "default",
      state: "default"
    }
  }
);
var TABLE_SLOT_CELL_OWN_KEYS = /* @__PURE__ */ new Set([
  "variant",
  "state",
  "className",
  "label",
  "leadIcon",
  "tailIcon",
  "badgeLabel",
  "badgeIcon",
  "badgeClassName",
  "progressValue",
  "checked",
  "indeterminate",
  "onCheckedChange",
  "avatarSrc",
  "avatarFallback",
  "description",
  "thumbnailSrc",
  "thumbnailAlt",
  "thumbnailClassName",
  "icon",
  "value"
]);
function getTableSlotCellRootDivProps(props) {
  const out = {};
  for (const [key, val] of Object.entries(props)) {
    if (!TABLE_SLOT_CELL_OWN_KEYS.has(key)) {
      out[key] = val;
    }
  }
  return out;
}
function SelectionHandle({ variant }) {
  return /* @__PURE__ */ jsx(
    "div",
    {
      className: cn(
        "absolute -right-[3.5px] -bottom-[3.5px] size-1.5 rounded-[var(--radius-2xs,2px)] border bg-background",
        variant === "selected" ? "border-[var(--theme-stroke-accent,#437dfc)]" : "border-destructive"
      )
    }
  );
}
function TableSlotCell(props) {
  var _a, _b, _c;
  const { className, variant = "default", state = "default" } = props;
  const rootDivProps = getTableSlotCellRootDivProps(props);
  const showHandle = state === "selected" || state === "failed";
  if (variant === "empty") {
    return /* @__PURE__ */ jsx(
      "div",
      __spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(
          "h-8 min-h-8 min-w-9",
          state === "selected" && "rounded-[var(--radius-2xs,2px)] border border-[var(--theme-stroke-accent,#437dfc)] bg-background",
          state === "failed" && "rounded-[var(--radius-2xs,2px)] border border-destructive bg-background",
          className
        )
      }, rootDivProps)
    );
  }
  if (variant === "checkbox") {
    const { checked, indeterminate, onCheckedChange } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsx(
            Checkbox,
            {
              checked,
              indeterminate,
              onCheckedChange: (val) => onCheckedChange == null ? void 0 : onCheckedChange(val)
            }
          ),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "icon") {
    const { icon } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          icon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: icon }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "number") {
    const { value } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsx("div", { className: "flex min-h-px min-w-px flex-1 items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-normal leading-4 text-muted-foreground tabular-nums", children: value }) }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "avatar") {
    const { label: label2, avatarSrc, avatarFallback, tailIcon: tailIcon2 } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsxs(Avatar, { size: "sm", className: "size-4", children: [
            avatarSrc && /* @__PURE__ */ jsx(AvatarImage, { src: avatarSrc, alt: label2 != null ? label2 : "" }),
            /* @__PURE__ */ jsx(AvatarFallback, { className: "text-[8px]", children: (_b = avatarFallback != null ? avatarFallback : (_a = label2 == null ? void 0 : label2.charAt(0)) == null ? void 0 : _a.toUpperCase()) != null ? _b : "?" })
          ] }),
          /* @__PURE__ */ jsx("div", { className: "flex min-h-px min-w-px flex-1 items-center", children: /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-normal leading-4 text-foreground", children: label2 }) }),
          tailIcon2 && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: tailIcon2 }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "media") {
    const {
      label: label2,
      description,
      thumbnailSrc,
      thumbnailAlt,
      thumbnailClassName,
      tailIcon: tailIcon2
    } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsx(
            "div",
            {
              className: cn(
                "flex h-14 w-18 shrink-0 items-center justify-center overflow-hidden rounded-sm bg-transparent",
                thumbnailClassName
              ),
              children: thumbnailSrc ? /* @__PURE__ */ jsx(
                Image,
                {
                  src: thumbnailSrc,
                  alt: (_c = thumbnailAlt != null ? thumbnailAlt : label2) != null ? _c : "",
                  width: 72,
                  height: 56,
                  className: "h-full w-full object-contain"
                }
              ) : null
            }
          ),
          /* @__PURE__ */ jsxs("div", { className: "flex min-h-px min-w-px flex-1 flex-col justify-center gap-0.5", children: [
            /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium leading-5 text-foreground", children: label2 }),
            description ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-normal leading-4 text-muted-foreground", children: description }) : null
          ] }),
          tailIcon2 && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: tailIcon2 }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "badge") {
    const { badgeLabel, badgeIcon, badgeClassName, tailIcon: tailIcon2 } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsx("div", { className: "flex h-5 min-h-px min-w-px flex-1 items-center", children: /* @__PURE__ */ jsxs(
            "span",
            {
              className: cn(
                "inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-xs font-medium leading-4 backdrop-blur-[2px]",
                "bg-muted/70 text-muted-foreground",
                badgeClassName
              ),
              children: [
                badgeIcon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center [&>svg]:size-3", children: badgeIcon }),
                badgeLabel
              ]
            }
          ) }),
          tailIcon2 && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: tailIcon2 }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  if (variant === "progress") {
    const { progressValue = 0, tailIcon: tailIcon2 } = props;
    return /* @__PURE__ */ jsxs(
      "div",
      __spreadProps(__spreadValues({
        "data-slot": "table-slot-cell",
        className: cn(tableSlotCellVariants({ variant, state }), className)
      }, rootDivProps), {
        children: [
          /* @__PURE__ */ jsxs("span", { className: "w-8 shrink-0 truncate text-xs font-normal leading-4 text-muted-foreground tabular-nums", children: [
            progressValue,
            "%"
          ] }),
          /* @__PURE__ */ jsx("div", { className: "flex min-h-px min-w-px flex-1 flex-col items-start", children: /* @__PURE__ */ jsx("div", { className: "flex h-1 w-full items-center overflow-clip rounded-full bg-muted", children: /* @__PURE__ */ jsx(
            "div",
            {
              className: "h-1 rounded-full bg-primary transition-all",
              style: { width: `${Math.min(100, Math.max(0, progressValue))}%` }
            }
          ) }) }),
          tailIcon2 && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: tailIcon2 }),
          showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
        ]
      })
    );
  }
  const { label, leadIcon, tailIcon } = props;
  return /* @__PURE__ */ jsxs(
    "div",
    __spreadProps(__spreadValues({
      "data-slot": "table-slot-cell",
      className: cn(tableSlotCellVariants({ variant, state }), className)
    }, rootDivProps), {
      children: [
        leadIcon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: leadIcon }),
        /* @__PURE__ */ jsx("div", { className: "flex min-h-px min-w-px flex-1 items-center", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-normal leading-5 text-foreground", children: label }) }),
        tailIcon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4", children: tailIcon }),
        showHandle && /* @__PURE__ */ jsx(SelectionHandle, { variant: state })
      ]
    })
  );
}

export { TableSlotCell, tableSlotCellVariants };
//# sourceMappingURL=table-slot-cell.js.map
//# sourceMappingURL=table-slot-cell.js.map