"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Download, Trash2, Workflow, UserCircle2, X } from "lucide-react";
import { Button } from "@open-mercato/ui/primitives/button";
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { translateWithFallback } from "@open-mercato/shared/lib/i18n/translate";
function BulkActionsBar({
  count,
  totalLabel,
  onChangeStage,
  onChangeOwner,
  onExportCsv,
  onDelete,
  onClear
}) {
  const t = useT();
  React.useEffect(() => {
    if (count === 0) return;
    const onKey = (event) => {
      if (event.key !== "Escape") return;
      const active = document.activeElement;
      if (active) {
        const tag = active.tagName;
        if (tag === "INPUT" || tag === "TEXTAREA" || active.isContentEditable) return;
      }
      event.preventDefault();
      onClear();
    };
    document.addEventListener("keydown", onKey);
    return () => document.removeEventListener("keydown", onKey);
  }, [count, onClear]);
  if (count === 0) return null;
  return /* @__PURE__ */ jsxs(
    "div",
    {
      role: "region",
      "aria-label": translateWithFallback(
        t,
        "customers.deals.kanban.bulk.aria.bar",
        "Bulk actions"
      ),
      className: "fixed bottom-6 left-1/2 z-toast flex w-[min(960px,calc(100%-2rem))] -translate-x-1/2 items-center gap-3 rounded-lg bg-foreground px-4 py-3 text-background shadow-xl",
      children: [
        /* @__PURE__ */ jsx(
          IconButton,
          {
            variant: "ghost",
            size: "xs",
            onClick: onClear,
            "aria-label": translateWithFallback(
              t,
              "customers.deals.kanban.bulk.aria.clear",
              "Clear selection"
            ),
            className: "inline-flex size-6 items-center justify-center rounded-md transition-colors hover:bg-background/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-foreground",
            children: /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": "true" })
          }
        ),
        /* @__PURE__ */ jsx("span", { className: "inline-flex size-7 items-center justify-center rounded-md bg-background/10 text-xs font-semibold", children: count }),
        /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: translateWithFallback(
          t,
          "customers.deals.kanban.bulk.selectedCount",
          "selected"
        ) }),
        totalLabel ? /* @__PURE__ */ jsxs("span", { className: "hidden text-sm text-background/80 sm:inline", children: [
          "\xB7",
          " ",
          translateWithFallback(
            t,
            "customers.deals.kanban.bulk.totalValue",
            "Total {value}",
            { value: totalLabel }
          )
        ] }) : null,
        /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
          /* @__PURE__ */ jsxs(
            Button,
            {
              variant: "ghost",
              size: "sm",
              type: "button",
              onClick: onChangeStage,
              className: "inline-flex items-center gap-1 rounded-md px-3 py-1 text-sm transition-colors hover:bg-background/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-foreground",
              children: [
                /* @__PURE__ */ jsx(Workflow, { className: "size-4", "aria-hidden": "true" }),
                /* @__PURE__ */ jsx("span", { children: translateWithFallback(
                  t,
                  "customers.deals.kanban.bulk.changeStage",
                  "Change stage"
                ) })
              ]
            }
          ),
          /* @__PURE__ */ jsxs(
            Button,
            {
              variant: "ghost",
              size: "sm",
              type: "button",
              onClick: onChangeOwner,
              className: "inline-flex items-center gap-1 rounded-md px-3 py-1 text-sm transition-colors hover:bg-background/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-foreground",
              children: [
                /* @__PURE__ */ jsx(UserCircle2, { className: "size-4", "aria-hidden": "true" }),
                /* @__PURE__ */ jsx("span", { children: translateWithFallback(
                  t,
                  "customers.deals.kanban.bulk.changeOwner",
                  "Change owner"
                ) })
              ]
            }
          ),
          /* @__PURE__ */ jsxs(
            Button,
            {
              variant: "ghost",
              size: "sm",
              type: "button",
              onClick: onExportCsv,
              className: "inline-flex items-center gap-1 rounded-md px-3 py-1 text-sm transition-colors hover:bg-background/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-foreground",
              children: [
                /* @__PURE__ */ jsx(Download, { className: "size-4", "aria-hidden": "true" }),
                /* @__PURE__ */ jsx("span", { children: translateWithFallback(
                  t,
                  "customers.deals.kanban.bulk.exportCsv",
                  "Export CSV"
                ) })
              ]
            }
          ),
          /* @__PURE__ */ jsxs(
            Button,
            {
              variant: "destructive-ghost",
              size: "sm",
              type: "button",
              onClick: onDelete,
              className: "inline-flex items-center gap-1 rounded-md px-3 py-1 text-sm text-status-error-text transition-colors hover:bg-status-error-bg/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-foreground",
              children: [
                /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" }),
                /* @__PURE__ */ jsx("span", { children: translateWithFallback(
                  t,
                  "customers.deals.kanban.bulk.delete",
                  "Delete"
                ) })
              ]
            }
          )
        ] })
      ]
    }
  );
}
var BulkActionsBar_default = BulkActionsBar;
export {
  BulkActionsBar,
  BulkActionsBar_default as default
};
//# sourceMappingURL=BulkActionsBar.js.map
