import { u as e, a as i } from "./styled-components-7cfa37e6.js";
import { iJ as t, eU as o, iK as n, iL as a, iM as r, iN as l, iO as s, ey as d, dQ as p, eD as c, iP as h, iQ as m, dH as f, dI as u, eh as g, iR as x, iS as b, ac as y, iT as w, iU as v, iV as k, iW as I, e0 as C, iX as P, iY as j, en as S, eo as R, iZ as T, i_ as L, i$ as $, j0 as O, ev as B, j1 as M, j2 as N, j3 as z, d9 as E, j4 as A, j5 as U, j6 as V, hU as D, eO as G, j7 as W, j8 as F, ep as H, j9 as _, ja as J, jb as X, jc as Y, fC as q, hp as K, ch as Q, eG as Z, el as ee, ek as ie, ei as te, ej as oe, e8 as ne, fB as ae, jd as re, je as le, jf as se, et as de, jg as pe, jh as ce, ji as he, jj as me, jk as fe, jl as ue, jm as ge, jn as xe, jo as be, jp as ye, jq as we, jr as ve, dW as ke, js as Ie, dR as Ce, jt as Pe, ju as je, eA as Se, jv as Re, jw as Te, jx as Le, jy as $e } from "./index-f927b013.js";
import { lI as Oe, lz as Be, lJ as Me } from "./ant-design-icons-6bfdc7d5.js";
import { v as Ne, D as ze, s as Ee, E as Ae, u as Ue, G as Ve } from "./antd-2abdded3.js";
import De, { useState as Ge, useEffect as We, useMemo as Fe, useContext as He, useRef as _e } from "react";
import { a as Je } from "./customerService-d62a9c61.js";
import { f as Xe } from "./folderSelector-e6108de8.js";
const Ye = e.header`
  display: flex;
  width: 100%;
  height: ${o};
  background-color: #2c2c2c;
  /* 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"};
  }
`, qe = e.div`
  display: flex;
  align-items: center;
`, Ke = e.div`
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
`, Qe = e.div`
  display: flex;
  align-items: center;
`;
function Ze(e2) {
  const { headerStart: i2, headerMiddle: o2, headerEnd: n2 } = e2, a2 = !!window.location.pathname.match(/\/edit|\/view|\/preview/);
  return Oe(Ye, { className: t, $isEditViewPreview: a2, style: e2.style, children: [Be(qe, { children: i2 }), Be(Ke, { children: o2 }), Be(Qe, { children: n2 })] });
}
const ei = 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 ii(e2) {
  const i2 = n(e2.userName, true), [t2, o2] = Ge(false), r2 = a(e2.source), l2 = (r2 || e2.svg) && !t2;
  return Be(ei, { $fontSize: e2.fontSize, style: e2.style, className: e2.className, $side: e2.side, title: e2.userName, children: l2 ? e2.source ? Be("img", { onError: () => o2(true), onLoad: () => o2(false), src: r2 }) : e2.svg : Be("span", { children: i2[0] }) });
}
const ti = i`
  input {
    border-radius: 4px;
    font-size: 13px;
    line-height: 13px;
    height: 32px;
  }

  input::placeholder {
    font-size: 13px;
    line-height: 13px;
  }
`, oi = e(r)`
  margin-bottom: 16px;
  ${ti};
`, ni = e(l)`
  margin-bottom: 16px;
  ${ti};
`;
e(s)`
  ${ti};
  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 ai = e(d)`
  border-radius: 4px;
  height: 28px;
  font-size: 13px;
  line-height: 13px;
  width: 76px;
  margin-left: auto;
  margin-top: 8px;
`, ri = e.div`
  display: flex;
  flex-direction: column;
  margin-top: 6px;
`, li = e.div`
  display: flex;
  align-items: center;
  width: 81px;
  height: 13px;

  img {
    width: 16px;
    height: 16px;
    margin-right: 6px;
  }
`, si = e(p)`
  transform: scaleX(-1) scaleY(-1) rotate(-90deg);
`, di = 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;
    }
  }
`, pi = e(ii)`
  span {
    font-size: 16px;
    font-weight: 500;
  }
`, ci = e.div`
  position: relative;
`, hi = 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);
  }
`, mi = e.div`
  display: flex;
  align-items: center;
  padding: 0 0 27px 0;

  > * {
    margin-left: 16px;
  }

  > *:first-child {
    margin-left: 0;
  }
`;
function fi(e2) {
  return Oe(di, { children: [Oe(li, { children: [e2.icon, Be(c, { children: e2.titleLabel })] }), e2.value ? Be(c, { style: { marginLeft: "7px", whiteSpace: "break-spaces" }, children: e2.value }) : Be(h, { style: { marginLeft: "7px", maxWidth: "165px" }, children: e2.infoLabel }), !e2.actionButtonConfig.hidden && Oe("button", { onClick: () => e2.actionButtonConfig.onClick(), disabled: e2.actionButtonConfig.disabled, children: [Be("span", { children: e2.actionButtonConfig.label }), Be(si, {})] })] });
}
function ui() {
  const e2 = f(), i2 = u(g);
  return i2 ? Oe(mi, { children: [Be("div", { style: { height: "72px" }, children: Be(Ne, { accept: "image/*", showUploadList: false, action: x, onChange: (i3) => {
    "done" === i3.file.status && k(i3.file.originFileObj, (i4) => {
      e2(I({ avatarUrl: i4 }));
    }), "error" === i3.file.status && C.error(y("profile.uploadError"));
  }, beforeUpload: b, withCredentials: true, children: Oe(ci, { children: [Be(pi, { side: 72, source: i2.avatarUrl, userName: i2.username }), Be(hi, { children: y("profile.editProfilePicture") })] }) }) }), Be(w, { 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(v({ name: i3 }));
  } })] }) : null;
}
function gi() {
  const [e2, i2] = Ge(""), t2 = f(), o2 = u(P), n2 = o2 == null ? void 0 : o2.form.id;
  return Oe(ri, { children: [Be(oi, { mustFill: true, label: y("profile.email"), onChange: (e3, t3) => i2(t3 ? e3 : ""), placeholder: y("profile.emailPlaceholder"), checkRule: { check: (e3) => j(e3), errorMsg: y("profile.emailCheck") } }), Be(ai, { buttonType: "primary", disabled: !e2, onClick: () => {
    return i3 = e2, void S.bindEmail({ email: i3, authId: n2 }).then((e3) => {
      R(e3) && (C.success(y("profile.bindEmailSuccess")), t2(T()));
    }).catch((e3) => {
      C.error(e3.message);
    });
    var i3;
  }, children: y("profile.submit") })] });
}
function xi(e2) {
  const [i2, t2] = Ge(""), [o2, n2] = Ge(""), a2 = f();
  return Oe(ri, { children: [e2.hasPass ? Oe(Me, { children: [Be(ni, { passInputConf: { label: y("profile.oldPassword"), placeholder: y("profile.inputCurrentPassword") }, onChange: (e3, i3) => {
    t2(i3 ? e3 : "");
  } }), Be(ni, { doubleCheck: true, valueCheck: L, onChange: (e3, i3) => n2(i3 ? e3 : ""), passInputConf: { label: y("profile.newPassword"), placeholder: y("profile.inputNewPassword") }, confirmPassConf: { label: y("profile.confirmNewPassword"), placeholder: y("profile.inputNewPasswordAgain") } })] }) : Be(ni, { doubleCheck: true, valueCheck: L, onChange: (e3, i3) => n2(i3 ? e3 : "") }), Be(ai, { buttonType: "primary", disabled: e2.hasPass && !i2 || !o2, onClick: () => {
    const t3 = e2.hasPass ? S.updatePassword({ oldPassword: i2, newPassword: o2 }) : S.setPassword({ password: o2 }), n3 = e2.hasPass ? y("profile.passwordModifiedSuccess") : y("profile.passwordSetSuccess");
    t3.then((e3) => {
      R(e3) && (C.success(n3), a2(T()));
    }).catch((e3) => {
      C.error(e3.message);
    });
  }, children: y("profile.submit") })] });
}
function bi(e2) {
  const i2 = u(g), { setModalContent: t2, setTitle: o2, setShowBackLink: n2 } = e2, a2 = i2.hasPassword, r2 = 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) ? m(t3.name) : "";
  }(i2, $.email);
  return Oe(Me, { children: [Be(ui, {}), Be(fi, { titleLabel: y("profile.bindEmail"), infoLabel: y("profile.loginAfterBind", { name: y("profile.email") }), value: r2, actionButtonConfig: { label: y(r2 ? "profile.binding" : "profile.toBind"), disabled: !!r2, onClick: () => {
    t2(Be(gi, {})), o2(y("profile.bindName", { name: y("profile.email") })), n2(true);
  } } }, "email"), Be(fi, { titleLabel: y("profile.password"), infoLabel: y(a2 ? "profile.alreadySetPassword" : "profile.setPassPlaceholder"), actionButtonConfig: { label: y(a2 ? "profile.modifyPassword" : "profile.setPassword"), onClick: () => {
    t2(Be(xi, { hasPass: a2 })), o2(y(a2 ? "profile.modifyPassword" : "profile.setPassword")), n2(true);
  }, hidden: false } }, "password")] });
}
function yi() {
  const e2 = u(O), i2 = f(), [t2, o2] = Ge(y("profile.personalInfo")), [n2, a2] = Ge(false), [r2, l2] = Ge(), s2 = Be(bi, { setModalContent: l2, setShowBackLink: a2, setTitle: o2 }), d2 = (e3) => {
    e3.data.type === N.THIRD_PARTY_BIND && (e3.data.success ? (i2(T()), C.info(y("profile.bindingSuccess", { sourceName: e3.data.sourceName }))) : (C.error(e3.data.message), l2(s2)));
  };
  return We(() => (l2(s2), window.addEventListener("message", d2), () => window.removeEventListener("message", d2)), []), Be(B, { title: t2, open: e2, onCancel: () => i2(M(false)), showOkButton: false, showCancelButton: false, showBackLink: n2, onBack: () => {
    a2(false), l2(s2), o2(y("profile.personalInfo"));
  }, children: r2 });
}
const { Item: wi } = Ee, vi = 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;
    }
  }
`, ki = e(ze)`
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: end;
`, Ii = e(p)`
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
`;
e((e2) => Be(wi, { ...e2 }))`
  .ant-dropdown-menu-item-icon {
    position: absolute;
    right: 0;
    width: 16px;
    height: 16px;
    margin-right: 8px;
  }

  .ant-dropdown-menu-title-content {
    color: #4965f2;
    padding-right: 22px;
  }
`, e(X)`
  min-width: 192px;

  .ant-dropdown-menu-item {
    height: 29px;
  }

  .ant-dropdown-menu-item-divider,
  .ant-dropdown-menu-submenu-title-divider {
    background-color: #e1e3eb;
  }
`;
const Ci = 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;
  }
`, Pi = e.div`
  font-size: 12px;
  color: #4965f2;
  line-height: 14px;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  padding: 1px 5px;
`;
function ji(e2) {
  const { avatarUrl: i2, username: t2, orgs: o2, currentOrgId: n2 } = e2.user, a2 = e2.user.orgRoleMap.get(n2), r2 = Fe(() => e2.user.orgs.find((e3) => e3.id === n2), [e2.user, n2]), l2 = u(O), s2 = u(P), d2 = f();
  let p2 = [{ key: "profile", label: Oe(vi, { children: [Be(ii, { source: i2, userName: t2, side: 48 }), Oe(Ci, { children: [Be(z, { title: t2, children: t2 }), !E(window.innerWidth) && Be(A, {})] }), r2 && Be(h, { style: { width: "130px", textAlign: "center", lineHeight: "15px" }, children: r2.name }), a2 && U[a2] && Be(Pi, { children: U[a2].name })] }) }, { key: "logout", label: y("profile.logout") }];
  if (o2 && o2.length > 0 && Je(e2.user, s2)) {
    const e3 = o2.map((e4) => ({ key: e4.id, icon: n2 === e4.id && Be(V, {}), label: e4.name }));
    let i3 = [];
    E(window.innerWidth) || (i3 = [{ type: "divider" }, { key: "newOrganization", icon: Be(D, {}), label: y("profile.createOrg") }]);
    const t3 = { key: "switchOrg", label: y("profile.switchOrg"), popupOffset: [4, -12], children: [{ key: "joinedOrg", label: Be(c, { style: { margin: "8px", color: "#B8B9BF" }, children: y("profile.joinedOrg") }), disabled: true }, ...e3, ...i3] };
    p2.splice(1, 0, t3);
  }
  const m2 = Be(G, { style: { width: "192px" }, onClick: (e3) => {
    if ("profile" === e3.key) {
      if (E(window.innerWidth))
        return;
      d2(M(true));
    } else
      "logout" === e3.key ? d2(W({})) : e3.keyPath.includes("switchOrg") && ("newOrganization" === e3.key ? (d2(F(o2)), H.push(_)) : n2 !== e3.key && d2(J(e3.key)));
  }, expandIcon: Be(Ii, {}), items: p2 });
  return Oe(Me, { children: [Be(ki, { dropdownRender: () => m2, trigger: ["click"], children: Be("div", { children: Be(ii, { style: { cursor: "pointer", userSelect: "none" }, source: i2, userName: t2, side: e2.profileSide, fontSize: e2.fontSize }) }) }), l2 && Be(yi, {})] });
}
e(Ne)`
  .ant-upload-wrapper .ant-upload-select {
    display: block;
  }
`;
function Si(e2) {
  var _a, _b;
  const [i2, t2] = Ge(""), o2 = u(g), n2 = u(Xe), [a2, r2] = Ge(((_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: l2, close: s2, name: d2, type: p2, id: c2 } = e2, h2 = d2.length > 25 ? `${d2.substring(0, 25)}...` : d2;
  return Be(B, { title: y("home.copyModalTitle", { name: h2 }), open: l2, okButtonProps: { disabled: !i2 }, destroyOnClose: true, onCancel: s2, showCancelButton: true, showOkButton: true, onOk: async () => {
    let e3 = null;
    await Y.getApplicationDetail({ applicationId: c2, type: "editing" }).then(async (i3) => {
      R(i3) && i3.data.data && (e3 = i3.data.data.applicationDSL);
    }), e3 && await Y.createApplicationWithDSL({ name: i2, orgId: o2.currentOrgId, applicationType: p2, editingApplicationDSL: e3 || {}, folderId: a2 }).then(async (e4) => {
      if (R(e4) && e4.data.data)
        return window.open(q(e4.data.data.applicationInfoView.applicationId, "edit")), window.location.reload(), e4.data.data;
    }).catch((e4) => {
      C.error(y("copyError"));
    });
  }, children: Oe(Me, { children: [Be("span", { style: { display: "block", marginBottom: "4px" }, children: y("home.copyNameLabel", { type: Bi[p2] }) }), Be(K, { placeholder: y("home.copyNamePlaceholder", { type: (_b = Bi[p2]) == null ? void 0 : _b.toLowerCase() }), onChange: (e3) => {
    t2(e3.target.value);
  } }), !!n2.length && Oe(Me, { children: [Be("span", { style: { display: "block", margin: "15px 0 4px" }, children: y("home.copyModalfolderLabel") }), Be(Q, { defaultValue: a2, 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 Ri = e(p)`
  transform: rotate(180deg);
  margin-left: 4px;
  min-width: 18px;

  path {
    fill: #ffffff;
  }
`, Ti = e(ze)`
  &.ant-dropdown-open {
    background-color: #8b8fa34c;
  }
`, Li = e(G)`
  .ant-dropdown-menu-item:hover {
    background: #edf4fa;
  }
`, $i = e(c)`
  color: #f73131;
`, Oi = e.div`
  display: inline-flex;
  align-items: center;
  margin-right: 4px;

  &.module svg {
    visibility: visible;
  }
`, Bi = { [Z.Application]: y("home.app"), [Z.Module]: y("home.module"), [Z.NavLayout]: y("home.navLayout"), [Z.MobileTabLayout]: y("home.mobileTabLayout") };
function Mi(e2) {
  const i2 = u(g), t2 = u(ee), o2 = ie(), n2 = u(te), a2 = u(oe), [r2, l2] = Ge(false), s2 = f(), { appType: d2, exportPublicAppToJson: p2 } = He(ne), h2 = d2 === Z.Module, m2 = ae(i2, n2), x2 = e2.isViewMarketplaceMode, b2 = Fe(() => {
    var _a;
    const e3 = [{ key: "export", label: Be(c, { children: y("header.export") }), visible: true }, { key: "duplicate", label: Be(c, { children: y("header.duplicate", { type: (_a = Bi[n2 == null ? void 0 : n2.applicationType]) == null ? void 0 : _a.toLowerCase() }) }), visible: !a2 }];
    return x2 || e3.unshift({ key: "edit", label: Be(c, { children: y("header.editName") }), visible: m2 }, { key: "delete", label: Be($i, { children: y("home.moveToTrash") }), visible: m2 }), e3;
  }, [m2, x2]);
  return Oe(Me, { children: [Be(Ti, { placement: "bottomLeft", trigger: ["click"], disabled: t2, dropdownRender: () => Be(Li, { style: { minWidth: "136px", maxWidth: "288px", borderRadius: "4px" }, onClick: (i3) => {
    if ("edit" === i3.key)
      e2.setEdit();
    else if ("export" === i3.key) {
      if (a2 && p2)
        return p2 == null ? void 0 : p2();
      ((e3) => {
        const i4 = "t--export-app-link", t3 = document.getElementById(i4);
        t3 && t3.remove();
        const o3 = document.createElement("a");
        Y.getApplicationDetail({ applicationId: e3, type: "editing" }).then((e4) => {
          if (R(e4)) {
            const t4 = e4.data.data, n3 = t4.applicationInfoView.name, a3 = { applicationInfo: { name: n3, createAt: t4.applicationInfoView.createAt, createBy: t4.applicationInfoView.createBy, applicationId: t4.applicationInfoView.applicationId, applicationType: t4.applicationInfoView.applicationType }, applicationDSL: t4.applicationDSL }, r3 = new Blob([JSON.stringify(a3)], { type: "application/json" }), l3 = URL.createObjectURL(r3);
            return o3.href = l3, o3.download = n3 + ".json", o3.id = i4, document.body.appendChild(o3), o3.click(), o3.remove(), void URL.revokeObjectURL(l3);
          }
        }).catch((e4) => C.error(y("home.exportError", { message: e4.message })));
      })(o2);
    } else
      "duplicate" === i3.key ? l2(true) : "delete" === i3.key && B.confirm({ title: y("home.moveToTrash"), content: re("home.moveToTrashSubTitle", { type: Bi[n2 == null ? void 0 : n2.applicationType], name: Be("b", { children: (n2 == null ? void 0 : n2.name) || "" }) }), onConfirm: () => s2(le({ applicationId: o2, folderId: "" }, () => {
        C.success(y("success")), H.push(ce);
      }, () => C.error(y("home.deleteErrorMsg")))), confirmBtnType: "delete", okText: y("home.moveToTrash") });
  }, items: b2.filter((e3) => e3.visible) }), children: Oe(se, { style: { width: "fit-content", maxWidth: "288px", padding: "0 8px" }, disabled: t2, children: [h2 && Be(Oi, { className: "module", children: Be(de, {}) }), Be(pe, { className: "taco-edit-text-body", children: (n2 == null ? void 0 : n2.name) ?? "" }), Be(Ri, { style: { visibility: t2 ? "hidden" : "visible" } })] }) }), Be(Si, { name: (n2 == null ? void 0 : n2.name) || "", id: o2, type: n2 == null ? void 0 : n2.applicationType, visible: r2, close: () => l2(false) })] });
}
const Ni = e(Q)`
  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;
  }
`, zi = e.div`
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 15px;
  height: fit-content;
`, Ei = e(he)`
  width: ${(e2) => e2.$side ?? 16}px;
  height: ${(e2) => e2.$side ?? 16}px;

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

  g path {
    fill: ${(e2) => e2.$color};
  }
`, Ui = 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 Vi(e2) {
  return Be(zi, { children: Be("div", { children: e2.role }) });
}
const Di = e(fe)`
  height: 353px;
  width: 100%;
`, Gi = e.li`
  display: flex;
  align-items: center;
  padding: 8px 8px;
  width: 424px;

  &:hover {
    background: #f2f7fc;
    border-radius: 4px;
  }
`, Wi = 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);
  }
`, Fi = 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 Hi(e2) {
  const { permissionItem: i2, isCreator: t2 } = e2;
  let o2;
  return "GROUP" === i2.type ? o2 = Ei : "ORG_ADMIN" === i2.type && (o2 = Ai), Oe(Gi, { children: [Be(ii, { side: 32, userName: i2.name, source: i2.avatar && ue(i2.avatar), svg: o2 && Be(o2, { $color: n(i2.name)[1] }) }), Oe(Ui, { title: i2.name, children: ["GROUP" === i2.type && y("home.groupWithSquareBrackets"), i2.name] }), t2 && Be(Fi, { children: y("home.creator") }), t2 || "ORG_ADMIN" === i2.type ? Be(h, { style: { color: "color: #B8B9BF", margin: "0 24px 0 auto" }, children: e2.ownerLabel }) : Oe(Ni, { style: { marginRight: "4px" }, dropdownStyle: { 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) => Be(Q.Option, { label: e3.label, value: e3.value, permissionid: i2.permissionId, children: Be(Vi, { role: e3.label }) }, e3.value)), Be(Q.Option, { label: y("remove"), value: "delete", permissionid: i2.permissionId, children: Be(ge, { $fontSize: 13, children: y("remove") }) }, "delete")] })] }, i2.permissionId);
}
const _i = (e2) => Oe(Me, { children: [Be(c, { style: { marginBottom: "4px" }, children: y("home.memberPermissionList") }), Be(Wi, { $height: 201, children: e2.permissionItems.map((i2, t2) => Be(Hi, { isCreator: i2.isCreator, permissionItem: i2.permissionItem, ...e2 }, t2)) })] }), Ji = e.div`
  display: flex;
  flex-direction: column;
`, Xi = 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);
      }
    }
  }
`, Yi = e.div`
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin-top: 8px;
  background: #fdfdfd;
  outline: 1px solid #d7d9e0;
  border-radius: 4px;

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

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

  &:focus-within {
    outline: 1px solid #315efb;
    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;
  }
`, qi = e(Q)`
  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;
  }
`, Ki = e.div`
  display: flex;
  align-items: center;
  padding: 8px 0 8px 8px;
`, Qi = e.div`
  margin: 4px 0 0 auto;
  display: flex;

  button {
    width: 76px;
    height: 28px;
  }
`, Zi = e(Ae)`
  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;
    }
  }
`, et = e(ii)`
  && > span {
    font-size: 1px;
    transform: scale(0.5, 0.5);
  }
`, it = e(Ni)`
  .ant-select {
    height: 24px;
  }

  display: ${(e2) => e2.$isVisible ? "unset" : "none"};
`;
function tt(e2) {
  const { optionView: i2 } = e2, t2 = "GROUP" === i2.type && Be(Ei, { $color: n(i2.name)[1] });
  return Oe(Ki, { children: [Be(ii, { userName: i2.name, side: 32, source: i2.avatarUrl, svg: t2 }), Be(Ui, { title: i2.name, children: i2.name })] });
}
function ot(e2) {
  const { view: i2 } = e2, t2 = "GROUP" === i2.type && Be(Ei, { $color: n(i2.name)[1], $side: 9 });
  return Oe("div", { style: { display: "flex", alignItems: "center" }, children: [Be(et, { userName: i2.name, side: 18, source: i2.avatarUrl, svg: t2 }), Be(c, { style: { marginLeft: "4px", maxWidth: "240px", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", lineHeight: "15px" }, children: i2.name })] });
}
function nt(e2) {
  const { label: i2, value: t2, closable: o2, onClose: n2 } = e2;
  return Be(Zi, { closeIcon: Be(ke, { style: { width: "12px", height: "12px" } }), color: t2, closable: o2, onClose: n2, style: { marginRight: 3 }, children: i2 });
}
var at = ((e2) => (e2.Viewer = "viewer", e2.Editor = "editor", e2.Owner = "owner", e2))(at || {});
const rt = (e2) => {
  const i2 = u(ye), t2 = u(we), { selectedItems: o2, setSelectRole: n2, setSelectedItems: a2, user: r2 } = e2, l2 = function(e3, i3, t3, o3) {
    let n3 = e3.map((e4) => ({ type: "GROUP", id: e4.groupId, name: e4.groupName }));
    return n3 = n3.concat(i3.map((e4) => ({ type: "USER", id: e4.userId, name: e4.name, avatarUrl: e4.avatarUrl }))), n3 = n3.filter((e4) => !(o3.find((i4) => i4.id === e4.id && i4.type === e4.type) || "USER" === e4.type && e4.id === t3.id)), n3;
  }(i2, t2, r2, e2.filterItems), [s2, d2] = Ge(false), p2 = _e(null);
  return We(() => {
    d2(o2.length > 0), p2 && p2.current && (p2.current.scrollTop = p2.current.scrollHeight);
  }, [o2]), Oe(Me, { children: [Oe(Yi, { children: [Be(qi, { open: true, ref: p2, placeholder: y("home.addPermissionPlaceholder"), mode: "multiple", getPopupContainer: () => document.getElementById("add-app-user-permission-dropdown"), optionLabelProp: "label", tagRender: nt, listHeight: 240, menuItemSelectedIcon: Be(V, {}), notFoundContent: Be(ve, { style: { paddingRight: "8px" } }), onSelect: (e3, i3) => {
    a2(o2.concat({ id: i3.entityid, type: i3.type, key: i3.key }));
  }, onDeselect: (e3, i3) => {
    a2(o2.filter((e4) => e4.key !== i3.key));
  }, children: l2.map((e3) => Be(Q.Option, { entityid: e3.id, type: e3.type, value: e3.name, label: Be(ot, { view: e3 }), children: Be(tt, { optionView: e3 }) }, `${e3.type}-${e3.id}`)) }), Be(it, { dropdownStyle: { width: "fit-content" }, $isVisible: s2, variant: "borderless", defaultValue: e2.supportRoles[0], optionLabelProp: "label", onChange: (e3) => n2(e3), children: e2.supportRoles.map((e3) => Be(Q.Option, { value: e3.value, label: e3.label, children: Be(Vi, { role: e3.label }) }, e3.value)) })] }), Be(Xi, { id: "add-app-user-permission-dropdown" })] });
}, lt = (e2) => {
  const { onCancel: i2 } = e2, t2 = f(), o2 = u(g), [n2, a2] = Ge("viewer"), [r2, l2] = Ge([]);
  return We(() => {
    t2(xe(o2.currentOrgId)), t2(be(o2.currentOrgId));
  }, []), Oe(Ji, { children: [Be(c, { style: { marginTop: "16px" }, children: y("home.searchMemberOrGroup") }), Be(rt, { selectedItems: r2, setSelectRole: a2, setSelectedItems: l2, user: o2, filterItems: e2.filterItems, supportRoles: e2.supportRoles }), Oe(Qi, { children: [Be(d, { style: { marginRight: "8px" }, onClick: i2, children: y("cancel") + " " }), Be(d, { buttonType: "primary", onClick: () => {
    const t3 = r2.filter((e3) => "USER" === e3.type).map((e3) => e3.id), o3 = r2.filter((e3) => "GROUP" === e3.type).map((e3) => e3.id);
    0 !== t3.length || 0 !== o3.length ? e2.addPermission(t3, o3, n2) : i2();
  }, children: y("finish") + " " })] })] });
}, st = e.div`
  margin: 12px 16px 0 16px;
  display: flex;
`, dt = e(d)`
  &,
  &: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;
    }
  }
`, pt = (e2) => {
  const { supportRoles: i2, permissionItems: t2, visible: o2, onVisibleChange: n2, addPermission: a2, viewBodyRender: r2 } = e2, [l2, s2] = Ge("view");
  return Be(Ie, { open: o2, destroyOnClose: true, onCancel: () => {
    s2("view"), n2(false);
  }, showOkButton: false, showCancelButton: false, width: "440px", onStepChange: s2, activeStepKey: l2, steps: [{ key: "view", titleRender: () => e2.title, bodyRender: () => r2 ? r2(Be(_i, { ...e2 })) : Be(_i, { ...e2 }), footerRender: (e3) => Oe(st, { children: [Be(dt, { style: { height: 28 }, icon: Be(D, { style: { color: Ce } }), onClick: () => {
    e3.next();
  }, children: y("home.addMember") }), Be(d, { buttonType: "primary", onClick: () => n2(false), style: { marginLeft: "auto", width: "76px", height: "28px" }, children: y("finish") + " " })] }) }, { key: "add", titleRender: () => y("home.addMember"), bodyRender: (e3) => Be(lt, { supportRoles: i2, filterItems: t2.map((e4) => e4.permissionItem), onCancel: e3.back, addPermission: (i3, t3, o3) => a2(i3, t3, o3, e3.back) }), footerRender: (e3) => null }] });
}, ct = De.memo((e2) => {
  const { applicationId: i2 } = e2, t2 = f(), o2 = u(Pe), { appType: n2 } = He(ne), a2 = n2 === Z.Module;
  We(() => {
    t2(je({ applicationId: i2 }));
  }, [i2, t2]);
  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 Be(pt, { ...e2, title: Se, ownerLabel: y("home.allPermissions"), viewBodyRender: (e3) => o2 ? Oe(Me, { children: [Be(ut, { isModule: a2, applicationId: i2, permissionInfo: o2 }), e3] }) : Be(Di, { size: 18 }), supportRoles: [{ label: y("share.viewer"), value: at.Viewer }, { label: y("share.editor"), value: at.Editor }, { label: y("share.owner"), value: at.Owner }], permissionItems: r2, addPermission: (e3, o3, n3, a3) => Y.grantAppPermission({ applicationId: i2, userIds: e3, groupIds: o3, role: n3 }).then((e4) => {
    R(e4) && (t2(je({ applicationId: i2 })), a3());
  }).catch((e4) => {
    C.error(y("home.addPermissionErrorMessage", { message: e4.message }));
  }), updatePermission: (e3, o3) => t2(Re({ applicationId: i2, role: o3, permissionId: e3 })), deletePermission: (e3) => t2(Te({ applicationId: i2, permissionId: e3 })) });
}), ht = e.div`
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;

  button {
    width: 76px;
  }
`, mt = (e2) => {
  const i2 = window.location.origin + q(e2.appId, "view");
  return Oe(Me, { children: [Be(c, { style: { marginTop: "16px" }, children: y("home.shareLink") }), Oe(ht, { children: [Be(K, { disabled: true, value: i2 }), Be(d, { buttonType: "primary", onClick: () => {
    Ve(i2) ? C.success(y("copySuccess")) : C.error(y("copyError"));
  }, children: y("home.copyLink") })] })] });
}, ft = e.div`
  display: flex;
  align-items: center;
  margin-top: 8px;
`;
function ut(e2) {
  const { applicationId: i2, permissionInfo: t2, isModule: o2 } = e2, [n2, a2] = Ge(t2.publicToAll), [r2, l2] = Ge(t2.publicToMarketplace), s2 = f();
  return We(() => {
    a2(t2.publicToAll);
  }, [t2.publicToAll]), We(() => {
    l2(t2.publicToMarketplace);
  }, [t2.publicToMarketplace]), Oe("div", { style: { marginBottom: "22px" }, children: [Be(ft, { children: Be(Le, { checked: n2, onChange: (e3) => {
    a2(e3), Y.publicToAll(i2, e3).then((i3) => {
      R(i3), s2($e({ publicToAll: e3 }));
    }).catch((e4) => {
      C.error(e4.message);
    });
  }, label: y(o2 ? "home.modulePublicMessage" : "home.appPublicMessage") }) }), n2 && Be(ft, { children: Be(Le, { checked: r2, onChange: (e3) => {
    l2(e3), Y.publicToMarketplace(i2, e3).then((i3) => {
      R(i3), s2($e({ publicToMarketplace: e3 }));
    }).catch((e4) => {
      C.error(e4.message);
    });
  }, label: y(o2 ? "home.moduleMarketplaceMessage" : "home.appMarketplaceMessage") }) }), r2 && Oe(Me, { children: [Be("div", { style: { margin: "10px 22px 22px 22px" }, children: y("home.marketplaceGoodPublishing") }), Be(Ue, {})] }), n2 && Be(mt, { appId: i2 })] });
}
export {
  ct as A,
  Mi as H,
  ii as P,
  Ze as a,
  ji as b
};
