const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_useWindowSize = require("../../hooks/useWindowSize.js");
const require_utils = require("./utils.js");
const require_context = require("./context.js");
const require_hooks = require("./hooks.js");
const require_index = require("./components/Content/index.js");
const require_locales = require("./locales.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/appointmentBooking/index.tsx
const AppointmentBooking = () => {
	var _context$engine;
	const context = require_useEngineContext.default();
	_pisell_utils.locales.init(require_locales.default, (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");
	require_useWindowSize.default({ debounceMs: 200 });
	const utils = require_hooks.contextUtils();
	const appointmentBooking = require_hooks.useAppointmentBooking();
	const isMobileLayout = (0, react.useMemo)(() => (0, _pisell_utils.isMobile)() && !(0, _pisell_utils.isIpad)(), []);
	(0, react.useEffect)(() => {
		var _appointmentBooking$o;
		const { bookingSubject } = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o = appointmentBooking.otherParams) === null || _appointmentBooking$o === void 0 ? void 0 : _appointmentBooking$o.productModuleParams) || {};
		if ((bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.type) === "form") return;
		appointmentBooking.getAccounts().then((data) => {
			if (!data.length) {
				const currentUser = require_utils.formatCurrentUser(utils);
				appointmentBooking.addAccounts([currentUser]);
			} else if (data.length >= 1) {
				const meAccount = data === null || data === void 0 ? void 0 : data.find((d) => !(d === null || d === void 0 ? void 0 : d.isGuest));
				const currentUser = require_utils.formatCurrentUser(utils);
				if (currentUser && meAccount.id !== currentUser.id) appointmentBooking.setLoginAccount(meAccount.id, currentUser);
			}
		});
	}, []);
	return /* @__PURE__ */ react.default.createElement("div", { className: `parallel-booking-wrap ${isMobileLayout ? "parallel-booking-mobile-wrap" : ""}` }, /* @__PURE__ */ react.default.createElement(require_context.AppointmentBookingProvider, null, /* @__PURE__ */ react.default.createElement(require_index.default, null)));
};
//#endregion
exports.default = AppointmentBooking;
