import { jsxs, jsx } from "react/jsx-runtime";
import * as React from "react";
import { X } from "lucide-react";
import { cn } from "../../lib/utils.js";
import { Button } from "../Button/button.js";
import { ButtonDivider } from "../Button/button-group.js";
const BULK_ACTION_BAR_DEFAULT_LABELS = {
  count: (n) => `已選 ${n} 項`,
  clear: "清除選取",
  hiddenSuffix: (hidden) => `· ${hidden} 個被 filter 隱藏`,
  toolbarAriaLabel: "批次操作"
};
const BulkActionBar = React.forwardRef(
  function BulkActionBar2({ selection, onClear, actions, hiddenByFilter, totalSelected, labels: labelsOverride, className, ...props }, ref) {
    const labels = React.useMemo(
      () => ({ ...BULK_ACTION_BAR_DEFAULT_LABELS, ...labelsOverride }),
      [labelsOverride]
    );
    if (selection.length === 0) return null;
    return /* @__PURE__ */ jsxs(
      "div",
      {
        ref,
        role: "toolbar",
        "aria-label": labels.toolbarAriaLabel,
        className: cn(
          "flex items-center gap-2",
          "px-[var(--layout-space-loose)] py-[var(--layout-space-tight)]",
          // 上分隔線:bottom toolbar canonical(Linear / Apple Mail / Notion 共識)— 視覺從上方內容收尾
          "border-t border-divider",
          className
        ),
        ...props,
        children: [
          onClear && /* @__PURE__ */ jsx(
            Button,
            {
              variant: "text",
              size: "md",
              iconOnly: true,
              dismiss: true,
              startIcon: X,
              "aria-label": labels.clear,
              onClick: onClear
            }
          ),
          /* @__PURE__ */ jsxs("span", { className: "text-body text-foreground font-medium tabular-nums", "aria-live": "polite", "aria-atomic": "true", children: [
            labels.count(typeof totalSelected === "number" ? totalSelected : selection.length),
            hiddenByFilter !== void 0 && hiddenByFilter > 0 && /* @__PURE__ */ jsxs("span", { className: "text-fg-muted font-normal", children: [
              " ",
              labels.hiddenSuffix(hiddenByFilter)
            ] })
          ] }),
          actions && /* @__PURE__ */ jsx(ButtonDivider, {}),
          actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: actions })
        ]
      }
    );
  }
);
BulkActionBar.displayName = "BulkActionBar";
const bulkActionBarMeta = {
  component: "BulkActionBar",
  family: null,
  variants: {},
  sizes: {},
  states: ["default"],
  tokens: {
    fg: ["text-foreground", "text-fg-muted"],
    border: ["border-divider"]
  }
};
export {
  BULK_ACTION_BAR_DEFAULT_LABELS,
  BulkActionBar,
  bulkActionBarMeta
};
//# sourceMappingURL=bulk-action-bar.js.map
