const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_reservationConstants = require("../reservationConstants.js");
const require_ReservationFloorMapHud = require("../floorMap/ReservationFloorMapHud.js");
const require_ReservationHudDrawerHandle = require("../floorMap/ReservationHudDrawerHandle.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/plus/pisellReservation/components/ReservationHudDrawer.tsx
/**
* 读取元素上均匀 scale（matrix(a,0,0,d,...)）；非均匀或无法解析时返回 1。
* body 整体 scale 时 layout×scale≈视觉；要保持「相当于 98vh」的屏幕占比，应用 height: calc(98vh / scale)。
*/
function readUniformScaleFromTransform(el) {
	const t = getComputedStyle(el).transform;
	if (!t || t === "none") return 1;
	try {
		const m = new DOMMatrixReadOnly(t);
		const sx = Math.abs(m.a);
		const sy = Math.abs(m.d);
		if (!Number.isFinite(sx) || !Number.isFinite(sy)) return 1;
		if (Math.abs(sx - sy) > .03) return 1;
		return sx > 1e-6 ? sx : 1;
	} catch (_unused) {
		return 1;
	}
}
/**
* 平面图 HUD：左下角 chip + 展开抽屉（内嵌 RecordBoard + 可选资源竖栏）。
*/
function ReservationHudDrawer({ floorMapHudTableDrawer, showVenueHudDock, hudDrawerOpen, hudDrawerRef, hudMapItems, dataSources, handleOpenHudTableDrawer, closeHudTableDrawer, rowKey, hudDrawerPagedRows, hudDrawerLoading, hudDrawerFilteredTotal, hudDrawerBookingPagination, hudDrawerOnPageChange, hudDrawerLocalSearchParams, hudDrawerOnSearch, hudDrawerOnReset, hudDrawerGrid, hudDrawerToolBar, batchActionBar, hudDrawerResourceRootBuckets, handleHudDrawerFormRecordIdsChange }) {
	/**
	* body 带均匀 scale 时：`98vh` 布局尺寸正确，屏幕上视觉高度会 ×scale；
	* 打开抽屉时用 `calc(98vh / scale)` 对齐「视觉上约 98vh」的占位。
	*/
	(0, react.useLayoutEffect)(() => {
		if (typeof window === "undefined") return;
		if (!hudDrawerOpen) {
			const cleared = hudDrawerRef.current;
			if (cleared) {
				cleared.style.height = "";
				cleared.style.maxHeight = "";
			}
			return;
		}
		const el = hudDrawerRef.current;
		if (!el) return;
		const scale = readUniformScaleFromTransform(document.body);
		if (scale > 0 && Math.abs(scale - 1) > .001) {
			el.style.height = `calc(98vh / ${scale})`;
			el.style.maxHeight = `calc(98vh / ${scale})`;
		} else {
			el.style.height = "";
			el.style.maxHeight = "";
		}
		return () => {
			const next = hudDrawerRef.current;
			if (next) {
				next.style.height = "";
				next.style.maxHeight = "";
			}
		};
	}, [hudDrawerOpen, hudDrawerRef]);
	if (!showVenueHudDock) return null;
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, !hudDrawerOpen ? /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-reservation-hud-title",
		role: "button",
		tabIndex: 0,
		"aria-label": _pisell_utils.locales.getText(require_reservationConstants.I18N_HUD_TABLE_DRAWER_TITLE),
		onClick: handleOpenHudTableDrawer,
		onKeyDown: (e) => {
			if (e.key === "Enter" || e.key === " ") {
				e.preventDefault();
				handleOpenHudTableDrawer();
			}
		}
	}, /* @__PURE__ */ react.default.createElement(require_ReservationFloorMapHud.ReservationFloorMapHudTitleBar, {
		items: hudMapItems,
		dataSources,
		actionMode: "expand",
		onAction: handleOpenHudTableDrawer,
		embedded: true,
		className: "pisell-reservation-hud-title-inner"
	})) : null, hudDrawerOpen ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-reservation-hud-drawer-mask",
		onClick: closeHudTableDrawer,
		"aria-hidden": "true"
	}), /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-reservation-hud-drawer",
		role: "dialog",
		"aria-modal": "false",
		"aria-label": _pisell_utils.locales.getText(require_reservationConstants.I18N_HUD_TABLE_DRAWER_TITLE),
		ref: hudDrawerRef
	}, /* @__PURE__ */ react.default.createElement(require_ReservationHudDrawerHandle.default, {
		onClose: closeHudTableDrawer,
		drawerRef: hudDrawerRef
	}), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-hud-drawer-record-board" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-hud-drawer-split" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-hud-drawer-split-main" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard, {
		layoutVariant: "phone",
		columnVisibilityStorageKey: require_reservationConstants.PISELL_RESERVATION_HUD_DRAWER_COLUMN_STORAGE_KEY,
		rowKey,
		data: hudDrawerPagedRows,
		loading: hudDrawerLoading,
		total: hudDrawerFilteredTotal,
		pagination: hudDrawerBookingPagination,
		onPageChange: hudDrawerOnPageChange,
		searchParams: hudDrawerLocalSearchParams,
		onSearch: hudDrawerOnSearch,
		onReset: hudDrawerOnReset,
		grid: hudDrawerGrid,
		toolBar: hudDrawerToolBar,
		batchActionBar,
		defaultBodyView: "grid",
		bodyViewSwitchable: false,
		lockedBodyView: "grid"
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard.ShellFrame, { belowToolbar: void 0 }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard.GridLayout, null)))), null)))) : null);
}
//#endregion
exports.ReservationHudDrawer = ReservationHudDrawer;
