const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_PisellReservation = require("../PisellReservation.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./SelectFloorMapResourceDialog.less");
//#region src/plus/pisellReservation/components/SelectFloorMapResourceDialog.tsx
const I18N_TITLE = "pisell-reservation.select-resource.title";
const DIALOG_WIDTH = "99%";
const DIALOG_BODY_STYLE = {
	padding: 0,
	height: "100%"
};
function normalizeScheduleValue(value) {
	if (value == null) return void 0;
	const at = (0, dayjs.default)(typeof value === "string" ? value : value.at);
	if (!at.isValid()) return void 0;
	const rawDate = typeof value === "string" ? void 0 : value.date;
	const parsedDate = (0, dayjs.default)(rawDate);
	return {
		date: rawDate != null && parsedDate.isValid() ? parsedDate.startOf("day") : at.startOf("day"),
		at
	};
}
function SelectFloorMapResourceDialog({ open, onClose, onClick, reservationBiz, businessCode, associatedMenuListIds, scheduleValue, floorPlanId, floorPlanCode, floorPlanCanvasWidth, floorPlanCanvasHeight, dataSources, floorMap, title }) {
	const handleSelectResource = (0, react.useCallback)((payload) => {
		onClick === null || onClick === void 0 || onClick(payload);
	}, [onClick]);
	const resourceSelectMode = (0, react.useMemo)(() => ({
		enabled: true,
		onSelectResource: handleSelectResource
	}), [handleSelectResource]);
	const normalizedScheduleValue = (0, react.useMemo)(() => normalizeScheduleValue(scheduleValue), [scheduleValue]);
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		platform: "pc",
		open,
		onCancel: onClose,
		title: title !== null && title !== void 0 ? title : _pisell_utils.locales.getText(I18N_TITLE),
		footer: null,
		destroyOnClose: true,
		width: DIALOG_WIDTH,
		className: "pisell-select-floor-map-resource-dialog-modal",
		bodyStyle: DIALOG_BODY_STYLE,
		wrapClassName: "pisell-select-floor-map-resource-dialog"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-select-floor-map-resource-dialog-content" }, /* @__PURE__ */ react.default.createElement(require_PisellReservation.PisellReservationCore, {
		reservationBiz: reservationBiz !== null && reservationBiz !== void 0 ? reservationBiz : businessCode,
		associatedMenuListIds,
		scheduleValue: normalizedScheduleValue,
		floorPlanId,
		floorPlanCode,
		floorPlanCanvasWidth,
		floorPlanCanvasHeight,
		dataSources,
		floorMap,
		bodyViewSwitchable: false,
		lockedBodyView: "floorMap",
		resourceSelectMode
	})));
}
//#endregion
exports.default = SelectFloorMapResourceDialog;
