var he = Object.defineProperty;
var X = Object.getOwnPropertySymbols;
var pe = Object.prototype.hasOwnProperty, ve = Object.prototype.propertyIsEnumerable;
var ee = (o, a, e) => a in o ? he(o, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[a] = e, te = (o, a) => {
  for (var e in a || (a = {}))
    pe.call(a, e) && ee(o, e, a[e]);
  if (X)
    for (var e of X(a))
      ve.call(a, e) && ee(o, e, a[e]);
  return o;
};
var ne = (o, a, e) => new Promise((s, c) => {
  var t = (r) => {
    try {
      l(e.next(r));
    } catch (n) {
      c(n);
    }
  }, d = (r) => {
    try {
      l(e.throw(r));
    } catch (n) {
      c(n);
    }
  }, l = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(t, d);
  l((e = e.apply(o, a)).next());
});
import { jsx as i, jsxs as g, Fragment as we } from "react/jsx-runtime";
import { x as P, U as re, dY as xe, g as ge, h as U, fk as F, fl as be, fm as ye, fn as ke, fo as Ce, df as Me, de as Ie, fp as Ne, el as Ee, fq as _e, dC as Se, fr as Re, fs as Te, ft as Be, fu as Ae, fv as De, d3 as Le, fw as He, V as ze, ac as ie, aa as oe, aC as We, cv as Fe, fx as Ue } from "./main-CxoAwMiG.js";
import { A as Pe } from "./TalkLoading-CJtNYhDp.js";
import { useEffect as ae, useState as ce, useRef as je } from "react";
import { u as Oe } from "./useCopyToClipboard-DWdHcqke.js";
import { A as Ve } from "./AddContact-MhyucOkv.js";
import { u as se } from "./JoinThreadDialog-N2K5Qro0.js";
import { flushSync as Ge } from "react-dom";
const $e = ({
  icon: o,
  title: a,
  to: e = void 0,
  onClick: s = void 0,
  subtitle: c,
  className: t,
  withBorder: d = !1,
  target: l = "_self",
  children: r
}) => {
  const n = P();
  return /* @__PURE__ */ i(re, { children: /* @__PURE__ */ g(
    "div",
    {
      className: `flex items-center ${d ? "border-b-2 border-divider" : ""} `,
      children: [
        /* @__PURE__ */ i(
          "div",
          {
            onClick: () => {
              e && (l === "_blank" ? window.open(e, "_blank", "noopener,noreferrer") : n(e)), s && s();
            },
            className: `flex items-center justify-between cursor-pointer px-4 py-[9px] hover:bg-bgHover flex-1 ${t} `,
            children: /* @__PURE__ */ g("div", { className: "flex items-center gap-3", children: [
              o && /* @__PURE__ */ i("div", { className: "flex-shrink-0 text-menuIconColor", children: o }),
              /* @__PURE__ */ g("div", { className: "text-right flex flex-col", children: [
                /* @__PURE__ */ i(
                  "p",
                  {
                    className: `text-[13px] font-normal !select-text text-invertBlackWhite ${c ? "mb-1" : "mb-0"}`,
                    children: a
                  }
                ),
                c && /* @__PURE__ */ i("p", { className: "text-[12px] font-normal !select-text text-lightText", children: c })
              ] })
            ] })
          }
        ),
        r && /* @__PURE__ */ i("div", { children: r })
      ]
    }
  ) });
}, qe = ({
  icon: o,
  title: a,
  isDarkMode: e,
  refProp: s,
  onToggle: c
}) => /* @__PURE__ */ i(re, { children: /* @__PURE__ */ g(
  "div",
  {
    ref: s,
    onClick: c,
    className: "flex items-center justify-between px-4 py-[9px] cursor-pointer hover:bg-bgHover border-b-2 border-divider",
    children: [
      /* @__PURE__ */ g("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ i("div", { className: "flex-shrink-0 text-menuIconColor", children: o }),
        /* @__PURE__ */ i("p", { className: "text-[13px] text-invertBlackWhite", children: a })
      ] }),
      /* @__PURE__ */ i("div", { className: "pointer-events-none", children: /* @__PURE__ */ i(xe, { checked: e, onChange: () => {
      } }) })
    ]
  }
) });
var Qe = function(o, a, e, s) {
  function c(t) {
    return t instanceof e ? t : new e(function(d) {
      d(t);
    });
  }
  return new (e || (e = Promise))(function(t, d) {
    function l(f) {
      try {
        n(s.next(f));
      } catch (v) {
        d(v);
      }
    }
    function r(f) {
      try {
        n(s.throw(f));
      } catch (v) {
        d(v);
      }
    }
    function n(f) {
      f.done ? t(f.value) : c(f.value).then(l, r);
    }
    n((s = s.apply(o, a || [])).next());
  });
}, Je = function(o, a) {
  var e = { label: 0, sent: function() {
    if (t[0] & 1) throw t[1];
    return t[1];
  }, trys: [], ops: [] }, s, c, t, d;
  return d = { next: l(0), throw: l(1), return: l(2) }, typeof Symbol == "function" && (d[Symbol.iterator] = function() {
    return this;
  }), d;
  function l(n) {
    return function(f) {
      return r([n, f]);
    };
  }
  function r(n) {
    if (s) throw new TypeError("Generator is already executing.");
    for (; d && (d = 0, n[0] && (e = 0)), e; ) try {
      if (s = 1, c && (t = n[0] & 2 ? c.return : n[0] ? c.throw || ((t = c.return) && t.call(c), 0) : c.next) && !(t = t.call(c, n[1])).done) return t;
      switch (c = 0, t && (n = [n[0] & 2, t.value]), n[0]) {
        case 0:
        case 1:
          t = n;
          break;
        case 4:
          return e.label++, { value: n[1], done: !1 };
        case 5:
          e.label++, c = n[1], n = [0];
          continue;
        case 7:
          n = e.ops.pop(), e.trys.pop();
          continue;
        default:
          if (t = e.trys, !(t = t.length > 0 && t[t.length - 1]) && (n[0] === 6 || n[0] === 2)) {
            e = 0;
            continue;
          }
          if (n[0] === 3 && (!t || n[1] > t[0] && n[1] < t[3])) {
            e.label = n[1];
            break;
          }
          if (n[0] === 6 && e.label < t[1]) {
            e.label = t[1], t = n;
            break;
          }
          if (t && e.label < t[2]) {
            e.label = t[2], e.ops.push(n);
            break;
          }
          t[2] && e.ops.pop(), e.trys.pop();
          continue;
      }
      n = a.call(o, e);
    } catch (f) {
      n = [6, f], c = 0;
    } finally {
      s = t = 0;
    }
    if (n[0] & 5) throw n[1];
    return { value: n[0] ? n[1] : void 0, done: !0 };
  }
}, le = typeof window != "undefined", Ye = function() {
  if (le) {
    var o = "theme-switch-base-style";
    if (!document.getElementById(o)) {
      var a = document.createElement("style");
      a.id = o;
      var e = window.innerWidth >= 3e3 || window.innerHeight >= 2e3;
      a.textContent = `
        ::view-transition-old(root),
        ::view-transition-new(root) {
          animation: none;
          mix-blend-mode: normal;
          `.concat(e ? "transform: translateZ(0);" : "", `
        }
        
        `).concat(e ? `
        ::view-transition-group(root),
        ::view-transition-image-pair(root),
        ::view-transition-old(root),
        ::view-transition-new(root) {
          backface-visibility: hidden;
          perspective: 1000px;
          transform: translate3d(0, 0, 0);
        }
        ` : "", `
      `), document.head.appendChild(a);
    }
  }
}, k;
(function(o) {
  o.CIRCLE = "circle", o.BLUR_CIRCLE = "blur-circle", o.QR_SCAN = "qr-scan";
})(k || (k = {}));
var Ze = function(o) {
  var a = o || {}, e = a.duration, s = e === void 0 ? 750 : e, c = a.easing, t = c === void 0 ? "ease-in-out" : c, d = a.pseudoElement, l = d === void 0 ? "::view-transition-new(root)" : d, r = a.globalClassName, n = r === void 0 ? "dark" : r, f = a.animationType, v = f === void 0 ? k.CIRCLE : f, N = a.blurAmount, E = N === void 0 ? 2 : N, _ = a.styleId, C = _ === void 0 ? "theme-switch-style" : _, u = a.isDarkMode, w = a.onDarkModeChange, y = typeof window != "undefined" && (window.innerWidth >= 3e3 || window.innerHeight >= 2e3), b = y ? Math.max(s * 0.8, 500) : s;
  ae(function() {
    Ye();
  }, []);
  var j = ce(le ? localStorage.getItem("theme") === "dark" : !1), de = j[0], fe = j[1], S = u != null ? u : de, O = function(x) {
    var p = typeof x == "function" ? x(S) : x;
    w ? w(p) : fe(p);
  }, D = je(null), ue = function(x) {
    var p = typeof window != "undefined" && (window.innerWidth >= 3e3 || window.innerHeight >= 2e3), R = '<filter id="blur"><feGaussianBlur stdDeviation="'.concat(x, '" /></filter>'), T = p ? 20 : 25;
    return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>`.concat(R, '</defs><circle cx="0" cy="0" r="').concat(T, `" fill="white" filter="url(%23blur)"/></svg>')`);
  }, me = function() {
    return Qe(void 0, void 0, void 0, function() {
      var x, p, R, T, V, G, m, h, $, q, Q, J, L, H, M, z, Y, B, Z, A, W;
      return Je(this, function(K) {
        switch (K.label) {
          case 0:
            return !D.current || !document.startViewTransition || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? (O(function(I) {
              return !I;
            }), [
              2
              /*return*/
            ]) : (x = document.getElementById(C), x && x.remove(), p = D.current.getBoundingClientRect(), R = p.top, T = p.left, V = p.width, G = p.height, m = T + V / 2, h = R + G / 2, $ = Math.hypot(m, h), q = Math.hypot(window.innerWidth - m, h), Q = Math.hypot(m, window.innerHeight - h), J = Math.hypot(window.innerWidth - m, window.innerHeight - h), L = Math.max($, q, Q, J), H = Math.max(window.innerWidth, window.innerHeight) + 200, M = window.innerWidth >= 3e3 || window.innerHeight >= 2e3, z = M ? 2.5 : 4, Y = M ? Math.min(H * z, 5e3) : H * z, v === k.BLUR_CIRCLE && (B = document.createElement("style"), B.id = C, Z = M ? 1.5 : 1.2, A = Math.max(Y, L * 2.5), B.textContent = `
        ::view-transition-group(root) {
          animation-duration: `.concat(b, `ms;
          animation-timing-function: `).concat(M ? "cubic-bezier(0.2, 0, 0.2, 1)" : "linear(0 0%, 0.2342 12.49%, 0.4374 24.99%,0.6093 37.49%, 0.6835 43.74%,0.7499 49.99%, 0.8086 56.25%,0.8593 62.5%, 0.9023 68.75%, 0.9375 75%,0.9648 81.25%, 0.9844 87.5%,0.9961 93.75%, 1 100%)", `;
          will-change: transform;
        }

        ::view-transition-new(root) {
          mask: `).concat(ue(E * Z), ` 0 0 / 100% 100% no-repeat;
          mask-position: `).concat(m, "px ").concat(h, `px;
          animation: maskScale `).concat(b, "ms ").concat(t, `;
          transform-origin: `).concat(m, "px ").concat(h, `px;
          will-change: mask-size, mask-position;
        }

        ::view-transition-old(root),
        .dark::view-transition-old(root) {
          animation: maskScale `).concat(b, "ms ").concat(t, `;
          transform-origin: `).concat(m, "px ").concat(h, `px;
          z-index: -1;
          will-change: mask-size, mask-position;
        }

        @keyframes maskScale {
          0% {
            mask-size: 0px;
            mask-position: `).concat(m, "px ").concat(h, `px;
          }
          100% {
            mask-size: `).concat(A, `px;
            mask-position: `).concat(m - A / 2, "px ").concat(h - A / 2, `px;
          }
        }
      `), document.head.appendChild(B)), [4, document.startViewTransition(function() {
              Ge(function() {
                O(function(I) {
                  return !I;
                });
              });
            }).ready]);
          case 1:
            return K.sent(), v === k.CIRCLE && document.documentElement.animate({
              clipPath: ["circle(0px at ".concat(m, "px ").concat(h, "px)"), "circle(".concat(L, "px at ").concat(m, "px ").concat(h, "px)")]
            }, {
              duration: b,
              easing: t,
              pseudoElement: l
            }), v === k.QR_SCAN && (W = M ? 8 : 4, document.documentElement.animate({
              clipPath: [
                "polygon(0% 0%, ".concat(W, "px 0%, ").concat(W, "px 100%, 0% 100%)"),
                "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
              ]
            }, {
              duration: b,
              easing: t,
              pseudoElement: l
            })), v === k.BLUR_CIRCLE && setTimeout(function() {
              var I = document.getElementById(C);
              I && I.remove();
            }, b), [
              2
              /*return*/
            ];
        }
      });
    });
  };
  return ae(function() {
    S ? (document.documentElement.classList.add(n), localStorage.theme = "dark") : (document.documentElement.classList.remove(n), localStorage.theme = "light");
  }, [S, n]), {
    ref: D,
    toggleSwitchTheme: me,
    isDarkMode: S
  };
};
const Ke = () => {
  var C;
  const [o, a] = ce(!1), { copyText: e } = Oe(), { handleToggle: s } = se(), { ref: c, toggleSwitchTheme: t, isDarkMode: d } = Ze({
    duration: 750
  }), l = ge(), r = U((u) => u.chat.currentUser), n = U((u) => u.threads.threads), f = P();
  function v() {
    const u = n.find((w) => w.type === ze.SELF);
    if (u) {
      location.pathname !== "/thread" && f("/thread", { replace: !0 }), l(ie(u)), l(oe(!1)), s(!0);
      return;
    }
    l(We()).unwrap().then(({ thread: w }) => {
      l(ie(w)), location.pathname !== "/thread" && f("/thread", { replace: !0 }), s(!0), l(oe(!1));
    }).catch((w) => {
      console.error("Create self thread failed:", w);
    });
  }
  const N = r != null && r.id ? btoa(
    JSON.stringify({
      i: r.id,
      pr: r.id
    })
  ) : "", E = N ? "https://" + window.location.host + "/?uid=" + N : "", _ = [
    {
      title: "اطلاعات کاربری",
      items: [
        {
          icon: /* @__PURE__ */ i(F, {}),
          title: "نام کاربری",
          onClick: () => {
            e((r == null ? void 0 : r.username) || "", "نام کاربری مورد نظر کپی شد");
          },
          subtitle: r == null ? void 0 : r.username
        },
        {
          icon: /* @__PURE__ */ i(be, {}),
          title: "شماره همراه",
          className: "cursor-default select-text",
          subtitle: r == null ? void 0 : r.cellphoneNumber
        },
        {
          icon: /* @__PURE__ */ i(ye, {}),
          title: "لینک من در تاک",
          className: "cursor-default select-text break-all",
          subtitle: E,
          onClick: () => {
            e(`  لینک من در تاک 
` + E || "", "لینک کپی شد");
          }
        },
        {
          icon: /* @__PURE__ */ i(ke, {}),
          title: "درباره من",
          className: "cursor-default select-text",
          subtitle: (C = r == null ? void 0 : r.chatProfileVO) == null ? void 0 : C.bio,
          withBorder: !0
        }
      ]
    },
    {
      title: "دستگاه‌ها و مخاطبین",
      items: [
        {
          icon: /* @__PURE__ */ i(Ce, {}),
          title: "دستگاه‌های فعال",
          to: "/devicesSessions",
          withBorder: !0
        },
        { icon: /* @__PURE__ */ i(F, {}), title: "مخاطبین", to: "/contacts" },
        {
          icon: /* @__PURE__ */ i(Me, {}),
          title: "افزودن مخاطب جدید",
          children: /* @__PURE__ */ i(
            Ve,
            {
              open: o,
              setOpen: a
            }
          ),
          onClick: () => {
            a(!0), s(!0);
          }
        },
        {
          icon: /* @__PURE__ */ i(F, {}),
          title: "کاربران مسدود",
          to: "/blockedUsers",
          withBorder: !0
        }
      ]
    },
    {
      title: "گروه و کانال",
      items: [
        {
          icon: /* @__PURE__ */ i(Ie, {}),
          title: "ایجاد گروه جدید",
          to: "/createGroup/chooseMembers"
        },
        {
          icon: /* @__PURE__ */ i(Ne, {}),
          title: "ایجاد کانال جدید",
          to: "/createChannel/chooseMembers",
          withBorder: !0
        }
      ]
    },
    {
      title: "پیام‌ها",
      items: [
        {
          icon: /* @__PURE__ */ i(Ee, {}),
          title: "صندوق پیام",
          to: "/",
          onClick: v
        },
        { icon: /* @__PURE__ */ i(_e, {}), title: "پوشه بایگانی", to: "/folders" },
        {
          icon: /* @__PURE__ */ i(Se, {}),
          title: "تنظیمات",
          to: "/setting",
          withBorder: !0
        }
      ]
    },
    {
      title: "حالت شب",
      items: [
        {
          icon: /* @__PURE__ */ i(Re, {}),
          type: "theme",
          title: "حالت شب"
        }
      ]
    },
    {
      title: "درباره ما و خروج",
      items: [
        { icon: /* @__PURE__ */ i(Te, {}), title: "درباره ما", to: "/about" },
        {
          icon: /* @__PURE__ */ i(Be, {}),
          title: "سوالات متداول",
          to: "/faq",
          target: "_blank"
        },
        {
          icon: /* @__PURE__ */ i(De, {}),
          title: "خروج",
          children: null,
          onClick: () => l(Ae(!0))
        }
      ]
    }
  ];
  return /* @__PURE__ */ i(we, { children: _.map((u, w) => /* @__PURE__ */ i("div", { children: u.items.map((y, b) => (y == null ? void 0 : y.type) === "theme" ? Le.getState().appConfig.darkModeDisabled ? void 0 : /* @__PURE__ */ i(
    qe,
    {
      icon: y.icon,
      title: y.title,
      isDarkMode: d,
      refProp: c,
      onToggle: () => ne(null, null, function* () {
        l(He(!d)), yield t();
      })
    },
    b
  ) : /* @__PURE__ */ i($e, te({}, y), b)) }, w)) });
}, dt = () => {
  const o = U((l) => l.chat.currentUser), a = P(), { handleToggle: e, showRightMenu: s } = se();
  return /* @__PURE__ */ g("div", { className: `
    rtl  absolute top-[60px] bottom-0 inset-0 z-chatRightMenu   
    ${s ? "pointer-events-auto" : "pointer-events-none"}
  `, children: [
    s && /* @__PURE__ */ i(
      "div",
      {
        onClick: e,
        className: "absolute inset-0 bg-menuAsideOverlay"
      }
    ),
    /* @__PURE__ */ i("div", { className: `
    flex flex-col h-full   absolute top-0 right-0 bottom-0
    w-[80vw] max-w-[260px]
    bg-bgColor shadow-lg
    transition-transform duration-300 ease-in-out
    ${s ? "translate-x-0" : "translate-x-full"}
  `, children: /* @__PURE__ */ g("div", { className: "flex flex-col h-full overflow-hidden", children: [
      /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto scroll-container", children: [
        /* @__PURE__ */ i(Xe, { user: o, onEdit: () => {
          a("/editProfile");
        } }),
        /* @__PURE__ */ i(Ke, {})
      ] }),
      /* @__PURE__ */ i(et, {})
    ] }) })
  ] });
}, Xe = ({ user: o, onEdit: a }) => /* @__PURE__ */ g("div", { className: "flex items-center gap-3 px-3 py-4 border-b border-divider min-h-[64px]", children: [
  /* @__PURE__ */ i(Pe, { firstName: o == null ? void 0 : o.name, image: o == null ? void 0 : o.image, size: "xs" }),
  /* @__PURE__ */ i("div", { className: "flex-1 text-right overflow-hidden", children: /* @__PURE__ */ i("p", { className: "text-invertBlackWhite text-sm truncate", children: o == null ? void 0 : o.name }) }),
  /* @__PURE__ */ i(
    "button",
    {
      className: "flex items-center justify-center text-menuIconColor",
      onClick: a,
      children: /* @__PURE__ */ i(Fe, { width: "20px" })
    }
  )
] }), et = () => /* @__PURE__ */ g("div", { className: "flex justify-center items-center px-4 py-5 bg-bgSecondary text-lightText text-xs", children: [
  "پیام رسان تاک نسخه ",
  Ue
] });
export {
  dt as default
};
