import { chainIds as e } from "../../constants/chains.constants.mjs";
import { getHinkalZkMeProvider as t } from "../../data-structures/Hinkal/hinkalGetZkMeProvider.mjs";
import { openDefaultPassportWindow as n } from "./openDefaultPassportWindow.mjs";
import { ethers as r } from "ethers";
//#region libs/shared/common/src/functions/kyc/zkMeHelper.ts
async function i(e, t) {
	if (e.origin === "https://widget.zk.me") {
		if (e.data.method === "getUserAccounts") {
			let n = await t.getUserAccounts();
			e.source?.postMessage({
				id: e.data.id,
				message: "ok",
				data: n
			}, { targetOrigin: e.origin });
		}
		if (e.data.method === "getAccessToken") {
			let n = await t.getAccessToken();
			e.source?.postMessage({
				id: e.data.id,
				message: "ok",
				data: n
			}, { targetOrigin: e.origin });
		}
		if (e.data.method === "delegateTransaction") {
			let n = e.data.params;
			if (t.delegateTransaction) {
				let r = await t.delegateTransaction(n);
				e.source?.postMessage({
					id: e.data.id,
					message: "ok",
					data: r
				}, { targetOrigin: e.origin });
			}
		}
	}
}
var a = async (a, o, s, c) => {
	let l = t(a), u = await l.getAccessToken(), d = r.toBeHex(e.polygon);
	window.addEventListener("message", (e) => i(e, l)), n(`${s}?mchNo=${c.merchId}&name=HinkalProtocol&chainId=${d}&accessToken=${u}`, o, 700, 510);
};
//#endregion
export { a as zkMeKycHandler };
