const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_const = require("../../const.js");
const require_index = require("../../store/index.js");
const require_hooks = require("../../hooks.js");
const require_manufacturer = require("../../manufacturer.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/eftposPay/component/prompt/index.tsx
/**
* @title: 支付状态未知页面
* @description:
* @Author: hongbing.wang
* @Date: 2024-08-20 11:42
*/
var prompt_default = ({ onChange, className = "" }) => {
	const [prompt, setPrompt] = (0, react.useState)(0);
	const { eftpos, mode, name, symbol, amount, order_id, number, device, client, originalParams } = require_index.useContextData();
	const dispatch = require_index.useDispatch();
	const [disabled, setDisabled] = (0, react.useState)(false);
	const { time, isRunning, start, cancel } = require_hooks.useCountdown(30);
	const onNotin = () => {
		setPrompt(2);
		onChange("print", [], "print_on_timeout");
	};
	const onClose = () => {
		setDisabled(true);
		cancel();
		onChange("print", [], "back_home");
	};
	(0, react.useEffect)(() => {
		if (isRunning && time === 0) onChange("print", [], "back_home");
	}, [time, isRunning]);
	(0, react.useEffect)(() => {
		if (prompt === 2) start();
	}, [prompt]);
	/**
	* @title: 重新支付
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:30
	*/
	const onRetry = () => {
		onChange("page", "pay");
		const params = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, originalParams || {}), {}, {
			mode,
			name,
			symbol,
			amount,
			order_id,
			client
		});
		if (mode !== require_const.ModeEnum.Query) params.number = "";
		dispatch(require_index.updateState(require_manufacturer.getInitState(eftpos, params)));
	};
	const context = (0, react.useMemo)(() => {
		if (prompt === 0) return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode__eft-pay-body",
			style: {
				display: "flex",
				flexDirection: "column",
				gap: "16px"
			}
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			type: "info",
			className: "pisell-lowcode__eft-pay-alert",
			showIcon: true,
			message: _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.title")
		}), /* @__PURE__ */ react.default.createElement("h3", {
			style: { margin: 0 },
			className: "pisell-lowcode__eft-pay-notion-title"
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.h1")), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.text")), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			className: "pisell-lowcode__eft-pay-alert",
			message: _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.info")
		})), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
			block: true,
			type: "primary",
			className: "pisell-lowcode__eft-pay-step-item-btn",
			onClick: () => {
				setPrompt(1);
			}
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.check.btn")), /* @__PURE__ */ react.default.createElement(antd.Button, {
			block: true,
			className: "pisell-lowcode__eft-pay-step-item-btn",
			onClick: onRetry
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.ask.again.btn"))));
		if (prompt === 1) return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode__eft-pay-body",
			style: {
				display: "flex",
				flexDirection: "column",
				gap: "16px"
			}
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			type: "success",
			className: "pisell-lowcode__eft-pay-alert",
			showIcon: true,
			message: "Let’s check it together!"
		}), /* @__PURE__ */ react.default.createElement("h3", {
			style: { margin: 0 },
			className: "pisell-lowcode__eft-pay-notion-title"
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.title")), /* @__PURE__ */ react.default.createElement("div", { style: {
			display: "flex",
			flexDirection: "column",
			gap: "16px"
		} }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.text-1")), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.text-2")), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.text-3"))), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			className: "pisell-lowcode__eft-pay-alert",
			type: "info",
			message: _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.info")
		})), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
			block: true,
			type: "primary",
			className: "pisell-lowcode__eft-pay-step-item-btn",
			onClick: onNotin
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.success.btn")), /* @__PURE__ */ react.default.createElement(antd.Button, {
			block: true,
			className: "pisell-lowcode__eft-pay-step-item-btn",
			onClick: onRetry
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.submit.again.btn"))));
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode__eft-pay-body",
			style: {
				display: "flex",
				flexDirection: "column",
				gap: "16px"
			}
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			type: "success",
			className: "pisell-lowcode__eft-pay-alert",
			showIcon: true,
			message: _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.title")
		}), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAlert, {
			type: "success",
			className: "pisell-lowcode__eft-pay-alert",
			message: _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.info")
		}), /* @__PURE__ */ react.default.createElement("h3", {
			className: "pisell-lowcode__eft-pay-notion-title",
			style: { margin: 0 }
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.h1")), /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.text-1")), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-notion-text" }, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.text-2")))), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
			type: "primary",
			block: true,
			disabled: disabled || time === 0,
			className: "pisell-lowcode__eft-pay-step-item-btn",
			onClick: onClose
		}, _pisell_utils.locales.getText("page.eftpos-pay.text.prompt.notion.btn"), !disabled && time ? `(${time}s)` : "")));
	}, [
		prompt,
		time,
		disabled
	]);
	return /* @__PURE__ */ react.default.createElement("div", { className: `pisell-lowcode__eft-pay-box ${className}` }, context);
};
//#endregion
exports.default = prompt_default;
