import { jsx as e, jsxs as r } from "react/jsx-runtime";
import me, { useState as R, useCallback as K, useMemo as P, createRef as Me, useRef as ve, useEffect as be } from "react";
import { useTranslation as xe } from "react-i18next";
import { Lock as Ce, ChevronRight as se, ChevronDown as ae, FolderOpen as $e, Database as Le, FileText as Oe, Box as Ee, Filter as je, Search as _e, Check as ue, RotateCcw as De, X as We, Loader2 as he, Link2 as ie, AlertCircle as ce, Sparkles as Be, Info as Ke, ChevronLeft as fe, Ban as Ne, Eye as pe, Star as ye, BookOpen as ze, ChevronUp as Ge, ShieldCheck as Ue, Pencil as Xe, User as Je } from "lucide-react";
import { x as Ze, I as qe, J as He, P as de, v as Qe } from "./index-CeEMms9z.js";
import { g as Ve, c as Ye, b as et, P as tt, d as rt } from "./PermissionPopover-CzuQmLbY.js";
function st({
  section: t,
  resources: v,
  moduleIndex: L,
  sectionIndex: k,
  isCollapsed: O,
  collapsedSections: F,
  paginatedRoles: b,
  canEditSystemRoles: _,
  statusFilters: l,
  openPopover: x,
  onToggleCollapse: A,
  onTogglePermission: T,
  onCellClick: h,
  setOpenPopover: N,
  renderResourceRow: y
}) {
  const M = F.has(t.id), d = v.length > 0;
  return /* @__PURE__ */ r(me.Fragment, { children: [
    y(t, L + k + 1, "section", d, M),
    d && !M && v.map(
      (E, $) => y(E, L + k + $ + 2, "resource", !1, !1)
    )
  ] }, t.id);
}
function at({
  roles: t,
  resources: v,
  canEditSystemRoles: L = !1,
  onTogglePermission: k,
  getPermissionInheritance: O,
  rolesPerPage: F,
  rolePageIndex: b,
  modulesPerPage: _,
  modulePageIndex: l,
  collapsedApps: x,
  onToggleApp: A,
  statusFilters: T
}) {
  const { t: h } = xe("admin"), [N, y] = R(null), [M, d] = R(/* @__PURE__ */ new Set()), [E, $] = R(/* @__PURE__ */ new Set()), D = K((s, o) => {
    o((i) => {
      const p = new Set(i);
      return p.has(s) ? p.delete(s) : p.add(s), p;
    });
  }, []), j = K((s) => {
    D(s, d);
  }, [D]), U = K((s) => {
    D(s, $);
  }, [D]), X = P(() => v.filter((s) => s.level === "module").length, [v]), W = P(() => {
    const s = b * F;
    return t.slice(s, s + F);
  }, [t, b, F]), z = P(() => Ve(v), [v]), a = K(() => {
    const s = l * _, o = s + _;
    let i = 0;
    const p = [];
    for (const w of z) {
      const C = x.has(w.application), g = [];
      if (!C)
        for (const S of w.modules)
          i >= s && i < o && g.push(S), i++;
      p.push({
        application: w.application,
        modules: g
      });
    }
    return p;
  }, [z, l, _, x]), u = P(() => a(), [a]), I = K((s, o) => {
    const i = O(s, o);
    return i.isDirect || i.isInherited;
  }, [O]), H = K((s, o) => Ye(o, (i) => I(s, i)), [I]), V = (s, o) => {
    N?.roleId === s && N?.resourceId === o ? y(null) : y({ roleId: s, resourceId: o });
  }, B = K((s, o) => {
    o === "module" ? j(s) : o === "section" && U(s);
  }, [j, U]);
  if (t.length === 0 || X === 0)
    return /* @__PURE__ */ e("div", { className: "text-center py-12 text-[var(--text-secondary)]", children: t.length === 0 ? h("assignments.noRoles") : h("assignments.noResources") });
  const G = (s) => {
    switch (s) {
      case "resource":
        return "pl-28";
      case "section":
        return "pl-22";
      default:
        return "pl-16";
    }
  }, Y = (s) => s === "resource" ? /* @__PURE__ */ e(Le, { className: "h-3.5 w-3.5 text-[var(--text-muted)]" }) : s === "section" ? /* @__PURE__ */ e(Oe, { className: "h-3.5 w-3.5 text-[var(--text-muted)]" }) : /* @__PURE__ */ e(Ee, { className: "h-3.5 w-3.5 text-[var(--text-secondary)]" }), ne = (s) => s === "resource" ? "text-[var(--text-muted)] italic" : s === "section" ? "text-[var(--text-secondary)]" : "font-medium text-[var(--text-primary)]", oe = (s, o, i, p) => s ? /* @__PURE__ */ e(
    "button",
    {
      onClick: () => B(o, i),
      className: "p-0.5 hover:bg-[var(--bg-hover)] rounded",
      children: p ? /* @__PURE__ */ e(se, { className: "h-3 w-3 text-[var(--text-muted)]" }) : /* @__PURE__ */ e(ae, { className: "h-3 w-3 text-[var(--text-muted)]" })
    }
  ) : null, le = (s) => W.map((o) => {
    const { status: i, grantedCount: p } = H(o.id, s), w = N?.roleId === o.id && N?.resourceId === s.id, C = Me(), g = !o.isSystem || L, S = et(i), f = (T?.size ?? 0) > 0 && !T?.has(i);
    return /* @__PURE__ */ r(
      "td",
      {
        className: `px-0 py-1 text-center relative ${f ? "" : S}`,
        style: { width: "44px", minWidth: "44px", maxWidth: "44px" },
        children: [
          /* @__PURE__ */ e(
            "button",
            {
              ref: C,
              type: "button",
              onClick: () => g && !f && V(o.id, s.id),
              disabled: !g || f,
              className: `w-full h-full min-h-[36px] flex items-center justify-center rounded transition-colors ${f ? "opacity-10 cursor-default" : g ? "hover:opacity-80" : "cursor-not-allowed opacity-50"} ${w ? "ring-2 ring-[var(--color-accent-500)]" : ""}`,
              title: f ? void 0 : g ? `${o.name} - ${s.moduleLabel}: ${p}/${s.permissions.length}` : `${o.name} - ${h("assignments.systemRoleReadOnly")}`,
              children: /* @__PURE__ */ e(
                tt,
                {
                  status: i,
                  grantedCount: p,
                  totalCount: s.permissions.length
                }
              )
            }
          ),
          w && g && !f && /* @__PURE__ */ e(
            rt,
            {
              mode: "editable",
              role: o,
              resource: s,
              onTogglePermission: (Q) => k(o.id, Q),
              onClose: () => y(null),
              getPermissionInheritance: O
            }
          )
        ]
      },
      `${o.id}-${s.id}`
    );
  }), ee = (s, o, i, p = !1, w = !1) => {
    const C = G(i), g = o % 2 === 0 ? "item-light" : "item-medium";
    return /* @__PURE__ */ r(
      "tr",
      {
        className: `hover:bg-[var(--bg-hover)] ${g}`,
        children: [
          /* @__PURE__ */ e(
            "td",
            {
              className: `sticky left-0 z-10 ${g} px-3 py-2 ${C}`,
              style: { width: "280px", minWidth: "280px", maxWidth: "280px" },
              children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
                oe(p, s.id, i, w),
                Y(i),
                /* @__PURE__ */ e("span", { className: `text-sm ${ne(i)}`, children: s.moduleLabel }),
                /* @__PURE__ */ r("span", { className: "text-xs text-[var(--text-muted)]", children: [
                  "(",
                  s.permissions.length,
                  ")"
                ] })
              ] })
            }
          ),
          le(s)
        ]
      },
      s.id
    );
  };
  return /* @__PURE__ */ e("div", { className: "overflow-x-auto overflow-y-visible", children: /* @__PURE__ */ r("table", { className: "border-collapse", style: { width: "auto" }, children: [
    /* @__PURE__ */ e("thead", { className: "item-medium border-b border-[var(--item-color-border)]", children: /* @__PURE__ */ r("tr", { children: [
      /* @__PURE__ */ e(
        "th",
        {
          scope: "col",
          className: "sticky left-0 z-20 item-medium px-3 text-left text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",
          style: { width: "280px", minWidth: "280px", maxWidth: "280px", height: "180px", verticalAlign: "bottom", paddingBottom: "12px" },
          children: h("assignments.resource")
        }
      ),
      W.map((s) => /* @__PURE__ */ e(
        "th",
        {
          scope: "col",
          className: "relative overflow-visible",
          style: { width: "44px", minWidth: "44px", maxWidth: "44px", height: "180px", padding: 0, verticalAlign: "bottom" },
          children: /* @__PURE__ */ e(
            "div",
            {
              className: "absolute bottom-2 left-1/2",
              style: {
                transform: "translateX(-6px) rotate(-55deg)",
                transformOrigin: "bottom left",
                width: "160px"
              },
              children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
                s.isSystem && /* @__PURE__ */ e(Ce, { className: "h-3 w-3 flex-shrink-0 text-[var(--warning-dot)]" }),
                /* @__PURE__ */ e(
                  "span",
                  {
                    className: "text-[10px] font-medium text-[var(--text-primary)] whitespace-nowrap",
                    title: s.name,
                    children: s.name
                  }
                )
              ] })
            }
          )
        },
        s.id
      ))
    ] }) }),
    /* @__PURE__ */ e("tbody", { className: "divide-y divide-[var(--item-color-border)]", children: u.map((s) => {
      const o = x.has(s.application), i = W.length;
      return /* @__PURE__ */ r(me.Fragment, { children: [
        /* @__PURE__ */ r("tr", { className: "bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50", children: [
          /* @__PURE__ */ e(
            "td",
            {
              className: "sticky left-0 z-10 px-3 py-3 bg-[var(--color-accent-900)]/30 dark:bg-[var(--color-accent-900)]/50",
              style: { width: "280px", minWidth: "280px", maxWidth: "280px" },
              children: /* @__PURE__ */ r(
                "button",
                {
                  onClick: () => A(s.application),
                  className: "flex items-center gap-3 w-full text-left hover:opacity-80",
                  children: [
                    o ? /* @__PURE__ */ e(se, { className: "h-5 w-5 text-[var(--color-accent-400)]" }) : /* @__PURE__ */ e(ae, { className: "h-5 w-5 text-[var(--color-accent-400)]" }),
                    /* @__PURE__ */ e($e, { className: "h-5 w-5 text-[var(--color-accent-400)]" }),
                    /* @__PURE__ */ e("span", { className: "text-sm font-bold text-[var(--color-accent-300)] uppercase tracking-wider", children: s.application }),
                    /* @__PURE__ */ e("span", { className: "text-xs text-[var(--color-accent-400)] ml-auto", children: h("assignments.moduleCount", { count: s.modules.length }) })
                  ]
                }
              )
            }
          ),
          /* @__PURE__ */ e("td", { colSpan: i, className: "px-0 py-3" })
        ] }),
        !o && s.modules.map((p, w) => {
          const { module: C, sections: g } = p, S = g.length > 0, f = M.has(C.id);
          return /* @__PURE__ */ r(me.Fragment, { children: [
            ee(C, w, "module", S, f),
            S && !f && g.map((Q, J) => {
              const { section: te, resources: Z } = Q;
              return /* @__PURE__ */ e(
                st,
                {
                  section: te,
                  resources: Z,
                  moduleIndex: w,
                  sectionIndex: J,
                  isCollapsed: f,
                  collapsedSections: E,
                  paginatedRoles: W,
                  canEditSystemRoles: L,
                  statusFilters: T,
                  openPopover: N,
                  onToggleCollapse: B,
                  onTogglePermission: k,
                  onCellClick: V,
                  setOpenPopover: y,
                  renderResourceRow: ee
                },
                te.id
              );
            })
          ] }, C.id);
        })
      ] }, s.application);
    }) })
  ] }) });
}
function nt({
  filters: t,
  roles: v,
  categories: L,
  applications: k,
  modules: O,
  hasChanges: F,
  onFilterChange: b,
  onReset: _
}) {
  const { t: l } = xe("admin"), [x, A] = R(!1), [T, h] = R(""), N = ve(null), y = ve(null), M = P(() => {
    let a = v;
    if (t.categoryFilter !== "all" && (a = a.filter((u) => u.category === t.categoryFilter)), T.trim()) {
      const u = T.toLowerCase();
      a = a.filter(
        (I) => I.name.toLowerCase().includes(u) || I.shortName?.toLowerCase().includes(u)
      );
    }
    return a;
  }, [v, t.categoryFilter, T]);
  be(() => {
    x && y.current && setTimeout(() => y.current?.focus(), 50);
  }, [x]);
  const d = (a) => {
    A(a), a || h("");
  }, E = O.filter((a) => !(t.applicationFilter !== "all" && a.app !== t.applicationFilter));
  be(() => {
    function a(u) {
      N.current && !N.current.contains(u.target) && d(!1);
    }
    return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
  }, []);
  const $ = (a) => {
    const u = t.selectedRoleIds.includes(a) ? t.selectedRoleIds.filter((I) => I !== a) : [...t.selectedRoleIds, a];
    b({ selectedRoleIds: u });
  }, D = () => {
    b({ selectedRoleIds: M.map((a) => a.id) });
  }, j = () => {
    b({ selectedRoleIds: [] });
  }, U = (a) => {
    b({ applicationFilter: a, moduleFilter: "all" });
  }, X = (a) => {
    b({ categoryFilter: a, selectedRoleIds: [] });
  }, W = t.selectedRoleIds.length > 0 || t.categoryFilter !== "all" || t.applicationFilter !== "all" || t.moduleFilter !== "all", z = t.selectedRoleIds.length === 0 ? l("permissions.filters.allRoles") : t.selectedRoleIds.length === 1 ? v.find((a) => a.id === t.selectedRoleIds[0])?.name || l("assignments.oneRoleSelected") : `${t.selectedRoleIds.length} ${l("permissions.filters.rolesSelected")}`;
  return /* @__PURE__ */ r("div", { className: "bg-[var(--bg-card)] border border-[var(--item-color-border)] rounded-[var(--radius-card)] p-4 space-y-4", children: [
    /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-sm font-medium text-[var(--text-secondary)]", children: [
      /* @__PURE__ */ e(je, { className: "h-4 w-4" }),
      /* @__PURE__ */ e("span", { children: l("assignments.filters") })
    ] }),
    /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-4", children: [
      /* @__PURE__ */ r("div", { className: "min-w-[160px] flex-1", children: [
        /* @__PURE__ */ e("label", { htmlFor: "category-filter", className: "block text-sm font-medium text-[var(--text-secondary)] mb-1", children: l("permissions.filters.selectCategory") }),
        /* @__PURE__ */ r(
          "select",
          {
            id: "category-filter",
            value: t.categoryFilter,
            onChange: (a) => X(a.target.value),
            className: "block w-full px-3 py-2 border border-[var(--border-color)] rounded-[var(--radius-input)] leading-5 bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-[var(--color-accent-500)] sm:text-sm",
            children: [
              /* @__PURE__ */ e("option", { value: "all", children: l("permissions.filters.allCategories") }),
              L.map((a) => /* @__PURE__ */ e("option", { value: a, children: l(`roles.categories.${a.toLowerCase()}`) }, a))
            ]
          }
        )
      ] }),
      /* @__PURE__ */ r("div", { ref: N, className: "relative min-w-[200px] flex-[2]", children: [
        /* @__PURE__ */ e("label", { className: "block text-sm font-medium text-[var(--text-secondary)] mb-1", children: l("permissions.filters.selectRoles") }),
        /* @__PURE__ */ r(
          "button",
          {
            type: "button",
            onClick: () => d(!x),
            className: "w-full flex items-center justify-between px-3 py-2 border border-[var(--border-color)] rounded-[var(--radius-input)] bg-[var(--bg-primary)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-[var(--color-accent-500)] text-sm",
            children: [
              /* @__PURE__ */ e("span", { className: "truncate", children: z }),
              /* @__PURE__ */ e(ae, { className: `h-4 w-4 text-[var(--text-muted)] transition-transform ${x ? "rotate-180" : ""}` })
            ]
          }
        ),
        x && /* @__PURE__ */ r("div", { className: "absolute z-50 mt-1 w-full bg-[var(--bg-card)] border border-[var(--border-color)] rounded-[var(--radius-card)] shadow-lg", children: [
          /* @__PURE__ */ e("div", { className: "px-3 py-2 border-b border-[var(--border-color)]", children: /* @__PURE__ */ r("div", { className: "relative", children: [
            /* @__PURE__ */ e("div", { className: "absolute inset-y-0 left-0 pl-2 flex items-center pointer-events-none", children: /* @__PURE__ */ e(_e, { className: "h-4 w-4 text-[var(--text-muted)]" }) }),
            /* @__PURE__ */ e(
              "input",
              {
                ref: y,
                type: "text",
                value: T,
                onChange: (a) => h(a.target.value),
                placeholder: l("permissions.filters.searchRoles"),
                className: "block w-full pl-8 pr-3 py-1.5 text-sm border border-[var(--border-color)] rounded-[var(--radius-input)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)] focus:border-[var(--color-accent-500)]"
              }
            )
          ] }) }),
          /* @__PURE__ */ r("div", { className: "flex items-center justify-between px-3 py-2 border-b border-[var(--border-color)] bg-[var(--bg-secondary)]", children: [
            /* @__PURE__ */ e(
              "button",
              {
                type: "button",
                onClick: D,
                className: "text-xs text-[var(--color-accent-600)] hover:text-[var(--color-accent-700)]",
                children: l("permissions.filters.selectAll")
              }
            ),
            /* @__PURE__ */ e(
              "button",
              {
                type: "button",
                onClick: j,
                className: "text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)]",
                children: l("permissions.filters.clearSelection")
              }
            )
          ] }),
          /* @__PURE__ */ e("div", { className: "max-h-64 overflow-auto", children: M.length === 0 ? /* @__PURE__ */ e("div", { className: "px-3 py-4 text-sm text-[var(--text-muted)] text-center", children: l("permissions.filters.noRolesFound") }) : M.map((a) => /* @__PURE__ */ r(
            "button",
            {
              type: "button",
              onClick: () => $(a.id),
              className: "w-full flex items-center gap-3 px-3 py-2 hover:bg-[var(--bg-secondary)] cursor-pointer text-left",
              children: [
                /* @__PURE__ */ e("div", { className: `w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 ${t.selectedRoleIds.includes(a.id) ? "bg-[var(--color-accent-600)] border-[var(--color-accent-600)]" : "border-[var(--border-color)] bg-[var(--bg-primary)]"}`, children: t.selectedRoleIds.includes(a.id) && /* @__PURE__ */ e(ue, { className: "h-3 w-3 text-white" }) }),
                /* @__PURE__ */ e("span", { className: "text-sm text-[var(--text-primary)] truncate", children: a.name }),
                a.isSystem && /* @__PURE__ */ e("span", { className: "text-xs px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-muted)] flex-shrink-0", children: l("assignments.systemRole") })
              ]
            },
            a.id
          )) })
        ] })
      ] }),
      /* @__PURE__ */ r("div", { className: "min-w-[160px] flex-1", children: [
        /* @__PURE__ */ e("label", { htmlFor: "application-filter", className: "block text-sm font-medium text-[var(--text-secondary)] mb-1", children: l("assignments.filterByApplication") }),
        /* @__PURE__ */ r(
          "select",
          {
            id: "application-filter",
            value: t.applicationFilter,
            onChange: (a) => U(a.target.value),
            disabled: k.length === 0,
            className: "block w-full px-3 py-2 border border-[var(--border-color)] rounded-[var(--radius-input)] leading-5 bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-[var(--color-accent-500)] sm:text-sm disabled:opacity-50 disabled:cursor-not-allowed",
            children: [
              /* @__PURE__ */ e("option", { value: "all", children: l("assignments.allApplications") }),
              k.map((a) => /* @__PURE__ */ e("option", { value: a.app, children: a.label }, a.app))
            ]
          }
        )
      ] }),
      /* @__PURE__ */ r("div", { className: "min-w-[160px] flex-1", children: [
        /* @__PURE__ */ e("label", { htmlFor: "module-filter", className: "block text-sm font-medium text-[var(--text-secondary)] mb-1", children: l("permissions.filters.selectModule") }),
        /* @__PURE__ */ r(
          "select",
          {
            id: "module-filter",
            value: t.moduleFilter,
            onChange: (a) => b({ moduleFilter: a.target.value }),
            disabled: E.length === 0,
            className: "block w-full px-3 py-2 border border-[var(--border-color)] rounded-[var(--radius-input)] leading-5 bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-[var(--color-accent-500)] sm:text-sm disabled:opacity-50 disabled:cursor-not-allowed",
            children: [
              /* @__PURE__ */ e("option", { value: "all", children: l("permissions.filters.allModules") }),
              E.map((a) => /* @__PURE__ */ e("option", { value: a.module, children: a.label }, `${a.app}:${a.module}`))
            ]
          }
        )
      ] }),
      /* @__PURE__ */ e("div", { className: "flex items-end flex-shrink-0", children: W && /* @__PURE__ */ r(
        "button",
        {
          type: "button",
          onClick: _,
          className: "w-full inline-flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] border border-[var(--border-color)] rounded-[var(--radius-input)] hover:bg-[var(--bg-secondary)] transition-colors",
          children: [
            /* @__PURE__ */ e(De, { className: "h-4 w-4" }),
            l("assignments.clearFilters")
          ]
        }
      ) })
    ] }),
    t.selectedRoleIds.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: t.selectedRoleIds.map((a) => {
      const u = v.find((I) => I.id === a);
      return u ? /* @__PURE__ */ r(
        "span",
        {
          className: "inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--color-accent-100)] text-[var(--color-accent-700)] dark:bg-[var(--color-accent-900)] dark:text-[var(--color-accent-300)]",
          children: [
            u.name,
            /* @__PURE__ */ e(
              "button",
              {
                type: "button",
                onClick: () => $(a),
                className: "hover:text-[var(--color-accent-900)] dark:hover:text-[var(--color-accent-100)]",
                children: /* @__PURE__ */ e(We, { className: "h-3 w-3" })
              }
            )
          ]
        },
        a
      ) : null;
    }) }),
    F && /* @__PURE__ */ e("div", { className: "flex items-center justify-end pt-2 border-t border-[var(--border-color)]", children: /* @__PURE__ */ e("div", { className: "text-sm text-[var(--warning-text)]", children: l("assignments.unsavedChanges") }) })
  ] });
}
const we = {
  viewer: {
    nameKey: "assignments.templates.viewer.name",
    descriptionKey: "assignments.templates.viewer.description",
    icon: pe,
    color: "blue",
    permissions: ["*.read"]
  },
  member: {
    nameKey: "assignments.templates.member.name",
    descriptionKey: "assignments.templates.member.description",
    icon: Je,
    color: "green",
    permissions: ["*.read", "*.create"]
  },
  contributor: {
    nameKey: "assignments.templates.contributor.name",
    descriptionKey: "assignments.templates.contributor.description",
    icon: Xe,
    color: "orange",
    permissions: ["*.read", "*.create", "*.update"]
  },
  admin: {
    nameKey: "assignments.templates.admin.name",
    descriptionKey: "assignments.templates.admin.description",
    icon: Ue,
    color: "red",
    permissions: ["*.*"]
  }
}, ot = [10, 25, 50], lt = [10, 15, 20, 25];
function xt() {
  const { t } = xe("admin"), { user: v } = Ze(), [L, k] = R(!1), [O, F] = R(null), [b, _] = R(25), [l, x] = R(1), [A, T] = R(10), [h, N] = R(0), [y, M] = R(/* @__PURE__ */ new Set()), [d, E] = R(/* @__PURE__ */ new Set()), [$, D] = R(!1), j = (n) => {
    E((m) => {
      const c = new Set(m);
      return c.has(n) ? c.delete(n) : c.add(n), c;
    }), x(1), N(0);
  }, U = (n) => {
    M((m) => {
      const c = new Set(m);
      return c.has(n) ? c.delete(n) : c.add(n), c;
    });
  }, X = P(() => v ? qe(v.permissions) : !1, [v]), {
    loading: W,
    error: z,
    saveError: a,
    saving: u,
    roles: I,
    assignments: H,
    filters: V,
    filteredRoles: B,
    filteredResources: G,
    hasChanges: Y,
    applications: ne,
    modules: oe,
    categories: le,
    togglePermission: ee,
    updateFilters: s,
    reloadData: o,
    resetChanges: i,
    clearSaveError: p,
    getPermissionInheritance: w
  } = He({ canEditSystemRoles: X }), C = K(
    (n, m) => {
      const c = m.permissions.filter((Ae) => {
        const ge = w(n, Ae.id);
        return ge.isDirect || ge.isInherited;
      }), q = c.length, Ie = m.totalPermissions;
      return q === 0 ? "none" : q === Ie ? "all" : q === 1 && c[0]?.action === "read" ? "read-only" : "some";
    },
    [w]
  ), g = P(
    () => G.filter((n) => n.level === "module"),
    [G]
  ), S = P(() => d.size === 0 ? B : B.filter((n) => {
    for (const m of g) {
      const c = C(n.id, m);
      if (d.has(c))
        return !0;
    }
    return !1;
  }), [B, g, d, C]), f = P(() => d.size === 0 ? G : G.filter((n) => {
    if (n.level !== "module") return !0;
    for (const m of B) {
      const c = C(m.id, n);
      if (d.has(c))
        return !0;
    }
    return !1;
  }), [G, B, d, C]), Q = P(() => {
    let n = 0;
    return Object.values(H).forEach((m) => {
      n += m.size;
    }), n;
  }, [H]), J = P(() => f.filter((n) => !(n.level !== "module" || y.has(n.applicationLabel))).length, [f, y]), te = P(() => f.filter((n) => n.level === "module").length, [f]), Z = Math.ceil(J / b), Re = (n) => {
    x(1), s(n);
  }, ke = (n) => {
    _(n), x(1);
  }, re = Math.ceil(S.length / A), Se = (n) => {
    T(n), N(0);
  }, Pe = async (n) => {
    const m = we[n];
    if (!m) return;
    const c = prompt(t("assignments.enterRoleName"), t(m.nameKey));
    if (c)
      try {
        F(null), await Qe.roles.create({
          name: c,
          description: t(m.descriptionKey),
          permissionIds: []
        }), k(!1), await o();
      } catch (q) {
        F(q instanceof Error ? q.message : "Failed to create role from template");
      }
  }, Fe = () => {
    x(1), s({
      selectedRoleIds: [],
      resourceSearch: "",
      applicationFilter: "all",
      moduleFilter: "all"
    });
  };
  if (W)
    return /* @__PURE__ */ e(
      de,
      {
        title: t("assignments.title"),
        subtitle: t("assignments.subtitle"),
        icon: /* @__PURE__ */ e(ie, { className: "h-6 w-6" }),
        breadcrumbs: [
          { label: t("header.title"), href: "/administration" },
          { label: t("assignments.title", "Assignments") }
        ],
        children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
          /* @__PURE__ */ e(he, { className: "h-8 w-8 animate-spin text-[var(--color-accent-500)] mx-auto mb-4" }),
          /* @__PURE__ */ e("p", { className: "text-[var(--text-secondary)]", children: t("assignments.loading") })
        ] }) })
      }
    );
  if (z)
    return /* @__PURE__ */ e(
      de,
      {
        title: t("assignments.title"),
        subtitle: t("assignments.subtitle"),
        icon: /* @__PURE__ */ e(ie, { className: "h-6 w-6" }),
        breadcrumbs: [
          { label: t("header.title"), href: "/administration" },
          { label: t("assignments.title", "Assignments") }
        ],
        children: /* @__PURE__ */ e("div", { className: "rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] p-4", children: /* @__PURE__ */ r("div", { className: "flex", children: [
          /* @__PURE__ */ e(ce, { className: "h-5 w-5 text-[var(--error-text)]" }),
          /* @__PURE__ */ r("div", { className: "ml-3", children: [
            /* @__PURE__ */ e("h3", { className: "text-sm font-medium text-[var(--error-text)]", children: t("common.error") }),
            /* @__PURE__ */ e("div", { className: "mt-2 text-sm text-[var(--error-text)] opacity-80", children: /* @__PURE__ */ e("p", { children: z }) })
          ] })
        ] }) })
      }
    );
  const Te = /* @__PURE__ */ r(
    "button",
    {
      type: "button",
      onClick: () => k(!0),
      className: "inline-flex items-center px-4 py-2 border border-[var(--border-color)] text-sm font-medium rounded-[var(--radius-button)] text-[var(--text-secondary)] bg-[var(--bg-card)] hover:bg-[var(--bg-hover)] transition-colors",
      children: [
        /* @__PURE__ */ e(Be, { className: "h-4 w-4 mr-2" }),
        t("assignments.createFromTemplate")
      ]
    }
  );
  return /* @__PURE__ */ r(
    de,
    {
      title: t("assignments.title"),
      subtitle: t("assignments.subtitle"),
      icon: /* @__PURE__ */ e(ie, { className: "h-6 w-6" }),
      breadcrumbs: [
        { label: t("header.title"), href: "/administration" },
        { label: t("assignments.title", "Assignments") }
      ],
      actions: Te,
      children: [
        a && /* @__PURE__ */ e("div", { className: "rounded-[var(--radius-card)] bg-[var(--error-bg)] p-3 border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center", children: [
          /* @__PURE__ */ e(ce, { className: "h-4 w-4 text-[var(--error-text)]" }),
          /* @__PURE__ */ e("p", { className: "ml-2 text-sm text-[var(--error-text)]", children: a }),
          /* @__PURE__ */ e(
            "button",
            {
              type: "button",
              onClick: p,
              className: "ml-auto text-sm text-[var(--error-text)] hover:opacity-80 font-medium",
              children: t("common.dismiss")
            }
          )
        ] }) }),
        (Y || u) && /* @__PURE__ */ e("div", { className: "rounded-[var(--radius-card)] bg-[var(--warning-bg)] p-3 border border-[var(--warning-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center", children: [
          u ? /* @__PURE__ */ e(he, { className: "h-4 w-4 text-[var(--warning-dot)] animate-spin" }) : /* @__PURE__ */ e(Ke, { className: "h-4 w-4 text-[var(--warning-dot)]" }),
          /* @__PURE__ */ e("p", { className: "ml-2 text-sm text-[var(--warning-text)]", children: t(u ? "assignments.saving" : "assignments.autoSaveActive") }),
          !u && /* @__PURE__ */ e(
            "button",
            {
              type: "button",
              onClick: i,
              className: "ml-auto text-sm text-[var(--warning-text)] hover:opacity-80 font-medium",
              children: t("assignments.discardChanges")
            }
          )
        ] }) }),
        /* @__PURE__ */ e(
          nt,
          {
            filters: V,
            roles: I,
            categories: le,
            applications: ne,
            modules: oe,
            hasChanges: Y,
            onFilterChange: Re,
            onReset: Fe
          }
        ),
        /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 py-2", children: [
          /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-4", children: [
            /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-3", children: [
              /* @__PURE__ */ r("span", { className: "px-2.5 py-1 text-xs font-semibold rounded-full bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]", children: [
                S.length,
                " ",
                t("assignments.roles")
              ] }),
              /* @__PURE__ */ r("span", { className: "px-2.5 py-1 text-xs font-semibold rounded-full bg-[var(--bg-tertiary)] text-[var(--text-secondary)]", children: [
                J,
                "/",
                te,
                " ",
                t("assignments.modules")
              ] }),
              /* @__PURE__ */ r("span", { className: "px-2.5 py-1 text-xs font-semibold rounded-full bg-[var(--success-bg)] text-[var(--success-text)] border border-[var(--success-border)]", children: [
                Q,
                " ",
                t("assignments.permissionsAssigned")
              ] })
            ] }),
            /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-sm text-[var(--text-secondary)] border-l border-[var(--border-color)] pl-4", children: [
              /* @__PURE__ */ r("span", { children: [
                t("assignments.rolesPerPage"),
                ":"
              ] }),
              /* @__PURE__ */ e(
                "select",
                {
                  value: A,
                  onChange: (n) => Se(Number(n.target.value)),
                  className: "px-2 py-1 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",
                  children: lt.map((n) => /* @__PURE__ */ e("option", { value: n, children: n }, n))
                }
              ),
              /* @__PURE__ */ r("span", { className: "text-[var(--text-muted)]", children: [
                h * A + 1,
                "-",
                Math.min((h + 1) * A, S.length),
                " / ",
                S.length
              ] }),
              re > 1 && /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
                /* @__PURE__ */ e(
                  "button",
                  {
                    onClick: () => N((n) => Math.max(0, n - 1)),
                    disabled: h === 0,
                    className: "p-1 rounded border border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",
                    children: /* @__PURE__ */ e(fe, { className: "h-3.5 w-3.5" })
                  }
                ),
                /* @__PURE__ */ r("span", { className: "text-xs min-w-[50px] text-center", children: [
                  h + 1,
                  " / ",
                  re
                ] }),
                /* @__PURE__ */ e(
                  "button",
                  {
                    onClick: () => N((n) => Math.min(re - 1, n + 1)),
                    disabled: h >= re - 1,
                    className: "p-1 rounded border border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",
                    children: /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5" })
                  }
                )
              ] })
            ] })
          ] }),
          /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
            /* @__PURE__ */ r(
              "button",
              {
                onClick: () => j("none"),
                className: `inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full border transition-colors cursor-pointer ${d.has("none") ? "bg-[var(--error-bg)] border-[var(--error-border)] text-[var(--error-text)]" : "bg-[var(--error-bg)]/30 border-[var(--error-border)]/30 text-[var(--error-text)] hover:bg-[var(--error-bg)]/50 hover:border-[var(--error-border)]"}`,
                children: [
                  /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5" }),
                  t("assignments.none")
                ]
              }
            ),
            /* @__PURE__ */ r(
              "button",
              {
                onClick: () => j("read-only"),
                className: `inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full border transition-colors cursor-pointer ${d.has("read-only") ? "bg-[var(--info-bg)] border-[var(--info-border)] text-[var(--info-text)]" : "bg-[var(--info-bg)]/30 border-[var(--info-border)]/30 text-[var(--info-text)] hover:bg-[var(--info-bg)]/50 hover:border-[var(--info-border)]"}`,
                children: [
                  /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5" }),
                  t("assignments.readOnly")
                ]
              }
            ),
            /* @__PURE__ */ r(
              "button",
              {
                onClick: () => j("some"),
                className: `inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full border transition-colors cursor-pointer ${d.has("some") ? "bg-[var(--warning-bg)] border-[var(--warning-border)] text-[var(--warning-text)]" : "bg-[var(--warning-bg)]/30 border-[var(--warning-border)]/30 text-[var(--warning-text)] hover:bg-[var(--warning-bg)]/50 hover:border-[var(--warning-border)]"}`,
                children: [
                  /* @__PURE__ */ e(ye, { className: "h-3.5 w-3.5" }),
                  t("assignments.partial")
                ]
              }
            ),
            /* @__PURE__ */ r(
              "button",
              {
                onClick: () => j("all"),
                className: `inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-full border transition-colors cursor-pointer ${d.has("all") ? "bg-[var(--success-bg)] border-[var(--success-border)] text-[var(--success-text)]" : "bg-[var(--success-bg)]/30 border-[var(--success-border)]/30 text-[var(--success-text)] hover:bg-[var(--success-bg)]/50 hover:border-[var(--success-border)]"}`,
                children: [
                  /* @__PURE__ */ e(ue, { className: "h-3.5 w-3.5" }),
                  t("assignments.complete")
                ]
              }
            ),
            d.size > 0 && /* @__PURE__ */ e(
              "button",
              {
                onClick: () => E(/* @__PURE__ */ new Set()),
                className: "text-xs text-[var(--color-accent-500)] hover:text-[var(--color-accent-600)] underline ml-2",
                children: t("assignments.clearFilters")
              }
            )
          ] })
        ] }),
        /* @__PURE__ */ r("div", { className: "bg-[var(--bg-card)] border border-[var(--item-color-border)] rounded-[var(--radius-card)] overflow-hidden", children: [
          /* @__PURE__ */ r(
            "button",
            {
              type: "button",
              onClick: () => D(!$),
              className: "w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",
              children: [
                /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
                  /* @__PURE__ */ e(ze, { className: "h-4 w-4 text-[var(--color-accent-500)]" }),
                  /* @__PURE__ */ e("span", { children: t("assignments.guide.title") })
                ] }),
                $ ? /* @__PURE__ */ e(Ge, { className: "h-4 w-4 text-[var(--text-muted)]" }) : /* @__PURE__ */ e(ae, { className: "h-4 w-4 text-[var(--text-muted)]" })
              ]
            }
          ),
          $ && /* @__PURE__ */ e("div", { className: "px-4 pb-4 border-t border-[var(--item-color-border)]", children: /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4 pt-3", children: [
            /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ e("h4", { className: "text-xs font-semibold text-[var(--text-primary)] uppercase tracking-wider mb-2", children: t("assignments.guide.colorLegendTitle") }),
              /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
                /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs", children: [
                  /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-[var(--error-bg)]/30 border border-[var(--error-border)]/30 text-[var(--error-text)]", children: /* @__PURE__ */ e(Ne, { className: "h-3 w-3" }) }),
                  /* @__PURE__ */ e("span", { className: "text-[var(--text-secondary)]", children: t("assignments.guide.noneDesc") })
                ] }),
                /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs", children: [
                  /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-[var(--info-bg)]/30 border border-[var(--info-border)]/30 text-[var(--info-text)]", children: /* @__PURE__ */ e(pe, { className: "h-3 w-3" }) }),
                  /* @__PURE__ */ e("span", { className: "text-[var(--text-secondary)]", children: t("assignments.guide.readOnlyDesc") })
                ] }),
                /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs", children: [
                  /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-[var(--warning-bg)]/30 border border-[var(--warning-border)]/30 text-[var(--warning-text)]", children: /* @__PURE__ */ e(ye, { className: "h-3 w-3" }) }),
                  /* @__PURE__ */ e("span", { className: "text-[var(--text-secondary)]", children: t("assignments.guide.partialDesc") })
                ] }),
                /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs", children: [
                  /* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-[var(--success-bg)]/30 border border-[var(--success-border)]/30 text-[var(--success-text)]", children: /* @__PURE__ */ e(ue, { className: "h-3 w-3" }) }),
                  /* @__PURE__ */ e("span", { className: "text-[var(--text-secondary)]", children: t("assignments.guide.completeDesc") })
                ] })
              ] })
            ] }),
            /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ e("h4", { className: "text-xs font-semibold text-[var(--text-primary)] uppercase tracking-wider mb-2", children: t("assignments.guide.howToUseTitle") }),
              /* @__PURE__ */ r("ul", { className: "space-y-1.5 text-xs text-[var(--text-secondary)]", children: [
                /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
                  /* @__PURE__ */ e("span", { className: "text-[var(--color-accent-500)] mt-0.5", children: "•" }),
                  t("assignments.guide.clickCell")
                ] }),
                /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
                  /* @__PURE__ */ e(Ce, { className: "h-3 w-3 flex-shrink-0 mt-0.5 text-[var(--warning-dot)]" }),
                  t("assignments.guide.systemRoles")
                ] }),
                /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
                  /* @__PURE__ */ e("span", { className: "text-[var(--color-accent-500)] mt-0.5", children: "•" }),
                  t("assignments.guide.inheritance")
                ] }),
                /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
                  /* @__PURE__ */ e("span", { className: "text-[var(--color-accent-500)] mt-0.5", children: "•" }),
                  t("assignments.guide.autoSave")
                ] }),
                /* @__PURE__ */ r("li", { className: "flex items-start gap-2", children: [
                  /* @__PURE__ */ e("span", { className: "text-[var(--color-accent-500)] mt-0.5", children: "•" }),
                  t("assignments.guide.filterButtons")
                ] })
              ] })
            ] })
          ] }) })
        ] }),
        /* @__PURE__ */ e("div", { className: "bg-[var(--bg-card)] shadow-[var(--shadow-md)] rounded-[var(--radius-card)] border border-[var(--item-color-border)]", children: /* @__PURE__ */ e(
          at,
          {
            roles: S,
            resources: f,
            assignments: H,
            canEditSystemRoles: X,
            onTogglePermission: ee,
            getPermissionInheritance: w,
            rolesPerPage: A,
            rolePageIndex: h,
            modulesPerPage: b,
            modulePageIndex: l - 1,
            collapsedApps: y,
            onToggleApp: U,
            statusFilters: d
          }
        ) }),
        /* @__PURE__ */ e("div", { className: "py-3 px-4 bg-[var(--bg-card)] rounded-[var(--radius-card)] border border-[var(--item-color-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3 text-sm text-[var(--text-secondary)]", children: [
          /* @__PURE__ */ r("span", { children: [
            t("assignments.itemsPerPage"),
            ":"
          ] }),
          /* @__PURE__ */ e(
            "select",
            {
              value: b,
              onChange: (n) => ke(Number(n.target.value)),
              className: "px-2 py-1 text-sm bg-[var(--bg-secondary)] border border-[var(--border-color)] rounded text-[var(--text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]",
              children: ot.map((n) => /* @__PURE__ */ e("option", { value: n, children: n }, n))
            }
          ),
          /* @__PURE__ */ r("span", { className: "text-[var(--text-muted)]", children: [
            (l - 1) * b + 1,
            "-",
            Math.min(l * b, J),
            " / ",
            J
          ] }),
          Z > 1 && /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
            /* @__PURE__ */ e(
              "button",
              {
                onClick: () => x((n) => Math.max(1, n - 1)),
                disabled: l === 1,
                className: "p-1.5 rounded border border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",
                children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" })
              }
            ),
            /* @__PURE__ */ r("span", { className: "text-sm min-w-[60px] text-center", children: [
              l,
              " / ",
              Z
            ] }),
            /* @__PURE__ */ e(
              "button",
              {
                onClick: () => x((n) => Math.min(Z, n + 1)),
                disabled: l >= Z,
                className: "p-1.5 rounded border border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-hover)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",
                children: /* @__PURE__ */ e(se, { className: "h-4 w-4" })
              }
            )
          ] })
        ] }) }),
        L && /* @__PURE__ */ e("div", { className: "fixed inset-0 z-50 overflow-y-auto", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:p-0", children: [
          /* @__PURE__ */ e("button", { type: "button", className: "fixed inset-0 bg-black/50 transition-opacity", onClick: () => k(!1), "aria-label": "Close modal" }),
          /* @__PURE__ */ r("div", { className: "inline-block align-bottom bg-[var(--bg-card)] rounded-[var(--radius-modal)] px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-2xl sm:w-full sm:p-6 border border-[var(--border-color)]", children: [
            /* @__PURE__ */ r("div", { className: "mb-4", children: [
              /* @__PURE__ */ e("h3", { className: "text-lg font-medium text-[var(--text-primary)]", children: t("assignments.createFromTemplate") }),
              /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-[var(--text-secondary)]", children: t("assignments.templateDescription") })
            ] }),
            O && /* @__PURE__ */ e("div", { className: "mb-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)] p-3", children: /* @__PURE__ */ r("div", { className: "flex", children: [
              /* @__PURE__ */ e(ce, { className: "h-5 w-5 text-[var(--error-text)]" }),
              /* @__PURE__ */ e("div", { className: "ml-3", children: /* @__PURE__ */ e("p", { className: "text-sm text-[var(--error-text)]", children: O }) })
            ] }) }),
            /* @__PURE__ */ e("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: Object.entries(we).map(([n, m]) => {
              const c = m.icon;
              return /* @__PURE__ */ e(
                "button",
                {
                  onClick: () => Pe(n),
                  className: "relative p-4 rounded-[var(--radius-card)] border-2 text-left transition-all hover:shadow-lg hover:scale-105 border-[var(--border-color)] hover:border-[var(--color-accent-500)]",
                  children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
                    /* @__PURE__ */ e(c, { className: "h-6 w-6 text-[var(--color-accent-500)]" }),
                    /* @__PURE__ */ r("div", { className: "flex-1", children: [
                      /* @__PURE__ */ e("h4", { className: "text-sm font-medium text-[var(--text-primary)]", children: t(m.nameKey) }),
                      /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-[var(--text-secondary)]", children: t(m.descriptionKey) })
                    ] })
                  ] })
                },
                n
              );
            }) }),
            /* @__PURE__ */ e("div", { className: "mt-5 sm:mt-6", children: /* @__PURE__ */ e(
              "button",
              {
                type: "button",
                onClick: () => {
                  k(!1), F(null);
                },
                className: "w-full inline-flex justify-center rounded-[var(--radius-button)] border border-[var(--border-color)] shadow-sm px-4 py-2 bg-[var(--bg-secondary)] text-base font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors",
                children: t("common.cancel")
              }
            ) })
          ] })
        ] }) })
      ]
    }
  );
}
export {
  xt as AssignmentsPage
};
//# sourceMappingURL=AssignmentsPage-DDWyTg2N.js.map
