const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_status = require("../../service2/status.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/booking/info/pet/ChangePetModal/index.tsx
const ChangePetModal = (props, ref) => {
	const [open, setOpen] = (0, react.useState)(false);
	const [params, setParams] = (0, react.useState)({});
	(0, react.useImperativeHandle)(ref, () => ({ open: (e) => {
		setParams(e);
		setOpen(true);
	} }));
	/**
	* @title: 确认之后的操作
	* @description:
	* @param {string} type
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-12 22:56
	*/
	const handleProduct = (type) => {
		const { ids, service, dispatch, setGlobalState, state, source } = params;
		let _service = [...service || []];
		if (source === "changeClient") if (type === "ok") _service = _service === null || _service === void 0 ? void 0 : _service.filter((item) => !require_status.appointmentTypes.includes(item.extension_type));
		else _service = [];
		else if (type === "ok") {
			_service = _service === null || _service === void 0 ? void 0 : _service.map((item) => {
				if (ids === null || ids === void 0 ? void 0 : ids.includes(item._extend.holder_id)) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { _extend: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item._extend || {}), {}, { holder_id: 0 }) });
				return item;
			});
			_service = _service.filter((item) => {
				var _item$_extend;
				return !((item === null || item === void 0 || (_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.holder_id) === 0 && require_status.appointmentTypes.includes(item.extension_type));
			});
		} else _service = _service.filter((item) => !ids.includes(item._extend.holder_id));
		if (dispatch) dispatch({
			type: "setService",
			payload: {
				value: [..._service],
				edit: true
			}
		});
		else setGlobalState({ service: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state.service), {}, {
			edit: true,
			value: [..._service]
		}) });
		setOpen(false);
	};
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal.Information, {
		open,
		platform: "pc",
		width: 432,
		title: _pisell_utils.locales.getText("pisell2.text.change.pet.title"),
		describe: /* @__PURE__ */ react.default.createElement("div", { className: "pisell2-change-pet-modal-content" }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.text.change.pet.content")), /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.text.change.pet.content1"))),
		cancelText: _pisell_utils.locales.getText("pisell2.text.change.pet.cancel"),
		okText: _pisell_utils.locales.getText("pisell2.text.change.pet.confirm"),
		closable: true,
		onOk: () => handleProduct("ok"),
		onCancel: () => handleProduct("cancel")
	});
};
var ChangePetModal_default = (0, react.forwardRef)(ChangePetModal);
//#endregion
exports.default = ChangePetModal_default;
