import { d as e, l as i } from "./styled-components-c6abe9a3.js";
import { fE as t, k2 as a, fR as o, k3 as n, k4 as l, k5 as r, k6 as s, k7 as d, fv as p, e2 as c, fA as h, k8 as m, k9 as g, dV as f, dW as u, fe as x, ka as b, kb as w, av as y, kc as v, kd as k, ke as I, kf as C, eA as P, kg as S, kh as $, fk as L, fl as R, ki as T, kj as A, kk as B, kl as O, fs as M, km as N, kn as z, ko as E, ed as V, kp as j, kq as F, kr as U, ks as D, kt as G, ku as W, kv as _, jr as H, fL as q, kw as J, kx as X, fm as Y, ky as K, kz as Q, gx as Z, iq as ee, cD as ie, fD as te, fi as ae, fh as oe, ff as ne, fg as le, f7 as re, gw as se, jQ as de, jR as pe, kA as ce, kB as he, kC as me, kD as ge, kE as fe, kF as ue, kG as xe, kH as be, kI as we, d$ as ye, kJ as ve, e8 as ke, kK as Ie, e3 as Ce, kL as Pe, kM as Se, kN as $e, kO as Le, kP as Re, kQ as Te, kR as Ae, kS as Be } from "./index-2be62fff.js";
import { lR as Oe, lA as Me, lS as Ne } from "./ant-design-icons-14ab96af.js";
import { V as ze, D as Ee, W as Ve, G as je, X as Fe, Y as Ue, Z as De, $ as Ge } from "./antd-97b654da.js";
import We, { useState as _e, useEffect as He, useContext as qe, useMemo as Je, useRef as Xe, useCallback as Ye } from "react";
import { a as Ke } from "./crypto-js-8020edb5.js";
import { a as Qe } from "./customerService-c27e6cd5.js";
import "./redux-saga-1b0a458d.js";
import { o as Ze } from "./folderSelector-82f1bcf3.js";
import { f as ei } from "./lodash-226cb5b1.js";
import "./loglevel-5e7e37fc.js";
const ii = (e2) => Ke.SHA256(e2).toString(), ti = async (e2, i2) => {
  try {
    return { success: true, data: (await t.getAvailableGroupsMembers(e2, i2)).data.data };
  } catch (e3) {
    return console.error("Failed to fetch data: ", e3), { success: false, error: e3 };
  }
}, ai = e.header`
  display: flex;
  width: 100%;
  height: ${o};
  background-color: #0066b3;
  /* filter: drop-shadow(0px 1px 0px #ebebeb); */
  padding: ${(e2) => e2.$isEditViewPreview ? "8px 24px 8px 8px" : "8px 24px"};
  justify-content: space-between;

  > div:nth-of-type(1) svg {
    max-width: ${(e2) => e2.$isEditViewPreview && "24px"};
  }
`, oi = e.div`
  display: flex;
  align-items: center;
`, ni = e.div`
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
`, li = e.div`
  display: flex;
  align-items: center;
`;
function ri(e2) {
  const { headerStart: i2, headerMiddle: t2, headerEnd: o2 } = e2, n2 = !!window.location.pathname.match(/\/edit|\/view|\/preview/);
  return Oe(ai, { className: a, $isEditViewPreview: n2, style: e2.style, children: [Me(oi, { children: i2 }), Me(ni, { children: t2 }), Me(li, { children: o2 })] });
}
const si = e.div`
  width: ${(e2) => e2.$side || 34}px;
  height: ${(e2) => e2.$side || 34}px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  justify-content: center;
  cursor: default;
  background-color: #0093E9;
  background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);

  & span {
    color: #ffffff;
    letter-spacing: normal;
    white-space: nowrap;
    font-size: ${(e2) => e2.$fontSize ?? 13}px;
    display: inline-block;
    ${(e2) => e2.$fontSize && e2.$fontSize < 12 ? "-webkit-transform:scale(" + e2.$fontSize / 12 + ");" : ""};
  }

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
`;
function di(e2) {
  const i2 = n(e2.userName, true), [t2, a2] = _e(false), o2 = l(e2.source), r2 = (o2 || e2.svg) && !t2;
  return Me(si, { $fontSize: e2.fontSize, style: e2.style, className: e2.className, $side: e2.side, title: e2.userName, children: r2 ? e2.source ? Me("img", { onError: () => a2(true), onLoad: () => a2(false), src: o2 }) : e2.svg : Me("span", { children: i2[0] }) });
}
const pi = i`
  input {
    border-radius: 4px;
    font-size: 13px;
    line-height: 13px;
    height: 32px;
  }

  input::placeholder {
    font-size: 13px;
    line-height: 13px;
  }
`, ci = e(r)`
  margin-bottom: 16px;
  ${pi};
`, hi = e(s)`
  margin-bottom: 16px;
  ${pi};
`;
e(d)`
  ${pi};
  margin-bottom: 24px;

  span {
    font-size: 16px;
    line-height: 16px;
  }

  div {
    border-radius: 4px;
  }

  button {
    width: 110px;
    padding: 0 12px;
    margin: 0;
    font-size: 13px;
    line-height: 13px;
  }
`;
const mi = e(p)`
  border-radius: 4px;
  height: 28px;
  font-size: 13px;
  line-height: 13px;
  width: 76px;
  margin-left: auto;
  margin-top: 8px;
`, gi = e.div`
  display: flex;
  flex-direction: column;
  margin-top: 6px;
`, fi = e.div`
  display: flex;
  align-items: center;
  width: 81px;
  height: 13px;

  img {
    width: 16px;
    height: 16px;
    margin-right: 6px;
  }
`, ui = e(c)`
  transform: scaleX(-1) scaleY(-1) rotate(-90deg);
`, xi = e.div`
  display: flex;
  align-items: center;
  margin-bottom: 19px;

  &:last-child {
    margin-bottom: 4px;
  }

  button {
    margin-left: auto;
    cursor: pointer;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    height: 13px;

    font-size: 13px;
    color: #4965f2;
    text-align: right;
    line-height: 13px;
    background: #ffffff;
  }

  button:hover svg g path {
    fill: #4965f2;
  }

  button:disabled,
  button:disabled button:hover {
    color: #b8b9bf;
    cursor: not-allowed;

    svg g path {
      fill: #b8b9bf;
    }
  }
`, bi = e(di)`
  span {
    font-size: 16px;
    font-weight: 500;
  }
`, wi = e.div`
  position: relative;
`, yi = e.div`
  font-size: 13px;
  position: absolute;
  width: 72px;
  height: 72px;
  line-height: 72px;
  left: 0;
  top: 0;
  border-radius: 50%;
  text-align: center;
  color: #ffffff;
  opacity: 0;
  cursor: pointer;

  &:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
`, vi = e.div`
  display: flex;
  align-items: center;
  padding: 0 0 27px 0;

  > * {
    margin-left: 16px;
  }

  > *:first-child {
    margin-left: 0;
  }
`;
function ki(e2) {
  return Oe(xi, { children: [Oe(fi, { children: [e2.icon, Me(h, { children: e2.titleLabel })] }), e2.value ? Me(h, { style: { marginLeft: "7px", whiteSpace: "break-spaces" }, children: e2.value }) : Me(m, { style: { marginLeft: "7px", maxWidth: "165px" }, children: e2.infoLabel }), !e2.actionButtonConfig.hidden && Oe("button", { onClick: () => e2.actionButtonConfig.onClick(), disabled: e2.actionButtonConfig.disabled, children: [Me("span", { children: e2.actionButtonConfig.label }), Me(ui, {})] })] });
}
function Ii() {
  const e2 = f(), i2 = u(x);
  return i2 ? Oe(vi, { children: [Me("div", { style: { height: "72px" }, children: Me(ze, { accept: "image/*", showUploadList: false, action: b, onChange: (i3) => {
    "done" === i3.file.status && I(i3.file.originFileObj, (i4) => {
      e2(C({ avatarUrl: i4 }));
    }), "error" === i3.file.status && P.error(y("profile.uploadError"));
  }, beforeUpload: w, withCredentials: true, children: Oe(wi, { children: [Me(bi, { side: 72, source: i2.avatarUrl, userName: i2.username }), Me(yi, { children: y("profile.editProfilePicture") })] }) }) }), Me(v, { valueCheck: { rule: (e3) => "" !== e3.trim(), message: y("profile.nameCheck") }, inputStyle: { width: "248px", height: " 32px" }, label: y("profile.name"), mustFill: true, placeholder: y("profile.namePlaceholder"), defaultValue: i2.username, onFinish: (i3) => {
    e2(k({ name: i3 }));
  } })] }) : null;
}
function Ci() {
  const [e2, i2] = _e(""), t2 = f(), a2 = u(S), o2 = a2 == null ? void 0 : a2.form.id;
  return Oe(gi, { children: [Me(ci, { mustFill: true, label: y("profile.email"), onChange: (e3, t3) => i2(t3 ? e3 : ""), placeholder: y("profile.emailPlaceholder"), checkRule: { check: (e3) => $(e3), errorMsg: y("profile.emailCheck") } }), Me(mi, { buttonType: "primary", disabled: !e2, onClick: () => {
    return i3 = e2, void L.bindEmail({ email: i3, authId: o2 }).then((e3) => {
      R(e3) && (P.success(y("profile.bindEmailSuccess")), t2(T()));
    }).catch((e3) => {
      P.error(e3.message);
    });
    var i3;
  }, children: y("profile.submit") })] });
}
function Pi(e2) {
  const [i2, t2] = _e(""), [a2, o2] = _e(""), n2 = f();
  return Oe(gi, { children: [e2.hasPass ? Oe(Ne, { children: [Me(hi, { passInputConf: { label: y("profile.oldPassword"), placeholder: y("profile.inputCurrentPassword") }, onChange: (e3, i3) => {
    t2(i3 ? e3 : "");
  } }), Me(hi, { doubleCheck: true, valueCheck: A, onChange: (e3, i3) => o2(i3 ? e3 : ""), passInputConf: { label: y("profile.newPassword"), placeholder: y("profile.inputNewPassword") }, confirmPassConf: { label: y("profile.confirmNewPassword"), placeholder: y("profile.inputNewPasswordAgain") } })] }) : Me(hi, { doubleCheck: true, valueCheck: A, onChange: (e3, i3) => o2(i3 ? e3 : "") }), Me(mi, { buttonType: "primary", disabled: e2.hasPass && !i2 || !a2, onClick: () => {
    const t3 = e2.hasPass ? L.updatePassword({ oldPassword: ii(i2), newPassword: ii(a2) }) : L.setPassword({ password: ii(a2) }), o3 = e2.hasPass ? y("profile.passwordModifiedSuccess") : y("profile.passwordSetSuccess");
    t3.then((e3) => {
      R(e3) && (P.success(o3), n2(T()));
    }).catch((e3) => {
      P.error(e3.message);
    });
  }, children: y("profile.submit") })] });
}
function Si(e2) {
  const i2 = u(x), { setModalContent: t2, setTitle: a2, setShowBackLink: o2 } = e2, n2 = i2.hasPassword, l2 = function(e3, i3) {
    var _a;
    const t3 = (_a = e3.connections) == null ? void 0 : _a.find((e4) => e4.source === i3);
    return (t3 == null ? void 0 : t3.name) ? g(t3.name) : "";
  }(i2, B.email);
  return Oe(Ne, { children: [Me(Ii, {}), Me(ki, { titleLabel: y("profile.bindEmail"), infoLabel: y("profile.loginAfterBind", { name: y("profile.email") }), value: l2, actionButtonConfig: { label: y(l2 ? "profile.binding" : "profile.toBind"), disabled: !!l2, onClick: () => {
    t2(Me(Ci, {})), a2(y("profile.bindName", { name: y("profile.email") })), o2(true);
  } } }, "email"), Me(ki, { titleLabel: y("profile.password"), infoLabel: y(n2 ? "profile.alreadySetPassword" : "profile.setPassPlaceholder"), actionButtonConfig: { label: y(n2 ? "profile.modifyPassword" : "profile.setPassword"), onClick: () => {
    t2(Me(Pi, { hasPass: n2 })), a2(y(n2 ? "profile.modifyPassword" : "profile.setPassword")), o2(true);
  }, hidden: false } }, "password")] });
}
function $i() {
  const e2 = u(O), i2 = f(), [t2, a2] = _e(y("profile.personalInfo")), [o2, n2] = _e(false), [l2, r2] = _e(), s2 = Me(Si, { setModalContent: r2, setShowBackLink: n2, setTitle: a2 }), d2 = (e3) => {
    e3.data.type === z.THIRD_PARTY_BIND && (e3.data.success ? (i2(T()), P.info(y("profile.bindingSuccess", { sourceName: e3.data.sourceName }))) : (P.error(e3.data.message), r2(s2)));
  };
  return He(() => (r2(s2), window.addEventListener("message", d2), () => window.removeEventListener("message", d2)), []), Me(M, { title: t2, open: e2, onCancel: () => i2(N(false)), showOkButton: false, showCancelButton: false, showBackLink: o2, onBack: () => {
    n2(false), r2(s2), a2(y("profile.personalInfo"));
  }, children: l2 });
}
const Li = e.div`
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 12px 0;

  p {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    word-break: keep-all;
  }

  svg {
    visibility: hidden;
  }

  :hover svg {
    visibility: visible;

    g g {
      fill: #3377ff;
    }
  }
`, Ri = e(Ee)`
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: end;
`, Ti = e(c)`
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
`, Ai = e.div`
  width: 160px;
  text-align: center;
  position: relative;
  margin-top: -3px;
  display: flex;
  justify-content: center;

  p {
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    color: #222222;
    padding-left: 16px;
  }
`, Bi = e.div`
  font-size: 12px;
  color: #4965f2;
  line-height: 14px;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  padding: 1px 5px;
`, Oi = e.div`
  max-width: 200px;
  white-space: break-spaces;
  overflow-wrap: break-word;
`, Mi = e.div`
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;

  svg {
    width: 16px;
    height: 16px;
  }
`;
function Ni(e2) {
  const { avatarUrl: i2, username: t2, orgs: a2, currentOrgId: o2 } = e2.user, n2 = e2.user.orgRoleMap.get(o2), l2 = u(E), r2 = u(O), s2 = u(S), d2 = f(), [p2, c2] = _e(false), [g2, x2] = _e(V), b2 = j.find((e3) => e3.languageCode === g2) || j[0];
  He(() => {
    const e3 = localStorage.getItem("selectedLanguage");
    e3 ? (F(e3), x2(e3)) : x2(V);
  }, []);
  let w2 = [{ key: "profile", label: Oe(Li, { children: [Me(di, { source: i2, userName: t2, side: 48 }), Oe(Ai, { children: [Me(U, { title: t2, children: t2 }), !D(window.innerWidth) && Me(G, {})] }), l2 && Me(m, { style: { width: "130px", textAlign: "center", lineHeight: "15px", height: "29px" }, children: (l2 == null ? void 0 : l2.name) ?? "" }), n2 && W[n2] && Me(Bi, { children: W[n2].name })] }) }, { key: "logout", label: y("profile.logout") }];
  const v2 = { key: "language", label: Oe("div", { style: { display: "flex", alignItems: "center:", gap: "8px" }, children: [Me("span", { children: y("profile.language") }), We.createElement(b2.flag, { width: "16", height: "16" })] }), children: j.map((e3) => ({ key: e3.languageCode, label: Oe(Mi, { children: [We.createElement(e3.flag, { width: "16", height: "16" }), Me("span", { children: e3.languageName })] }) })) };
  if (w2.splice(1, 0, v2), a2 && a2.length > 0 && Qe(e2.user, s2)) {
    const e3 = a2.map((e4) => ({ key: e4.id, icon: o2 === e4.id && Me(_, {}), label: Me(Oi, { children: e4.name }) }));
    let i3 = [];
    D(window.innerWidth) || "super_admin" !== n2 || (i3 = [{ type: "divider" }, { key: "newOrganization", icon: Me(H, {}), label: y("profile.createOrg") }]);
    const t3 = { key: "switchOrg", label: y("profile.switchOrg"), popupOffset: D(window.innerWidth) ? [-200, 36] : [4, -12], children: [{ key: "joinedOrg", label: Me(h, { style: { margin: "8px", color: "#B8B9BF" }, children: y("profile.joinedOrg") }), disabled: true }, ...e3, ...i3] };
    w2.splice(2, 0, t3);
  }
  const k2 = Me(q, { style: { width: "192px" }, onClick: (e3) => {
    if ("profile" === e3.key) {
      if (D(window.innerWidth))
        return;
      d2(N(true));
    } else if ("logout" === e3.key) {
      const e4 = localStorage.getItem("lowcoder_login_orgId");
      e4 && localStorage.removeItem("lowcoder_login_orgId"), d2(J({ organizationId: e4 || void 0 }));
    } else if (e3.keyPath.includes("switchOrg"))
      "newOrganization" === e3.key ? (d2(X(a2)), Y.push(K)) : o2 !== e3.key && d2(Q(e3.key));
    else if (e3.keyPath.includes("language")) {
      const i3 = e3.key;
      F(i3), x2(i3), localStorage.setItem("selectedLanguage", i3), window.location.reload();
    }
  }, expandIcon: Me(Ti, {}), items: w2 });
  return Oe(Ne, { children: [Me(Ri, { open: p2, onOpenChange: c2, popupRender: () => k2, trigger: ["click"], placement: "bottomRight", children: Me("div", { children: Me(di, { style: { cursor: "pointer", userSelect: "none" }, source: i2, userName: t2, side: e2.profileSide, fontSize: e2.fontSize }) }) }), r2 && Me($i, {})] });
}
e(ze)`
  .ant-upload-wrapper .ant-upload-select {
    display: block;
  }
`;
function zi(e2) {
  var _a, _b;
  const [i2, a2] = _e(""), o2 = u(x), n2 = u(Ze), [l2, r2] = _e(((_a = n2.find((i3) => {
    var _a2, _b2;
    return ((_a2 = i3.subApplications) == null ? void 0 : _a2.length) && ((_b2 = i3.subApplications) == null ? void 0 : _b2.findIndex((i4) => (i4 == null ? void 0 : i4.applicationId) === e2.id)) > -1;
  })) == null ? void 0 : _a.folderId) || ""), { visible: s2, close: d2, name: p2, type: c2, id: h2 } = e2, m2 = p2.length > 25 ? `${p2.substring(0, 25)}...` : p2;
  return Me(M, { title: y("home.copyModalTitle", { name: m2 }), open: s2, okButtonProps: { disabled: !i2 }, destroyOnHidden: true, onCancel: d2, showCancelButton: true, showOkButton: true, onOk: async () => {
    let e3 = null;
    await t.getApplicationDetail({ applicationId: h2, type: "editing" }).then(async (i3) => {
      R(i3) && i3.data.data && (e3 = i3.data.data.applicationDSL);
    }), e3 && await t.createApplicationWithDSL({ name: i2, orgId: o2.currentOrgId, applicationType: c2, editingApplicationDSL: e3 || {}, folderId: l2 }).then(async (e4) => {
      if (R(e4) && e4.data.data)
        return window.open(Z(e4.data.data.applicationInfoView.applicationId, "edit")), window.location.reload(), e4.data.data;
    }).catch((e4) => {
      P.error(y("copyError"));
    });
  }, children: Oe(Ne, { children: [Me("span", { style: { display: "block", marginBottom: "4px" }, children: y("home.copyNameLabel", { type: Di[c2] }) }), Me(ee, { maxLength: 255, placeholder: y("home.copyNamePlaceholder", { type: (_b = Di[c2]) == null ? void 0 : _b.toLowerCase() }), onChange: (e3) => {
    a2(e3.target.value);
  } }), !!n2.length && Oe(Ne, { children: [Me("span", { style: { display: "block", margin: "15px 0 4px" }, children: y("home.copyModalfolderLabel") }), Me(ie, { defaultValue: l2, style: { width: "100%" }, onChange: (e3) => r2(e3), options: [{ label: y("home.rootFolder"), value: "" }, ...n2.map((e3) => ({ label: e3.name, value: e3.folderId }))], filterOption: (e3, i3) => (i3 == null ? void 0 : i3.label).includes(e3) })] })] }) });
}
const Ei = e(c)`
  transform: rotate(180deg);
  margin-left: 4px;
  min-width: 18px;

  path {
    fill: #ffffff;
  }
`, Vi = e(Ee)`
  &.ant-dropdown-open {
    background-color: #8b8fa34c;
  }
`, ji = e(q)`
  .ant-dropdown-menu-item:hover {
    background: #edf4fa;
  }
`, Fi = e(h)`
  color: #f73131;
`, Ui = e.div`
  display: inline-flex;
  align-items: center;
  margin-right: 4px;

  &.module svg {
    visibility: visible;
  }
`, Di = { [te.Application]: y("home.app"), [te.Module]: y("home.module"), [te.NavLayout]: y("home.navLayout"), [te.MobileTabLayout]: y("home.mobileTabLayout") };
function Gi(e2) {
  const i2 = u(x), a2 = u(ae), o2 = oe(), n2 = u(ne), l2 = u(le), [r2, s2] = _e(false), d2 = f(), { appType: p2, exportPublicAppToJson: c2 } = qe(re), m2 = p2 === te.Module, g2 = se(i2, n2), b2 = e2.isViewMarketplaceMode, w2 = Je(() => {
    var _a;
    const e3 = [{ key: "export", label: Me(h, { children: y("header.export") }), visible: true }, { key: "duplicate", label: Me(h, { children: y("header.duplicate", { type: (_a = Di[n2 == null ? void 0 : n2.applicationType]) == null ? void 0 : _a.toLowerCase() }) }), visible: true }];
    return b2 || e3.unshift({ key: "edit", label: Me(h, { children: y("header.editName") }), visible: g2 }, { key: "delete", label: Me(Fi, { children: y("home.moveToTrash") }), visible: g2 }), e3;
  }, [g2, b2]);
  return Oe(Ne, { children: [Me(Vi, { placement: "bottomLeft", trigger: ["click"], disabled: a2, popupRender: () => Me(ji, { style: { minWidth: "136px", maxWidth: "288px", borderRadius: "4px" }, onClick: (i3) => {
    if ("edit" === i3.key)
      e2.setEdit();
    else if ("export" === i3.key) {
      if (l2 && c2)
        return c2 == null ? void 0 : c2();
      ((e3) => {
        const i4 = "t--export-app-link", a3 = document.getElementById(i4);
        a3 && a3.remove();
        const o3 = document.createElement("a");
        t.getApplicationDetail({ applicationId: e3, type: "editing" }).then((e4) => {
          if (R(e4)) {
            const t2 = e4.data.data, a4 = t2.applicationInfoView.name, n3 = { applicationInfo: { name: a4, createAt: t2.applicationInfoView.createAt, createBy: t2.applicationInfoView.createBy, applicationId: t2.applicationInfoView.applicationId, applicationType: t2.applicationInfoView.applicationType }, applicationDSL: t2.applicationDSL }, l3 = new Blob([JSON.stringify(n3)], { type: "application/json" }), r3 = URL.createObjectURL(l3);
            return o3.href = r3, o3.download = a4 + ".json", o3.id = i4, document.body.appendChild(o3), o3.click(), o3.remove(), void URL.revokeObjectURL(r3);
          }
        }).catch((e4) => P.error(y("home.exportError", { message: e4.message })));
      })(o2);
    } else
      "duplicate" === i3.key ? s2(true) : "delete" === i3.key && M.confirm({ title: y("home.moveToTrash"), content: de("home.moveToTrashSubTitle", { type: Di[n2 == null ? void 0 : n2.applicationType], name: Me("b", { children: (n2 == null ? void 0 : n2.name) || "" }) }), onConfirm: () => d2(pe({ applicationId: o2, folderId: "" }, () => {
        P.success(y("success")), Y.push(ge);
      }, () => P.error(y("home.deleteErrorMsg")))), confirmBtnType: "delete", okText: y("home.moveToTrash") });
  }, items: w2.filter((e3) => e3.visible) }), children: Oe(ce, { style: { width: "fit-content", maxWidth: "288px", padding: "0 8px" }, disabled: a2, children: [m2 && Me(Ui, { className: "module", children: Me(he, {}) }), Me(me, { className: "taco-edit-text-body", children: (n2 == null ? void 0 : n2.name) ?? "" }), Me(Ei, { style: { visibility: a2 ? "hidden" : "visible" } })] }) }), Me(zi, { name: (n2 == null ? void 0 : n2.name) || "", id: o2, type: n2 == null ? void 0 : n2.applicationType, visible: r2, close: () => s2(false) })] });
}
const Wi = e(ie)`
  margin-left: auto;

  .ant-select-arrow {
    right: 0;
  }

  .ant-select-selector {
    border: none !important;
  }

  .ant-select:hover {
    .ant-select-selector .ant-select-selection-item {
      color: #4965f2;
    }

    .ant-select-arrow svg g path {
      fill: #4965f2;
    }
  }

  .ant-select .ant-select-selector .ant-select-selection-item {
    padding-right: 12px;

    font-size: 13px;
    color: #333333;
    text-align: right;
    line-height: 15px;
  }
`, _i = e.div`
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 15px;
  height: fit-content;
`, Hi = e(fe)`
  width: ${(e2) => e2.$side ?? 16}px;
  height: ${(e2) => e2.$side ?? 16}px;

  g g {
    fill: ${(e2) => e2.$color};
  }
`, qi = e(ue)`
  width: 16px;
  height: 16px;

  g path {
    fill: ${(e2) => e2.$color};
  }
`, Ji = e.div`
  font-weight: 500;
  font-size: 14px;
  color: #333333;
  line-height: 16px;
  margin-left: 12px;
  max-width: 276px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
`;
function Xi(e2) {
  return Me(_i, { children: Me("div", { children: e2.role }) });
}
const Yi = e(xe)`
  height: 353px;
  width: 100%;
`, Ki = e.li`
  display: flex;
  align-items: center;
  padding: 8px 8px;
  width: 424px;

  &:hover {
    background: #f2f7fc;
    border-radius: 4px;
  }
`, Qi = e.ul`
  padding: 0;
  height: ${(e2) => e2.$height}px;
  overflow-y: overlay !important;
  overflow-x: hidden;
  margin: 0 -16px 0 -8px;

  &::-webkit-scrollbar {
    width: 16px;
  }

  &::-webkit-scrollbar-thumb {
    border: 5px solid transparent;
    background-clip: content-box;
    border-radius: 9999px;
    background-color: rgba(139, 143, 163, 0.12);
  }

  &::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 143, 163, 0.25);
  }
`, Zi = e.div`
  background: #ffffff;
  border: 1px solid #d6e4ff;
  border-radius: 8px;

  font-size: 12px;
  color: #4965f2;
  line-height: 12px;
  width: fit-content;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0 4px;
`;
function et(e2) {
  const { permissionItem: i2, isCreator: t2 } = e2;
  let a2;
  return "GROUP" === i2.type ? a2 = Hi : "ORG_ADMIN" === i2.type && (a2 = qi), Oe(Ki, { children: [Me(di, { side: 32, userName: i2.name, source: i2.avatar && be(i2.avatar), svg: a2 && Me(a2, { $color: n(i2.name)[1] }) }), Oe(Ji, { title: i2.name, children: ["GROUP" === i2.type && y("home.groupWithSquareBrackets"), i2.name] }), t2 && Me(Zi, { children: y("home.creator") }), t2 || "ORG_ADMIN" === i2.type ? Me(m, { style: { color: "color: #B8B9BF", margin: "0 24px 0 auto" }, children: e2.ownerLabel }) : Oe(Wi, { style: { marginRight: "4px" }, styles: { popup: { root: { width: "100px" } } }, defaultValue: i2.role, variant: "borderless", optionLabelProp: "label", onSelect: (i3, t3) => {
    "delete" === t3.key ? e2.deletePermission(t3.permissionid) : e2.updatePermission(t3.permissionid, t3.key);
  }, children: [e2.supportRoles.map((e3) => Me(ie.Option, { label: e3.label, value: e3.value, permissionid: i2.permissionId, children: Me(Xi, { role: e3.label }) }, e3.value)), Me(ie.Option, { label: y("remove"), value: "delete", permissionid: i2.permissionId, children: Me(we, { $fontSize: 13, children: y("remove") }) }, "delete")] })] }, i2.permissionId);
}
const it = (e2) => Oe(Ne, { children: [Me(h, { style: { marginBottom: "4px" }, children: y("home.memberPermissionList") }), Me(Qi, { $height: 201, children: e2.permissionItems.map((i2, t2) => Me(et, { isCreator: i2.isCreator, permissionItem: i2.permissionItem, ...e2 }, t2)) })] }), tt = e.div`
  display: flex;
  flex-direction: column;
`, at = e.div`
  margin: 8px -16px 0 -8px;

  > div {
    position: inherit !important;
  }

  .custom-ant-select-dropdown {
    height: 240px;
    position: inherit !important;
    box-shadow: none;
    border: none;
    padding: 0;

    .ant-select-item {
      width: 424px;
      transition: unset;
      padding: 0;

      .ant-select-item-option-state {
        width: 16px;
        height: 16px;
        margin-right: 8px;
      }
    }

    .rc-virtual-list-holder {
      overflow-y: overlay !important;

      &::-webkit-scrollbar {
        width: 16px;
      }

      &::-webkit-scrollbar-thumb {
        border: 5px solid transparent;
        background-clip: content-box;
        border-radius: 9999px;
        background-color: rgba(139, 143, 163, 0.12);
      }

      &::-webkit-scrollbar-thumb:hover {
        background-color: rgba(139, 143, 163, 0.25);
      }
    }
  }
`, ot = e.div`
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin-top: 8px;
  background: #fdfdfd;
  outline: 1px dashed #d7d9e0;

  .ant-select {
    font-size: 13px;
    line-height: 13px;
  }

  &:hover {
    outline: 1px dashed #8b8fa3;
  }

  &:focus-within {
    outline: 1px dashed rgb(203, 212, 245);
    border-radius: 4px;
    box-shadow: 0 0 0 3px rgb(24 144 255 / 20%);
  }

  .ant-select-selection-item {
    padding: 0;
    display: flex;
    align-items: center;
  }
`, nt = e(ie)`
  width: 328px;
  max-height: 64px;
  overflow-y: scroll;
  overflow-x: hidden;

  &::-webkit-scrollbar {
    display: none;
  }

  &&& {
    .ant-select,
    .ant-select .ant-select-selector {
      width: 100%;
      border: none;
      box-shadow: none;
      padding: 0;
    }
  }

  .ant-select-selection-placeholder {
    color: #b8b9bf;
  }
`, lt = e.div`
  display: flex;
  align-items: center;
  padding: 8px 0 8px 8px;
`, rt = e.div`
  margin: 4px 0 0 auto;
  display: flex;

  button {
    width: 76px;
    height: 28px;
  }
`, st = e(Ve)`
  height: 24px;
  display: flex;
  background: #efeff1;
  border-radius: 12px;
  padding: 0 8px 0 3px;

  margin: 2px 0;

  .ant-tag-close-icon {
    display: flex;
    align-items: center;
    margin-left: 8px;

    &:hover svg g line {
      stroke: #222222;
    }
  }
`, dt = e(di)`
  && > span {
    font-size: 1px;
    transform: scale(0.5, 0.5);
  }
`, pt = e(Wi)`
  .ant-select {
    height: 24px;
  }

  display: ${(e2) => e2.$isVisible ? "unset" : "none"};
`;
function ct(e2) {
  return "Group" === (e2 == null ? void 0 : e2.type);
}
function ht(e2, i2) {
  let t2 = e2 == null ? void 0 : e2.map((e3) => ({ type: e3.type, id: ct(e3) ? e3.data.groupId : e3.data.userId, name: ct(e3) ? e3.data.groupName : e3.data.name, ...ct(e3) ? {} : { avatarUrl: e3.data.avatarUrl } }));
  return t2 = t2.filter((e3) => !i2.find((i3) => i3.id === e3.id && i3.type === e3.type)), t2.filter((e3) => e3.id && e3.name);
}
function mt(e2) {
  const { optionView: i2 } = e2, t2 = "Group" === i2.type && Me(Hi, { $color: n(i2.name)[1] });
  return Oe(lt, { children: [Me(di, { userName: i2.name, side: 32, source: i2.avatarUrl, svg: t2 }), Me(Ji, { title: i2.name, children: i2.name })] });
}
function gt(e2) {
  const { view: i2 } = e2, t2 = "Group" === i2.type && Me(Hi, { $color: n(i2.name)[1], $side: 9 });
  return Oe("div", { style: { display: "flex", alignItems: "center" }, children: [Me(dt, { userName: i2.name, side: 18, source: i2.avatarUrl, svg: t2 }), Me(h, { style: { marginLeft: "4px", maxWidth: "240px", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", lineHeight: "15px" }, children: i2.name })] });
}
function ft(e2) {
  const { label: i2, value: t2, closable: a2, onClose: o2 } = e2;
  return Me(st, { closeIcon: Me(ke, { style: { width: "12px", height: "12px" } }), color: t2, closable: a2, onClose: o2, style: { marginRight: 3 }, children: i2 });
}
var ut = ((e2) => (e2.Viewer = "viewer", e2.Editor = "editor", e2.Owner = "owner", e2))(ut || {});
const xt = (e2) => {
  const { selectedItems: i2, setSelectRole: t2, setSelectedItems: a2, user: o2 } = e2, [n2, l2] = _e(false), r2 = Xe(null), [s2, d2] = _e(), [p2, c2] = _e(""), [h2, m2] = _e(false), g2 = u(ne), f2 = Ye(ei.debounce((i3) => {
    g2 && (m2(true), ti(g2.applicationId, i3).then((i4) => {
      i4.success && d2(ht(i4.data, e2.filterItems)), m2(false);
    }).catch(() => {
      m2(false);
    }));
  }, 500), [g2, e2.filterItems]);
  return He(() => (f2(p2), () => {
    f2.cancel();
  }), [p2, f2]), He(() => {
    g2 && (m2(true), ti(g2.applicationId, "").then((i3) => {
      i3.success && d2(ht(i3.data, e2.filterItems)), m2(false);
    }).catch(() => {
      m2(false);
    }));
  }, [g2, e2.filterItems]), He(() => {
    l2(i2.length > 0), r2 && r2.current && (r2.current.scrollTop = r2.current.scrollHeight);
  }, [i2]), Oe(Ne, { children: [Me(ye, { placeholder: y("home.addPermissionPlaceholder"), value: p2, onChange: (e3) => c2(e3.target.value) }), Oe(ot, { children: [Me(nt, { open: true, ref: r2, placeholder: y("home.selectedUsersAndGroups"), mode: "multiple", showSearch: false, getPopupContainer: () => document.getElementById("add-app-user-permission-dropdown"), optionLabelProp: "label", tagRender: ft, listHeight: 240, menuItemSelectedIcon: Me(_, {}), notFoundContent: Me(ve, { style: { paddingRight: "8px" } }), onSelect: (e3, t3) => {
    a2(i2.concat({ id: t3.entityid, type: t3.type, key: t3.key }));
  }, onDeselect: (e3, t3) => {
    a2(i2.filter((e4) => e4.key !== t3.key));
  }, children: s2 == null ? void 0 : s2.map((e3) => Me(ie.Option, { entityid: e3.id, type: e3.type, value: e3.name, label: Me(gt, { view: e3 }), children: Me(mt, { optionView: e3 }) }, `${e3.type}-${e3.id}`)) }), Me(pt, { styles: { popup: { root: { width: "fit-content" } } }, $isVisible: n2, variant: "borderless", defaultValue: e2.supportRoles[0], optionLabelProp: "label", onChange: (e3) => t2(e3), children: e2.supportRoles.map((e3) => Me(ie.Option, { value: e3.value, label: e3.label, children: Me(Xi, { role: e3.label }) }, e3.value)) })] }), Me(at, { id: "add-app-user-permission-dropdown" })] });
}, bt = (e2) => {
  const { onCancel: i2 } = e2, t2 = u(x), [a2, o2] = _e("viewer"), [n2, l2] = _e([]);
  return Oe(tt, { children: [Me(h, { style: { marginTop: "16px" }, children: y("home.searchMemberOrGroup") }), Me(xt, { selectedItems: n2, setSelectRole: o2, setSelectedItems: l2, user: t2, filterItems: e2.filterItems, supportRoles: e2.supportRoles }), Oe(rt, { children: [Me(p, { style: { marginRight: "8px" }, onClick: i2, children: y("cancel") + " " }), Me(p, { buttonType: "primary", onClick: () => {
    const t3 = n2.filter((e3) => "User" === e3.type).map((e3) => e3.id), o3 = n2.filter((e3) => "Group" === e3.type).map((e3) => e3.id);
    0 !== t3.length || 0 !== o3.length ? e2.addPermission(t3, o3, a2) : i2();
  }, children: y("finish") + " " })] })] });
}, wt = e.div`
  margin: 12px 16px 0 16px;
  display: flex;
`, yt = e(p)`
  &,
  &:hover,
  &:focus {
    border: none;
    box-shadow: none;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 14px;
    line-height: 14px;
    background: #ffffff;
    transition: unset;
  }

  svg {
    margin-right: 4px;
  }

  &:hover {
    color: #315efb;

    svg g path {
      fill: #315efb;
    }
  }
`, vt = (e2) => {
  const { supportRoles: i2, permissionItems: t2, visible: a2, onVisibleChange: o2, addPermission: n2, viewBodyRender: l2 } = e2, [r2, s2] = _e("view");
  return Me(Ie, { open: a2, destroyOnHidden: true, onCancel: () => {
    s2("view"), o2(false);
  }, showOkButton: false, showCancelButton: false, width: e2.width || "440px", onStepChange: s2, activeStepKey: r2, steps: [{ key: "view", titleRender: () => e2.title, bodyRender: () => l2 ? l2(Me(it, { ...e2 })) : Me(it, { ...e2 }), footerRender: (e3) => Oe(wt, { children: [Me(yt, { style: { height: 28 }, icon: Me(H, { style: { color: Ce } }), onClick: () => {
    e3.next();
  }, children: y("home.addMember") }), Me(p, { buttonType: "primary", onClick: () => o2(false), style: { marginLeft: "auto", width: "76px", height: "28px" }, children: y("finish") + " " })] }) }, { key: "add", titleRender: () => y("home.addMember"), bodyRender: (e3) => Me(bt, { supportRoles: i2, filterItems: t2.map((e4) => e4.permissionItem), onCancel: e3.back, addPermission: (i3, t3, a3) => n2(i3, t3, a3, e3.back) }), footerRender: (e3) => null }] });
}, kt = We.memo((e2) => {
  const { applicationId: i2 } = e2, a2 = f(), o2 = u(Pe), { appType: n2 } = qe(re), l2 = n2 === te.Module;
  He(() => {
    a2(Se({ applicationId: i2 }));
  }, [i2, a2]);
  let r2 = [];
  if (o2) {
    const e3 = o2.permissions.find((e4) => "USER" === e4.type && e4.id === o2.creatorId);
    r2 = [{ permissionItem: { permissionId: "orgAdmin", id: "orgAdmin", role: "owner", name: y("home.orgName", { orgName: o2.orgName }), type: "ORG_ADMIN" } }, ...o2.permissions.filter((e4) => !("USER" === e4.type && e4.id === o2.creatorId)).map((e4) => ({ permissionItem: e4 }))], e3 && (r2 = [{ isCreator: true, permissionItem: e3 }, ...r2]);
  }
  return Me(vt, { ...e2, width: "750px", title: y("home.appSharingDialogueTitle"), ownerLabel: y("home.allPermissions"), viewBodyRender: (e3) => o2 ? Oe(Ne, { children: [Me(St, { isModule: l2, applicationId: i2, permissionInfo: o2 }), e3] }) : Me(Yi, { size: 18 }), supportRoles: [{ label: y("share.viewer"), value: ut.Viewer }, { label: y("share.editor"), value: ut.Editor }, { label: y("share.owner"), value: ut.Owner }], permissionItems: r2, addPermission: (e3, o3, n3, l3) => t.grantAppPermission({ applicationId: i2, userIds: e3, groupIds: o3, role: n3 }).then((e4) => {
    R(e4) && (a2(Se({ applicationId: i2 })), l3());
  }).catch((e4) => {
    P.error(y("home.addPermissionErrorMessage", { message: e4.message }));
  }), updatePermission: (e3, t2) => a2($e({ applicationId: i2, role: t2, permissionId: e3 })), deletePermission: (e3) => a2(Le({ applicationId: i2, permissionId: e3 })) });
}), It = e.div`
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;

  button {
    width: 76px;
  }
`, Ct = (e2) => {
  const [i2] = Fe.useForm();
  He(() => {
    (async () => {
      const a2 = await t.getAppSlug(e2.appId);
      200 === a2.status ? a2.data.data.applicationInfoView.slug && i2.setFieldsValue({ slug: a2.data.data.applicationInfoView.slug }) : i2.setFieldsValue({ slug: e2.appId });
    })();
  }, []);
  return Oe(Ne, { children: [Me(h, { style: { marginTop: "16px" }, children: y("home.shareLink") }), Me(It, { children: Me(Fe, { form: i2, onFinish: async (i3) => {
    const a2 = i3.slug;
    if (a2 === e2.appId) {
      const i4 = window.location.origin + Z(e2.appId, "view");
      return Ge(i4), void P.info(y("home.slugIsSameAsAppId"));
    }
    const o2 = await t.setAppSlug(e2.appId, a2);
    if (200 === o2.status) {
      const e3 = `${window.location.origin}${Ae}/${a2}/view`;
      Ge(e3), P.success(y("home.saveAndCopySucess"));
    } else
      P.error(`${y("home.saveAndCopyFail")} - ${o2.data.message}`);
  }, style: { width: "100%" }, children: Oe(Ue, { gutter: [16, 0], children: [Me(De, { span: 20, children: Me(Fe.Item, { name: "slug", rules: [{ pattern: /^[a-zA-Z0-9_-]+$/, message: "Only letters, numbers, underscore and hyphens are allowed" }], children: Me(ee, { className: "slug-input", prefix: `${window.location.origin}${Ae}/`, maxLength: 50, suffix: "/view", onChange: (e3) => {
    e3.target.value && i2.validateFields(["slug"]).then(() => i2.setFields([{ name: "slug", errors: [] }])).catch(() => {
    });
  } }) }) }), Me(De, { span: 4, children: Me(Fe.Item, { shouldUpdate: true, children: () => Me(p, { htmlType: "submit", buttonType: "primary", style: { width: "100%" }, disabled: !i2.getFieldValue("slug") || i2.getFieldError("slug").length > 0, children: y("home.saveAndCopy") }) }) })] }) }) })] });
}, Pt = e.div`
  display: flex;
  align-items: center;
  margin-top: 8px;
`;
function St(e2) {
  const { applicationId: i2, permissionInfo: a2, isModule: o2 } = e2, [n2, l2] = _e(a2.publicToAll), [r2, s2] = _e(a2.publicToMarketplace), d2 = f();
  return He(() => {
    l2(a2.publicToAll);
  }, [a2.publicToAll]), He(() => {
    s2(a2.publicToMarketplace);
  }, [a2.publicToMarketplace]), Oe("div", { style: { marginBottom: "22px" }, children: [Me(Pt, { children: Me(Re, { checked: n2, onChange: (e3) => {
    t.publicToAll(i2, e3).then((e4) => {
      R(e4), d2(Se({ applicationId: i2 }));
    }).catch((e4) => {
      P.error(e4.message);
    });
  }, label: y(o2 ? "home.modulePublicMessage" : "home.appPublicMessage") }) }), n2 && Me(Pt, { children: Me(Re, { checked: r2, onChange: (e3) => {
    s2(e3), t.publicToMarketplace(i2, e3).then((i3) => {
      R(i3), d2(Te({ publicToMarketplace: e3 }));
    }).catch((e4) => {
      P.error(e4.message);
    });
  }, label: y(o2 ? "home.moduleMarketplaceMessage" : "home.appMarketplaceMessage") }) }), r2 && Oe(Ne, { children: [Me("div", { style: { margin: "10px 22px 22px 22px" }, children: y("home.marketplaceGoodPublishing") }), Me(je, {})] }), n2 && Me(Ct, { appId: i2 })] });
}
const $t = (e2) => `${Be}/api/materials/${e2}?type=preview`;
export {
  kt as A,
  Gi as H,
  di as P,
  ri as a,
  $t as b,
  Ni as c
};
