const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_locales = require("../../../utils/locales.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_locales$1 = require("../locales.js");
const require_utils = require("./service2/utils.js");
const require_utils$1 = require("../utils.js");
const require_model = require("./model.js");
const require_index = require("./client/index.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_index$1 = require("../components/tabPane/index.js");
const require_index$2 = require("../components/footer/index.js");
const require_index$3 = require("./pet/index.js");
const require_index$4 = require("./date/index.js");
const require_index$5 = require("./header/index.js");
const require_index$6 = require("./notes/index.js");
const require_useCreateBookingPageHeader = require("../hooks/useCreateBookingPageHeader.js");
const require_index$7 = require("../info2/service/contactInfoMode/index.js");
const require_index$8 = require("./service/index.js");
const require_index$9 = require("./service2/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/booking/info/main.tsx
const defaultModules = {
	client: 1,
	date: 1,
	service: 1,
	holder: 1,
	note: 1,
	service2: 0
};
_pisell_utils.locales.init(require_locales$1.default, require_locales.getLocale());
const Info = require_model.Provider((props) => {
	var _modal$state2, _modal$state3, _modal$state4, _modal$state5;
	const { style, globalState, modules = defaultModules, slot } = props;
	const modal = (0, react.useContext)(require_model.Context);
	const context = require_useEngineContext.default();
	require_utils$1.request.setRequest(context.appHelper.utils.request);
	const params = (0, react.useMemo)(() => {
		var _modal$state;
		return ((_modal$state = modal.state) === null || _modal$state === void 0 || (_modal$state = _modal$state.bookingConfig) === null || _modal$state === void 0 || (_modal$state = _modal$state.config) === null || _modal$state === void 0 || (_modal$state = _modal$state.basic) === null || _modal$state === void 0 ? void 0 : _modal$state.appointment_subject) || {};
	}, [(_modal$state2 = modal.state) === null || _modal$state2 === void 0 || (_modal$state2 = _modal$state2.bookingConfig) === null || _modal$state2 === void 0 || (_modal$state2 = _modal$state2.config) === null || _modal$state2 === void 0 || (_modal$state2 = _modal$state2.basic) === null || _modal$state2 === void 0 ? void 0 : _modal$state2.appointment_subject]);
	const { createHeader, isBookingCreatePage, isBookingCreatePageCreateMode } = require_useCreateBookingPageHeader.default(globalState);
	(0, react.useEffect)(() => {
		document.body.id = "body";
		if (props.setState) props.setState({ bookingFunctions: {
			formatResource: require_utils$1.formatResource,
			getErrorList: require_utils$1.getErrorList,
			sliceDayIntoFiveMinutes: require_utils$1.sliceDayIntoFiveMinutes,
			findNextDuration: require_utils$1.findNextDuration,
			flexibleObj: require_utils$1.flexibleObj,
			updateServiceDate: require_index$4.updateServiceDate
		} });
	}, []);
	(0, react.useEffect)(() => {
		var _context$appHelper, _context$appHelper$ge, _context$appHelper2, _context$appHelper2$i, _context$appHelper3;
		const isFranchisee = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.businessUtils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getAppByModal) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper, "franchisee");
		modal.dispatch({
			type: "setState",
			payload: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ setGlobalState: props.setGlobalState }, globalState), {}, {
				isTerminal: context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 || (_context$appHelper2 = _context$appHelper2.utils) === null || _context$appHelper2 === void 0 || (_context$appHelper2$i = _context$appHelper2.isTerminal) === null || _context$appHelper2$i === void 0 ? void 0 : _context$appHelper2$i.call(_context$appHelper2),
				isFranchisee,
				timezone: context === null || context === void 0 || (_context$appHelper3 = context.appHelper) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.utils) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.store) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.getState()) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.global) === null || _context$appHelper3 === void 0 || (_context$appHelper3 = _context$appHelper3.globalConfig) === null || _context$appHelper3 === void 0 ? void 0 : _context$appHelper3.timezone,
				isDayBooking: (globalState === null || globalState === void 0 ? void 0 : globalState.renderType) === "dayBooking"
			})
		});
	}, [globalState]);
	const header$1 = (0, react.useMemo)(() => {
		if ((globalState === null || globalState === void 0 ? void 0 : globalState.renderType) === "eventBooking") return _pisell_utils.locales.getText("pisell2.text.enroll.detail");
		return (globalState === null || globalState === void 0 ? void 0 : globalState.bookingId) ? /* @__PURE__ */ react.default.createElement(require_index$5.default, {
			state: modal.state,
			dispatch: modal.dispatch
		}) : /* @__PURE__ */ react.default.createElement("div", {
			className: "",
			style: { height: 0 }
		});
	}, [
		globalState === null || globalState === void 0 ? void 0 : globalState.bookingId,
		modal.state,
		modal.dispatch,
		globalState === null || globalState === void 0 ? void 0 : globalState.renderType
	]);
	const notes = (0, react.useMemo)(() => {
		if (!modules.note) return null;
		if (require_utils.isEventBooking(modal.state)) return null;
		if (require_utils.isDayBooking(globalState)) return null;
		return (globalState === null || globalState === void 0 ? void 0 : globalState.bookingId) ? globalState.renderType === "eventBooking" || globalState.isBookingCreatePage ? /* @__PURE__ */ react.default.createElement(require_index$6.default, null) : null : null;
	}, [
		modules.note,
		globalState === null || globalState === void 0 ? void 0 : globalState.bookingId,
		globalState.render,
		(_modal$state3 = modal.state) === null || _modal$state3 === void 0 || (_modal$state3 = _modal$state3.notes) === null || _modal$state3 === void 0 ? void 0 : _modal$state3.orderNote
	]);
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, !!modal.state.setGlobalState ? /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, style), {}, { height: "100%" }),
		header: header$1,
		footer: /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			state: modal.state,
			dispatch: modal.dispatch,
			source: "info"
		}),
		bodyClassName: (0, classnames.default)("booking-info-warp", {
			["create-booking-page-info-wrap"]: isBookingCreatePage,
			["create-booking-page-info-wrap-create"]: isBookingCreatePageCreateMode && !require_utils.isTerminalDayBooking(modal.state)
		}),
		state: modal.state,
		dispatch: modal.dispatch,
		source: "info"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "booking-info" }, createHeader, modules.client ? /* @__PURE__ */ react.default.createElement(require_index.default, null) : null, (modal === null || modal === void 0 || (_modal$state4 = modal.state) === null || _modal$state4 === void 0 || (_modal$state4 = _modal$state4.bookingConfig) === null || _modal$state4 === void 0 || (_modal$state4 = _modal$state4.config) === null || _modal$state4 === void 0 || (_modal$state4 = _modal$state4.cart_settings_tab) === null || _modal$state4 === void 0 || (_modal$state4 = _modal$state4.display_contact_info) === null || _modal$state4 === void 0 ? void 0 : _modal$state4.show_contact_info) === true ? /* @__PURE__ */ react.default.createElement(require_index$7.default, null) : null, modules.holder && !((_modal$state5 = modal.state) === null || _modal$state5 === void 0 ? void 0 : _modal$state5.disabledEdit) ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, params.type === "form" ? /* @__PURE__ */ react.default.createElement(require_index$3.default, null) : null) : null, modules.date ? /* @__PURE__ */ react.default.createElement(require_index$4.default, null) : null, /* @__PURE__ */ react.default.createElement(antd.Skeleton, {
		loading: globalState.loading,
		round: true,
		active: true,
		avatar: false,
		style: { paddingTop: 20 }
	}, modules.service ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, modal.state.date.value ? /* @__PURE__ */ react.default.createElement(require_index$8.default, null) : null) : null, modules.service2 ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, modal.state.date.value ? /* @__PURE__ */ react.default.createElement(require_index$9.Service2Cart, null) : null) : null, notes, slot ? slot : null))) : null);
});
//#endregion
exports.default = Info;
