import { jsx as t, jsxs as r, Fragment as de } from "react/jsx-runtime";
import { useState as l, useCallback as M, useEffect as z, useRef as me } from "react";
import { useTranslation as _ } from "react-i18next";
import { k as pe, B, G as te, h as Ce, i as re, D as Re } from "./index-Dh9kUeDn.js";
import { Loader2 as E, Cloud as X, RefreshCw as $, Play as Ee, AlertTriangle as G, AlertCircle as he, CheckCircle as I, XCircle as se, Database as ke, Calendar as ve, Link2 as Ae, Building2 as Y, Users as P, Clock as ge, X as ee, Search as De, Filter as be, LayoutGrid as Ie, List as Ge, Shield as L, Plus as ue, ChevronUp as Te, ChevronDown as Fe, GitBranch as H, Mail as Pe, ExternalLink as ae, Settings as Me, Check as Ue, Copy as Le, Key as $e, EyeOff as je, Eye as Ke, TestTube as Oe, Save as xe, Layers as He, GitMerge as ze } from "lucide-react";
import { e as w, C as _e, R as Be } from "./ResolutionModal-Dgh6LGI2.js";
import { useNavigate as ye, Link as Ve } from "react-router-dom";
function We({
  resourceType: e,
  icon: h,
  status: N,
  lastFullSyncAt: x,
  lastDeltaSyncAt: v,
  totalItemsSynced: S,
  pendingConflicts: y,
  lastError: g,
  syncing: f,
  canSync: s,
  onSync: d,
  formatDate: u,
  t: n
}) {
  const m = (() => {
    switch (N) {
      case "Success":
        return {
          icon: I,
          color: "text-[var(--success-text)]",
          bg: "bg-[var(--success-bg)]",
          label: n("common:success")
        };
      case "Failed":
        return {
          icon: se,
          color: "text-[var(--error-text)]",
          bg: "bg-[var(--error-bg)]",
          label: n("common:failed")
        };
      case "Running":
        return {
          icon: E,
          color: "text-[var(--color-accent-500)]",
          bg: "bg-[var(--color-accent-100)]",
          label: n("common:running"),
          animate: !0
        };
      default:
        return {
          icon: ge,
          color: "text-[var(--text-tertiary)]",
          bg: "bg-[var(--bg-tertiary)]",
          label: n("common:pending")
        };
    }
  })(), c = m.icon;
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)] overflow-hidden shadow-sm hover:shadow-md transition-shadow", children: [
    /* @__PURE__ */ t("div", { className: "px-4 py-3 bg-gradient-to-r from-[var(--color-accent-500)]/10 to-[var(--color-accent-600)]/5 border-b border-[var(--border-color)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-lg bg-[var(--color-accent-500)]/20", children: /* @__PURE__ */ t(h, { className: "w-5 h-5 text-[var(--color-accent-600)]" }) }),
        /* @__PURE__ */ t("h3", { className: "font-semibold text-[var(--text-primary)]", children: n(`entra:resourceTypes.${e.toLowerCase()}`) })
      ] }),
      /* @__PURE__ */ r("div", { className: `inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${m.bg} ${m.color}`, children: [
        /* @__PURE__ */ t(c, { className: `w-3.5 h-3.5 ${m.animate ? "animate-spin" : ""}` }),
        m.label
      ] })
    ] }) }),
    /* @__PURE__ */ r("div", { className: "flex-1 flex flex-col p-4", children: [
      /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-3 mb-4", children: [
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t(ke, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-xl font-bold text-[var(--text-primary)]", children: S.toLocaleString() }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.itemsSynced") })
        ] }),
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t(ve, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", title: u(x), children: x ? new Date(x).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) : "-" }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.lastFullSync") })
        ] }),
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t($, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", title: u(v), children: v ? new Date(v).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) : "-" }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.lastDeltaSync") })
        ] })
      ] }),
      y > 0 && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-3 mb-4 rounded-lg bg-[var(--warning-bg)] border border-[var(--warning-border)]", children: [
        /* @__PURE__ */ t(he, { className: "w-4 h-4 text-[var(--warning-text)] flex-shrink-0" }),
        /* @__PURE__ */ r("span", { className: "text-sm text-[var(--warning-text)] font-medium", children: [
          y,
          " ",
          n("entra:dashboard.pendingConflicts")
        ] })
      ] }),
      g && /* @__PURE__ */ t("div", { className: "p-3 mb-4 rounded-lg bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ t("p", { className: "text-xs text-[var(--error-text)] line-clamp-2", children: g }) }),
      /* @__PURE__ */ t(
        te,
        {
          content: s ? void 0 : n("entra:dashboard.noSyncPermission"),
          position: "top",
          variant: "error",
          disabled: s,
          children: /* @__PURE__ */ r(
            "button",
            {
              onClick: d,
              disabled: f || !s,
              className: "mt-auto w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
              children: [
                f ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t($, { className: "w-4 h-4" }),
                n("entra:dashboard.syncNow")
              ]
            }
          )
        }
      )
    ] })
  ] });
}
function lt() {
  const { t: e } = _(["entra", "common"]), { hasPermission: h } = pe(), [N, x] = l(!0), [v, S] = l(!1), [y, g] = l([]), [f, s] = l(null), [d, u] = l(null), [n, p] = l(null), m = h("administration.entra.execute"), c = M(async () => {
    try {
      s(null);
      const o = await w.dashboard.getSyncStatus();
      g(Array.isArray(o) ? o : []);
    } catch (o) {
      console.error("Failed to load Entra dashboard data:", o), g([]);
      const b = o;
      b.response?.status === 401 ? s(e("common:errors.sessionExpired")) : b.response?.status === 403 ? s(e("common:errors.noPermission")) : s(e("entra:dashboard.loadError"));
    } finally {
      x(!1), S(!1);
    }
  }, [e]);
  z(() => {
    c();
  }, [c]);
  const C = () => {
    S(!0), c();
  }, A = async (o) => {
    u(o), p(null);
    try {
      let b;
      switch (o) {
        case "users":
          b = await w.sync.syncUsers();
          break;
        case "groups":
          b = await w.sync.syncGroups();
          break;
        case "memberships":
          b = await w.sync.syncMemberships();
          break;
        default:
          b = await w.sync.syncAll();
      }
      p(b), await c();
    } catch (b) {
      console.error("Sync failed:", b);
      const F = b;
      F.response?.status === 403 ? s(e("entra:dashboard.syncPermissionDenied")) : F.response?.status === 401 ? s(e("common:errors.sessionExpired")) : s(e("entra:dashboard.syncError"));
    } finally {
      u(null);
    }
  }, T = async () => {
    if (confirm(e("entra:dashboard.forceFullSyncConfirm"))) {
      u("force");
      try {
        await w.sync.forceFullSync(), await c();
      } catch (o) {
        console.error("Force full sync failed:", o);
        const b = o;
        b.response?.status === 403 ? s(e("entra:dashboard.syncPermissionDenied")) : b.response?.status === 401 ? s(e("common:errors.sessionExpired")) : s(e("entra:dashboard.syncError"));
      } finally {
        u(null);
      }
    }
  }, D = (o) => o ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(o)) : e("common:never"), U = (o) => {
    switch (o) {
      case "Users":
        return P;
      case "Groups":
        return Y;
      case "Memberships":
        return Ae;
      default:
        return X;
    }
  };
  if (N)
    return /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) });
  const k = y.reduce((o, b) => o + b.pendingConflicts, 0);
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(
      B,
      {
        items: [
          { label: e("header.title"), href: "/administration" },
          { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
          { label: e("entra.dashboard", "Dashboard") }
        ]
      }
    ),
    /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--color-accent-500)]/10", children: /* @__PURE__ */ t(X, { className: "w-6 h-6 text-[var(--color-accent-500)]" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: e("entra:dashboard.title") }),
          /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:dashboard.subtitle") })
        ] })
      ] }),
      /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ r(
          "button",
          {
            onClick: C,
            disabled: v,
            className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] disabled:opacity-50 transition-colors",
            children: [
              /* @__PURE__ */ t($, { className: `w-4 h-4 ${v ? "animate-spin" : ""}` }),
              e("common:refresh")
            ]
          }
        ),
        /* @__PURE__ */ t(
          te,
          {
            content: m ? void 0 : e("entra:dashboard.noSyncPermission"),
            position: "bottom",
            variant: "error",
            disabled: m,
            children: /* @__PURE__ */ r(
              "button",
              {
                onClick: () => A("all"),
                disabled: d !== null || !m,
                className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
                children: [
                  d === "all" ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(Ee, { className: "w-4 h-4" }),
                  e("entra:dashboard.syncAll")
                ]
              }
            )
          }
        )
      ] })
    ] }),
    f && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
      /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
      /* @__PURE__ */ t("span", { children: f })
    ] }) }),
    k > 0 && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--warning-text)]", children: [
      /* @__PURE__ */ t(he, { className: "w-5 h-5" }),
      /* @__PURE__ */ t("span", { children: e("entra:dashboard.conflictsWarning", { count: k }) })
    ] }) }),
    n && /* @__PURE__ */ r("div", { className: `p-4 rounded-[var(--radius-card)] border ${n.success ? "bg-[var(--success-bg)] border-[var(--success-border)]" : "bg-[var(--error-bg)] border-[var(--error-border)]"}`, children: [
      /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
        /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
          n.success ? /* @__PURE__ */ t(I, { className: "w-5 h-5 text-[var(--success-text)]" }) : /* @__PURE__ */ t(se, { className: "w-5 h-5 text-[var(--error-text)]" }),
          /* @__PURE__ */ t("span", { className: n.success ? "text-[var(--success-text)]" : "text-[var(--error-text)]", children: n.success ? e("entra:dashboard.syncSuccess") : e("entra:dashboard.syncFailed") })
        ] }),
        /* @__PURE__ */ t("div", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:dashboard.syncStats", {
          created: n.created,
          updated: n.updated,
          deleted: n.deleted
        }) })
      ] }),
      n.errorMessage && /* @__PURE__ */ t("p", { className: "mt-2 text-sm text-[var(--error-text)]", children: n.errorMessage })
    ] }),
    /* @__PURE__ */ t("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-6", children: y.map((o) => /* @__PURE__ */ t(
      We,
      {
        resourceType: o.resourceType,
        icon: U(o.resourceType),
        status: o.status,
        lastFullSyncAt: o.lastFullSyncAt,
        lastDeltaSyncAt: o.lastDeltaSyncAt,
        totalItemsSynced: o.totalItemsSynced,
        pendingConflicts: o.pendingConflicts,
        lastError: o.lastError,
        syncing: d === o.resourceType.toLowerCase(),
        canSync: m,
        onSync: () => A(o.resourceType.toLowerCase()),
        formatDate: D,
        t: e
      },
      o.resourceType
    )) }),
    /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { children: [
        /* @__PURE__ */ t("h3", { className: "font-semibold text-[var(--text-primary)]", children: e("entra:dashboard.forceFullSync") }),
        /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:dashboard.forceFullSyncDescription") })
      ] }),
      /* @__PURE__ */ t(
        te,
        {
          content: m ? void 0 : e("entra:dashboard.noSyncPermission"),
          position: "left",
          variant: "error",
          disabled: m,
          children: /* @__PURE__ */ r(
            "button",
            {
              onClick: T,
              disabled: d !== null || !m,
              className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
              children: [
                d === "force" ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(G, { className: "w-4 h-4" }),
                e("entra:dashboard.forceFullSync")
              ]
            }
          )
        }
      )
    ] }) })
  ] });
}
const Qe = (e) => e.parentGroupName ? /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs", children: [
  /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
  e.parentGroupName
] }) : e.childGroupCount > 0 ? /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs text-[var(--text-tertiary)]", children: [
  e.childGroupCount,
  " child groups"
] }) : /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)]", children: "-" });
function ct() {
  const { t: e } = _(["entra", "admin", "common"]), { hasPermission: h } = pe(), { currentTenant: N, isGlobalView: x } = Ce(), v = ye(), [S, y] = l(!0), [g, f] = l([]), [s, d] = l([]), [u, n] = l(null), [p, m] = l(""), [c, C] = l(null), [A, T] = l(!1), [D, U] = l(null), [k, o] = l({}), [b, F] = l(null), [V, ne] = l("cards"), [j, fe] = l("all"), [ie, le] = l(!1), W = h("administration.entra.assign"), J = M(async () => {
    try {
      n(null);
      const [a, i] = await Promise.all([
        w.groups.getAll(),
        re.roles.getAssignable()
      ]);
      f(Array.isArray(a) ? a : []), d(Array.isArray(i) ? i : []);
    } catch (a) {
      console.error("Failed to load Entra groups:", a), f([]), d([]);
      const i = a;
      i.response?.status === 401 ? n(e("common:errors.sessionExpired")) : i.response?.status === 403 ? n(e("common:errors.noPermission")) : i.response?.data?.code === "TENANT_REQUIRED" ? n(e("entra:groups.tenantRequired")) : n(e("entra:groups.loadError"));
    } finally {
      y(!1);
    }
  }, [e, N?.id, x]);
  z(() => {
    J();
  }, [J]);
  const Ne = async (a) => {
    if (k[a]) {
      U(D === a ? null : a);
      return;
    }
    F(a);
    try {
      const i = await w.groups.getMembers(a);
      o((R) => ({ ...R, [a]: i })), U(a);
    } catch (i) {
      console.error("Failed to load members:", i), n(e("entra:groups.loadMembersError"));
    } finally {
      F(null);
    }
  }, ce = M(async () => {
    const [a, i] = await Promise.all([
      w.groups.getAll(),
      re.roles.getAssignable()
    ]), R = Array.isArray(a) ? a : [];
    return f(R), d(Array.isArray(i) ? i : []), R;
  }, [N?.id]), we = async (a, i = !0) => {
    if (c) {
      le(!0);
      try {
        await w.groups.assignRole(c.id, { roleId: a, isInheritable: i });
        const O = (await ce()).find((Z) => Z.id === c.id);
        O && C(O);
      } catch (R) {
        console.error("Failed to assign role:", R), n(e("entra:groups.assignError"));
      } finally {
        le(!1);
      }
    }
  }, Se = async (a, i) => {
    if (confirm(e("entra:groups.removeRoleConfirm")))
      try {
        if (await w.groups.removeRole(a, i), await ce(), c?.id === a) {
          const O = (await w.groups.getAll()).find((Z) => Z.id === a);
          O && C(O);
        }
      } catch (R) {
        console.error("Failed to remove role:", R), n(e("entra:groups.removeError"));
      }
  }, K = g.filter((a) => {
    const i = a.displayName.toLowerCase().includes(p.toLowerCase()) || a.description?.toLowerCase().includes(p.toLowerCase()), R = j === "all" || j === "security" && a.isSecurityGroup || j === "distribution" && !a.isSecurityGroup;
    return i && R;
  }), oe = (a) => a ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(a)) : "-";
  return S ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(
      B,
      {
        items: [
          { label: e("header.title"), href: "/administration" },
          { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
          { label: e("entra.groups", "Groups") }
        ]
      }
    ),
    /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-blue-500/10", children: /* @__PURE__ */ t(X, { className: "w-6 h-6 text-blue-500" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: e("entra:groups.title") }),
          /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:groups.subtitle", { count: g.length }) })
        ] })
      ] }),
      /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ r(
        "button",
        {
          onClick: J,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",
          children: [
            /* @__PURE__ */ t($, { className: "w-4 h-4" }),
            e("common:refresh")
          ]
        }
      ) })
    ] }),
    /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-blue-500/10 border border-blue-500/20", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
      /* @__PURE__ */ t(X, { className: "w-5 h-5 text-blue-500 flex-shrink-0 mt-0.5" }),
      /* @__PURE__ */ r("div", { children: [
        /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-primary)]", children: e("entra:groups.syncedInfo") }),
        /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-secondary)] mt-1", children: e("entra:groups.syncedInfoDescription") })
      ] })
    ] }) }),
    u && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
      /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
      /* @__PURE__ */ t("span", { children: u }),
      /* @__PURE__ */ t(
        "button",
        {
          onClick: () => n(null),
          className: "ml-auto p-1 hover:bg-[var(--error-text)]/10 rounded",
          children: /* @__PURE__ */ t(ee, { className: "w-4 h-4" })
        }
      )
    ] }) }),
    /* @__PURE__ */ r("div", { className: "flex flex-col sm:flex-row gap-4", children: [
      /* @__PURE__ */ r("div", { className: "relative flex-1", children: [
        /* @__PURE__ */ t(De, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]" }),
        /* @__PURE__ */ t(
          "input",
          {
            type: "text",
            placeholder: e("entra:groups.searchPlaceholder"),
            value: p,
            onChange: (a) => m(a.target.value),
            className: "w-full pl-10 pr-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"
          }
        )
      ] }),
      /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ t(be, { className: "w-4 h-4 text-[var(--text-tertiary)]" }),
        /* @__PURE__ */ r(
          "select",
          {
            value: j,
            onChange: (a) => fe(a.target.value),
            className: "px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",
            children: [
              /* @__PURE__ */ t("option", { value: "all", children: e("admin:groups.allTypes") }),
              /* @__PURE__ */ t("option", { value: "security", children: e("admin:groups.securityGroup") }),
              /* @__PURE__ */ t("option", { value: "distribution", children: e("admin:groups.distributionGroup") })
            ]
          }
        )
      ] }),
      /* @__PURE__ */ r("div", { className: "flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]", children: [
        /* @__PURE__ */ t(
          "button",
          {
            onClick: () => ne("cards"),
            className: `p-2 rounded-[var(--radius-button)] transition-colors ${V === "cards" ? "bg-[var(--color-accent-500)] text-white" : "text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,
            title: e("admin:groups.cardView"),
            children: /* @__PURE__ */ t(Ie, { className: "w-4 h-4" })
          }
        ),
        /* @__PURE__ */ t(
          "button",
          {
            onClick: () => ne("table"),
            className: `p-2 rounded-[var(--radius-button)] transition-colors ${V === "table" ? "bg-[var(--color-accent-500)] text-white" : "text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,
            title: e("admin:groups.tableView"),
            children: /* @__PURE__ */ t(Ge, { className: "w-4 h-4" })
          }
        )
      ] })
    ] }),
    K.length === 0 && /* @__PURE__ */ t("div", { className: "text-center py-12 text-[var(--text-secondary)]", children: e(p || j !== "all" ? "admin:groups.noResults" : "entra:groups.noGroups") }),
    K.length > 0 && V === "table" && /* Table View */
    /* @__PURE__ */ t("div", { className: "rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden", children: /* @__PURE__ */ r("table", { className: "w-full", children: [
      /* @__PURE__ */ t("thead", { className: "bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("tr", { children: [
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.groupName") }),
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("common:type") }),
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.members") }),
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("entra:groups.hierarchy") }),
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.assignedRoles") }),
        /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("entra:groups.lastSynced") }),
        W && !x && /* @__PURE__ */ t("th", { className: "px-4 py-3 text-right text-sm font-medium text-[var(--text-secondary)]", children: e("common:actionsColumn") })
      ] }) }),
      /* @__PURE__ */ t("tbody", { className: "divide-y divide-[var(--border-color)]", children: K.map((a) => /* @__PURE__ */ r(
        "tr",
        {
          className: "hover:bg-[var(--bg-hover)] cursor-pointer",
          onClick: () => v(`/administration/users/groups/${a.id}`),
          children: [
            /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
              /* @__PURE__ */ t("div", { className: `w-8 h-8 rounded-full flex items-center justify-center ${a.isSecurityGroup ? "bg-blue-500/10 text-blue-500" : "bg-purple-500/10 text-purple-500"}`, children: a.isSecurityGroup ? /* @__PURE__ */ t(L, { className: "w-4 h-4" }) : /* @__PURE__ */ t(Y, { className: "w-4 h-4" }) }),
              /* @__PURE__ */ r("div", { children: [
                /* @__PURE__ */ t("span", { className: "font-medium text-[var(--text-primary)]", children: a.displayName }),
                a.description && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] truncate max-w-xs", children: a.description })
              ] })
            ] }) }),
            /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ t("span", { className: `px-2 py-1 text-xs rounded-[var(--radius-badge)] ${a.isSecurityGroup ? "bg-blue-500/10 text-blue-500" : "bg-purple-500/10 text-purple-500"}`, children: a.isSecurityGroup ? e("admin:groups.securityGroup") : e("admin:groups.distributionGroup") }) }),
            /* @__PURE__ */ t("td", { className: "px-4 py-3 text-sm text-[var(--text-secondary)]", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
              /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
              a.memberCount
            ] }) }),
            /* @__PURE__ */ t("td", { className: "px-4 py-3 text-sm text-[var(--text-secondary)]", children: Qe(a) }),
            /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1", children: [
              a.assignedRoles.slice(0, 2).map((i) => /* @__PURE__ */ t(
                "span",
                {
                  className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--color-accent-500)]/10 text-[var(--color-accent-500)]",
                  children: i.roleName
                },
                i.roleId
              )),
              a.assignedRoles.length > 2 && /* @__PURE__ */ r("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]", children: [
                "+",
                a.assignedRoles.length - 2
              ] }),
              a.inheritedRoles.length > 0 && /* @__PURE__ */ r("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-green-500/10 text-green-600", title: e("entra:groups.inheritedRoles"), children: [
                "+",
                a.inheritedRoles.length,
                " ",
                e("entra:groups.inherited")
              ] })
            ] }) }),
            /* @__PURE__ */ t("td", { className: "px-4 py-3 text-xs text-[var(--text-tertiary)]", children: oe(a.lastSyncedAt) }),
            W && !x && /* @__PURE__ */ t("td", { className: "px-4 py-3 text-right", onClick: (i) => i.stopPropagation(), children: /* @__PURE__ */ t(
              "button",
              {
                onClick: () => {
                  C(a), T(!0);
                },
                className: "p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--color-accent-500)] hover:bg-[var(--bg-hover)] transition-colors",
                title: e("admin:groups.assignRole"),
                children: /* @__PURE__ */ t(ue, { className: "w-4 h-4" })
              }
            ) })
          ]
        },
        a.id
      )) })
    ] }) }),
    K.length > 0 && V !== "table" && /* Cards View */
    /* @__PURE__ */ t("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-4", children: K.map((a) => /* @__PURE__ */ r(
      "button",
      {
        type: "button",
        className: "rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-secondary)] overflow-hidden cursor-pointer hover:border-[var(--color-accent-500)] transition-colors text-left",
        onClick: () => v(`/administration/users/groups/${a.id}`),
        children: [
          /* @__PURE__ */ r("div", { className: "p-4", children: [
            /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
              /* @__PURE__ */ r("div", { className: "flex items-start gap-3 min-w-0", children: [
                /* @__PURE__ */ t("div", { className: `p-2.5 rounded-[var(--radius-button)] flex-shrink-0 ${a.isSecurityGroup ? "bg-blue-500/10 text-blue-500" : "bg-purple-500/10 text-purple-500"}`, children: a.isSecurityGroup ? /* @__PURE__ */ t(L, { className: "w-5 h-5" }) : /* @__PURE__ */ t(Y, { className: "w-5 h-5" }) }),
                /* @__PURE__ */ r("div", { className: "min-w-0", children: [
                  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 flex-wrap", children: [
                    /* @__PURE__ */ t("span", { className: "font-semibold text-[var(--text-primary)] truncate", children: a.displayName }),
                    /* @__PURE__ */ t("span", { className: `px-2 py-0.5 text-xs rounded-[var(--radius-badge)] ${a.isSecurityGroup ? "bg-blue-500/10 text-blue-500 border border-blue-500/20" : "bg-purple-500/10 text-purple-500 border border-purple-500/20"}`, children: a.isSecurityGroup ? e("admin:groups.securityGroup") : e("admin:groups.distributionGroup") }),
                    !a.isActive && /* @__PURE__ */ t("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]", children: e("common:inactive") })
                  ] }),
                  a.description && /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)] mt-1 line-clamp-2", children: a.description }),
                  /* @__PURE__ */ r("div", { className: "flex items-center gap-4 mt-2 text-sm text-[var(--text-tertiary)] flex-wrap", children: [
                    /* @__PURE__ */ r(
                      "button",
                      {
                        onClick: (i) => {
                          i.stopPropagation(), Ne(a.id);
                        },
                        className: "flex items-center gap-1 hover:text-[var(--color-accent-500)] transition-colors",
                        children: [
                          /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
                          e("admin:groups.memberCount", { count: a.memberCount }),
                          b === a.id && /* @__PURE__ */ t(E, { className: "w-3 h-3 animate-spin ml-1" }),
                          b !== a.id && D === a.id && /* @__PURE__ */ t(Te, { className: "w-3 h-3 ml-1" }),
                          b !== a.id && D !== a.id && /* @__PURE__ */ t(Fe, { className: "w-3 h-3 ml-1" })
                        ]
                      }
                    ),
                    a.childGroupCount > 0 && /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs", children: [
                      /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                      a.childGroupCount,
                      " ",
                      e("entra:groups.childGroups")
                    ] })
                  ] }),
                  a.parentGroupName && /* @__PURE__ */ r("p", { className: "text-xs text-[var(--text-tertiary)] mt-1 flex items-center gap-1", children: [
                    /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                    e("entra:groups.parentGroup"),
                    ": ",
                    a.parentGroupName
                  ] }),
                  /* @__PURE__ */ r("p", { className: "text-xs text-[var(--text-tertiary)] mt-1", children: [
                    e("entra:groups.lastSynced"),
                    ": ",
                    oe(a.lastSyncedAt)
                  ] })
                ] })
              ] }),
              W && !x && /* @__PURE__ */ r(
                "button",
                {
                  onClick: (i) => {
                    i.stopPropagation(), C(a), T(!0);
                  },
                  className: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors flex-shrink-0",
                  children: [
                    /* @__PURE__ */ t(ue, { className: "w-4 h-4" }),
                    e("admin:groups.assignRole")
                  ]
                }
              )
            ] }),
            (a.assignedRoles.length > 0 || a.inheritedRoles.length > 0) && /* @__PURE__ */ r("div", { className: "mt-4 pt-4 border-t border-[var(--border-color)]", children: [
              a.assignedRoles.length > 0 && /* @__PURE__ */ r(de, { children: [
                /* @__PURE__ */ t("h4", { className: "text-sm font-medium text-[var(--text-primary)] mb-2", children: e("admin:groups.assignedRoles") }),
                /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2 mb-3", children: a.assignedRoles.map((i) => /* @__PURE__ */ r(
                  "div",
                  {
                    className: "inline-flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-badge)] bg-[var(--bg-primary)] border border-[var(--border-color)] group",
                    children: [
                      /* @__PURE__ */ t(L, { className: "w-4 h-4 text-[var(--color-accent-500)]" }),
                      /* @__PURE__ */ t("span", { className: "text-sm text-[var(--text-primary)]", children: i.roleName }),
                      i.isInheritable && /* @__PURE__ */ t("span", { className: "text-xs text-green-600", title: e("entra:groups.inheritableRole"), children: "↓" }),
                      W && /* @__PURE__ */ t(
                        "button",
                        {
                          onClick: (R) => {
                            R.stopPropagation(), Se(a.id, i.roleId);
                          },
                          className: "ml-1 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-[var(--error-bg)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] transition-all",
                          title: e("common:remove"),
                          children: /* @__PURE__ */ t(ee, { className: "w-3 h-3" })
                        }
                      )
                    ]
                  },
                  i.roleId
                )) })
              ] }),
              a.inheritedRoles.length > 0 && /* @__PURE__ */ r(de, { children: [
                /* @__PURE__ */ r("h4", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-2 flex items-center gap-1", children: [
                  /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                  e("entra:groups.inheritedRoles")
                ] }),
                /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: a.inheritedRoles.map((i) => /* @__PURE__ */ r(
                  "div",
                  {
                    className: "inline-flex items-center gap-2 px-2 py-1 rounded-[var(--radius-badge)] bg-green-500/5 border border-green-500/20",
                    title: `${e("entra:groups.inheritedFrom")} ${i.sourceGroupName}`,
                    children: [
                      /* @__PURE__ */ t(L, { className: "w-3 h-3 text-green-600" }),
                      /* @__PURE__ */ t("span", { className: "text-xs text-green-700", children: i.roleName }),
                      /* @__PURE__ */ r("span", { className: "text-xs text-green-600/60", children: [
                        "← ",
                        i.sourceGroupName
                      ] })
                    ]
                  },
                  `${i.roleId}-${i.sourceGroupId}`
                )) })
              ] })
            ] })
          ] }),
          D === a.id && k[a.id] && /* @__PURE__ */ t("div", { className: "border-t border-[var(--border-color)] bg-[var(--bg-primary)]", onClick: (i) => i.stopPropagation(), onKeyDown: (i) => i.stopPropagation(), role: "presentation", children: /* @__PURE__ */ r("div", { className: "p-4", children: [
            /* @__PURE__ */ r("h4", { className: "text-sm font-medium text-[var(--text-primary)] mb-3 flex items-center gap-2", children: [
              /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
              e("admin:groups.members"),
              " (",
              k[a.id].length,
              ")"
            ] }),
            k[a.id].length === 0 ? /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-tertiary)]", children: e("admin:groups.noMembers") }) : /* @__PURE__ */ t("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-64 overflow-y-auto", children: k[a.id].slice(0, 10).map((i) => /* @__PURE__ */ r(
              Ve,
              {
                to: `/administration/users/${i.userId}`,
                className: "flex items-center gap-3 p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",
                children: [
                  /* @__PURE__ */ t("div", { className: "w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium bg-[var(--color-accent-500)]/10 text-[var(--color-accent-500)]", children: i.fullName.charAt(0).toUpperCase() }),
                  /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
                    /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", children: i.fullName }),
                    /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] truncate", children: i.email })
                  ] }),
                  !i.isDirect && i.sourceGroupName && /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)] flex items-center gap-1", title: e("entra:groups.memberFromChildGroup"), children: /* @__PURE__ */ t(H, { className: "w-3 h-3" }) })
                ]
              },
              i.userId
            )) }),
            k[a.id].length > 10 && /* @__PURE__ */ t("p", { className: "mt-3 text-center text-sm text-[var(--text-tertiary)]", children: e("admin:groups.showingMembers", {
              shown: 10,
              total: k[a.id].length
            }) })
          ] }) })
        ]
      },
      a.id
    )) }),
    A && c && /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ r("div", { className: "w-full max-w-md rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-xl", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center justify-between p-4 border-b border-[var(--border-color)]", children: [
        /* @__PURE__ */ t("h2", { className: "text-lg font-semibold text-[var(--text-primary)]", children: e("admin:groups.assignRoleTitle") }),
        /* @__PURE__ */ t(
          "button",
          {
            onClick: () => {
              T(!1), C(null);
            },
            className: "p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)]",
            children: /* @__PURE__ */ t(ee, { className: "w-5 h-5" })
          }
        )
      ] }),
      /* @__PURE__ */ r("div", { className: "p-4", children: [
        /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)] mb-4", children: e("admin:groups.assignRoleDescription", { group: c.displayName }) }),
        /* @__PURE__ */ r("div", { className: "space-y-2 max-h-64 overflow-y-auto", children: [
          s.filter((a) => !c.assignedRoles.some((i) => i.roleId === a.id)).map((a) => /* @__PURE__ */ r(
            "button",
            {
              onClick: () => we(a.id),
              disabled: ie,
              className: "w-full flex items-center gap-3 p-3 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)] transition-colors text-left disabled:opacity-50",
              children: [
                /* @__PURE__ */ t(L, { className: "w-5 h-5 text-[var(--color-accent-500)]" }),
                /* @__PURE__ */ r("div", { className: "flex-1", children: [
                  /* @__PURE__ */ t("p", { className: "font-medium text-[var(--text-primary)]", children: a.name }),
                  a.description && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: a.description })
                ] }),
                ie && /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin text-[var(--color-accent-500)]" })
              ]
            },
            a.id
          )),
          s.filter((a) => !c.assignedRoles.some((i) => i.roleId === a.id)).length === 0 && /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-tertiary)] text-center py-4", children: e("admin:groups.allRolesAssigned") })
        ] })
      ] })
    ] }) })
  ] });
}
function ot() {
  const { t: e } = _(["entra", "common"]), h = ye(), [N, x] = l(!0), [v, S] = l([]), [y, g] = l(null), f = M(async () => {
    try {
      x(!0), g(null);
      const n = await re.users.getAll({ pageSize: 1e3, entraOnly: !0 });
      S(n?.items ?? []);
    } catch (n) {
      console.error("Failed to load users:", n);
      const p = n;
      p.response?.status === 401 ? g(e("common:errors.sessionExpired")) : p.response?.status === 403 ? g(e("common:errors.noPermission")) : g(e("entra:users.loadError"));
    } finally {
      x(!1);
    }
  }, [e]);
  z(() => {
    f();
  }, [f]);
  const s = (n) => n ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(n)) : e("common:never"), d = [
    {
      key: "fullName",
      label: e("entra:users.columns.user"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "w-10 h-10 rounded-full bg-[var(--color-primary-100)] dark:bg-[var(--color-primary-900)] flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ t("span", { className: "text-sm font-medium text-[var(--color-primary-600)]", children: n.fullName?.charAt(0).toUpperCase() || "?" }) }),
        /* @__PURE__ */ t("span", { className: "font-medium text-[var(--text-primary)]", children: n.fullName })
      ] })
    },
    {
      key: "email",
      label: e("entra:users.columns.email"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-1 text-sm text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ t(Pe, { className: "w-4 h-4" }),
        n.email
      ] })
    },
    {
      key: "isActive",
      label: e("entra:users.columns.status"),
      sortable: !0,
      render: (n) => n.isActive ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400", children: [
        /* @__PURE__ */ t(I, { className: "w-3 h-3" }),
        e("common:active")
      ] }) : /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400", children: [
        /* @__PURE__ */ t(se, { className: "w-3 h-3" }),
        e("common:inactive")
      ] })
    },
    {
      key: "lastEntraSyncAt",
      label: e("entra:users.columns.lastSync"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-1 text-sm text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ t(ve, { className: "w-4 h-4" }),
        s(n.lastEntraSyncAt)
      ] })
    },
    {
      key: "actions",
      label: e("entra:users.columns.actions"),
      align: "right",
      render: (n) => /* @__PURE__ */ r(
        "button",
        {
          onClick: (p) => {
            p.stopPropagation(), h(`/administration/users/${n.id}`);
          },
          className: "inline-flex items-center gap-1 text-sm text-[var(--color-primary-600)] hover:underline",
          children: [
            e("common:viewDetails"),
            /* @__PURE__ */ t(ae, { className: "w-4 h-4" })
          ]
        }
      )
    }
  ], u = (n, p) => {
    const m = p.toLowerCase();
    return n.fullName?.toLowerCase().includes(m) || n.email?.toLowerCase().includes(m) || !1;
  };
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(
      B,
      {
        items: [
          { label: e("header.title"), href: "/administration" },
          { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
          { label: e("entra.users", "Users") }
        ]
      }
    ),
    /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-lg bg-[var(--color-primary-100)] dark:bg-[var(--color-primary-900)]", children: /* @__PURE__ */ t(P, { className: "w-6 h-6 text-[var(--color-primary-600)]" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: e("entra:users.title") }),
          /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:users.subtitle", { count: v.length }) })
        ] })
      ] }),
      /* @__PURE__ */ r(
        "button",
        {
          onClick: f,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg border border-[var(--border-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]",
          children: [
            /* @__PURE__ */ t($, { className: "w-4 h-4" }),
            e("common:refresh")
          ]
        }
      )
    ] }),
    y && /* @__PURE__ */ t("div", { className: "p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-red-700 dark:text-red-400", children: [
      /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
      /* @__PURE__ */ t("span", { children: y })
    ] }) }),
    /* @__PURE__ */ t(
      Re,
      {
        data: v,
        columns: d,
        loading: N,
        searchable: !0,
        searchPlaceholder: e("entra:users.searchPlaceholder"),
        searchFilter: u,
        pagination: { pageSize: 20, showSizeSelector: !0 },
        onRowClick: (n) => h(`/administration/users/${n.id}`),
        getRowKey: (n) => n.id,
        emptyMessage: e("entra:users.noUsers"),
        emptyIcon: /* @__PURE__ */ t(P, { className: "w-12 h-12 mx-auto text-[var(--text-secondary)] opacity-50" }),
        defaultSortKey: "fullName",
        striped: !0
      }
    )
  ] });
}
function dt() {
  const { t: e } = _(["entra", "common"]), [h, N] = l(!0), [x, v] = l([]), [S, y] = l(null), [g, f] = l(null), [s, d] = l(!1), u = me(null), n = me(!1), p = M(async () => {
    if (!n.current) {
      u.current && u.current.abort(), u.current = new AbortController(), n.current = !0;
      try {
        y(null);
        const c = await w.conflicts.getAll();
        v(Array.isArray(c) ? c : []);
      } catch (c) {
        if (c instanceof Error && c.name === "AbortError")
          return;
        console.error("Failed to load conflicts:", c instanceof Error ? c.message : "Unknown error"), v([]);
        const C = c;
        C.response?.status === 401 ? y(e("common:errors.sessionExpired")) : C.response?.status === 403 ? y(e("common:errors.noPermission")) : y(e("entra:conflicts.loadError"));
      } finally {
        n.current = !1, N(!1);
      }
    }
  }, [e]);
  z(() => (p(), () => {
    u.current && u.current.abort();
  }), [p]);
  const m = M(async (c, C) => {
    if (!(!g || s)) {
      d(!0);
      try {
        await w.conflicts.resolve(g.id, {
          resolution: c,
          notes: C || void 0
        }), f(null), await p();
      } catch (A) {
        console.error("Failed to resolve conflict:", A instanceof Error ? A.message : "Unknown error"), y(e("entra:conflicts.resolveError"));
      } finally {
        d(!1);
      }
    }
  }, [g, s, p, e]);
  return h ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(
      B,
      {
        items: [
          { label: e("header.title"), href: "/administration" },
          { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
          { label: e("entra.conflicts", "Conflicts") }
        ]
      }
    ),
    /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--color-accent-500)]/10", children: /* @__PURE__ */ t(G, { className: "w-6 h-6 text-[var(--color-accent-600)]" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: e("entra:conflicts.title") }),
          /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:conflicts.subtitle", { count: x.length }) })
        ] })
      ] }),
      /* @__PURE__ */ r(
        "button",
        {
          onClick: p,
          disabled: h,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",
          children: [
            /* @__PURE__ */ t($, { className: `w-4 h-4 ${h ? "animate-spin" : ""}` }),
            e("common:refresh")
          ]
        }
      )
    ] }),
    S && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
        /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
        /* @__PURE__ */ t("span", { children: S })
      ] }),
      /* @__PURE__ */ t(
        "button",
        {
          onClick: () => y(null),
          className: "text-[var(--error-text)] hover:opacity-70",
          children: "×"
        }
      )
    ] }) }),
    x.length === 0 ? /* @__PURE__ */ r("div", { className: "text-center py-16 px-6 rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)]", children: [
      /* @__PURE__ */ t("div", { className: "mx-auto w-16 h-16 rounded-full bg-[var(--success-bg)] flex items-center justify-center mb-4", children: /* @__PURE__ */ t(I, { className: "w-8 h-8 text-[var(--success-text)]" }) }),
      /* @__PURE__ */ t("h2", { className: "text-xl font-semibold text-[var(--text-primary)] mb-2", children: e("entra:conflicts.noConflicts") }),
      /* @__PURE__ */ t("p", { className: "text-[var(--text-secondary)] max-w-md mx-auto", children: e("entra:conflicts.noConflictsDescription") })
    ] }) : (
      /* Conflicts Grid */
      /* @__PURE__ */ t("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: x.map((c) => /* @__PURE__ */ t(
        _e,
        {
          conflict: c,
          onResolve: f
        },
        c.id
      )) })
    ),
    g && /* @__PURE__ */ t(
      Be,
      {
        conflict: g,
        onClose: () => f(null),
        onResolve: m,
        resolving: s
      }
    )
  ] });
}
const qe = [
  { id: "member", labelKey: "userTypes.member", descriptionKey: "userTypes.memberDescription", supported: !0 },
  { id: "guest", labelKey: "userTypes.guest", descriptionKey: "userTypes.guestDescription", supported: !0 },
  { id: "shared", labelKey: "userTypes.shared", descriptionKey: "userTypes.sharedDescription", supported: !1 },
  { id: "room", labelKey: "userTypes.room", descriptionKey: "userTypes.roomDescription", supported: !1 },
  { id: "equipment", labelKey: "userTypes.equipment", descriptionKey: "userTypes.equipmentDescription", supported: !1 }
], Xe = [
  { code: "User.Read.All", descriptionKey: "userReadAll" },
  { code: "Group.Read.All", descriptionKey: "groupReadAll" },
  { code: "GroupMember.Read.All", descriptionKey: "groupMemberReadAll" }
];
function Q({ icon: e, title: h, description: N, action: x, children: v, className: S = "" }) {
  return /* @__PURE__ */ r("div", { className: `rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)] shadow-sm overflow-hidden ${S}`, children: [
    /* @__PURE__ */ t("div", { className: "px-6 py-4 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)]/30", children: /* @__PURE__ */ t(e, { className: "w-5 h-5 text-[var(--color-accent-500)]" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h2", { className: "text-base font-semibold text-[var(--text-primary)]", children: h }),
          N && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: N })
        ] })
      ] }),
      x
    ] }) }),
    /* @__PURE__ */ t("div", { className: "p-6", children: v })
  ] });
}
function q({ checked: e, onChange: h, label: N, description: x }) {
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between py-3", children: [
    /* @__PURE__ */ r("div", { className: "flex-1 min-w-0 pr-4", children: [
      /* @__PURE__ */ t("label", { className: "text-sm font-medium text-[var(--text-primary)]", children: N }),
      x && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: x })
    ] }),
    /* @__PURE__ */ t(
      "button",
      {
        type: "button",
        role: "switch",
        "aria-checked": e,
        onClick: h,
        className: `relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:ring-offset-2 focus:ring-offset-[var(--bg-primary)] ${e ? "bg-[var(--color-accent-600)]" : "bg-[var(--bg-tertiary)]"}`,
        children: /* @__PURE__ */ t(
          "span",
          {
            className: `inline-block h-4 w-4 transform rounded-full bg-[var(--toggle-knob)] shadow-md transition-transform ${e ? "translate-x-6" : "translate-x-1"}`
          }
        )
      }
    )
  ] });
}
const Ye = (e) => e ? /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e) : !0, Je = () => {
  const { t: e } = _(["entra", "common"]), [h, N] = l(!0), [x, v] = l(!1), [S, y] = l(!1), [g, f] = l(null), [s, d] = l(!1), [u, n] = l(null), [p, m] = l(null), [c, C] = l(!1), [A, T] = l(null), [D, U] = l({}), [k, o] = l({
    tenantId: "",
    clientId: "",
    clientSecret: ""
  }), [b, F] = l({
    syncEnabled: !1,
    syncIntervalMinutes: 60,
    useDeltaSync: !0,
    defaultConflictResolution: "ManualReview",
    autoCreateReferences: !0,
    syncOnlyActiveUsers: !0,
    syncUserTypes: "member"
  });
  return {
    t: e,
    loading: h,
    setLoading: N,
    saving: x,
    setSaving: v,
    testing: S,
    setTesting: y,
    testResult: g,
    setTestResult: f,
    showSecret: s,
    setShowSecret: d,
    error: u,
    setError: n,
    success: p,
    setSuccess: m,
    hasExistingSecret: c,
    setHasExistingSecret: C,
    copiedPermission: A,
    setCopiedPermission: T,
    validationErrors: D,
    setValidationErrors: U,
    credentials: k,
    setCredentials: o,
    syncSettings: b,
    setSyncSettings: F
  };
};
function Ze(e, h) {
  return e ? "opacity-50 cursor-not-allowed border-[var(--border-color)] bg-[var(--bg-tertiary)]" : h ? "cursor-pointer border-[var(--color-accent-500)] bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20" : "cursor-pointer border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]";
}
function mt() {
  const e = Je(), h = M(async () => {
    try {
      e.setLoading(!0);
      const s = await w.settings.getConfiguration();
      e.setCredentials({
        tenantId: s.tenantId || "",
        clientId: s.clientId || "",
        clientSecret: ""
      }), e.setHasExistingSecret(s.hasClientSecret), e.setSyncSettings({
        syncEnabled: s.syncEnabled,
        syncIntervalMinutes: s.syncIntervalMinutes,
        useDeltaSync: s.useDeltaSync,
        defaultConflictResolution: s.defaultConflictResolution,
        autoCreateReferences: s.autoCreateReferences,
        syncOnlyActiveUsers: s.syncOnlyActiveUsers ?? !0,
        syncUserTypes: s.syncUserTypes ?? "member"
      });
    } catch (s) {
      console.error("Failed to load configuration:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setLoading(!1);
    }
  }, []);
  z(() => {
    h();
  }, [h]);
  const N = async (s) => {
    try {
      await navigator.clipboard.writeText(s), e.setCopiedPermission(s), setTimeout(() => e.setCopiedPermission(null), 2e3);
    } catch (d) {
      console.error("Failed to copy:", d);
    }
  }, x = (s, d) => {
    const u = Ye(d) ? void 0 : e.t("entra:settings.invalidGuidFormat");
    e.setValidationErrors((n) => ({ ...n, [s]: u }));
  }, v = (s, d) => {
    e.setCredentials((u) => ({ ...u, [s]: d })), (s === "tenantId" || s === "clientId") && x(s, d);
  }, S = !!(e.validationErrors.tenantId || e.validationErrors.clientId), y = async () => {
    e.setTesting(!0), e.setTestResult(null), e.setError(null), e.setSuccess(null);
    try {
      let s;
      if (e.credentials.clientSecret)
        s = await w.settings.testConnection({
          tenantId: e.credentials.tenantId,
          clientId: e.credentials.clientId,
          clientSecret: e.credentials.clientSecret
        });
      else if (e.hasExistingSecret)
        s = await w.settings.testStoredConnection();
      else {
        e.setError(e.t("entra:settings.testFailed")), e.setTesting(!1);
        return;
      }
      e.setTestResult(s), s.success ? e.setSuccess(e.t("entra:settings.testSuccess")) : e.setError(s.errorMessage || e.t("entra:settings.testFailed"));
    } catch (s) {
      console.error("Connection test failed:", s), e.setTestResult({ success: !1, errorMessage: e.t("entra:settings.testFailed"), tenantName: null, userCount: null, groupCount: null }), e.setError(e.t("entra:settings.testFailed"));
    } finally {
      e.setTesting(!1);
    }
  }, g = async () => {
    e.setSaving(!0), e.setError(null), e.setSuccess(null);
    try {
      await w.settings.saveCredentials({
        tenantId: e.credentials.tenantId,
        clientId: e.credentials.clientId,
        clientSecret: e.credentials.clientSecret
      }), e.setSuccess(e.t("entra:settings.credentialsSaved")), e.setHasExistingSecret(!0), e.setCredentials((s) => ({ ...s, clientSecret: "" }));
    } catch (s) {
      console.error("Failed to save credentials:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setSaving(!1);
    }
  }, f = async () => {
    e.setSaving(!0), e.setError(null), e.setSuccess(null);
    try {
      await w.settings.saveSyncSettings({
        syncEnabled: e.syncSettings.syncEnabled,
        syncIntervalMinutes: e.syncSettings.syncIntervalMinutes,
        useDeltaSync: e.syncSettings.useDeltaSync,
        defaultConflictResolution: e.syncSettings.defaultConflictResolution,
        autoCreateReferences: e.syncSettings.autoCreateReferences,
        syncOnlyActiveUsers: e.syncSettings.syncOnlyActiveUsers,
        syncUserTypes: e.syncSettings.syncUserTypes
      }), e.setSuccess(e.t("entra:settings.settingsSaved"));
    } catch (s) {
      console.error("Failed to save settings:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setSaving(!1);
    }
  };
  return e.loading ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center h-64", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
    /* @__PURE__ */ t(
      B,
      {
        items: [
          { label: e.t("header.title"), href: "/administration" },
          { label: e.t("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
          { label: e.t("entra.settings", "Settings") }
        ]
      }
    ),
    /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
      /* @__PURE__ */ t("div", { className: "p-3 rounded-[var(--radius-card)] bg-gradient-to-br from-[var(--color-accent-500)] to-[var(--color-accent-700)] shadow-lg", children: /* @__PURE__ */ t(Me, { className: "w-7 h-7 text-white" }) }),
      /* @__PURE__ */ r("div", { children: [
        /* @__PURE__ */ t("h1", { className: "text-2xl font-bold text-[var(--text-primary)]", children: e.t("entra:settings.title") }),
        /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e.t("entra:settings.subtitle") })
      ] })
    ] }),
    /* @__PURE__ */ t("div", { className: "rounded-[var(--radius-card)] border-2 border-[var(--warning-border)] bg-[var(--warning-bg)] overflow-hidden", children: /* @__PURE__ */ t("div", { className: "px-5 py-4", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-4", children: [
      /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--warning-border)]", children: /* @__PURE__ */ t(L, { className: "w-5 h-5 text-[var(--warning-text)]" }) }),
      /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
        /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-4 mb-2", children: [
          /* @__PURE__ */ t("h2", { className: "font-semibold text-[var(--warning-text)]", children: e.t("entra:settings.permissionsWarningTitle") }),
          /* @__PURE__ */ r(
            "a",
            {
              href: "https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
              target: "_blank",
              rel: "noopener noreferrer",
              className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--warning-border)] text-[var(--warning-text)] hover:opacity-80 transition-opacity",
              children: [
                e.t("entra:settings.configureInAzure"),
                /* @__PURE__ */ t(ae, { className: "w-3.5 h-3.5" })
              ]
            }
          )
        ] }),
        /* @__PURE__ */ t("p", { className: "text-sm text-[var(--warning-text)] opacity-90 mb-4", children: e.t("entra:settings.permissionsWarningDescription") }),
        /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: Xe.map((s) => /* @__PURE__ */ r(
          "button",
          {
            onClick: () => N(s.code),
            className: "group inline-flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--warning-border)] hover:border-[var(--warning-dot)] transition-all hover:shadow-sm",
            title: e.t(`entra:settings.permissions.${s.descriptionKey}`),
            children: [
              /* @__PURE__ */ t("code", { className: "text-sm font-mono font-medium text-[var(--text-primary)]", children: s.code }),
              e.copiedPermission === s.code ? /* @__PURE__ */ t(Ue, { className: "w-4 h-4 text-[var(--success-text)]" }) : /* @__PURE__ */ t(Le, { className: "w-4 h-4 text-[var(--warning-text)] group-hover:opacity-80" })
            ]
          },
          s.code
        )) })
      ] })
    ] }) }) }),
    e.error && /* @__PURE__ */ r("div", { className: "flex items-center gap-3 p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: [
      /* @__PURE__ */ t(G, { className: "w-5 h-5 text-[var(--error-text)] flex-shrink-0" }),
      /* @__PURE__ */ t("span", { className: "text-sm text-[var(--error-text)]", children: e.error })
    ] }),
    e.success && /* @__PURE__ */ r("div", { className: "flex items-center gap-3 p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)]", children: [
      /* @__PURE__ */ t(I, { className: "w-5 h-5 text-[var(--success-text)] flex-shrink-0" }),
      /* @__PURE__ */ t("span", { className: "text-sm text-[var(--success-text)]", children: e.success })
    ] }),
    /* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: [
      /* @__PURE__ */ t(
        Q,
        {
          icon: $e,
          title: e.t("entra:settings.credentials"),
          description: "Azure AD Application",
          action: /* @__PURE__ */ r(
            "a",
            {
              href: "https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
              target: "_blank",
              rel: "noopener noreferrer",
              className: "inline-flex items-center gap-1.5 text-sm text-[var(--color-accent-500)] hover:text-[var(--color-accent-600)] transition-colors",
              children: [
                e.t("entra:settings.azurePortal"),
                /* @__PURE__ */ t(ae, { className: "w-4 h-4" })
              ]
            }
          ),
          children: /* @__PURE__ */ r("div", { className: "space-y-5", children: [
            /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: e.t("entra:settings.tenantId") }),
              /* @__PURE__ */ t(
                "input",
                {
                  type: "text",
                  value: e.credentials.tenantId,
                  onChange: (s) => v("tenantId", s.target.value),
                  placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                  autoComplete: "off",
                  className: `w-full px-3 py-2.5 rounded-[var(--radius-input)] border bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:border-transparent transition-shadow ${e.validationErrors.tenantId ? "border-[var(--error-border)] focus:ring-[var(--error-border)]" : "border-[var(--border-color)] focus:ring-[var(--color-accent-500)]"}`
                }
              ),
              e.validationErrors.tenantId ? /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--error-text)]", children: e.validationErrors.tenantId }) : /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.tenantIdHelp") })
            ] }),
            /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: e.t("entra:settings.clientId") }),
              /* @__PURE__ */ t(
                "input",
                {
                  type: "text",
                  value: e.credentials.clientId,
                  onChange: (s) => v("clientId", s.target.value),
                  placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                  autoComplete: "off",
                  className: `w-full px-3 py-2.5 rounded-[var(--radius-input)] border bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:border-transparent transition-shadow ${e.validationErrors.clientId ? "border-[var(--error-border)] focus:ring-[var(--error-border)]" : "border-[var(--border-color)] focus:ring-[var(--color-accent-500)]"}`
                }
              ),
              e.validationErrors.clientId ? /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--error-text)]", children: e.validationErrors.clientId }) : /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.clientIdHelp") })
            ] }),
            /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ r("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: [
                e.t("entra:settings.clientSecret"),
                e.hasExistingSecret && /* @__PURE__ */ r("span", { className: "ml-2 inline-flex items-center gap-1 text-xs text-[var(--success-text)]", children: [
                  /* @__PURE__ */ t(I, { className: "w-3 h-3" }),
                  e.t("common:configured")
                ] })
              ] }),
              /* @__PURE__ */ r("div", { className: "relative", children: [
                /* @__PURE__ */ t(
                  "input",
                  {
                    type: e.showSecret ? "text" : "password",
                    value: e.credentials.clientSecret,
                    onChange: (s) => v("clientSecret", s.target.value),
                    placeholder: e.hasExistingSecret ? "••••••••••••••••••••••••••••••••••••••••" : "OvA8Q~xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                    autoComplete: "new-password",
                    className: "w-full px-3 py-2.5 pr-10 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-transparent transition-shadow"
                  }
                ),
                /* @__PURE__ */ t(
                  "button",
                  {
                    type: "button",
                    onClick: () => e.setShowSecret(!e.showSecret),
                    className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",
                    children: e.showSecret ? /* @__PURE__ */ t(je, { className: "w-4 h-4" }) : /* @__PURE__ */ t(Ke, { className: "w-4 h-4" })
                  }
                )
              ] }),
              /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.clientSecretHelp") })
            ] }),
            /* @__PURE__ */ r("div", { className: "flex items-center gap-3 pt-2", children: [
              /* @__PURE__ */ r(
                "button",
                {
                  onClick: y,
                  disabled: e.testing || S || !e.credentials.tenantId || !e.credentials.clientId || !e.credentials.clientSecret && !e.hasExistingSecret,
                  className: "inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
                  children: [
                    e.testing && /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }),
                    !e.testing && e.testResult?.success && /* @__PURE__ */ t(I, { className: "w-4 h-4 text-[var(--success-text)]" }),
                    !e.testing && e.testResult && !e.testResult.success && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-[var(--error-text)]" }),
                    !e.testing && !e.testResult && /* @__PURE__ */ t(Oe, { className: "w-4 h-4" }),
                    e.t("entra:settings.testConnection")
                  ]
                }
              ),
              /* @__PURE__ */ r(
                "button",
                {
                  onClick: g,
                  disabled: e.saving || S || !e.credentials.tenantId || !e.credentials.clientId || !e.credentials.clientSecret,
                  className: "inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
                  children: [
                    e.saving ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(xe, { className: "w-4 h-4" }),
                    e.t("common:save")
                  ]
                }
              )
            ] }),
            e.testResult?.success && /* @__PURE__ */ r("div", { className: "mt-4 p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)]", children: [
              /* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-3", children: [
                /* @__PURE__ */ t(I, { className: "w-5 h-5 text-[var(--success-text)]" }),
                /* @__PURE__ */ t("span", { className: "font-medium text-[var(--success-text)]", children: e.t("entra:settings.connectionSuccessful") })
              ] }),
              /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-3", children: [
                e.testResult.tenantName && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                  /* @__PURE__ */ t(Y, { className: "w-4 h-4 text-[var(--success-text)]" }),
                  /* @__PURE__ */ r("div", { className: "min-w-0", children: [
                    /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.tenantName") }),
                    /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", children: e.testResult.tenantName })
                  ] })
                ] }),
                e.testResult.userCount !== null && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                  /* @__PURE__ */ t(P, { className: "w-4 h-4 text-[var(--success-text)]" }),
                  /* @__PURE__ */ r("div", { children: [
                    /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.userCount") }),
                    /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.testResult.userCount })
                  ] })
                ] }),
                e.testResult.groupCount !== null && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                  /* @__PURE__ */ t(He, { className: "w-4 h-4 text-[var(--success-text)]" }),
                  /* @__PURE__ */ r("div", { children: [
                    /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.groupCount") }),
                    /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.testResult.groupCount })
                  ] })
                ] })
              ] })
            ] })
          ] })
        }
      ),
      /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        /* @__PURE__ */ t(
          Q,
          {
            icon: ge,
            title: e.t("entra:settings.syncSettings"),
            description: "Scheduling & Performance",
            children: /* @__PURE__ */ r("div", { className: "divide-y divide-[var(--border-subtle)]", children: [
              /* @__PURE__ */ t(
                q,
                {
                  checked: e.syncSettings.syncEnabled,
                  onChange: () => e.setSyncSettings((s) => ({ ...s, syncEnabled: !s.syncEnabled })),
                  label: e.t("entra:settings.syncEnabled"),
                  description: e.t("entra:settings.syncEnabledHelp")
                }
              ),
              /* @__PURE__ */ r("div", { className: "py-4", children: [
                /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-2", children: e.t("entra:settings.syncInterval") }),
                /* @__PURE__ */ r(
                  "select",
                  {
                    value: e.syncSettings.syncIntervalMinutes,
                    onChange: (s) => e.setSyncSettings((d) => ({ ...d, syncIntervalMinutes: Number(s.target.value) })),
                    className: "w-full px-3 py-2.5 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] transition-shadow",
                    children: [
                      /* @__PURE__ */ r("option", { value: 15, children: [
                        "15 ",
                        e.t("common:minutes")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 30, children: [
                        "30 ",
                        e.t("common:minutes")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 60, children: [
                        "1 ",
                        e.t("common:hour")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 120, children: [
                        "2 ",
                        e.t("common:hours")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 360, children: [
                        "6 ",
                        e.t("common:hours")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 720, children: [
                        "12 ",
                        e.t("common:hours")
                      ] }),
                      /* @__PURE__ */ r("option", { value: 1440, children: [
                        "24 ",
                        e.t("common:hours")
                      ] })
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ t(
                q,
                {
                  checked: e.syncSettings.useDeltaSync,
                  onChange: () => e.setSyncSettings((s) => ({ ...s, useDeltaSync: !s.useDeltaSync })),
                  label: e.t("entra:settings.useDeltaSync"),
                  description: e.t("entra:settings.useDeltaSyncHelp")
                }
              ),
              /* @__PURE__ */ t(
                q,
                {
                  checked: e.syncSettings.autoCreateReferences,
                  onChange: () => e.setSyncSettings((s) => ({ ...s, autoCreateReferences: !s.autoCreateReferences })),
                  label: e.t("entra:settings.autoCreateReferences"),
                  description: e.t("entra:settings.autoCreateReferencesHelp")
                }
              )
            ] })
          }
        ),
        /* @__PURE__ */ t(
          Q,
          {
            icon: ze,
            title: e.t("entra:settings.conflictResolution"),
            description: "Data Priority",
            children: /* @__PURE__ */ r("div", { children: [
              /* @__PURE__ */ r(
                "select",
                {
                  value: e.syncSettings.defaultConflictResolution,
                  onChange: (s) => e.setSyncSettings((d) => ({ ...d, defaultConflictResolution: s.target.value })),
                  className: "w-full px-3 py-2.5 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] transition-shadow",
                  children: [
                    /* @__PURE__ */ t("option", { value: "ManualReview", children: e.t("entra:settings.conflictResolutions.manualReview") }),
                    /* @__PURE__ */ t("option", { value: "EntraWins", children: e.t("entra:settings.conflictResolutions.entraWins") }),
                    /* @__PURE__ */ t("option", { value: "LocalWins", children: e.t("entra:settings.conflictResolutions.localWins") })
                  ]
                }
              ),
              /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.conflictResolutionHelp") })
            ] })
          }
        ),
        /* @__PURE__ */ t(
          Q,
          {
            icon: be,
            title: e.t("entra:settings.userSyncFilters"),
            description: "User Types & Filters",
            children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
              /* @__PURE__ */ t(
                q,
                {
                  checked: e.syncSettings.syncOnlyActiveUsers,
                  onChange: () => e.setSyncSettings((s) => ({ ...s, syncOnlyActiveUsers: !s.syncOnlyActiveUsers })),
                  label: e.t("entra:settings.syncOnlyActiveUsers"),
                  description: e.t("entra:settings.syncOnlyActiveUsersHelp")
                }
              ),
              /* @__PURE__ */ r("div", { className: "pt-2 border-t border-[var(--border-subtle)]", children: [
                /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-2", children: e.t("entra:settings.syncUserTypesLabel") }),
                /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mb-3", children: e.t("entra:settings.syncUserTypesHelp") }),
                /* @__PURE__ */ t("div", { className: "space-y-2", children: qe.map((s) => {
                  const d = e.syncSettings.syncUserTypes.split(",").map((m) => m.trim()).filter(Boolean), u = d.includes(s.id), n = !s.supported, p = () => {
                    if (n) return;
                    let m;
                    u ? m = d.filter((c) => c !== s.id) : m = [...d, s.id], m.length === 0 && (m = ["member"]), e.setSyncSettings((c) => ({ ...c, syncUserTypes: m.join(",") }));
                  };
                  return /* @__PURE__ */ r(
                    "label",
                    {
                      className: `flex items-start gap-3 p-3 rounded-[var(--radius-button)] border transition-all ${Ze(n, u)}`,
                      children: [
                        /* @__PURE__ */ t(
                          "input",
                          {
                            type: "checkbox",
                            checked: u,
                            onChange: p,
                            disabled: n,
                            className: "mt-0.5 w-4 h-4 rounded border-[var(--border-color)] text-[var(--color-accent-600)] focus:ring-[var(--color-accent-500)] disabled:opacity-50"
                          }
                        ),
                        /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
                          /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
                            /* @__PURE__ */ t("span", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.t(`entra:settings.${s.labelKey}`) }),
                            n && /* @__PURE__ */ t("span", { className: "text-xs px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]", children: e.t("common:comingSoon") })
                          ] }),
                          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: e.t(`entra:settings.${s.descriptionKey}`) })
                        ] })
                      ]
                    },
                    s.id
                  );
                }) })
              ] })
            ] })
          }
        ),
        /* @__PURE__ */ t("div", { className: "flex justify-end", children: /* @__PURE__ */ r(
          "button",
          {
            onClick: f,
            disabled: e.saving,
            className: "inline-flex items-center gap-2 px-6 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
            children: [
              e.saving ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(xe, { className: "w-4 h-4" }),
              e.t("common:save")
            ]
          }
        ) })
      ] })
    ] })
  ] });
}
export {
  dt as EntraConflictsPage,
  lt as EntraDashboardPage,
  ct as EntraGroupsPage,
  mt as EntraSettingsPage,
  ot as EntraUsersPage
};
//# sourceMappingURL=index-Dy1EpZIs.js.map
