import { jsx as e, jsxs as c } from "react/jsx-runtime";
import { Fragment as x } from "react";
import { Menu as I, MenuButton as _, MenuItems as C, MenuItem as m } from "@headlessui/react";
import { ChevronLeftW700 as p } from "@material-symbols-svg/react-rounded/icons/chevron-left";
import { AnimatePresence as k, motion as A } from "framer-motion";
import { I as M, d as v, G as O } from "../../config-D-Ik_SSx.js";
import { Hr as T } from "../../components/Hr.js";
import { AllNetworksIcon as E } from "../../components/AllNetworksIcon.js";
import { notReachable as h } from "../../utils/notReachable.js";
import { useTypedTranslation as S } from "../../localisation.js";
import { NEAR_INTENTS_ICON as F, CHAIN_ICONS as z, UNKNOWN_ICON as j } from "../../icons/index.js";
import { getThemeCssVariables as H } from "../../theme/getThemeCssVariables.js";
import { ChainItem as d } from "./ChainItem.js";
const Y = ({
  variant: w,
  selected: n,
  chainsFilter: u,
  onMsg: a
}) => {
  const { t: f } = S(), g = M(), b = H(g), s = v(w), { enableAccountAbstraction: y } = O(), o = y && u.intents !== "none";
  return s.length + (o ? 1 : 0) < 2 ? null : /* @__PURE__ */ e(I, { children: ({ open: N, close: i }) => /* @__PURE__ */ c("div", { children: [
    /* @__PURE__ */ e(_, { as: x, children: ({ open: t }) => /* @__PURE__ */ c("div", { className: "py-sw-sm pr-sw-md pl-sw-lg gap-sw-xs flex h-[36px] cursor-pointer items-center rounded-sw-md bg-sw-gray-800 hover:bg-sw-gray-700", children: [
      /* @__PURE__ */ e("span", { className: "text-sw-label-md text-sw-gray-50", children: f("chain.more.label", "More") }),
      t ? /* @__PURE__ */ e(
        p,
        {
          size: 18,
          className: "text-sw-gray-50 rotate-90"
        }
      ) : /* @__PURE__ */ e(
        p,
        {
          size: 18,
          className: "text-sw-gray-50 -rotate-90"
        }
      )
    ] }) }),
    /* @__PURE__ */ e(k, { children: N && /* @__PURE__ */ e(
      C,
      {
        static: !0,
        anchor: { to: "bottom end", gap: 8, padding: 32 },
        style: b,
        className: "sw hide-scrollbar overflow-y-auto z-10 max-h-[400px] min-w-[200px] rounded-sw-lg bg-sw-gray-800 shadow-[0_6px_48px_0_rgba(36,38,45,0.3)] ring-1 ring-inset ring-sw-gray-700 outline-none",
        children: /* @__PURE__ */ c(
          A.div,
          {
            animate: { opacity: 1, scale: 1 },
            initial: { opacity: 0, scale: 0.95 },
            className: "flex w-full flex-col gap-sw-xxs p-sw-md",
            children: [
              s.length > 1 && /* @__PURE__ */ e(m, { children: ({ focus: t }) => /* @__PURE__ */ e(
                d,
                {
                  chain: "all",
                  label: "All networks",
                  isSelected: n === "all",
                  isFocused: t,
                  icon: /* @__PURE__ */ e(E, {}),
                  iconClassName: "bg-sw-gray-50",
                  onMsg: (r) => {
                    switch (r.type) {
                      case "on_click_chain":
                        i(), a(r);
                        break;
                      default:
                        h(r.type, { throwError: !1 });
                    }
                  }
                }
              ) }),
              o && /* @__PURE__ */ e(m, { children: ({ focus: t }) => /* @__PURE__ */ e(
                d,
                {
                  chain: "intents",
                  label: "Near Intents",
                  isSelected: n === "intents",
                  isFocused: t,
                  icon: F,
                  onMsg: (r) => {
                    switch (r.type) {
                      case "on_click_chain":
                        i(), a(r);
                        break;
                      default:
                        h(r.type, { throwError: !1 });
                    }
                  }
                }
              ) }),
              !!s.length && !!(s.length > 1 || o) && /* @__PURE__ */ e(T, { className: "shrink-0 my-sw-sm bg-sw-gray-700" }),
              s.map((t) => /* @__PURE__ */ e(m, { children: ({ focus: r }) => /* @__PURE__ */ e(
                d,
                {
                  chain: t.id,
                  label: t.label,
                  icon: z[t.id] ?? j,
                  isSelected: n === t.id,
                  isFocused: r,
                  onMsg: (l) => {
                    switch (l.type) {
                      case "on_click_chain":
                        i(), a(l);
                        break;
                      default:
                        h(l.type, {
                          throwError: !1
                        });
                    }
                  }
                }
              ) }, t.id))
            ]
          }
        )
      }
    ) })
  ] }) });
};
export {
  Y as ChainsDropdown
};
//# sourceMappingURL=index.js.map
