const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_calendarI18n = require("../calendarI18n.js");
const require_bookingCalendarDateUtils = require("../utils/bookingCalendarDateUtils.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/pisellRecordBoard/shellFrame/Calendar/modal/MoveConfirmModal.tsx
/** 拖拽改期后的确认弹窗（Court / 日期 / 起止时间） */
function MoveConfirmModal({ moveConfirm, moveDraft, setMoveDraft, panelRef, isLight, courts, visibleCourts, hourSlots, isBusinessHour, firstTimelineHour, endTimelineExclusive, onConfirm, onClose }) {
	var _detail$customer, _detail$customer2, _detail$customer3, _courts$find, _courts$find2, _moveDraft$targetHour;
	if (!moveConfirm) return null;
	const detail = require_bookingCalendarDateUtils.getBookingDetailData(moveConfirm.item, courts);
	const currentCustomer = {
		name: ((_detail$customer = detail.customer) === null || _detail$customer === void 0 ? void 0 : _detail$customer.name) || detail.headerSummary.customerName,
		phone: ((_detail$customer2 = detail.customer) === null || _detail$customer2 === void 0 ? void 0 : _detail$customer2.phone) || "",
		email: ((_detail$customer3 = detail.customer) === null || _detail$customer3 === void 0 ? void 0 : _detail$customer3.email) || ""
	};
	const originalCourtName = ((_courts$find = courts.find((c) => c.id === moveConfirm.item.courtId)) === null || _courts$find === void 0 ? void 0 : _courts$find.name) || detail.headerSummary.resourceLabel || require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.courtFallback");
	const nextCourtName = ((_courts$find2 = courts.find((c) => c.id === ((moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetCourtId) || moveConfirm.targetCourtId))) === null || _courts$find2 === void 0 ? void 0 : _courts$find2.name) || require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.courtFallback");
	const originalDate = moveConfirm.item.date;
	const originalStart = require_bookingCalendarDateUtils.formatHourLabel(moveConfirm.item.startHour);
	const originalEnd = require_bookingCalendarDateUtils.formatHourLabel(moveConfirm.item.endHour);
	const nextDate = (moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetDate) || moveConfirm.targetDate;
	const nextStartHour = (_moveDraft$targetHour = moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetHour) !== null && _moveDraft$targetHour !== void 0 ? _moveDraft$targetHour : moveConfirm.targetHour;
	const duration = moveConfirm.item.endHour - moveConfirm.item.startHour;
	const nextEndHour = nextStartHour + duration;
	const changed = originalDate !== nextDate || moveConfirm.item.courtId !== ((moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetCourtId) || moveConfirm.targetCourtId) || moveConfirm.item.startHour !== nextStartHour;
	const isDragScenario = moveConfirm.item.date !== moveConfirm.targetDate || moveConfirm.item.startHour !== moveConfirm.targetHour || moveConfirm.item.courtId !== moveConfirm.targetCourtId;
	const slotDisabledLabel = (hour) => require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.slotDisabled", { time: require_bookingCalendarDateUtils.formatHourLabel(hour) });
	return /* @__PURE__ */ react.default.createElement("div", { className: "fixed inset-0 z-[72] bg-black/45 backdrop-blur-sm flex items-center justify-center p-4" }, /* @__PURE__ */ react.default.createElement("div", {
		ref: panelRef,
		className: `w-full max-w-[980px] rounded-3xl border p-6 shadow-2xl ${isLight ? "theme-panel theme-border soft-shadow" : "border-zinc-700 bg-[#121217]"}`
	}, /* @__PURE__ */ react.default.createElement("div", { className: "text-[22px] font-semibold" }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.title")), /* @__PURE__ */ react.default.createElement("div", { className: `mt-2 text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.subtitle")), /* @__PURE__ */ react.default.createElement("div", { className: "mt-5 space-y-4" }, /* @__PURE__ */ react.default.createElement("div", { className: `rounded-3xl border p-5 ${isLight ? "theme-panel-alt theme-border" : "border-zinc-700 bg-[#171820]"}` }, /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0 flex-1" }, /* @__PURE__ */ react.default.createElement("div", { className: `text-xs uppercase tracking-[0.14em] ${isLight ? "theme-text-muted" : "text-zinc-500"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.customer")), /* @__PURE__ */ react.default.createElement("div", { className: `mt-3 text-[20px] font-semibold ${isLight ? "theme-text" : "text-white"}` }, currentCustomer.name), /* @__PURE__ */ react.default.createElement("div", { className: `mt-2 text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, currentCustomer.phone || require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.noPhone")), /* @__PURE__ */ react.default.createElement("div", { className: `mt-1 text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, currentCustomer.email || require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.noEmail")))), /* @__PURE__ */ react.default.createElement("div", { className: "grid min-w-0 gap-4 md:grid-cols-2" }, /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ react.default.createElement("label", { className: `mb-2 block text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.court")), /* @__PURE__ */ react.default.createElement("select", {
		value: (moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetCourtId) || moveConfirm.targetCourtId,
		onChange: (e) => setMoveDraft((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev || {}), {}, { targetCourtId: e.target.value })),
		className: `min-w-0 w-full rounded-2xl px-4 py-4 outline-none ${isLight ? "theme-input theme-text" : "border border-zinc-700 bg-[#171820] text-white"}`
	}, visibleCourts.map((court) => /* @__PURE__ */ react.default.createElement("option", {
		key: court.id,
		value: court.id
	}, court.name)))), /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ react.default.createElement("label", { className: `mb-2 block text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.newDate")), /* @__PURE__ */ react.default.createElement("input", {
		type: "date",
		value: (moveDraft === null || moveDraft === void 0 ? void 0 : moveDraft.targetDate) || moveConfirm.targetDate,
		onChange: (e) => setMoveDraft((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev || {}), {}, { targetDate: e.target.value })),
		className: `min-w-0 w-full rounded-2xl py-4 pl-4 pr-11 outline-none [color-scheme:dark] [&::-webkit-calendar-picker-indicator]:ml-auto [&::-webkit-calendar-picker-indicator]:mr-1 ${isLight ? "theme-input theme-text [color-scheme:light]" : "border border-zinc-700 bg-[#171820] text-white"}`
	}))), /* @__PURE__ */ react.default.createElement("div", { className: "grid min-w-0 gap-4 md:grid-cols-2" }, /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ react.default.createElement("label", { className: `mb-2 block text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.newStartTime")), /* @__PURE__ */ react.default.createElement("select", {
		value: nextStartHour,
		onChange: (e) => setMoveDraft((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev || {}), {}, { targetHour: Number(e.target.value) })),
		className: `min-w-0 w-full rounded-2xl px-4 py-4 outline-none ${isLight ? "theme-input theme-text" : "border border-zinc-700 bg-[#171820] text-white"}`
	}, hourSlots.filter(isBusinessHour).map((hour) => {
		const disabled = hour + duration > endTimelineExclusive;
		return /* @__PURE__ */ react.default.createElement("option", {
			key: hour,
			value: hour,
			disabled
		}, disabled ? slotDisabledLabel(hour) : require_bookingCalendarDateUtils.formatHourLabel(hour));
	}))), /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ react.default.createElement("label", { className: `mb-2 block text-sm ${isLight ? "theme-text-muted" : "text-zinc-400"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.newEndTime")), /* @__PURE__ */ react.default.createElement("select", {
		value: nextEndHour,
		onChange: (e) => {
			const nextEnd = Number(e.target.value);
			setMoveDraft((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev || {}), {}, { targetHour: nextEnd - duration }));
		},
		className: `min-w-0 w-full rounded-2xl px-4 py-4 outline-none ${isLight ? "theme-input theme-text" : "border border-zinc-700 bg-[#171820] text-white"}`
	}, hourSlots.filter(isBusinessHour).map((hour) => {
		const disabled = hour - duration < firstTimelineHour;
		return /* @__PURE__ */ react.default.createElement("option", {
			key: `end-${hour}`,
			value: hour,
			disabled
		}, disabled ? slotDisabledLabel(hour) : require_bookingCalendarDateUtils.formatHourLabel(hour));
	})))), changed && /* @__PURE__ */ react.default.createElement("div", { className: `rounded-3xl border p-5 ${isLight ? "theme-panel-alt theme-border" : "border-zinc-700 bg-[#171820]"}` }, /* @__PURE__ */ react.default.createElement("div", { className: `text-xs uppercase tracking-[0.14em] ${isLight ? "theme-text-muted" : "text-zinc-500"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.previousInfo")), /* @__PURE__ */ react.default.createElement("div", { className: "mt-3 grid gap-3 md:grid-cols-2" }, /* @__PURE__ */ react.default.createElement("div", { className: `rounded-2xl p-4 ${isLight ? "theme-panel" : "bg-[#101117]"}` }, /* @__PURE__ */ react.default.createElement("div", { className: `text-xs ${isLight ? "theme-text-muted" : "text-zinc-500"}` }, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.original")), /* @__PURE__ */ react.default.createElement("div", { className: `mt-2 text-sm ${isLight ? "theme-text-soft" : "text-zinc-300"}` }, originalCourtName), /* @__PURE__ */ react.default.createElement("div", { className: `mt-1 text-sm ${isLight ? "theme-text-soft" : "text-zinc-300"}` }, originalDate), /* @__PURE__ */ react.default.createElement("div", { className: `mt-1 text-sm ${isLight ? "theme-text-soft" : "text-zinc-300"}` }, originalStart, " - ", originalEnd)), /* @__PURE__ */ react.default.createElement("div", { className: `rounded-2xl p-4 ${isLight ? "theme-brand-surface border border-[var(--brand-light)]" : "bg-violet-600/10 border border-violet-500/30"}` }, /* @__PURE__ */ react.default.createElement("div", { className: `text-xs ${isLight ? "theme-brand-text" : "text-violet-300"}` }, isDragScenario ? require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.dropTarget") : require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.updated")), /* @__PURE__ */ react.default.createElement("div", { className: `mt-2 text-sm ${isLight ? "theme-text" : "text-white"}` }, nextCourtName), /* @__PURE__ */ react.default.createElement("div", { className: `mt-1 text-sm ${isLight ? "theme-text" : "text-white"}` }, nextDate), /* @__PURE__ */ react.default.createElement("div", { className: `mt-1 text-sm ${isLight ? "theme-text" : "text-white"}` }, require_bookingCalendarDateUtils.formatHourLabel(nextStartHour), " -", " ", require_bookingCalendarDateUtils.formatHourLabel(nextEndHour)))))), /* @__PURE__ */ react.default.createElement("div", { className: "mt-6 flex justify-end gap-3" }, /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		onClick: onClose,
		className: `rounded-2xl px-5 py-3 ${isLight ? "btn-neutral" : "border border-zinc-700 text-zinc-300"}`
	}, require_calendarI18n.tCal("pisell2.recordBoard.calendar.common.cancel")), /* @__PURE__ */ react.default.createElement("button", {
		type: "button",
		onClick: onConfirm,
		className: "rounded-2xl bg-violet-600 px-6 py-3 font-semibold text-white"
	}, require_calendarI18n.tCal("pisell2.recordBoard.calendar.move.confirm")))));
}
//#endregion
exports.MoveConfirmModal = MoveConfirmModal;
