import { networkRegistry as e } from "../../constants/chains.constants.mjs";
import { validateAndGetChainId as t } from "../../functions/utils/token-check.utils.mjs";
import { createCustomSolanaConnection as n } from "../../functions/utils/create-provider.mjs";
import { constructAdminData as r } from "../../functions/pre-transaction/constructAdminData.mjs";
import { AccountActions as i } from "../AccountActions/AccountActions.mjs";
import { sendProxyV0Transaction as a } from "../../functions/pre-transaction/sendV0Transaction.mjs";
import { emitTxPublicData as o } from "../../API/admin-calls.mjs";
import { buildSolanaTransferInstructions as s } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
import { PublicKey as c } from "@solana/web3.js";
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaProxySend.ts
var l = async (r, a, o, l) => {
	let u = t([r]), d = i.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 = n(f), m = new c(d), { instructions: h, programId: g } = await s(p, m, new c(l), r, a);
	return {
		connection: p,
		chainId: u,
		senderAddress: d,
		senderPublickey: m,
		programId: g,
		instructions: h
	};
}, u = async (e, t, n, i, s, c) => {
	let [{ connection: u, chainId: d, senderPublickey: f, instructions: p }, m] = await Promise.all([l(t, n, i, s), e.getEthereumAddress()]), h = await a({
		connection: u,
		chainId: d,
		subAccount: i,
		payerPublicKey: f,
		instructions: p
	});
	return o(r(c, d, [t.erc20TokenAddress], [n], m)), h;
};
//#endregion
export { u as hinkalSolanaProxySend };
