const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_context = require("./context.js");
const require_utils = require("./utils.js");
const require_hooks = require("./hooks.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/pay/toB/store/provider.tsx
const ToBPayProvider = ({ children }) => {
	const osPayment = require_hooks.useOSPayment();
	const [order, setOrder] = (0, react.useState)({});
	const [orderInfo, setOrderInfo] = (0, react.useState)({});
	const [payMethodGroupList, setPayMethodGroupList] = (0, react.useState)([]);
	const contextValue = {
		order,
		setOrder,
		orderInfo,
		setOrderInfo,
		payMethodGroupList,
		setPayMethodGroupList,
		getPayMethodList: function() {
			var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
				if (!osPayment) {
					setPayMethodGroupList([]);
					console.error("osPayment is not initialized");
					return;
				}
				try {
					const payMethodList = yield osPayment.getPayMethodListAsync();
					console.log("payMethodList", payMethodList);
					setPayMethodGroupList(require_utils.handlePayMethodList(payMethodList));
				} catch (error) {
					console.error(error);
				}
			});
			return function getPayMethodList() {
				return _ref.apply(this, arguments);
			};
		}()
	};
	return /* @__PURE__ */ react.default.createElement(require_context.ToBPayContext.Provider, { value: contextValue }, children);
};
//#endregion
exports.ToBPayProvider = ToBPayProvider;
