import { safeJsonStringify as e } from "../functions/utils/serialize.utils.mjs";
import { httpClient as t } from "../data-structures/http/HttpClient.mjs";
import { Logger as n } from "../error-handling/logger.mjs";
import { Connection as r } from "@solana/web3.js";
//#region libs/shared/common/src/providers/CustomSolanaConnection.ts
var i = class extends r {
	constructor(r, i = "confirmed") {
		let a = async (r, i) => {
			let a;
			a = typeof r == "string" ? r : r instanceof URL ? r.toString() : r.url;
			let o = typeof i?.body == "string" ? i.body : null, s = o ? JSON.parse(o) : {};
			try {
				let n = await t.post(a, s);
				if (n.error) throw Error(n.error.message || "RPC Error");
				return new Response(e(n), {
					status: 200,
					statusText: "OK",
					headers: { "Content-Type": "application/json" }
				});
			} catch (e) {
				throw n.error(`Solana RPC Error [${s.method}]:`, e), e;
			}
		}, o = {
			...typeof i == "object" ? i : {},
			fetch: a
		};
		super(r, o);
	}
};
//#endregion
export { i as CustomSolanaConnection };
