const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_utils = require("../utils.js");
const require_index = require("./components/PolicyModal/index.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/appointmentBooking/deposit/index.tsx
const Deposit = (props) => {
	var _context$engine2;
	const { protocols, total, title, isAgreePolicy = true, isShowTitle = true, onChange, depositProtocolRequest } = props;
	const context = require_useEngineContext.default();
	const [visible, setVisible] = (0, react.useState)(false);
	const [policyItem, setPolicyItem] = (0, react.useState)();
	const isEn = (0, react.useMemo)(() => {
		var _context$engine;
		return ((context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en") === "en";
	}, [context === null || context === void 0 || (_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.locale]);
	/**
	* @title: 协议文案
	* @description: 根据中英文不同显示文案不同
	* @param {*} useMemo
	* @return {*}
	* @Author: wh
	* @Date: 2023-01-30 16:25
	*/
	const _policyText = (0, react.useCallback)((item, index) => {
		if (!item || !(protocols === null || protocols === void 0 ? void 0 : protocols.length)) return "";
		return require_utils.getPunctuationMark(index, protocols.length, isEn);
	}, [protocols]);
	const handleAgreed = () => {
		onChange && onChange(!isAgreePolicy);
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "appointment-deposit-bottom" }, isShowTitle ? /* @__PURE__ */ react.default.createElement("span", { className: "title" }, title) : null, /* @__PURE__ */ react.default.createElement("div", { className: "tip" }, isEn ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText.Amount, {
		value: total,
		showCurrencySymbol: true,
		className: "amount"
	}), /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.appointment.deposit.amount.tip1"))) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.appointment.deposit.amount.tip1")), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText.Amount, {
		value: total,
		showCurrencySymbol: true,
		className: "amount"
	}), /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.appointment.deposit.amount.tip2")))), (protocols === null || protocols === void 0 ? void 0 : protocols.length) > 0 ? /* @__PURE__ */ react.default.createElement("div", {
		className: "checkbox-wrap",
		onClick: () => handleAgreed()
	}, /* @__PURE__ */ react.default.createElement(antd.Checkbox, { checked: isAgreePolicy }), /* @__PURE__ */ react.default.createElement("div", { className: "policy-box" }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.appointment.deposit.agreed")), /* @__PURE__ */ react.default.createElement("div", { className: "policy-wrap" }, protocols === null || protocols === void 0 ? void 0 : protocols.map((item, index) => {
		return /* @__PURE__ */ react.default.createElement("span", {
			key: item === null || item === void 0 ? void 0 : item.id,
			onClick: (e) => {
				e.stopPropagation();
				e.preventDefault();
				setPolicyItem(item);
				setVisible(true);
			}
		}, item === null || item === void 0 ? void 0 : item.title, /* @__PURE__ */ react.default.createElement("span", { className: "symbol" }, _policyText(item, index)));
	})))) : null), /* @__PURE__ */ react.default.createElement(require_index.default, {
		open: visible,
		onCancel: () => setVisible(false),
		item: policyItem,
		depositProtocolRequest
	}));
};
//#endregion
exports.default = Deposit;
