import { jsxs as t, jsx as o, Fragment as x } from "react/jsx-runtime";
import { entryPointToHumanReadable as C, formatTruncatedAddress as s } from "@argent/x-shared";
import { useColorMode as A, Box as a, Accordion as k, AccordionItem as w, AccordionButton as T, AccordionPanel as W, Divider as v, Flex as b } from "@chakra-ui/react";
import { useMemo as D } from "react";
import { useTranslation as R } from "react-i18next";
import { CallData as _, num as B } from "starknet";
import { CopyTooltip as O } from "../CopyTooltip.js";
import { P3 as d } from "../typography.generated.js";
const V = ({ transactions: r, type: g = "INVOKE_FUNCTION" }) => {
  const { t: c } = R(), { colorMode: p } = A(), e = D(() => p === "dark", [p]);
  return /* @__PURE__ */ t(a, { borderRadius: "xl", w: "100%", children: [
    /* @__PURE__ */ o(a, { backgroundColor: e ? "neutrals.700" : "gray.50", px: "3", py: "2.5", borderTopRadius: "xl", children: /* @__PURE__ */ o(d, { fontWeight: "bold", color: e ? "neutrals.100" : "black", children: c("transactionActions.actions") }) }),
    /* @__PURE__ */ o(k, { allowToggle: !0, backgroundColor: e ? "neutrals.300" : "white", borderBottomRadius: "xl", children: r == null ? void 0 : r.map((l, n) => {
      var h;
      return /* @__PURE__ */ o(w, { border: "none", isDisabled: !l.calldata || ((h = l.calldata) == null ? void 0 : h.length) === 0, children: ({ isDisabled: f, isExpanded: y }) => {
        var u;
        return /* @__PURE__ */ t(x, { children: [
          /* @__PURE__ */ o("h2", { children: /* @__PURE__ */ t(
            T,
            {
              display: "flex",
              color: "text-primary",
              width: "100%",
              justifyContent: "space-between",
              outline: "none",
              px: "3",
              pb: n !== r.length - 1 ? "3" : "3.5",
              _expanded: {
                backgroundColor: e ? "neutrals.700" : "gray.50",
                pb: "3.5"
              },
              disabled: !l.calldata || ((u = l.calldata) == null ? void 0 : u.length) === 0,
              _disabled: {
                cursor: "auto",
                opacity: 1
              },
              _hover: {
                backgroundColor: f ? "" : e ? "neutrals.700" : "gray.50",
                borderBottomRadius: n === r.length - 1 && !y ? "xl" : "0"
              },
              children: [
                /* @__PURE__ */ o(d, { fontWeight: "bold", children: g === "DEPLOY_ACCOUNT" && r.length === 1 ? c("transactionActions.activateAccount") : C(l.entrypoint) }),
                /* @__PURE__ */ o(d, { fontWeight: "bold", children: s(l.contractAddress) })
              ]
            }
          ) }),
          /* @__PURE__ */ t(W, { backgroundColor: e ? "neutrals.700" : "gray.50", borderBottomRadius: n === r.length - 1 ? "xl" : "0", px: "3", pb: "0", children: [
            /* @__PURE__ */ o(v, { color: "black", opacity: "1" }),
            /* @__PURE__ */ o(b, { flexDirection: "column", gap: "12px", py: "3.5", children: _.toCalldata(l.calldata).map((i, m) => /* @__PURE__ */ t(b, { justifyContent: "space-between", gap: "2", children: [
              /* @__PURE__ */ t(d, { fontWeight: "bold", color: "text-primary", children: [
                c("transactionActions.calldata"),
                m + 1
              ] }),
              /* @__PURE__ */ o(O, { copyValue: i, prompt: i, children: /* @__PURE__ */ o(a, { _hover: {
                backgroundColor: e ? "neutrals.700" : "gray.50",
                color: "text-primary",
                cursor: "pointer"
              }, color: "text-primary", whiteSpace: "nowrap", textOverflow: "ellipsis", overflow: "hidden", minWidth: "0", children: /* @__PURE__ */ o(d, { fontWeight: "bold", maxWidth: "70%", children: B.isHex(i) ? s(i) : i }) }) })
            ] }, m)) })
          ] })
        ] });
      } }, n);
    }) })
  ] });
};
export {
  V as TransactionActions
};
