const require_runtime = 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_locales = require("../../locales.js");
const require_useToast = require("../../../../hooks/useToast.js");
const require_index = require("../PaymentDetailModal/index.js");
const require_PisellPriceKeyboardPopover = require("../../../../pro/pisellSimplePriceKeyboardPopover/PisellPriceKeyboardPopover.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let decimal_js = require("decimal.js");
decimal_js = require_runtime.__toESM(decimal_js);
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let _ant_design_icons = require("@ant-design/icons");
let _pisell_icon = require("@pisell/icon");
require("./index.less");
//#region src/components/checkout/components/AmountSummary/index.tsx
const ChevronSelectorVertical = ({ style }) => /* @__PURE__ */ react.default.createElement("svg", {
	width: "36",
	height: "36",
	viewBox: "0 0 36 36",
	fill: "none",
	xmlns: "http://www.w3.org/2000/svg",
	style
}, /* @__PURE__ */ react.default.createElement("path", {
	d: "M21 15L18 12L15 15M15 21L18 24L21 21",
	stroke: "currentColor",
	strokeWidth: "2",
	strokeLinecap: "round",
	strokeLinejoin: "round"
}));
function AmountSummary({ amountSymbol = "$", orderInfo, open_deposit = false, customAmount, balanceDueAmount, clientInfo, onAmountChange, onDepositStatusChange, onBalanceDueAmountClick, onConfirm, paymentItems, cartData, walletPassData, totalAmount = 0 }) {
	var _context$appHelper;
	const context = require_useEngineContext.default();
	const { pisellos, action, token, store, getApp } = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils;
	const Toast = require_useToast.default();
	const getText = (key, fallback) => {
		var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4, _checkoutLocales;
		const checkoutText = (_checkoutLocales = require_locales.default[((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut2 = _context$appHelper$ut2.locales) === null || _context$appHelper$ut2 === void 0 || (_context$appHelper$ut3 = _context$appHelper$ut2.getLocale) === null || _context$appHelper$ut3 === void 0 ? void 0 : _context$appHelper$ut3.call(_context$appHelper$ut2)) || ((_context$appHelper$ut4 = context.appHelper.utils) === null || _context$appHelper$ut4 === void 0 || (_context$appHelper$ut4 = _context$appHelper$ut4.storage) === null || _context$appHelper$ut4 === void 0 ? void 0 : _context$appHelper$ut4.get("umi_locale")) || "en"]) === null || _checkoutLocales === void 0 ? void 0 : _checkoutLocales[key];
		if (checkoutText) return checkoutText;
		return _pisell_utils.locales.getText(key) || fallback;
	};
	const [paymentType, setPaymentType] = (0, react.useState)("regular");
	const [isPaymentDetailOpen, setIsPaymentDetailOpen] = (0, react.useState)(false);
	const [summaryData, setSummaryData] = (0, react.useState)([]);
	const [partialPaidAmount, setPartialPaidAmount] = (0, react.useState)("0");
	const checkoutModule = pisellos.getModule("checkout");
	const [isKeyboardVisible, setIsKeyboardVisible] = (0, react.useState)(false);
	const labelMaps = {
		deposit: getText("pisell2.subtotal.deposit") || "Deposit",
		total: getText("pisell2.subtotal.total") || "Total",
		sub_total: getText("pisell2.subtotal.subtotal") || "Subtotal",
		tax: getText("pisell2.subtotal.tax") || "Tax",
		delivery_fee: getText("pisell2.subtotal.delivery-fee") || "Delivery Fee",
		discount: getText("pisell2.subtotal.discount") || "Discount",
		point_deduction: getText("pisell2.subtotal.point-deduction") || "Point Deduction",
		member_deduction: getText("pisell2.subtotal.member-deduction") || "Member Deduction",
		expect_amount: getText("pisell2.subtotal.expect-amount") || "Expected Amount"
	};
	const getBalanceDueAmount = () => {
		if (paymentType === "deposit") return (orderInfo === null || orderInfo === void 0 ? void 0 : orderInfo.depositAmount) || "0";
		return (paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.reduce((acc, item) => {
			if (item.isSynced || !item.voucher_id) return acc;
			return acc.plus(item.amount);
		}, new decimal_js.default(0)).toNumber()) || 0;
	};
	const parseFormattedAmount = (formattedAmount) => {
		if (typeof formattedAmount === "number") return formattedAmount;
		if (typeof formattedAmount === "string") {
			const numericString = formattedAmount.replace(/[^-0-9.]/g, "");
			try {
				return new decimal_js.default(numericString || "0").toNumber();
			} catch (_unused) {
				return 0;
			}
		}
		return 0;
	};
	const [currentAmount, setCurrentAmount] = (0, react.useState)(customAmount && customAmount !== "" ? customAmount : parseFormattedAmount(getBalanceDueAmount()));
	(0, react.useEffect)(() => {
		if (customAmount && customAmount !== "") setCurrentAmount(customAmount);
	}, [customAmount]);
	(0, react.useEffect)(() => {
		if (checkoutModule && orderInfo) try {
			const summary = checkoutModule.getCartSummary();
			if (Array.isArray(summary)) setSummaryData(summary);
			setPaymentType(orderInfo.isDeposit ? "deposit" : "regular");
		} catch (error) {
			console.warn("Failed to get cart summary:", error);
		}
	}, [checkoutModule, orderInfo]);
	(0, react.useEffect)(() => {
		if (summaryData.length > 0 && (!customAmount || customAmount === "")) setCurrentAmount(parseFormattedAmount(getBalanceDueAmount()));
	}, [summaryData, customAmount]);
	(0, react.useEffect)(() => {
		var _paymentItems$reduce;
		setPartialPaidAmount((paymentItems === null || paymentItems === void 0 || (_paymentItems$reduce = paymentItems.reduce((acc, item) => {
			if (!item.voucher_id || item.voucher_id && item.isSynced) {
				let itemAmount = new decimal_js.default(item.amount || "0");
				if (item.rounding_amount) {
					const roundingAmount = new decimal_js.default(item.rounding_amount);
					if (roundingAmount.isNegative()) {
						itemAmount = itemAmount.plus(roundingAmount.abs());
						console.log("添加抹零金额到已付:", roundingAmount.abs().toNumber(), "项目:", item);
					}
				}
				return acc.plus(itemAmount);
			}
			return acc;
		}, new decimal_js.default(0))) === null || _paymentItems$reduce === void 0 ? void 0 : _paymentItems$reduce.toNumber()) || 0);
	}, [paymentItems]);
	const paymentOptions = [{
		key: "regular",
		label: /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("amount-summary-dropdown-option") }, /* @__PURE__ */ react.default.createElement(_ant_design_icons.CheckCircleOutlined, { className: (0, classnames.default)("dropdown-icon") }), getText("regular.payment") || "普通支付")
	}, {
		key: "deposit",
		label: /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("amount-summary-dropdown-option") }, /* @__PURE__ */ react.default.createElement(_ant_design_icons.PieChartOutlined, { className: (0, classnames.default)("dropdown-icon") }), getText("deposit.payment") || "定金支付")
	}];
	const handlePaymentTypeChange = (key) => {
		const newPaymentType = key;
		setPaymentType(newPaymentType);
		if (onDepositStatusChange) onDepositStatusChange(newPaymentType === "deposit");
	};
	const handleMoreClick = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
			setIsPaymentDetailOpen(true);
		});
		return function handleMoreClick() {
			return _ref.apply(this, arguments);
		};
	}();
	const handlePaymentDetailClose = () => {
		setIsPaymentDetailOpen(false);
	};
	const getPaymentButtonClassName = () => {
		return (0, classnames.default)(open_deposit ? "payment-button-with-dropdown" : "payment-button-without-dropdown", paymentType === "deposit" ? "payment-button-deposit" : "payment-button-regular");
	};
	const shouldShowPartialPaidCard = () => {
		var _paymentItems$reduce2;
		const partialPaidAmountDecimal = new decimal_js.default(partialPaidAmount || "0");
		const voucherPaymentAmount = (paymentItems === null || paymentItems === void 0 || (_paymentItems$reduce2 = paymentItems.reduce((acc, item) => {
			if (item.voucher_id && !item.isSynced) try {
				const amount = new decimal_js.default(item.amount || "0");
				const roundingAmount = new decimal_js.default(item.rounding_amount || "0");
				return acc.plus(amount).plus(roundingAmount);
			} catch (_unused5) {
				return acc;
			}
			return acc;
		}, new decimal_js.default(0))) === null || _paymentItems$reduce2 === void 0 ? void 0 : _paymentItems$reduce2.toNumber()) || 0;
		const totalPaidAmount = partialPaidAmountDecimal.plus(voucherPaymentAmount).toNumber();
		const syncedPaymentItems = (paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.filter((item) => item.isSynced && !item.voucher_id)) || [];
		if ((syncedPaymentItems === null || syncedPaymentItems === void 0 ? void 0 : syncedPaymentItems.length) > 0 && totalPaidAmount < totalAmount) return true;
		if (totalPaidAmount >= totalAmount) return false;
		return partialPaidAmountDecimal.toNumber() > 0;
	};
	const renderSummaryItems = () => {
		if (!summaryData || summaryData.length === 0) return null;
		const maxVisibleItems = shouldShowPartialPaidCard() ? 2 : 3;
		return (summaryData.length > maxVisibleItems ? summaryData.slice(0, maxVisibleItems) : summaryData).map((item) => {
			const displayLabel = item.label || labelMaps[item.key] || item.key;
			return /* @__PURE__ */ react.default.createElement("div", {
				key: item.key,
				className: (0, classnames.default)("payment-detail-row")
			}, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("payment-detail-label") }, displayLabel), /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("payment-detail-amount") }, (0, _pisell_utils.formatAmountWithOptions)(item.value, amountSymbol, {
				precision: 2,
				hideDecimalForWholeNumbers: false,
				useThousandsSeparator: true,
				showCurrencySymbol: true
			})));
		});
	};
	const hasMoreItems = () => {
		if (!summaryData) return false;
		const maxVisibleItems = shouldShowPartialPaidCard() ? 2 : 3;
		return summaryData.length > maxVisibleItems;
	};
	const shouldShowConfirmMode = () => {
		if (!customAmount) return false;
		let amount;
		try {
			amount = new decimal_js.default(customAmount).toNumber();
		} catch (_unused6) {
			return false;
		}
		if (amount <= 0) {
			var _walletPassData$selec, _walletPassData$selec2;
			const unSyncedPaymentItems = paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.filter((item) => !item.isSynced);
			return (unSyncedPaymentItems === null || unSyncedPaymentItems === void 0 ? void 0 : unSyncedPaymentItems.every((item) => item.voucher_id)) || ((_walletPassData$selec = walletPassData === null || walletPassData === void 0 || (_walletPassData$selec2 = walletPassData.selectedDiscountList) === null || _walletPassData$selec2 === void 0 ? void 0 : _walletPassData$selec2.length) !== null && _walletPassData$selec !== void 0 ? _walletPassData$selec : 0) > 0;
		}
		return false;
	};
	const handleConfirmClick = () => {
		if (onConfirm) onConfirm();
	};
	const handleVoidPayment = function() {
		var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (paymentItem) {
			console.log("Void payment:", paymentItem);
			yield checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.deletePaymentItemAsync(paymentItem.uuid);
			console.log("支付项已删除");
		});
		return function handleVoidPayment(_x) {
			return _ref2.apply(this, arguments);
		};
	}();
	const renderConfirmMode = () => {
		let balanceDecimal = new decimal_js.default(parseFormattedAmount(getBalanceDueAmount()));
		const syncedVoucherAmount = paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.reduce((acc, item) => {
			if ((item.isSynced || item.voucher_id) && (paymentType === "regular" && item.order_payment_type !== "deposit" || paymentType === "deposit" && item.order_payment_type === "deposit")) return acc.plus(item.amount).plus(Number(item.rounding_amount) > 0 ? 0 : item.rounding_amount || 0);
			return acc;
		}, new decimal_js.default(0)).toNumber();
		balanceDecimal = new decimal_js.default(Math.abs(balanceDecimal.minus(new decimal_js.default(syncedVoucherAmount)).toNumber()));
		const finalBalanceAmount = (0, _pisell_utils.formatAmountWithOptions)(balanceDecimal.toNumber(), amountSymbol, {
			precision: 2,
			hideDecimalForWholeNumbers: false,
			useThousandsSeparator: true,
			showCurrencySymbol: true
		});
		return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("confirm-payment-container") }, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("confirm-payment-content") }, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("confirm-payment-text") }, getText("will.be.paid.in.full") || "Will be paid in full", " ", /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("amount-text") }, finalBalanceAmount), " ", getText("by.wallet") || "by Wallet"), /* @__PURE__ */ react.default.createElement(antd.Button, {
			className: (0, classnames.default)("confirm-button"),
			onClick: handleConfirmClick,
			type: "primary"
		}, getText("confirm") || "Confirm")));
	};
	const getMiddleContent = () => {
		if (paymentType === "deposit") return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("partial-paid-card") }, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("partial-paid-label") }, paymentType === "deposit" ? getText("deposit.partial.paid") || "Deposit Paid" : getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("partial-paid-amount") }, (0, _pisell_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
			precision: 2,
			hideDecimalForWholeNumbers: false,
			useThousandsSeparator: true,
			showCurrencySymbol: true
		}))), renderSummaryItems(), hasMoreItems() && /* @__PURE__ */ react.default.createElement("div", {
			className: (0, classnames.default)("more-section"),
			onClick: handleMoreClick,
			style: { cursor: "pointer" },
			role: "button"
		}, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("more-text") }, getText("more") || "更多"), /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, {
			type: "pisell2-TriangleFill",
			style: { fontSize: "12px" }
		}))));
		else return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("partial-paid-card") }, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("partial-paid-label") }, getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("partial-paid-amount") }, (0, _pisell_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
			precision: 2,
			hideDecimalForWholeNumbers: false,
			useThousandsSeparator: true,
			showCurrencySymbol: true
		}))), renderSummaryItems(), hasMoreItems() && /* @__PURE__ */ react.default.createElement("div", {
			className: (0, classnames.default)("more-section"),
			onClick: handleMoreClick,
			style: { cursor: "pointer" },
			role: "button"
		}, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("more-text") }, getText("more") || "更多"), /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, {
			type: "pisell2-TriangleFill",
			style: {
				fontSize: "24px",
				color: "#C3B2E7"
			}
		})));
	};
	const canSwitch = (0, react.useMemo)(() => {
		if (Number(orderInfo === null || orderInfo === void 0 ? void 0 : orderInfo.totalAmount) === 0) return false;
		if (paymentType === "regular") {
			const depositFlag = (paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.reduce((acc, item) => {
				if (item.order_payment_type === "deposit") return acc.plus(item.amount).plus(Number(item.rounding_amount) > 0 ? 0 : item.rounding_amount || 0);
				return acc;
			}, new decimal_js.default(0)).toNumber()) >= new decimal_js.default((orderInfo === null || orderInfo === void 0 ? void 0 : orderInfo.depositAmount) || "0").toNumber() && Number(orderInfo === null || orderInfo === void 0 ? void 0 : orderInfo.depositAmount) > 0;
			return !(paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.some((item) => item.order_payment_type === "normal")) && !depositFlag;
		} else return (paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.reduce((acc, item) => {
			if (item.order_payment_type === "deposit") return acc.plus(item.amount).plus(Number(item.rounding_amount) > 0 ? 0 : item.rounding_amount || 0);
			return acc;
		}, new decimal_js.default(0)).toNumber()) < new decimal_js.default(totalAmount).toNumber();
	}, [
		paymentItems,
		paymentType,
		totalAmount
	]);
	(0, react.useMemo)(() => {
		return balanceDueAmount !== customAmount && Number(balanceDueAmount) > 0 && Number(customAmount) > 0;
	}, [customAmount, balanceDueAmount]);
	const handleChangeDepositAmount = (value) => {
		const valueStr = String(value);
		console.log("handleChangeDepositAmount", valueStr);
		checkoutModule === null || checkoutModule === void 0 || checkoutModule.setDepositAmountAsync(valueStr);
	};
	const hasDepositPayment = (0, react.useMemo)(() => {
		return paymentItems === null || paymentItems === void 0 ? void 0 : paymentItems.some((item) => item.order_payment_type === "deposit" && item.status !== "voided");
	}, [paymentItems]);
	const showCanNotChangeDepositAmount = () => {
		Toast === null || Toast === void 0 || Toast.fail(_pisell_utils.locales.getText("pisell2.checkout.can-not-change-deposit-amount"));
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("amount-summary-module", "amount-summary-container") }, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("left-section") }, open_deposit && canSwitch ? /* @__PURE__ */ react.default.createElement(antd.Dropdown, {
		menu: {
			items: paymentOptions,
			onClick: ({ key }) => handlePaymentTypeChange(key),
			style: {
				backgroundColor: "#7F56DA",
				border: "1px solid #C3B2E7",
				borderRadius: "8px",
				padding: "8px 16px"
			}
		},
		trigger: ["click"],
		placement: "bottomLeft",
		overlayClassName: "amount-summary-dropdown"
	}, /* @__PURE__ */ react.default.createElement(antd.Button, { className: getPaymentButtonClassName() }, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("button-content") }, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("button-text") }, paymentType === "deposit" ? getText("deposit.payment.short") || "定金\n支付" : getText("regular.payment.short") || "普通\n支付"), /* @__PURE__ */ react.default.createElement(ChevronSelectorVertical, { style: {
		width: "36px",
		height: "36px"
	} })))) : /* @__PURE__ */ react.default.createElement(antd.Button, { className: getPaymentButtonClassName() }, /* @__PURE__ */ react.default.createElement("div", null, paymentType === "deposit" ? getText("deposit.text") || "定金" : getText("regular.text") || "普通"), /* @__PURE__ */ react.default.createElement("div", null, getText("payment.text") || "支付")), /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, {
		type: "pisell2-arrow-right",
		style: { fontSize: "20px" }
	})), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("middle-section") }, getMiddleContent()), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-card", { "confirm-mode": shouldShowConfirmMode() }) }, shouldShowConfirmMode() ? renderConfirmMode() : /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-info") }, paymentType === "deposit" ? hasDepositPayment ? /* @__PURE__ */ react.default.createElement("div", { onClick: () => showCanNotChangeDepositAmount() }, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-label") }, getText("deposit.due") || "Deposit Due"), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-amount") }, (0, _pisell_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
		precision: 2,
		hideDecimalForWholeNumbers: false,
		useThousandsSeparator: true,
		showCurrencySymbol: true
	}), /* @__PURE__ */ react.default.createElement(_pisell_icon.Edit05, {
		className: (0, classnames.default)("edit-icon"),
		style: { color: "#7F56DA" }
	}))) : /* @__PURE__ */ react.default.createElement(require_PisellPriceKeyboardPopover.default, {
		value: balanceDueAmount || "0",
		onConfirm: handleChangeDepositAmount,
		showCurrencySymbol: true,
		useThousandsSeparator: true,
		selectType: "dark",
		overlayClassName: "cash-payment-keyboard-popover"
	}, /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-label") }, getText("deposit.due") || "Deposit Due"), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-amount") }, (0, _pisell_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
		precision: 2,
		hideDecimalForWholeNumbers: false,
		useThousandsSeparator: true,
		showCurrencySymbol: true
	}), /* @__PURE__ */ react.default.createElement(_pisell_icon.Edit05, {
		className: (0, classnames.default)("edit-icon"),
		style: { color: "#7F56DA" }
	})))) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("balance-due-label") }, getText("balance.due") || "Balance Due"), /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("balance-due-amount"),
		onClick: () => {
			onBalanceDueAmountClick === null || onBalanceDueAmountClick === void 0 || onBalanceDueAmountClick("manual-discount");
		}
	}, (0, _pisell_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
		precision: 2,
		hideDecimalForWholeNumbers: false,
		useThousandsSeparator: true,
		showCurrencySymbol: true
	}), /* @__PURE__ */ react.default.createElement(_pisell_icon.Edit05, {
		className: (0, classnames.default)("edit-icon"),
		style: { color: "#7F56DA" }
	})))), Number(currentAmount) > 0 && /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pay-section"),
		style: { cursor: "pointer" },
		role: "button"
	}, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("pay-text") }, getText("pay") || "支付"), /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("pay-amount") }, (0, _pisell_utils.formatAmountWithOptions)((() => {
		try {
			return new decimal_js.default(currentAmount || "0").toNumber();
		} catch (_unused7) {
			return 0;
		}
	})(), amountSymbol, {
		precision: 2,
		hideDecimalForWholeNumbers: false,
		useThousandsSeparator: true,
		showCurrencySymbol: true
	})))), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open: isPaymentDetailOpen,
		onCancel: handlePaymentDetailClose,
		footer: null,
		closable: true,
		mask: true,
		maskClosable: true,
		centered: true,
		width: 600,
		wrapClassName: "payment-detail-modal-wrapper",
		title: getText("order.and.payment.summary") || "Order and Payment Summary"
	}, isPaymentDetailOpen && /* @__PURE__ */ react.default.createElement(require_index.default, {
		amountSymbol,
		orderInfo,
		cartData,
		onClose: handlePaymentDetailClose,
		summaryData,
		labelMaps,
		paymentItems,
		customAmount,
		voidPayment: handleVoidPayment,
		walletPassData,
		clientInfo
	})));
}
//#endregion
exports.default = AmountSummary;
