require("../../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_useEngineContext = require("../../../../../hooks/useEngineContext.js");
const require_utils = require("../../utils.js");
const require_model = require("../../model.js");
const require_usePaymentLogger = require("../../../../../hooks/usePaymentLogger.js");
let react = require("react");
require("./index.less");
//#region src/components/pay/toC/PaymentMethods/BankDeposit/index.tsx
/**
* @title: 银行转账
* @description:
* @param {BankDepositProps} props
* @param {React} ref
* @return {*}
* @Author: zhiwei.Wang
* @Date: 2024-08-16 10:59
*/
const BankDeposit = (props, ref) => {
	var _context$appHelper, _context$appHelper2, _state$payGroup;
	const { state, dispatch } = (0, react.useContext)(require_model.Context);
	const context = require_useEngineContext.default();
	const { config } = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.constants) || {};
	const { interaction, storage } = ((_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils) || {};
	const paymentLogger = require_usePaymentLogger.default({
		orderId: ((_state$payGroup = state.payGroup) === null || _state$payGroup === void 0 ? void 0 : _state$payGroup.order_id) || "unknown",
		step: "2"
	});
	/**
	* @title: 初始化
	* @description:
	* @param {any} param1
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-08-16 11:00
	*/
	const init = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ payGroup }) {
			paymentLogger.addLog({
				key: "BankDeposit初始化开始",
				value: ""
			});
			try {
				var _context$appHelper3;
				const platform = ((_context$appHelper3 = context.appHelper) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.constants) === null || _context$appHelper3 === void 0 ? void 0 : _context$appHelper3.platform) || "h5";
				let _item = payGroup === null || payGroup === void 0 ? void 0 : payGroup.otherPayment;
				paymentLogger.addLog({
					key: "BankDeposit平台检测",
					value: ""
				});
				if (platform === "pc") {
					paymentLogger.addLog({
						key: "BankDepositPC处理",
						value: ""
					});
					state.payCallback({
						key: _item.service,
						data: {
							order_id: payGroup.order_id,
							payment_method: _item.title
						}
					});
					paymentLogger.sendLogs("BankDepositPC处理成功");
					return;
				}
				let _href = `${require_utils.formatFranchiseeRoute(`/pay/manual-transfer?id=${(payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id) || (payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id)}`, state.history)}`;
				paymentLogger.addLog({
					key: "BankDepositH5准备跳转",
					value: ""
				});
				paymentLogger.sendLogs("BankDepositH5跳转成功");
				if (require_utils.isMiniProgram(interaction)) _href = `/${storage.get("umi_locale") || "en"}${_href}`;
				window.location.href = _href;
			} catch (err) {
				paymentLogger.addLog({
					key: "BankDeposit处理错误",
					value: {
						title: `订单${payGroup === null || payGroup === void 0 ? void 0 : payGroup.order_id} BankDeposit处理失败: ${(err === null || err === void 0 ? void 0 : err.message) || "未知错误"}`,
						data: { payGroup }
					}
				});
				paymentLogger.sendLogs("BankDeposit处理失败", err);
			}
		});
		return function init(_x) {
			return _ref.apply(this, arguments);
		};
	}();
	(0, react.useImperativeHandle)(ref, () => ({ init }));
	return null;
};
var BankDeposit_default = (0, react.forwardRef)(BankDeposit);
//#endregion
exports.default = BankDeposit_default;
