import { networkRegistry as e } from "../../constants/chains.constants.mjs";
import { emitTxPublicData as t } from "../../API/admin-calls.mjs";
import { validateAndGetChainId as n } from "../../functions/utils/token-check.utils.mjs";
import { createCustomSolanaConnection as r } from "../../functions/utils/create-provider.mjs";
import { constructAdminData as i } from "../../functions/pre-transaction/constructAdminData.mjs";
import { AccountActions as a } from "../AccountActions/AccountActions.mjs";
import { sendProxyV0Transaction as o, serializeProxyV0Transaction as s } from "../../functions/pre-transaction/sendV0Transaction.mjs";
import { buildSolanaTransferInstructions as c } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
import { PublicKey as l } from "@solana/web3.js";
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProxySend.ts
var u = async (t, i, o, s) => {
	let u = n([t]), d = a.getAddressFromSubAccount(u, o);
	if (!d) throw Error("Public account address is not available");
	let { fetchRpcUrl: f } = e[u];
	if (!f) throw Error("RPC URL not found for the specified chain ID");
	let p = r(f), m = new l(d), { instructions: h, programId: g } = await c(p, m, new l(s), t, i);
	return {
		connection: p,
		chainId: u,
		senderAddress: d,
		senderPublickey: m,
		programId: g,
		instructions: h
	};
}, d = async (e, n, r, a, s, c) => {
	let [{ connection: l, chainId: d, senderPublickey: f, instructions: p }, m] = await Promise.all([u(n, r, a, s), e.getEthereumAddress()]), h = await o({
		connection: l,
		chainId: d,
		subAccount: a,
		payerPublicKey: f,
		instructions: p
	});
	return t(i(c, d, [n.erc20TokenAddress], [r], m)), h;
}, f = async (e, t, n, r) => {
	let { connection: i, senderPublickey: a, instructions: o } = await u(e, t, n, r);
	return s(i, a, o);
};
//#endregion
export { f as getSolanaProxySendSerializedTransaction, d as hinkalSolanaProxySend };
