"use client";
import { j as e } from "../../../node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.mjs";
import C from "react";
import P from "../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.mjs";
import v from "../Button/index.mjs";
import n from "./QuestsTable.module.scss.mjs";
function I(x, t) {
  switch (x) {
    case "DRAFT":
      return t.draft;
    case "ACTIVE":
      return t.active;
    case "INACTIVE":
      return t.inactive;
    default:
      return "???";
  }
}
function E({
  quests: x,
  filter: t,
  onFilterChange: c,
  i18n: s = {
    name: "Name",
    type: "Type",
    rewardPerPlayer: "Reward / Player",
    balance: "Balance",
    claims: "Claims",
    status: "Status",
    player: "Player",
    active: "Active",
    inactive: "Inactive",
    draft: "Draft"
  }
}) {
  let l = x;
  const d = t === "ACTIVE", o = t === "INACTIVE", j = t === null;
  d ? l = l.filter((r) => r.status === "ACTIVE") : o && (l = l.filter((r) => r.status !== "ACTIVE"));
  function h(r, i) {
    let m = "";
    for (let a = 0; a < 2 && a < r.length; ++a) {
      const y = r[a];
      a === 1 && (m += ", "), m += i(y);
    }
    const f = r.length - 2;
    return f > 0 && (m += `, +${f} more`), m;
  }
  function p(r) {
    return h(
      r.rewards,
      (i) => `${i.amountPerPlayer} ${i.symbol}`
    );
  }
  function u(r) {
    return h(
      r.rewards,
      (i) => `${i.balance} ${i.symbol}`
    );
  }
  return /* @__PURE__ */ e.jsxs("div", { children: [
    /* @__PURE__ */ e.jsxs("div", { className: n.actionButtonRow, children: [
      /* @__PURE__ */ e.jsx(
        v,
        {
          type: d ? "secondary" : "tertiary",
          onClick: () => {
            o || j ? c("ACTIVE") : d && c(null);
          },
          children: s.active
        }
      ),
      /* @__PURE__ */ e.jsx(
        v,
        {
          type: o ? "secondary" : "tertiary",
          onClick: () => {
            d || j ? c("INACTIVE") : o && c(null);
          },
          children: s.inactive
        }
      )
    ] }),
    /* @__PURE__ */ e.jsx("table", { className: n.questsTableContainer, children: /* @__PURE__ */ e.jsx("tbody", { children: l.map((r) => {
      const i = r.linkComponent ?? C.Fragment;
      return /* @__PURE__ */ e.jsxs(
        "tr",
        {
          className: n.rowContainer,
          onClick: r.onClick,
          children: [
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.name }),
              /* @__PURE__ */ e.jsx("div", { children: r.name })
            ] }) }),
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.type }),
              /* @__PURE__ */ e.jsx("div", { children: r.type })
            ] }) }),
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.rewardPerPlayer }),
              /* @__PURE__ */ e.jsx("div", { children: p(r) })
            ] }) }),
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.balance }),
              /* @__PURE__ */ e.jsx("div", { children: u(r) })
            ] }) }),
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.claims }),
              /* @__PURE__ */ e.jsx("div", { children: r.claims })
            ] }) }),
            /* @__PURE__ */ e.jsx("td", { children: /* @__PURE__ */ e.jsxs(i, { ...r.linkProps, children: [
              /* @__PURE__ */ e.jsx("div", { children: s.status }),
              /* @__PURE__ */ e.jsxs("div", { className: n.statusContainer, children: [
                /* @__PURE__ */ e.jsx(
                  "div",
                  {
                    className: P(
                      "circle",
                      n.statusCircle,
                      n[r.status]
                    )
                  }
                ),
                I(r.status, s)
              ] })
            ] }) })
          ]
        },
        r.name
      );
    }) }) })
  ] });
}
export {
  E as QuestsTable
};
//# sourceMappingURL=index.mjs.map
