const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_floorMapDataRecordLabel = require("./floorMapDataRecordLabel.js");
const require_floorMapResourcePickerTypes = require("./floorMapResourcePickerTypes.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _ant_design_icons = require("@ant-design/icons");
//#region src/components/pisellFloorMapLayout/utils/floorMapResourcePickerDisplay.ts
function pickField(record, key) {
	const raw = record[key];
	if (raw == null) return null;
	const t = String(raw).trim();
	return t ? t : null;
}
/** 人数/容量：无值或为 0 时不展示 */
function resolveResourcePickerCapacity(record) {
	var _pickField;
	const raw = (_pickField = pickField(record, "capacityLabel")) !== null && _pickField !== void 0 ? _pickField : pickField(record, "capacity");
	if (!raw) return void 0;
	const num = Number(raw);
	if (!Number.isNaN(num) && num <= 0) return void 0;
	return raw;
}
function resolveReservationAreaRaw(record) {
	return pickField(record, "area");
}
/**
* 预约桌位：从 `area` 解析路径，最多 3 段。
* 当前资源多为单段（如 `party_room1`）；将来 `广东/中山/三乡` 会自动出现二、三级筛选行。
*/
function getFloorMapResourcePickerCategoryPath(record) {
	return require_floorMapResourcePickerTypes.parseNestedPathSegments(resolveReservationAreaRaw(record), 3);
}
/** 平面图 / 预约：area 最多三级；仅展示 chip，不显示行左侧「区域」等标签 */
function getFloorMapCardPickerCategoryConfig() {
	return {
		mode: "nested",
		levels: [
			{},
			{},
			{}
		],
		getCategoryPath: getFloorMapResourcePickerCategoryPath
	};
}
/**
* 把 capacity 字符串包装成「人数图标 + 数值」badge。
* 抽出来便于业务侧组合（如再追加 status badge 等）。
*/
function buildResourceCapacityBadge(capacity) {
	if (!capacity) return null;
	return {
		text: capacity,
		icon: react.default.createElement(_ant_design_icons.TeamOutlined, { "aria-hidden": true })
	};
}
/**
* 小卡片主标题 + 标签（人数等；区域已在筛选区展示，副文案不再重复 area）。
*/
function getFloorMapResourcePickerCardMeta(record) {
	var _record$id;
	const title = require_floorMapDataRecordLabel.formatDataRecordOptionLabel(record);
	const idStr = String((_record$id = record.id) !== null && _record$id !== void 0 ? _record$id : "").trim();
	const capacityBadge = buildResourceCapacityBadge(resolveResourcePickerCapacity(record));
	return {
		id: idStr,
		title,
		subtitles: [],
		badges: capacityBadge ? [capacityBadge] : []
	};
}
function floorMapResourcePickerRecordSearchText(record) {
	var _meta$badges;
	const meta = getFloorMapResourcePickerCardMeta(record);
	const areaRaw = resolveReservationAreaRaw(record);
	const badgeTexts = ((_meta$badges = meta.badges) !== null && _meta$badges !== void 0 ? _meta$badges : []).map((b) => b.text);
	return [
		meta.title,
		areaRaw,
		...badgeTexts,
		...meta.subtitles,
		meta.id
	].filter(Boolean).join(" ").toLowerCase();
}
//#endregion
exports.floorMapResourcePickerRecordSearchText = floorMapResourcePickerRecordSearchText;
exports.getFloorMapCardPickerCategoryConfig = getFloorMapCardPickerCategoryConfig;
exports.getFloorMapResourcePickerCardMeta = getFloorMapResourcePickerCardMeta;
