const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_floorRoomCardUtils = require("../floorRoomCard/floorRoomCardUtils.js");
const require_mapRowToFloorRoomCardData = require("../floorRoomCard/mapRowToFloorRoomCardData.js");
const require_ReservationFloorRoomCard = require("../floorRoomCard/ReservationFloorRoomCard.js");
const require_reservationMock = require("./reservationMock.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./ReservationCards.less");
//#region src/plus/pisellReservation/floorMap/reservationCards.tsx
const I18N_BOUND = "pisell-reservation.room-kind-bound";
const I18N_CARD_HINT_SELECT_ROW = "pisell-reservation.card-placeholder.hint-select-row";
const I18N_CARD_HINT_BIND_DATASOURCE = "pisell-reservation.card-placeholder.hint-bind-datasource";
const I18N_CARD_HINT_NEW_SLOT = "pisell-reservation.card-placeholder.hint-new-slot";
const I18N_CARD_HINT_ROW_NOT_FOUND = "pisell-reservation.card-placeholder.hint-row-not-found";
function findReservationRow(item, dataSources) {
	return (0, _pisell_materials.findFloorMapRowByDataBinding)(item, dataSources);
}
function getReservationPlaceholderCopy(item, dataSources) {
	const el = item._sceneElement;
	const kindLabel = _pisell_utils.locales.getText(I18N_BOUND);
	const title = ((el === null || el === void 0 ? void 0 : el.name) != null ? String(el.name).trim() : "") || kindLabel;
	const reason = (0, _pisell_materials.getFloorMapBindingPlaceholderReason)(item, dataSources);
	let hint;
	switch (reason) {
		case "missing_data_source_key":
			hint = _pisell_utils.locales.getText(I18N_CARD_HINT_BIND_DATASOURCE);
			break;
		case "missing_record_id":
			hint = _pisell_utils.locales.getText(I18N_CARD_HINT_SELECT_ROW);
			break;
		case "new_unsaved_slot":
			hint = _pisell_utils.locales.getText(I18N_CARD_HINT_NEW_SLOT);
			break;
		default: hint = _pisell_utils.locales.getText(I18N_CARD_HINT_ROW_NOT_FOUND);
	}
	const shape = item.elementKind === "reservationBoundRoundTable" || item.shape === "circle" ? "circle" : "rect";
	return {
		title,
		hint,
		shape
	};
}
function ReservationNoDataPlaceholder(props) {
	const { title, hint, shape } = props;
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-reservation-card-placeholder", shape === "circle" && "pisell-reservation-card-placeholder--circle") }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-card-placeholder-title" }, title), hint ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-card-placeholder-hint" }, hint) : null);
}
function boundTableCardShape(item) {
	return item.elementKind === "reservationBoundRoundTable" || item.shape === "circle" ? "circle" : "rect";
}
function renderReservationBoundRoomCardInner(item, dataSources) {
	var _item$_sceneElement;
	const row = findReservationRow(item, dataSources);
	const cardShape = boundTableCardShape(item);
	if (!row) {
		const ph = getReservationPlaceholderCopy(item, dataSources);
		return /* @__PURE__ */ react.default.createElement(ReservationNoDataPlaceholder, {
			title: ph.title,
			hint: ph.hint,
			shape: ph.shape
		});
	}
	const data = require_mapRowToFloorRoomCardData.mapPisellReservationRowToFloorRoomCardData(row, require_floorRoomCardUtils.displayRoomTitleFromRow(row, ((_item$_sceneElement = item._sceneElement) === null || _item$_sceneElement === void 0 ? void 0 : _item$_sceneElement.name) != null ? String(item._sceneElement.name).trim() : void 0) || row.code || _pisell_utils.locales.getText(I18N_BOUND));
	const layoutH = item.height != null && Number.isFinite(item.height) && item.height > 0 ? item.height : item.width;
	return /* @__PURE__ */ react.default.createElement(require_ReservationFloorRoomCard.ReservationFloorRoomCard, {
		data,
		shellShape: cardShape,
		elementLayoutHeightPx: layoutH != null && Number.isFinite(layoutH) && layoutH > 0 && cardShape === "circle" ? layoutH : void 0
	});
}
function getReservationRenderItemByKind(dataSources) {
	const bound = (item, _index, _options) => renderReservationBoundRoomCardInner(item, dataSources);
	return {
		[_pisell_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND]: (item, _index, _options) => (0, _pisell_materials.renderFloorMapFallbackPlaceholder)(item),
		[require_reservationMock.RESERVATION_BOUND_TABLE_ELEMENT_KIND]: bound,
		[require_reservationMock.RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND]: bound,
		reservationTable: bound,
		reservationPartyBench: bound,
		reservationBarSeat: bound
	};
}
//#endregion
exports.findReservationRow = findReservationRow;
exports.getReservationRenderItemByKind = getReservationRenderItemByKind;
