import { ExternalActionId as e } from "../../types/external-action.types.mjs";
import { isValidPrivateAddress as t } from "../../functions/utils/addresses.mjs";
import { transactionErrorCodes as n } from "../../error-handling/error-codes.constants.mjs";
import { validateAndGetChainId as r } from "../../functions/utils/token-check.utils.mjs";
import { modifyVolatileTokenAmountChanges as i } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
import { AccountActions as a } from "../AccountActions/AccountActions.mjs";
import { getFeeStructure as o } from "../../functions/pre-transaction/getFeeStructure.mjs";
import { convertEmporiumOpToCallInfo as s } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
import { createTransaferEmporiumOpsBatch as c } from "../../functions/private-wallet/emporium.helpers.mjs";
//#region libs/shared/common/src/data-structures/Hinkal/hinkalProxyToPrivate.ts
var l = async (l, u, d, f, p, m, h, g) => {
	if (!h) throw Error("hinkalProxyToPrivate: subAccount should be provided");
	if (!p) throw Error("Fee token is required in hinkalProxyToPrivate");
	if (!t(f)) throw Error(n.RECIPIENT_FORMAT_INCORRECT);
	let _ = r(u), v = a.getAddressFromSubAccount(_, h);
	if (!v) throw Error("Public account address is not available");
	let y = u.map((e) => e.erc20TokenAddress), b = await i(_, u, d, v), x = c(l, _, y, b), S = m ?? await o(_, p, y, e.Emporium, x.map((e) => s(e, v, _))), C = u.map((e, t) => ({
		token: e,
		amount: -1n * b[t]
	}));
	return l.actionPrivateWallet(_, [u[0]], [0n], [!1], x, C, h, p, S, void 0, void 0, void 0, g, {
		recipientInfo: f,
		amount: b[0],
		token: u[0]
	});
};
//#endregion
export { l as hinkalProxyToPrivate };
