const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_reservationConstants = require("../reservationConstants.js");
const require_reservationDataUtils = require("../data/reservationDataUtils.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/plus/pisellReservation/components/PisellReservationSubcomponents.tsx
/**
* 预约页拆出的轻量子组件（无业务数据请求）：
* - `RecordBoardBodyViewCapture`：把当前 grid/floorMap 同步到父组件 ref，供 debounce effect 读 bodyView；
* - `ScheduleSyncOnFloorEnter`：从表格回到平面图时，用当前营业日 patch 预约列表时间窗口；
* - `PisellReservationToolbarTabs`：平面图下的日程带 + 表格/平面图 Segmented；
* - `ReservationGridTopRight` / `PisellReservationScheduleEndActions` / `ReservationFloorMapCanvasTabsTrailing`：工具栏与画布尾区。
*/
/** 无 UI：仅将 RecordBoard Context 中的 `bodyView` 写入 ref */
function RecordBoardBodyViewCapture(props) {
	const { bodyView } = (0, _pisell_materials.useRecordBoardContext)();
	(0, react.useEffect)(() => {
		props.bodyViewRef.current = bodyView;
	}, [bodyView, props.bodyViewRef]);
	return null;
}
/** 从表格切回平面图时，用当前日程把列表区间同步到平面图维度 */
function ScheduleSyncOnFloorEnter(props) {
	const { bodyView } = (0, _pisell_materials.useRecordBoardContext)();
	const prevRef = (0, react.useRef)(null);
	(0, react.useEffect)(() => {
		const prev = prevRef.current;
		if (props.isInternalListData && bodyView === "floorMap" && prev !== null && prev !== "floorMap") props.patchSearchParams((p) => require_reservationDataUtils.mergeSearchParamsBookingWindow(p, props.schedule.date));
		prevRef.current = bodyView;
	}, [
		bodyView,
		props.schedule.date.valueOf(),
		props.isInternalListData,
		props.patchSearchParams,
		props.schedule.date
	]);
	return null;
}
/**
* 顶栏 tabs：平面图下为日程带 + 时间轴 + 标题旁切换；表格下不展示 ScheduleBand，
* 切换器由 RecordBoard 工具栏顶行（Find 左侧）承担，与历史行为一致。
*/
function PisellReservationToolbarTabs(props) {
	var _shellMeta$hasGridCon, _props$scheduleProps, _props$timeNavigatorP, _props$timeNavigatorP2, _props$timeNavigatorP3, _props$timeNavigatorP4, _props$timeNavigatorP7;
	const { bodyView, setBodyView, bodyViewSwitchable } = (0, _pisell_materials.useRecordBoardContext)();
	const shellMeta = (0, _pisell_materials.useRecordBoardShellBodyMeta)();
	const hasGrid = (_shellMeta$hasGridCon = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasGridContent) !== null && _shellMeta$hasGridCon !== void 0 ? _shellMeta$hasGridCon : true;
	const hasFloor = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.hasFloorMapSlot;
	const floorForToggle = shellMeta === null || shellMeta === void 0 ? void 0 : shellMeta.effectiveFloorMapProps;
	const allowBodyViewToggle = hasGrid && hasFloor && floorForToggle != null && bodyViewSwitchable !== false;
	if (bodyView === "grid") return props.extraTabs ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, props.extraTabs) : null;
	const bodyViewToggle = allowBodyViewToggle ? /* @__PURE__ */ react.default.createElement(antd.Segmented, {
		className: "pisell-reservation-body-view-segmented",
		size: "large",
		value: bodyView,
		onChange: (v) => setBodyView(v),
		options: [{
			label: _pisell_utils.locales.getText(require_reservationConstants.I18N_VIEW_FLOOR),
			value: "floorMap"
		}, {
			label: _pisell_utils.locales.getText(require_reservationConstants.I18N_VIEW_GRID),
			value: "grid"
		}]
	}) : null;
	const scheduleStartMerged = /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-schedule-start-merge" }, props.scheduleStartSlot, bodyViewToggle);
	const afterDateSlot = /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-follow-time-slot" }, props.followWallClock ? /* @__PURE__ */ react.default.createElement("span", {
		className: "pisell-reservation-follow-time-hint pisell-reservation-follow-time-hint--at-current",
		"aria-live": "polite"
	}, _pisell_utils.locales.getText(require_reservationConstants.I18N_AT_CURRENT_TIME)) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("span", {
		className: "pisell-reservation-follow-time-hint pisell-reservation-follow-time-hint--off-current",
		"aria-live": "polite"
	}, _pisell_utils.locales.getText(require_reservationConstants.I18N_NON_CURRENT_HINT)), /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		className: "pisell-reservation-follow-current-btn pisell-reservation-follow-current-btn--go-current",
		onClick: props.onFollowWallClockToggle,
		"aria-pressed": false
	}, /* @__PURE__ */ react.default.createElement("span", { className: "pisell-reservation-follow-current-btn-label" }, _pisell_utils.locales.getText(require_reservationConstants.I18N_GO_CURRENT)))));
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellReservationScheduleBand, {
		value: props.schedule,
		onChange: props.onScheduleChange,
		scheduleProps: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.scheduleProps), {}, { navigationLocked: Boolean((_props$scheduleProps = props.scheduleProps) === null || _props$scheduleProps === void 0 ? void 0 : _props$scheduleProps.navigationLocked) }),
		timeNavigatorProps: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
			range: require_reservationConstants.RESERVATION_TIMELINE_BUSINESS_RANGE,
			businessHours: require_reservationConstants.RESERVATION_TIMELINE_BUSINESS_RANGE
		}, props.timeNavigatorProps), {}, {
			showNowButton: (_props$timeNavigatorP = (_props$timeNavigatorP2 = props.timeNavigatorProps) === null || _props$timeNavigatorP2 === void 0 ? void 0 : _props$timeNavigatorP2.showNowButton) !== null && _props$timeNavigatorP !== void 0 ? _props$timeNavigatorP : false,
			snapToStep: false,
			cursorMode: (_props$timeNavigatorP3 = (_props$timeNavigatorP4 = props.timeNavigatorProps) === null || _props$timeNavigatorP4 === void 0 ? void 0 : _props$timeNavigatorP4.cursorMode) !== null && _props$timeNavigatorP3 !== void 0 ? _props$timeNavigatorP3 : "cursor-moves",
			onUserInteraction: () => {
				var _props$timeNavigatorP5, _props$timeNavigatorP6;
				props.onTimeNavigatorUserInteraction();
				(_props$timeNavigatorP5 = props.timeNavigatorProps) === null || _props$timeNavigatorP5 === void 0 || (_props$timeNavigatorP6 = _props$timeNavigatorP5.onUserInteraction) === null || _props$timeNavigatorP6 === void 0 || _props$timeNavigatorP6.call(_props$timeNavigatorP5);
			},
			userInteractionLocked: Boolean((_props$timeNavigatorP7 = props.timeNavigatorProps) === null || _props$timeNavigatorP7 === void 0 ? void 0 : _props$timeNavigatorP7.userInteractionLocked),
			loadDensity: props.loadDensity
		}),
		scheduleStartSlot: scheduleStartMerged,
		scheduleAfterDateSlot: afterDateSlot,
		scheduleEndSlot: props.scheduleEndSlot
	}), props.extraTabs);
}
/** 表格视图时展示工具栏右上角透传；平面图时收起（编辑入口在画布 Tab 行右侧） */
function ReservationGridTopRight(props) {
	var _props$extra;
	const { bodyView } = (0, _pisell_materials.useRecordBoardContext)();
	if (bodyView === "floorMap") return null;
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, (_props$extra = props.extra) !== null && _props$extra !== void 0 ? _props$extra : null);
}
/** 顶栏日程带右侧：新建 */
function PisellReservationScheduleEndActions(props) {
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-reservation-schedule-end-slots" }, /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		className: "pisell-reservation-new-btn",
		onClick: () => {
			var _props$onNewReservati;
			return (_props$onNewReservati = props.onNewReservation) === null || _props$onNewReservati === void 0 ? void 0 : _props$onNewReservati.call(props);
		}
	}, _pisell_utils.locales.getText(require_reservationConstants.I18N_NEW)));
}
/** 平面图左下 Dock 展开区：编辑 / 完成编辑（经 PisellFloorMapLayout.viewportDockTrailing） */
function ReservationFloorMapCanvasTabsTrailing(props) {
	const { bodyView } = (0, _pisell_materials.useRecordBoardContext)();
	(0, react.useEffect)(() => {
		if (bodyView !== "floorMap" && props.mapEditInternal) props.setMapEditInternal(false);
	}, [
		bodyView,
		props.mapEditInternal,
		props.setMapEditInternal
	]);
	if (props.isFloorModeControlled || bodyView !== "floorMap") return null;
	return /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "primary",
		size: "middle",
		className: "pisell-reservation-topbar-edit-btn",
		onClick: () => {
			if (props.mapEditInternal) {
				var _props$floorMapLayout, _props$floorMapLayout2;
				(_props$floorMapLayout = props.floorMapLayoutRef.current) === null || _props$floorMapLayout === void 0 || (_props$floorMapLayout2 = _props$floorMapLayout.saveLayout) === null || _props$floorMapLayout2 === void 0 || _props$floorMapLayout2.call(_props$floorMapLayout);
			}
			props.setMapEditInternal((v) => !v);
		}
	}, _pisell_utils.locales.getText(props.mapEditInternal ? require_reservationConstants.I18N_EDIT_MAP_DONE : require_reservationConstants.I18N_EDIT_MAP));
}
/** 默认顶栏标题 slot */
function ReservationDefaultScheduleStart() {
	return /* @__PURE__ */ react.default.createElement("span", { className: "pisell-reservation-page-title" }, _pisell_utils.locales.getText(require_reservationConstants.I18N_PAGE_TITLE));
}
/** 场控页顶栏标题 slot */
function ReservationVenueScheduleStart() {
	return /* @__PURE__ */ react.default.createElement("span", { className: "pisell-reservation-page-title" }, _pisell_utils.locales.getText(require_reservationConstants.I18N_PAGE_TITLE_VENUE));
}
//#endregion
exports.PisellReservationScheduleEndActions = PisellReservationScheduleEndActions;
exports.PisellReservationToolbarTabs = PisellReservationToolbarTabs;
exports.RecordBoardBodyViewCapture = RecordBoardBodyViewCapture;
exports.ReservationDefaultScheduleStart = ReservationDefaultScheduleStart;
exports.ReservationFloorMapCanvasTabsTrailing = ReservationFloorMapCanvasTabsTrailing;
exports.ReservationGridTopRight = ReservationGridTopRight;
exports.ReservationVenueScheduleStart = ReservationVenueScheduleStart;
exports.ScheduleSyncOnFloorEnter = ScheduleSyncOnFloorEnter;
