require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_locales = require("../locales/locales.js");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/plus/pisellReservation/floorMap/reservationMock.ts
const PALETTE_IMAGE_BG_I18N_KEY = "pisell-reservation.floor-map.palette-image-bg";
/** 合并远程图元种类时识别「旧版图片底图」展示名（各语言 + 历史简体中文） */
const LEGACY_PALETTE_IMAGE_BG_LABELS = new Set([
	require_locales.default.en[PALETTE_IMAGE_BG_I18N_KEY],
	require_locales.default["zh-CN"][PALETTE_IMAGE_BG_I18N_KEY],
	require_locales.default["zh-HK"][PALETTE_IMAGE_BG_I18N_KEY],
	"图片（底图）"
]);
const I18N_FLOOR_CATEGORY_BG = "pisell-reservation.floor-map.category-background";
const I18N_FLOOR_DS_LABEL = "pisell-reservation.floor-map.data-source-label";
const I18N_PALETTE_IMAGE_BG = PALETTE_IMAGE_BG_I18N_KEY;
const I18N_ROOM_KIND_BOUND = "pisell-reservation.room-kind-bound";
const I18N_ROOM_KIND_BOUND_ROUND = "pisell-reservation.room-kind-bound-round";
/**
* 与 Story 款 `floorMapImage` 重复的旧版/接口图片图元（合并时整项丢弃，只保留默认里那份）
*/
const LEGACY_IMAGE_ELEMENT_KIND_VALUES = new Set([
	"image",
	"floorMapBg",
	"floor_map_image"
]);
function stripConflictingImageElementKinds(kinds) {
	return kinds.filter((k) => {
		if (LEGACY_IMAGE_ELEMENT_KIND_VALUES.has(k.value)) return false;
		if (k.value !== _pisell_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND && LEGACY_PALETTE_IMAGE_BG_LABELS.has(k.label)) return false;
		return true;
	});
}
/** 按 value 去重，保留先出现的项 */
function dedupeElementKindsByValue(kinds) {
	const seen = /* @__PURE__ */ new Set();
	return kinds.filter((k) => {
		if (seen.has(k.value)) return false;
		seen.add(k.value);
		return true;
	});
}
/**
* 父级/接口 elementKinds 与预约默认合并：
* - 去掉与 Story 图片图元重复的旧版种类；
* - 远程若已有 `floorMapImage` 也先去掉，统一用 defaults 里那份（避免两套「图片底图」并存）。
*/
function mergeFloorMapElementKindsWithDefaults(defaults, remote) {
	if (!(remote === null || remote === void 0 ? void 0 : remote.length)) return defaults;
	const base = dedupeElementKindsByValue(stripConflictingImageElementKinds(remote)).filter((k) => k.value !== _pisell_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND).filter((k) => !LEGACY_RESERVATION_TABLE_KIND_VALUES.has(k.value));
	const seen = new Set(base.map((k) => k.value));
	const out = [...base];
	for (const d of defaults) if (!seen.has(d.value)) {
		out.push(d);
		seen.add(d.value);
	}
	return dedupeElementKindsByValue(out);
}
/** 同上，补全图元分类（如「底图」），避免调色板分组缺失 */
function mergeFloorMapElementKindCategoriesWithDefaults(defaults, remote) {
	if (!(remote === null || remote === void 0 ? void 0 : remote.length)) return defaults;
	const seen = new Set(remote.map((c) => c.id));
	const out = [...remote];
	for (const d of defaults) if (!seen.has(d.id)) {
		out.push(d);
		seen.add(d.id);
	}
	return [...out].sort((a, b) => {
		var _a$order, _b$order;
		return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : 0) - ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : 0);
	});
}
/**
* 按当前 {@link locales} 刷新调色板分组、图元展示名（底图 / 资源绑定等）。
* 持久化里若仍使用约定 `categoryId`：`background`、`dining` 与约定 kind value，会覆盖旧快照文案以便随引擎语言切换。
*/
function applyReservationFloorMapLiveLabels(config) {
	var _config$elementKindCa, _config$elementKinds;
	const nextCats = (_config$elementKindCa = config.elementKindCategories) === null || _config$elementKindCa === void 0 ? void 0 : _config$elementKindCa.map((c) => {
		if (c.id === "background") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, c), {}, { label: _pisell_utils.locales.getText(I18N_FLOOR_CATEGORY_BG) });
		if (c.id === "dining") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, c), {}, { label: _pisell_utils.locales.getText(I18N_FLOOR_DS_LABEL) });
		return c;
	});
	const nextKinds = (_config$elementKinds = config.elementKinds) === null || _config$elementKinds === void 0 ? void 0 : _config$elementKinds.map((k) => {
		if (k.value === _pisell_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, k), {}, { label: _pisell_utils.locales.getText(I18N_PALETTE_IMAGE_BG) });
		if (k.value === "reservationBoundTable") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, k), {}, { label: _pisell_utils.locales.getText(I18N_ROOM_KIND_BOUND) });
		if (k.value === "reservationBoundRoundTable") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, k), {}, { label: _pisell_utils.locales.getText(I18N_ROOM_KIND_BOUND_ROUND) });
		return k;
	});
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, config), {}, {
		elementKindCategories: nextCats !== null && nextCats !== void 0 ? nextCats : config.elementKindCategories,
		elementKinds: nextKinds !== null && nextKinds !== void 0 ? nextKinds : config.elementKinds
	});
}
/** 默认画布展示名（与 reservation locales 中 canvas.* 文案对齐） */
const RESERVATION_CANVAS_NAME_MAIN = {
	en: "Main Area",
	"zh-CN": "主区域",
	"zh-HK": "主區域",
	ja: "Main Area",
	pt: "Main Area"
};
const RESERVATION_CANVAS_NAME_SECONDARY = {
	en: "Secondary Area",
	"zh-CN": "副区域",
	"zh-HK": "副區域",
	ja: "Secondary Area",
	pt: "Secondary Area"
};
const RESERVATION_CANVAS_NAME_VIP = {
	en: "VIP Area",
	"zh-CN": "VIP 区",
	"zh-HK": "VIP 區",
	ja: "VIP Area",
	pt: "VIP Area"
};
/**
* 预约平面图「绑定桌位」唯一图元 value（与底图 `floorMapImage` 并存）。
* 旧版方桌 / 长条 / 吧台图元仍可从接口 scene 回显，渲染走同一套房间卡片。
*/
const RESERVATION_BOUND_TABLE_ELEMENT_KIND = "reservationBoundTable";
/** 绑定圆桌位：与方桌同一数据源与卡片逻辑，默认 `shape: circle` */
const RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND = "reservationBoundRoundTable";
const LEGACY_RESERVATION_TABLE_KIND_VALUES = new Set([
	"reservationTable",
	"reservationPartyBench",
	"reservationBarSeat"
]);
/** 与设计稿一致的预约桌位 mock（表格 + 平面图同源） */
const defaultReservationTableRows = [
	{
		id: "t1",
		code: "VIP 1号厅",
		area: "Main",
		cardStatus: "occupied",
		guestName: "张总",
		guestPhone: "135****6789",
		time: "13:00",
		timeEnd: "15:30",
		partySize: 8,
		capacityLabel: "12",
		priceDisplay: "$ 1288",
		isPaid: true,
		delayMinutes: 13,
		progress: .62,
		progressTone: "warning",
		nextGuest: "Alex",
		nextTime: "14:30"
	},
	{
		id: "t2",
		code: "T-2",
		area: "Main",
		cardStatus: "occupied",
		guestName: "Tom",
		guestPhone: "138****1024",
		time: "13:30",
		partySize: 4,
		priceDisplay: "$ 680",
		isPaid: false,
		topAccentOrange: true,
		elapsedLabel: "1h45m",
		progress: .35,
		progressTone: "success"
	},
	{
		id: "t3",
		code: "T-3",
		area: "Main",
		cardStatus: "booked",
		guestName: "Grace",
		time: "14:08",
		partySize: 5,
		startsInMinutes: 8
	},
	{
		id: "t4",
		code: "T-4",
		area: "Main",
		cardStatus: "booked",
		guestName: "Rachel Wu",
		guestPhone: "186****5511",
		time: "14:00",
		partySize: 4,
		lateMinutes: 8,
		nextGuest: "David",
		nextTime: "15:00"
	},
	{
		id: "t5",
		code: "T-5",
		area: "Main",
		cardStatus: "booked",
		guestName: "Sophia",
		time: "12:00",
		partySize: 4
	},
	{
		id: "t6",
		code: "大包 C2",
		area: "Main",
		cardStatus: "booked",
		capacityLabel: "10",
		slots: [{
			name: "James",
			time: "10:00-12:00",
			progress: .45
		}, {
			name: "Wang Li",
			time: "12:30-14:00",
			progress: .28
		}],
		moreCount: 4
	},
	{
		id: "t7",
		code: "T-7",
		area: "Main",
		cardStatus: "available"
	},
	{
		id: "t8",
		code: "T-8",
		area: "Main",
		cardStatus: "maintenance",
		capacityLabel: "6p"
	},
	{
		id: "p1",
		code: "P-1",
		area: "Private",
		cardStatus: "occupied",
		slots: [{
			name: "Michael",
			time: "13:45"
		}, {
			name: "Grace",
			time: "14:00"
		}],
		moreCount: 3
	},
	{
		id: "p2",
		code: "P-2",
		area: "Private",
		cardStatus: "booked",
		guestName: "Mark",
		time: "13:00",
		partySize: 2
	},
	{
		id: "b1",
		code: "B-1",
		area: "Bar",
		cardStatus: "barBusy",
		time: "14:00",
		partySize: 2,
		barRemainingLabel: "1h10m"
	},
	{
		id: "b2",
		code: "B-2",
		area: "Bar",
		cardStatus: "occupied",
		time: "13:45",
		partySize: 1,
		barRemainingLabel: "55m"
	},
	{
		id: "b3",
		code: "B-3",
		area: "Bar",
		cardStatus: "booked",
		time: "13:30",
		partySize: 4
	},
	{
		id: "b4",
		code: "B-4",
		area: "Bar",
		cardStatus: "occupied",
		barSlots: [{
			name: "Sarah",
			time: "13:50"
		}, {
			name: "Kevin",
			time: "14:15"
		}]
	},
	{
		id: "b5",
		code: "B-5",
		area: "Bar",
		cardStatus: "available"
	},
	{
		id: "b6",
		code: "B-6",
		area: "Bar",
		cardStatus: "booked",
		time: "13:30",
		partySize: 4
	},
	{
		id: "b7",
		code: "B-7",
		area: "Bar",
		cardStatus: "maintenance"
	}
];
const DS = "tables";
const CANVAS_MAIN = "main";
function getReservationElementKindCategories() {
	return [{
		id: "background",
		label: _pisell_utils.locales.getText(I18N_FLOOR_CATEGORY_BG),
		order: 0
	}, {
		id: "dining",
		label: _pisell_utils.locales.getText(I18N_FLOOR_DS_LABEL),
		order: 1
	}];
}
function getReservationPaletteElementKinds() {
	return [
		{
			value: _pisell_materials.FLOOR_MAP_IMAGE_ELEMENT_KIND,
			label: _pisell_utils.locales.getText(I18N_PALETTE_IMAGE_BG),
			categoryId: "background",
			dataBindingPolicy: "none",
			showInPalette: true
		},
		{
			value: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
			label: _pisell_utils.locales.getText(I18N_ROOM_KIND_BOUND),
			categoryId: "dining",
			dataBindingPolicy: "optional",
			allowedDataSourceKeys: [DS],
			showInPalette: true
		},
		{
			value: RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND,
			label: _pisell_utils.locales.getText(I18N_ROOM_KIND_BOUND_ROUND),
			categoryId: "dining",
			dataBindingPolicy: "optional",
			allowedDataSourceKeys: [DS],
			defaultShape: "circle",
			showInPalette: true
		}
	];
}
const CANVAS_SECONDARY = "secondary";
const CANVAS_VIP = "vip";
/**
* 默认平面图图元（唯一真相源）。
* 有 floorMapConfig 时 PisellFloorMapLayout 强制 itemUnit=pixel，故 x/y/width/height 均为「像素」，非格子数。
*/
const defaultReservationSceneElements = [
	{
		instanceId: "res_t1",
		canvasId: CANVAS_MAIN,
		x: 40,
		y: 40,
		width: 150,
		height: 100,
		name: "T-1",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t1"
		}
	},
	{
		instanceId: "res_t2",
		canvasId: CANVAS_MAIN,
		x: 210,
		y: 40,
		width: 150,
		height: 100,
		name: "T-2",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t2"
		}
	},
	{
		instanceId: "res_t3",
		canvasId: CANVAS_MAIN,
		x: 380,
		y: 40,
		width: 150,
		height: 100,
		name: "T-3",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t3"
		}
	},
	{
		instanceId: "res_p2",
		canvasId: CANVAS_MAIN,
		x: 550,
		y: 40,
		width: 140,
		height: 100,
		name: "P-2",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "p2"
		}
	},
	{
		instanceId: "res_t4",
		canvasId: CANVAS_MAIN,
		x: 40,
		y: 170,
		width: 150,
		height: 100,
		name: "T-4",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t4"
		}
	},
	{
		instanceId: "res_t5",
		canvasId: CANVAS_MAIN,
		x: 210,
		y: 170,
		width: 150,
		height: 100,
		name: "T-5",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t5"
		}
	},
	{
		instanceId: "res_t6",
		canvasId: CANVAS_MAIN,
		x: 380,
		y: 170,
		width: 150,
		height: 100,
		name: "T-6",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t6"
		}
	},
	{
		instanceId: "res_p1",
		canvasId: CANVAS_MAIN,
		x: 710,
		y: 40,
		width: 240,
		height: 240,
		name: "P-1",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "p1"
		}
	},
	{
		instanceId: "res_t7",
		canvasId: CANVAS_MAIN,
		x: 40,
		y: 300,
		width: 150,
		height: 100,
		name: "T-7",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t7"
		}
	},
	{
		instanceId: "res_t8",
		canvasId: CANVAS_MAIN,
		x: 210,
		y: 300,
		width: 150,
		height: 100,
		name: "T-8",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "t8"
		}
	},
	{
		instanceId: "res_b1",
		canvasId: CANVAS_MAIN,
		x: 40,
		y: 440,
		width: 90,
		height: 90,
		name: "B-1",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b1"
		}
	},
	{
		instanceId: "res_b2",
		canvasId: CANVAS_MAIN,
		x: 150,
		y: 440,
		width: 90,
		height: 90,
		name: "B-2",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b2"
		}
	},
	{
		instanceId: "res_b3",
		canvasId: CANVAS_MAIN,
		x: 260,
		y: 440,
		width: 90,
		height: 90,
		name: "B-3",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b3"
		}
	},
	{
		instanceId: "res_b4",
		canvasId: CANVAS_MAIN,
		x: 370,
		y: 440,
		width: 90,
		height: 90,
		name: "B-4",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b4"
		}
	},
	{
		instanceId: "res_b5",
		canvasId: CANVAS_MAIN,
		x: 480,
		y: 440,
		width: 90,
		height: 90,
		name: "B-5",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b5"
		}
	},
	{
		instanceId: "res_b6",
		canvasId: CANVAS_MAIN,
		x: 590,
		y: 440,
		width: 90,
		height: 90,
		name: "B-6",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b6"
		}
	},
	{
		instanceId: "res_b7",
		canvasId: CANVAS_MAIN,
		x: 700,
		y: 440,
		width: 90,
		height: 90,
		name: "B-7",
		zIndex: 0,
		elementKind: RESERVATION_BOUND_TABLE_ELEMENT_KIND,
		dataBinding: {
			dataSourceKey: DS,
			recordId: "b7"
		}
	}
];
defaultReservationSceneElements.map((el) => {
	var _el$name, _el$elementKind;
	const placement = {
		dataSourceKey: el.dataBinding.dataSourceKey,
		id: String(el.dataBinding.recordId),
		floorMapId: el.canvasId,
		x: el.x,
		y: el.y,
		name: String((_el$name = el.name) !== null && _el$name !== void 0 ? _el$name : ""),
		width: el.width,
		height: el.height,
		elementKind: String((_el$elementKind = el.elementKind) !== null && _el$elementKind !== void 0 ? _el$elementKind : "")
	};
	if (el.shape === "circle") placement.shape = "circle";
	return placement;
});
function cloneSceneElements(els) {
	return els.map((el) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, el), {}, { dataBinding: el.dataBinding ? require_objectSpread2._objectSpread2({}, el.dataBinding) : void 0 }));
}
/**
* 预约页默认平面图壳子：画布/图元种类与 mock 一致，但不带演示 sceneElements。
* 生产态布局以 floor-plan 接口与编辑保存为准。
*/
function getReservationFloorMapShellConfig() {
	return {
		canvases: [
			{
				id: CANVAS_MAIN,
				name: RESERVATION_CANVAS_NAME_MAIN,
				order: 0,
				enabled: true
			},
			{
				id: CANVAS_SECONDARY,
				name: RESERVATION_CANVAS_NAME_SECONDARY,
				order: 1,
				enabled: true
			},
			{
				id: CANVAS_VIP,
				name: RESERVATION_CANVAS_NAME_VIP,
				order: 2,
				enabled: true
			}
		],
		canvasUi: {
			canCreate: true,
			canEdit: true
		},
		elementKindCategories: getReservationElementKindCategories(),
		elementKinds: getReservationPaletteElementKinds(),
		sceneElements: []
	};
}
/** 平面图初始配置：sceneElements 使用上方完整 width/height，勿仅依赖派生表 */
function getDefaultReservationFloorMapConfig() {
	return {
		canvases: [
			{
				id: CANVAS_MAIN,
				name: RESERVATION_CANVAS_NAME_MAIN,
				order: 0,
				enabled: true
			},
			{
				id: CANVAS_SECONDARY,
				name: RESERVATION_CANVAS_NAME_SECONDARY,
				order: 1,
				enabled: true
			},
			{
				id: CANVAS_VIP,
				name: RESERVATION_CANVAS_NAME_VIP,
				order: 2,
				enabled: true
			}
		],
		canvasUi: {
			canCreate: true,
			canEdit: true
		},
		elementKindCategories: getReservationElementKindCategories(),
		elementKinds: getReservationPaletteElementKinds(),
		sceneElements: cloneSceneElements(defaultReservationSceneElements)
	};
}
/** 平面图侧栏数据源记录表单列（随当前语言刷新） */
function getReservationDataSourceFormColumns() {
	return [
		{
			key: "code",
			label: _pisell_utils.locales.getText("pisell-reservation.grid.code"),
			type: "string"
		},
		{
			key: "guestName",
			label: _pisell_utils.locales.getText("pisell-reservation.grid.guest"),
			type: "string"
		},
		{
			key: "time",
			label: _pisell_utils.locales.getText("pisell-reservation.grid.time"),
			type: "string"
		},
		{
			key: "partySize",
			label: _pisell_utils.locales.getText("pisell-reservation.grid.party"),
			type: "number"
		},
		{
			key: "cardStatus",
			label: _pisell_utils.locales.getText("pisell-reservation.resource-grid.card-status"),
			type: "string"
		},
		{
			key: "area",
			label: _pisell_utils.locales.getText("pisell-reservation.grid.area"),
			type: "string"
		}
	];
}
//#endregion
exports.RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND = RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND;
exports.RESERVATION_BOUND_TABLE_ELEMENT_KIND = RESERVATION_BOUND_TABLE_ELEMENT_KIND;
exports.applyReservationFloorMapLiveLabels = applyReservationFloorMapLiveLabels;
exports.defaultReservationTableRows = defaultReservationTableRows;
exports.getDefaultReservationFloorMapConfig = getDefaultReservationFloorMapConfig;
exports.getReservationDataSourceFormColumns = getReservationDataSourceFormColumns;
exports.getReservationFloorMapShellConfig = getReservationFloorMapShellConfig;
exports.mergeFloorMapElementKindCategoriesWithDefaults = mergeFloorMapElementKindCategoriesWithDefaults;
exports.mergeFloorMapElementKindsWithDefaults = mergeFloorMapElementKindsWithDefaults;
