import "../../constants/protocol.constants.mjs";
import { PublicKey as e, SystemProgram as t } from "@solana/web3.js";
import { TOKEN_2022_PROGRAM_ID as n, TOKEN_PROGRAM_ID as r, createAssociatedTokenAccountInstruction as i, createTransferCheckedInstruction as a, createTransferInstruction as o, getAssociatedTokenAddress as s } from "@solana/spl-token";
//#region libs/shared/common/src/functions/pre-transaction/solanaTransfer.utils.ts
var c = async (c, l, u, d, f) => {
	let { erc20TokenAddress: p, is2022Program: m, decimals: h } = d, g = [];
	if (p === "11111111111111111111111111111111") return g.push(t.transfer({
		fromPubkey: l,
		toPubkey: u,
		lamports: Number(f)
	})), {
		instructions: g,
		programId: t.programId
	};
	let _ = m ? n : r, v = new e(p), y = await s(v, l, !0, _), b = await s(v, u, !0, _);
	return await c.getAccountInfo(b) || g.push(i(l, b, u, v, _)), m ? g.push(a(y, v, b, l, f, h, [], _)) : g.push(o(y, b, l, f, [], _)), {
		instructions: g,
		programId: _
	};
};
//#endregion
export { c as buildSolanaTransferInstructions };
