var f = (n, s, e) => new Promise((t, u) => {
  var r = (a) => {
    try {
      i(e.next(a));
    } catch (o) {
      u(o);
    }
  }, h = (a) => {
    try {
      i(e.throw(a));
    } catch (o) {
      u(o);
    }
  }, i = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(r, h);
  i((e = e.apply(n, s)).next());
});
import { jsx as c, jsxs as x } from "react/jsx-runtime";
import { useRef as w, useState as m, useEffect as T } from "react";
import { g, h as y, eS as C, fg as b, x as M, e as N, aF as v, fj as R, ac as $, aa as j, ad as I, ah as S } from "./main-CxoAwMiG.js";
const k = () => {
  const n = g(), s = y(
    (t) => t.setting.showRightMenu
  );
  return { showRightMenu: s, handleToggle: (t) => {
    n(C(t === !0 ? !1 : !s));
  } };
}, O = () => {
  const n = w(null), { handleToggle: s, showRightMenu: e } = k(), t = "absolute block w-4 h-[2px] rounded bg-white transition-all duration-300 ease-in-out";
  return /* @__PURE__ */ c("div", { ref: n, children: /* @__PURE__ */ x(
    "button",
    {
      onClick: () => s(),
      "aria-label": e ? "Close menu" : "Open menu",
      "aria-expanded": e,
      className: "relative flex justify-center items-center w-9 h-9 m-[5px] rounded-md bg-asideHeadBg cursor-pointer",
      children: [
        /* @__PURE__ */ c(
          "span",
          {
            className: `${t} ${e ? "rotate-45" : "-translate-y-[6px]"}`
          }
        ),
        /* @__PURE__ */ c(
          "span",
          {
            className: `${t} ${e ? "opacity-0" : "opacity-100"}`
          }
        ),
        /* @__PURE__ */ c(
          "span",
          {
            className: `${t} ${e ? "-rotate-45" : "translate-y-[6px]"}`
          }
        )
      ]
    }
  ) });
}, q = () => {
  const [n] = b(), s = M(), e = g(), { showToast: t } = S(), [u, r] = m(!1), [h, i] = m(!1);
  let a = n.get("tn");
  const o = n.get("state");
  if (o && !a && o.startsWith("tn_")) {
    const l = o.match(/tn_(.*?)_-_/);
    a = l ? l[1] : null;
  }
  T(() => {
    a && r(!0);
  }, [a]);
  const p = () => f(null, null, function* () {
    if (a) {
      if (!v()) {
        d();
        return;
      }
      i(!0);
      try {
        const l = yield e(
          R({ uniqueName: a })
        ).unwrap();
        e($(l.thread)), e(j(!1)), e(I("threadInfo")), r(!1), s("/thread", { replace: !0 });
      } catch (l) {
        t(l || "خطا در ملحق شدن به گروه", "error", {
          containerId: "link-toaster"
        });
      } finally {
        i(!1);
      }
    }
  }), d = () => {
    r(!1), s("/", { replace: !0 });
  };
  return a ? /* @__PURE__ */ c(
    N,
    {
      open: u,
      onOpenChange: r,
      title: "از ملحق شدن به گروه مطمئنید؟",
      confirmText: "بله",
      cancelText: "انصراف",
      onConfirm: p,
      onCancel: d,
      size: "sm",
      closable: !1,
      children: /* @__PURE__ */ c("div", { className: "mt-4 h-6 text-invertBlackWhite", children: h ? "در حال ملحق شدن به گروه..." : "" })
    }
  ) : null;
};
export {
  O as H,
  q as J,
  k as u
};
