"use client";
'use strict';

var chunk7AM2SXEF_js = require('./chunk-7AM2SXEF.js');
var chunkMT66VKLS_js = require('./chunk-MT66VKLS.js');
var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
var chunkBHOT22QL_js = require('./chunk-BHOT22QL.js');
var react = require('react');
var outline = require('@heroicons/react/24/outline');
var jsxRuntime = require('react/jsx-runtime');

var ROLE_OPTIONS = [
  { value: "admin", label: "Admin" },
  { value: "manager", label: "Manager" },
  { value: "analyst", label: "Analyst" },
  { value: "viewer", label: "Viewer" }
];
function UsersPageView({ labels, users, onCreateUser, onUpdateRole }) {
  const [createOpen, setCreateOpen] = react.useState(false);
  const [searchTerm, setSearchTerm] = react.useState("");
  const allUsers = users;
  const term = searchTerm.trim().toLowerCase();
  const filteredUsers = term ? allUsers.filter(
    (user) => user.name.toLowerCase().includes(term) || user.email.toLowerCase().includes(term)
  ) : allUsers;
  const isEmpty = allUsers.length === 0;
  const labelsAny = labels;
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.HeroSection,
      {
        icon: /* @__PURE__ */ jsxRuntime.jsx(outline.UserGroupIcon, { className: "h-5 w-5" }),
        label: labels.title,
        title: labels.title,
        subtitle: labels.subtitle,
        gradient: "from-violet-500 to-indigo-600",
        toolbar: /* @__PURE__ */ jsxRuntime.jsx(
          chunkMT66VKLS_js.CreateActionButton,
          {
            mode: "desktop",
            label: labels.create,
            onClick: () => setCreateOpen(true),
            accent: "violet"
          }
        )
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.CreateActionButton,
      {
        mode: "mobile",
        label: labels.create,
        onClick: () => setCreateOpen(true),
        accent: "violet"
      }
    ),
    !isEmpty && /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.SearchBar,
      {
        searchTerm,
        onSearchChange: setSearchTerm,
        placeholder: labelsAny.searchPlaceholder ?? labels.title
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.list }),
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: filteredUsers.map((user) => /* @__PURE__ */ jsxRuntime.jsx(
        chunkMT66VKLS_js.EntityCard,
        {
          accentGradient: "from-violet-500 to-indigo-700",
          icon: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-violet-500/10 text-violet-600 dark:bg-violet-500/20 dark:text-violet-400", children: /* @__PURE__ */ jsxRuntime.jsx(outline.UserGroupIcon, { className: "h-6 w-6" }) }),
          title: user.name,
          subtitle: user.email,
          status: /* @__PURE__ */ jsxRuntime.jsx(
            chunkMT66VKLS_js.StatusBadge,
            {
              status: user.active ? "active" : "inactive",
              label: user.active ? labels.statusActive : labels.statusInactive,
              size: "sm"
            }
          ),
          footer: /* @__PURE__ */ jsxRuntime.jsx(
            "form",
            {
              onSubmit: (event) => {
                event.preventDefault();
                const formData = new FormData(event.currentTarget);
                const role = String(formData.get("role") ?? "viewer");
                onUpdateRole({ email: user.email, role });
              },
              children: /* @__PURE__ */ jsxRuntime.jsxs(chunkMT66VKLS_js.InlineForm, { children: [
                /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormSelect, { name: "role", options: ROLE_OPTIONS, defaultValue: user.role }),
                /* @__PURE__ */ jsxRuntime.jsx(chunkBHOT22QL_js.Button, { type: "submit", outline: true, size: "sm", children: labels.save })
              ] })
            }
          )
        },
        user.email
      )) })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.GlassModal,
      {
        open: createOpen,
        onClose: () => setCreateOpen(false),
        title: labels.create,
        maxWidth: "lg",
        showFormFooter: true,
        cancelLabel: labels.list,
        submitLabel: labels.add,
        onSubmit: (event) => {
          const formData = new FormData(event.currentTarget);
          const name = String(formData.get("name") ?? "").trim();
          const email = String(formData.get("email") ?? "").trim().toLowerCase();
          const role = String(formData.get("role") ?? "viewer");
          if (!name || !email) return;
          onCreateUser({ name, email, role });
          setCreateOpen(false);
        },
        children: /* @__PURE__ */ jsxRuntime.jsxs(chunkMT66VKLS_js.FormGrid, { children: [
          /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormInput, { name: "name", label: labels.name, placeholder: labels.userNamePlaceholder, required: true }),
          /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormInput, { name: "email", label: labels.email, placeholder: labels.userEmailPlaceholder, required: true, type: "email" }),
          /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormSelect, { name: "role", label: labels.role, options: ROLE_OPTIONS })
        ] })
      }
    )
  ] });
}
function RolesPageView({
  labels,
  users,
  onAssignRole,
  roleDefinitions,
  roleOptions
}) {
  const [assignOpen, setAssignOpen] = react.useState(false);
  const [searchTerm, setSearchTerm] = react.useState("");
  const allRoleDefinitions = Object.values(roleDefinitions);
  const allUsers = users;
  const term = searchTerm.trim().toLowerCase();
  const filteredRoleDefinitions = term ? allRoleDefinitions.filter((role) => role.label.toLowerCase().includes(term)) : allRoleDefinitions;
  const filteredUsers = term ? allUsers.filter(
    (user) => user.name.toLowerCase().includes(term) || user.email.toLowerCase().includes(term)
  ) : allUsers;
  const isEmpty = allRoleDefinitions.length === 0 && allUsers.length === 0;
  const labelsAny = labels;
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.HeroSection,
      {
        icon: /* @__PURE__ */ jsxRuntime.jsx(outline.ShieldCheckIcon, { className: "h-5 w-5" }),
        label: labels.title,
        title: labels.title,
        subtitle: labels.subtitle,
        gradient: "from-emerald-500 to-teal-600",
        toolbar: /* @__PURE__ */ jsxRuntime.jsx(
          chunkMT66VKLS_js.CreateActionButton,
          {
            mode: "desktop",
            label: labels.assign,
            onClick: () => setAssignOpen(true),
            accent: "emerald"
          }
        )
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.CreateActionButton,
      {
        mode: "mobile",
        label: labels.assign,
        onClick: () => setAssignOpen(true),
        accent: "emerald"
      }
    ),
    !isEmpty && /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.SearchBar,
      {
        searchTerm,
        onSearchChange: setSearchTerm,
        placeholder: labelsAny.searchPlaceholder ?? labels.title
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.definitions }),
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: filteredRoleDefinitions.map((role) => /* @__PURE__ */ jsxRuntime.jsxs(
        chunkMT66VKLS_js.EntityCard,
        {
          accentGradient: "from-emerald-500 to-teal-700",
          icon: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-600 dark:bg-emerald-500/20 dark:text-emerald-400", children: /* @__PURE__ */ jsxRuntime.jsx(outline.ShieldCheckIcon, { className: "h-6 w-6" }) }),
          title: role.label,
          subtitle: role.id,
          children: [
            /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: role.description }),
            /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs font-medium text-slate-600 dark:text-slate-300", children: labels.permissionsEnabled })
          ]
        },
        role.id
      )) })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.current }),
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: filteredUsers.map((user) => /* @__PURE__ */ jsxRuntime.jsx(
        chunkMT66VKLS_js.EntityCard,
        {
          accentGradient: "from-violet-500 to-indigo-700",
          icon: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-violet-500/10 text-violet-600 dark:bg-violet-500/20 dark:text-violet-400", children: /* @__PURE__ */ jsxRuntime.jsx(outline.ShieldCheckIcon, { className: "h-6 w-6" }) }),
          title: user.name,
          subtitle: user.email,
          status: /* @__PURE__ */ jsxRuntime.jsx(chunkBHOT22QL_js.Badge, { color: "violet", size: "xs", children: user.role })
        },
        user.email
      )) })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsx(
      chunkMT66VKLS_js.GlassModal,
      {
        open: assignOpen,
        onClose: () => setAssignOpen(false),
        title: labels.assign,
        maxWidth: "lg",
        showFormFooter: true,
        cancelLabel: labels.current,
        submitLabel: labels.apply,
        onSubmit: (event) => {
          const formData = new FormData(event.currentTarget);
          const email = String(formData.get("email") ?? "").trim().toLowerCase();
          const role = String(formData.get("role") ?? "viewer");
          if (!email) return;
          onAssignRole({ email, role });
          setAssignOpen(false);
        },
        children: /* @__PURE__ */ jsxRuntime.jsxs(chunkMT66VKLS_js.FormGrid, { children: [
          /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormInput, { name: "email", label: labels.userEmail, placeholder: "user@company.com", required: true }),
          /* @__PURE__ */ jsxRuntime.jsx(chunkMT66VKLS_js.FormSelect, { name: "role", label: labels.role, options: roleOptions })
        ] })
      }
    )
  ] });
}
function WorkflowWorkspace({ graph }) {
  const locale = chunkYXN2K77G_js.useLocale();
  return /* @__PURE__ */ jsxRuntime.jsx(chunk7AM2SXEF_js.Workspace, { initialGraph: graph, locale });
}

exports.RolesPageView = RolesPageView;
exports.UsersPageView = UsersPageView;
exports.WorkflowWorkspace = WorkflowWorkspace;
//# sourceMappingURL=chunk-IVKFXPLO.js.map
//# sourceMappingURL=chunk-IVKFXPLO.js.map