import { jsxs as i, jsx as e } from "react/jsx-runtime";
import { getAllServer as se, getAllServerDetails as de, updateServer as ce, updateServerMappingList as ue, addServer as pe, addServerMappingList as me } from "@/common/services/SyncWithServer";
import { FontAwesomeIcon as f } from "@fortawesome/react-fontawesome";
import { faPlus as V, faServer as Y, faCircleCheck as Q, faMagnifyingGlass as he, faCircleXmark as ve, faPen as H } from "@fortawesome/free-solid-svg-icons";
import { useTheme as ae } from "@mui/material/styles";
import { Paper as X, Typography as u, Button as G, Chip as b, TextField as D, InputAdornment as ge, Divider as K, TableContainer as fe, Table as be, TableHead as Se, TableRow as j, TableCell as m, TableBody as ye, Tooltip as Z, IconButton as xe, Dialog as Ce, DialogTitle as Pe, Box as N, DialogContent as ze, Autocomplete as J, FormHelperText as _, FormControl as Ae, RadioGroup as we, FormControlLabel as ee, Radio as re, DialogActions as Te } from "@mui/material";
import v from "@mui/material/Grid2";
import { Box as z } from "@mui/system";
import { useState as x, useEffect as ne, useMemo as ke, createElement as oe } from "react";
import { showToast as y } from "@/common/toaster/toaster";
import { useDebounceFn as We } from "@/hooks/useDebounceFn";
import U from "@/views/custom-components/CustomTextField";
import { yupResolver as Re } from "@hookform/resolvers/yup";
import S from "prop-types";
import { useForm as Ne, Controller as F } from "react-hook-form";
import * as w from "yup";
import { useTranslateProvider as Fe } from "@/common/languageTranslator/TranslationContext";
function te({
  openAddServer: q,
  openAddServerFunc: k,
  allServerList: C,
  reloadPageFunc: A,
  editServer: g,
  editServerFunc: W,
  serverData: p = {}
}) {
  var R;
  const { translate: c } = Fe(), [I, O] = x(""), L = ["STAGING", "PRODUCTION"], P = ae(), E = (n) => P.palette.mode === "light" ? n : `${n}-dark`, M = w.object().shape({
    name: w.string().required("Name is required"),
    code: w.string().required("Code is required"),
    type: w.string().required("Type is required"),
    url: w.string().required("URL is required").matches(
      /^https?:\/\/(localhost|\d{1,3}(?:\.\d{1,3}){3}|[a-zA-Z0-9.-]+)(:\d+)?(\/.*)?$/,
      "Invalid URL"
    ),
    isActive: w.boolean().required("This field is required.")
  }), l = Ne({
    defaultValues: {
      name: "",
      code: "",
      type: "",
      url: "",
      isActive: null,
      canPullServer: [],
      canPushServer: []
    },
    resolver: Re(M),
    mode: "onChange"
  });
  ne(() => {
    g && l.reset({
      name: p.name,
      code: p.code,
      type: p.type,
      url: p.url,
      isActive: p.isActive,
      canPullServer: p.canPullServers ? p.canPullServers : [],
      canPushServer: p.canPushServers ? p.canPushServers : []
    });
  }, []);
  const T = () => {
    k(!1), W(!1);
  }, $ = We(async (n) => {
    C != null && C.find((s) => s.code === n) ? l.setError("code", {
      type: "manual",
      message: "Code already exists"
    }) : O(`${n} is available`);
  }, 500), B = async (n) => {
    var s, r;
    let o = /* @__PURE__ */ new Map();
    (s = n.canPullServer) == null || s.forEach((a) => {
      let d = {
        canPull: !0,
        canPush: !1
      };
      o.set(a.code, d);
    }), (r = n.canPushServer) == null || r.forEach((a) => {
      if (o.has(a.code))
        o.get(a.code).canPush = !0;
      else {
        let d = {
          canPull: !1,
          canPush: !0
        };
        o.set(a.code, d);
      }
    });
    const t = [];
    if (o.forEach((a, d) => {
      t.push({
        sourceServerCode: n.code,
        destinationServerCode: d,
        canPull: a.canPull,
        canPush: a.canPush
      }), t.push({
        sourceServerCode: d,
        destinationServerCode: n.code,
        canPull: a.canPush,
        canPush: a.canPull
      });
    }), g)
      try {
        if (o.size === 0 && t.push({
          sourceServerCode: n.code,
          destinationServerCode: null,
          canPull: null,
          canPush: null
        }), n.uuid = p.uuid, await ce(n), y({
          type: "success",
          message: "Server updated successfully"
        }), t.length > 0)
          try {
            await ue(t), y({
              type: "success",
              message: "Server mapping updated successfully"
            });
          } catch (a) {
            y({
              type: "error",
              message: "Failed to update server mapping"
            }), console.error("Error updating server mapping:", a);
          }
        A((a) => !a), T();
      } catch (a) {
        y({
          type: "error",
          message: "Failed to update server"
        }), console.error("Error updating server:", a);
      }
    else
      try {
        const a = {
          name: n.name,
          code: n.code,
          type: n.type,
          url: n.url,
          isActive: n.isActive
        };
        if (await pe(a), y({
          type: "success",
          message: "Server added successfully"
        }), t.length > 0)
          try {
            await me(t), y({
              type: "success",
              message: "Server mapping added successfully"
            });
          } catch (d) {
            y({
              type: "error",
              message: "Failed to add server mapping"
            }), console.error("Error adding server mapping:", d);
          }
        A((d) => !d), k(!1);
      } catch (a) {
        y({
          type: "error",
          message: "Failed to add server"
        }), console.error("Error adding server:", a);
      }
  }, h = ({ label: n, required: s, children: r }) => /* @__PURE__ */ i(N, { sx: { display: "flex", flexDirection: "column", gap: 0.75 }, children: [
    /* @__PURE__ */ i(
      u,
      {
        variant: "body2",
        sx: { fontWeight: 600, color: "text.primary" },
        children: [
          n,
          s && /* @__PURE__ */ e(u, { component: "span", sx: { color: "error.main", ml: 0.5 }, children: "*" })
        ]
      }
    ),
    r
  ] });
  return h.propTypes = {
    label: S.string.isRequired,
    required: S.bool,
    children: S.node.isRequired
  }, /* @__PURE__ */ i(
    Ce,
    {
      open: q,
      fullWidth: !0,
      maxWidth: "sm",
      onClose: T,
      className: E("add-server-dialog"),
      PaperProps: {
        sx: {
          borderRadius: 3,
          scrollbarWidth: "none",
          msOverflowStyle: "none",
          "&::-webkit-scrollbar": { display: "none" },
          "& .MuiDialogContent-root": {
            scrollbarWidth: "none",
            msOverflowStyle: "none",
            "&::-webkit-scrollbar": { display: "none" }
          }
        }
      },
      children: [
        /* @__PURE__ */ e(
          Pe,
          {
            sx: {
              px: 3,
              pt: 2.5,
              pb: 2,
              borderBottom: "1px solid",
              borderColor: "divider",
              backgroundColor: "background.paper"
            },
            children: /* @__PURE__ */ i(N, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
              /* @__PURE__ */ e(
                N,
                {
                  sx: {
                    width: 36,
                    height: 36,
                    borderRadius: 2,
                    display: "flex",
                    alignItems: "center",
                    justifyContent: "center",
                    backgroundColor: "primary.main",
                    color: "primary.contrastText",
                    flexShrink: 0
                  },
                  children: /* @__PURE__ */ e(
                    f,
                    {
                      icon: g ? H : V,
                      style: { fontSize: "0.85rem" }
                    }
                  )
                }
              ),
              /* @__PURE__ */ i(N, { children: [
                /* @__PURE__ */ e(u, { variant: "h6", sx: { fontWeight: 700, lineHeight: 1.3 }, children: c(g ? "Update Server" : "Add Server") }),
                /* @__PURE__ */ e(u, { variant: "caption", color: "text.secondary", children: g ? "Modify server configuration and sync permissions." : "Configure a new server connection." })
              ] })
            ] })
          }
        ),
        /* @__PURE__ */ i("form", { noValidate: !0, onSubmit: l.handleSubmit(B), children: [
          /* @__PURE__ */ e(
            ze,
            {
              sx: {
                px: 3,
                py: 3,
                scrollbarWidth: "none",
                "&::-webkit-scrollbar": { display: "none" }
              },
              children: /* @__PURE__ */ i(v, { container: !0, spacing: 2.5, children: [
                /* @__PURE__ */ i(v, { size: 12, children: [
                  /* @__PURE__ */ e(
                    u,
                    {
                      variant: "subtitle2",
                      sx: {
                        fontWeight: 700,
                        color: "text.primary",
                        mb: 0.5,
                        textTransform: "uppercase",
                        fontSize: "0.7rem",
                        letterSpacing: "0.05em"
                      },
                      children: "Server Details"
                    }
                  ),
                  /* @__PURE__ */ e(K, {})
                ] }),
                /* @__PURE__ */ e(v, { size: 6, children: /* @__PURE__ */ e(h, { label: c("Name"), required: !0, children: /* @__PURE__ */ e(
                  U,
                  {
                    control: l.control,
                    name: "name",
                    id: "name",
                    errors: l.formState.errors,
                    placeholder: "Enter server name"
                  }
                ) }) }),
                /* @__PURE__ */ e(v, { size: 6, children: /* @__PURE__ */ e(h, { label: c("Code"), required: !0, children: /* @__PURE__ */ e(
                  U,
                  {
                    control: l.control,
                    name: "code",
                    id: "code",
                    disabled: g,
                    errors: l.formState.errors,
                    placeholder: "Enter server code",
                    successMessage: I,
                    onChange: (n) => $(n.target.value)
                  }
                ) }) }),
                /* @__PURE__ */ e(v, { size: 6, children: /* @__PURE__ */ i(h, { label: c("Type"), required: !0, children: [
                  /* @__PURE__ */ e(
                    F,
                    {
                      name: "type",
                      control: l.control,
                      render: ({ field: { onChange: n, value: s } }) => /* @__PURE__ */ e(
                        J,
                        {
                          size: "small",
                          options: L || [],
                          getOptionLabel: (r) => r,
                          defaultValue: s,
                          onChange: (r, o) => {
                            n(o);
                          },
                          renderInput: (r) => {
                            var o;
                            return /* @__PURE__ */ e(
                              D,
                              {
                                ...r,
                                placeholder: "Select type",
                                variant: "outlined",
                                error: !!((o = l.formState.errors) != null && o.type)
                              }
                            );
                          }
                        }
                      )
                    }
                  ),
                  l.formState.errors.type && /* @__PURE__ */ e(_, { error: !0, children: (R = l.formState.errors.type) == null ? void 0 : R.message })
                ] }) }),
                /* @__PURE__ */ e(v, { size: 6, children: /* @__PURE__ */ e(h, { label: c("URL"), required: !0, children: /* @__PURE__ */ e(
                  U,
                  {
                    control: l.control,
                    name: "url",
                    id: "url",
                    errors: l.formState.errors,
                    placeholder: "https://example.com"
                  }
                ) }) }),
                /* @__PURE__ */ e(v, { size: 12, children: /* @__PURE__ */ e(h, { label: c("Active"), required: !0, children: /* @__PURE__ */ e(
                  F,
                  {
                    name: "isActive",
                    control: l.control,
                    rules: { required: "This field is required." },
                    render: ({
                      field: { onChange: n, value: s },
                      fieldState: { error: r }
                    }) => {
                      var o;
                      return /* @__PURE__ */ i(Ae, { component: "fieldset", error: !!r, children: [
                        /* @__PURE__ */ i(we, { row: !0, value: s, onChange: n, children: [
                          /* @__PURE__ */ e(
                            ee,
                            {
                              value: !0,
                              control: /* @__PURE__ */ e(re, { size: "small" }),
                              label: /* @__PURE__ */ e(u, { variant: "body2", children: "Yes" })
                            }
                          ),
                          /* @__PURE__ */ e(
                            ee,
                            {
                              value: !1,
                              control: /* @__PURE__ */ e(re, { size: "small" }),
                              label: /* @__PURE__ */ e(u, { variant: "body2", children: "No" })
                            }
                          )
                        ] }),
                        r && /* @__PURE__ */ e(_, { children: (o = l.formState.errors.isActive) == null ? void 0 : o.message })
                      ] });
                    }
                  }
                ) }) }),
                /* @__PURE__ */ i(v, { size: 12, sx: { mt: 0.5 }, children: [
                  /* @__PURE__ */ e(
                    u,
                    {
                      variant: "subtitle2",
                      sx: {
                        fontWeight: 700,
                        color: "text.primary",
                        mb: 0.5,
                        textTransform: "uppercase",
                        fontSize: "0.7rem",
                        letterSpacing: "0.05em"
                      },
                      children: "Sync Permissions"
                    }
                  ),
                  /* @__PURE__ */ e(K, {})
                ] }),
                /* @__PURE__ */ e(v, { size: 12, children: /* @__PURE__ */ e(h, { label: c("Can Pull From"), children: /* @__PURE__ */ e(
                  F,
                  {
                    name: "canPullServer",
                    control: l.control,
                    render: ({ field: { onChange: n, value: s } }) => /* @__PURE__ */ e(
                      J,
                      {
                        size: "small",
                        multiple: !0,
                        options: C || [],
                        getOptionLabel: (r) => r.name || "",
                        getOptionKey: (r) => r.code || "",
                        getOptionDisabled: (r) => r.code === l.getValues("code") || l.getValues("canPullServer").some((o) => o.code === r.code),
                        value: s,
                        onChange: (r, o) => {
                          n(o);
                        },
                        renderTags: (r, o) => r.map((t, a) => /* @__PURE__ */ oe(
                          b,
                          {
                            ...o({ index: a }),
                            key: t.code,
                            label: t.name,
                            size: "small",
                            color: "primary",
                            variant: "outlined",
                            sx: { borderRadius: 2, fontWeight: 500 }
                          }
                        )),
                        renderInput: (r) => /* @__PURE__ */ e(
                          D,
                          {
                            ...r,
                            placeholder: (s == null ? void 0 : s.length) > 0 ? "" : "Select servers to pull from...",
                            variant: "outlined"
                          }
                        )
                      }
                    )
                  }
                ) }) }),
                /* @__PURE__ */ e(v, { size: 12, children: /* @__PURE__ */ e(h, { label: c("Can Push To"), children: /* @__PURE__ */ e(
                  F,
                  {
                    name: "canPushServer",
                    control: l.control,
                    render: ({ field: { onChange: n, value: s } }) => /* @__PURE__ */ e(
                      J,
                      {
                        size: "small",
                        multiple: !0,
                        options: C || [],
                        getOptionLabel: (r) => r.name || "",
                        getOptionKey: (r) => r.code || "",
                        getOptionDisabled: (r) => r.code === l.getValues("code") || l.getValues("canPushServer").some((o) => o.code === r.code),
                        value: s,
                        onChange: (r, o) => {
                          n(o);
                        },
                        renderTags: (r, o) => r.map((t, a) => /* @__PURE__ */ oe(
                          b,
                          {
                            ...o({ index: a }),
                            key: t.code,
                            label: t.name,
                            size: "small",
                            color: "primary",
                            variant: "outlined",
                            sx: { borderRadius: 2, fontWeight: 500 }
                          }
                        )),
                        renderInput: (r) => /* @__PURE__ */ e(
                          D,
                          {
                            ...r,
                            placeholder: (s == null ? void 0 : s.length) > 0 ? "" : "Select servers to push to...",
                            variant: "outlined"
                          }
                        )
                      }
                    )
                  }
                ) }) })
              ] })
            }
          ),
          /* @__PURE__ */ i(
            Te,
            {
              sx: {
                px: 3,
                py: 2,
                borderTop: "1px solid",
                borderColor: "divider",
                gap: 1
              },
              children: [
                /* @__PURE__ */ e(
                  G,
                  {
                    onClick: T,
                    size: "small",
                    variant: "outlined",
                    sx: {
                      borderRadius: 2,
                      textTransform: "none",
                      fontWeight: 600,
                      px: 2.5,
                      borderColor: "divider",
                      color: "text.secondary",
                      "&:hover": {
                        backgroundColor: "action.hover",
                        borderColor: "text.disabled"
                      }
                    },
                    children: c("Cancel")
                  }
                ),
                /* @__PURE__ */ e(
                  G,
                  {
                    type: "submit",
                    size: "small",
                    variant: "contained",
                    sx: {
                      borderRadius: 2,
                      textTransform: "none",
                      fontWeight: 600,
                      px: 2.5,
                      boxShadow: "none"
                    },
                    startIcon: /* @__PURE__ */ e(
                      f,
                      {
                        icon: g ? H : V,
                        style: { fontSize: "0.75rem" }
                      }
                    ),
                    children: g ? "Update Server" : "Add Server"
                  }
                )
              ]
            }
          )
        ] })
      ]
    }
  );
}
te.propTypes = {
  openAddServer: S.bool,
  openAddServerFunc: S.func,
  allServerList: S.array,
  reloadPageFunc: S.func,
  editServer: S.bool,
  editServerFunc: S.func,
  serverData: S.object
};
function Ye() {
  const [q, k] = x([]), [C, A] = x(!1), [g, W] = x(!1), [p, R] = x({}), [c, I] = x([]), [O, L] = x(!1), [P, E] = x(""), M = ae();
  ne(() => {
    (async () => (await T(), await $()))();
  }, [O]);
  const l = (r) => M.palette.mode === "light" ? r : `${r}-dark`, T = async () => {
    try {
      const r = (await se()).data;
      r && k(
        r.map((o) => ({ code: o.code, name: o.name }))
      );
    } catch (r) {
      console.error("Error fetching servers:", r);
    }
  }, $ = async () => {
    try {
      const r = (await de()).data;
      r && (r.forEach((o) => {
        let t = o.canPullServers ? JSON.parse(o.canPullServers) : [], a = o.canPushServers ? JSON.parse(o.canPushServers) : [];
        o.canPullServers = JSON.parse(o.canPullServers), o.canPushServers = JSON.parse(o.canPushServers), o.pullServersName = t.length > 0 ? t.map((d) => d.name) : [], o.pushServersName = a.length > 0 ? a.map((d) => d.name) : [];
      }), I(r));
    } catch (r) {
      console.error("Error fetching servers:", r);
    }
  }, B = (r) => {
    W(!0), R(r), A(!0);
  }, h = ke(() => {
    if (!P.trim()) return c;
    const r = P.toLowerCase();
    return c.filter(
      (o) => {
        var t, a, d;
        return ((t = o.name) == null ? void 0 : t.toLowerCase().includes(r)) || ((a = o.code) == null ? void 0 : a.toLowerCase().includes(r)) || ((d = o.url) == null ? void 0 : d.toLowerCase().includes(r));
      }
    );
  }, [c, P]), n = c.filter((r) => r.isActive).length, s = (r) => {
    if (!r) return "-";
    const o = new Date(r), t = String(o.getDate()).padStart(2, "0"), a = [
      "Jan",
      "Feb",
      "Mar",
      "Apr",
      "May",
      "Jun",
      "Jul",
      "Aug",
      "Sep",
      "Oct",
      "Nov",
      "Dec"
    ][o.getMonth()], d = o.getFullYear(), le = String(o.getHours()).padStart(2, "0"), ie = String(o.getMinutes()).padStart(2, "0");
    return `${t} ${a} ${d}, ${le}:${ie}`;
  };
  return /* @__PURE__ */ i(v, { pt: 2, sx: { height: "calc(100vh)", zoom: "0.9" }, children: [
    /* @__PURE__ */ e(z, { sx: { p: 3 }, className: l("server-management-wrapper"), children: /* @__PURE__ */ i(
      X,
      {
        elevation: 0,
        sx: {
          p: { xs: 2.5, md: 3 },
          border: "1px solid",
          borderColor: "divider",
          borderRadius: 3,
          backgroundColor: "background.paper"
        },
        children: [
          /* @__PURE__ */ i(z, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: [
            /* @__PURE__ */ i(
              z,
              {
                sx: {
                  display: "flex",
                  justifyContent: "space-between",
                  alignItems: "flex-start",
                  flexWrap: "wrap",
                  gap: 2
                },
                children: [
                  /* @__PURE__ */ i(z, { sx: { minWidth: { xs: "100%", lg: "40%" } }, children: [
                    /* @__PURE__ */ e(
                      u,
                      {
                        variant: "h5",
                        sx: { fontWeight: 800, color: "text.primary", mb: 0.5 },
                        children: "Server Management"
                      }
                    ),
                    /* @__PURE__ */ e(u, { variant: "body2", color: "text.secondary", children: "Configure and manage server connections, sync permissions, and server details." })
                  ] }),
                  /* @__PURE__ */ e(
                    z,
                    {
                      sx: {
                        display: "flex",
                        alignItems: "center",
                        gap: 1.5,
                        flexWrap: "wrap"
                      },
                      children: /* @__PURE__ */ e(
                        G,
                        {
                          size: "small",
                          variant: "contained",
                          sx: {
                            borderRadius: 2,
                            fontWeight: 600,
                            px: 2,
                            boxShadow: "none",
                            textTransform: "none"
                          },
                          startIcon: /* @__PURE__ */ e(f, { icon: V }),
                          onClick: () => {
                            A(!0);
                          },
                          children: "Add Server"
                        }
                      )
                    }
                  )
                ]
              }
            ),
            /* @__PURE__ */ i(
              z,
              {
                sx: {
                  display: "flex",
                  justifyContent: "space-between",
                  alignItems: "center",
                  flexWrap: "wrap",
                  gap: 2,
                  backgroundColor: "action.hover",
                  p: 1.5,
                  borderRadius: 2.5,
                  border: "1px solid",
                  borderColor: "divider"
                },
                children: [
                  /* @__PURE__ */ i(z, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
                    /* @__PURE__ */ e(
                      b,
                      {
                        icon: /* @__PURE__ */ e(
                          f,
                          {
                            icon: Y,
                            style: { fontSize: "0.7rem" }
                          }
                        ),
                        label: `${c.length} Total`,
                        size: "small",
                        variant: "outlined",
                        sx: {
                          fontWeight: 600,
                          borderRadius: 2,
                          px: 0.5,
                          borderColor: "divider"
                        }
                      }
                    ),
                    /* @__PURE__ */ e(
                      b,
                      {
                        icon: /* @__PURE__ */ e(
                          f,
                          {
                            icon: Q,
                            style: { fontSize: "0.7rem" }
                          }
                        ),
                        label: `${n} Active`,
                        size: "small",
                        color: "success",
                        variant: "filled",
                        sx: { fontWeight: 700, borderRadius: 2, px: 0.5 }
                      }
                    ),
                    c.length - n > 0 && /* @__PURE__ */ e(
                      b,
                      {
                        label: `${c.length - n} Inactive`,
                        size: "small",
                        color: "default",
                        variant: "outlined",
                        sx: {
                          fontWeight: 600,
                          borderRadius: 2,
                          px: 0.5,
                          borderColor: "divider"
                        }
                      }
                    )
                  ] }),
                  /* @__PURE__ */ e(
                    D,
                    {
                      value: P,
                      size: "small",
                      placeholder: "Search servers...",
                      onChange: (r) => E(r.target.value),
                      InputProps: {
                        startAdornment: /* @__PURE__ */ e(ge, { position: "start", children: /* @__PURE__ */ e(
                          f,
                          {
                            icon: he,
                            style: { fontSize: "0.85rem", color: "#999" }
                          }
                        ) }),
                        sx: {
                          backgroundColor: "background.paper",
                          borderRadius: 2,
                          minWidth: 260
                        }
                      }
                    }
                  )
                ]
              }
            )
          ] }),
          /* @__PURE__ */ e(K, { sx: { my: 3 } }),
          /* @__PURE__ */ e(
            fe,
            {
              className: l("server-table"),
              component: X,
              elevation: 0,
              sx: {
                borderRadius: 2.5,
                border: "1px solid",
                borderColor: "divider",
                overflowY: "auto",
                maxHeight: "calc(100vh - 340px)"
              },
              children: /* @__PURE__ */ i(be, { stickyHeader: !0, children: [
                /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ e(j, { children: [
                  "Sr. No.",
                  "Name",
                  "Code",
                  "Type",
                  "URL",
                  "Status",
                  "Can Pull From",
                  "Can Push To",
                  "Modified On",
                  "Actions"
                ].map((r, o) => /* @__PURE__ */ e(
                  m,
                  {
                    align: r === "Actions" ? "center" : "left",
                    sx: {
                      fontWeight: 700,
                      fontSize: "0.78rem",
                      textTransform: "uppercase",
                      letterSpacing: "0.04em",
                      color: "text.secondary",
                      backgroundColor: "background.default",
                      borderBottom: "2px solid",
                      borderColor: "divider",
                      py: 1.5
                    },
                    children: r
                  },
                  o
                )) }) }),
                /* @__PURE__ */ i(ye, { children: [
                  h.map((r, o) => /* @__PURE__ */ i(
                    j,
                    {
                      sx: {
                        transition: "background-color 0.15s ease",
                        "&:hover": { backgroundColor: "action.hover" },
                        "&:last-child td": { borderBottom: 0 }
                      },
                      children: [
                        /* @__PURE__ */ e(
                          m,
                          {
                            sx: { color: "text.secondary", fontWeight: 500 },
                            children: o + 1
                          }
                        ),
                        /* @__PURE__ */ e(m, { sx: { fontWeight: 600 }, children: r.name }),
                        /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(
                          b,
                          {
                            label: r.code,
                            size: "small",
                            variant: "outlined",
                            sx: {
                              fontFamily: "monospace",
                              fontSize: "0.75rem",
                              borderRadius: 1.5,
                              borderColor: "divider"
                            }
                          }
                        ) }),
                        /* @__PURE__ */ e(m, { children: r.type }),
                        /* @__PURE__ */ e(
                          m,
                          {
                            sx: {
                              maxWidth: 200,
                              overflow: "hidden",
                              textOverflow: "ellipsis",
                              whiteSpace: "nowrap"
                            },
                            children: /* @__PURE__ */ e(Z, { title: r.url || "", arrow: !0, placement: "top", children: /* @__PURE__ */ e("span", { children: r.url }) })
                          }
                        ),
                        /* @__PURE__ */ e(m, { children: r.isActive ? /* @__PURE__ */ e(
                          b,
                          {
                            icon: /* @__PURE__ */ e(
                              f,
                              {
                                icon: Q,
                                style: { fontSize: "0.7rem" }
                              }
                            ),
                            label: "Active",
                            size: "small",
                            color: "success",
                            variant: "filled",
                            sx: { fontWeight: 600, borderRadius: 2 }
                          }
                        ) : /* @__PURE__ */ e(
                          b,
                          {
                            icon: /* @__PURE__ */ e(
                              f,
                              {
                                icon: ve,
                                style: { fontSize: "0.7rem" }
                              }
                            ),
                            label: "Inactive",
                            size: "small",
                            color: "default",
                            variant: "outlined",
                            sx: {
                              fontWeight: 600,
                              borderRadius: 2,
                              borderColor: "divider"
                            }
                          }
                        ) }),
                        /* @__PURE__ */ e(m, { children: Array.isArray(r.pullServersName) && r.pullServersName.length > 0 ? r.pullServersName.map((t, a) => /* @__PURE__ */ e(
                          b,
                          {
                            label: t || "-",
                            color: "primary",
                            size: "small",
                            variant: "outlined",
                            sx: {
                              mr: 0.5,
                              mb: 0.5,
                              borderRadius: 2,
                              fontWeight: 500
                            }
                          },
                          a
                        )) : /* @__PURE__ */ e(u, { variant: "caption", color: "text.disabled", children: "—" }) }),
                        /* @__PURE__ */ e(m, { children: Array.isArray(r.pushServersName) && r.pushServersName.length > 0 ? r.pushServersName.map((t, a) => /* @__PURE__ */ e(
                          b,
                          {
                            label: t || "-",
                            color: "primary",
                            size: "small",
                            variant: "outlined",
                            sx: {
                              mr: 0.5,
                              mb: 0.5,
                              borderRadius: 2,
                              fontWeight: 500
                            }
                          },
                          a
                        )) : /* @__PURE__ */ e(u, { variant: "caption", color: "text.disabled", children: "—" }) }),
                        /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(
                          u,
                          {
                            variant: "caption",
                            sx: { color: "text.secondary" },
                            children: s(r.modifiedOn)
                          }
                        ) }),
                        /* @__PURE__ */ e(m, { align: "center", children: /* @__PURE__ */ e(Z, { title: "Edit server", arrow: !0, placement: "top", children: /* @__PURE__ */ e(
                          xe,
                          {
                            size: "small",
                            onClick: () => {
                              B(r);
                            },
                            sx: {
                              color: "primary.main",
                              "&:hover": { backgroundColor: "primary.50" }
                            },
                            children: /* @__PURE__ */ e(
                              f,
                              {
                                icon: H,
                                style: { fontSize: "0.8rem" }
                              }
                            )
                          }
                        ) }) })
                      ]
                    },
                    o
                  )),
                  h.length === 0 && /* @__PURE__ */ e(j, { children: /* @__PURE__ */ i(m, { colSpan: 10, align: "center", sx: { py: 6 }, children: [
                    /* @__PURE__ */ e(
                      f,
                      {
                        icon: Y,
                        style: {
                          fontSize: "2rem",
                          color: "#ccc",
                          marginBottom: 8,
                          display: "block",
                          margin: "0 auto 8px"
                        }
                      }
                    ),
                    /* @__PURE__ */ e(u, { variant: "body2", color: "text.secondary", children: P ? "No servers match your search." : 'No servers found. Click "Add Server" to get started.' })
                  ] }) })
                ] })
              ] })
            }
          )
        ]
      }
    ) }),
    C && /* @__PURE__ */ e(
      te,
      {
        openAddServer: C,
        openAddServerFunc: A,
        allServerList: q,
        reloadPageFunc: L,
        editServer: g,
        editServerFunc: W,
        serverData: p
      }
    )
  ] });
}
export {
  Ye as default
};
//# sourceMappingURL=NewServerManagement-5YcAtF-g-DHV6PFTR.js.map
