const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_model = require("../model.js");
const require_useQuotation = require("../../hooks/useQuotation.js");
const require_index = require("../service/addService/index.js");
const require_index$1 = require("../service/editService/index.js");
const require_Lists = require("./Lists.js");
let react = require("react");
react = require_runtime.__toESM(react);
(0, react.createContext)({});
const Service2Cart = ({ hideAdd, hideEdit }) => {
	const detailRef = (0, react.useRef)();
	const { state, dispatch } = (0, react.useContext)(require_model.Context);
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	/**
	* @title: 更新服务
	* @description:
	* @param {string} type
	* @param {any} payload
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-09 16:02
	*/
	const dispatchService = (type, payload) => {
		dispatch({
			type,
			payload: require_objectSpread2._objectSpread2({}, payload)
		});
	};
	const handleEdit = (cacheItem, type) => {
		setTimeout(() => {
			var _detailRef$current, _detailRef$current$in;
			(_detailRef$current = detailRef.current) === null || _detailRef$current === void 0 || (_detailRef$current$in = _detailRef$current.init) === null || _detailRef$current$in === void 0 || _detailRef$current$in.call(_detailRef$current, cacheItem, false, type === "edit_product");
		}, 100);
	};
	const { dom } = require_useQuotation.default(state, dispatch);
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-wrap" }, /* @__PURE__ */ react.default.createElement(require_Lists.default, {
		onEdit: handleEdit,
		onChange: (e, type) => dispatchService(type || "setService", e)
	}), !hideAdd && /* @__PURE__ */ react.default.createElement(require_index.default, { onEdit: handleEdit })), !hideEdit && /* @__PURE__ */ react.default.createElement(require_index$1.default, { ref: detailRef }), dom);
};
//#endregion
exports.Service2Cart = Service2Cart;
