const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_useComponents = require("../../../../../hooks/useComponents.js");
const require_utils = require("../../../utils.js");
const require_context = require("../../../context.js");
const require_hooks = require("../../../hooks.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.tsx
const SelectDate = (props) => {
	const { onDateChange, times, currentDate } = props;
	const appointmentBooking = require_hooks.useAppointmentBooking();
	const { currentSelectedResources, setTimes } = require_context.useAppointmentBookingContext();
	const utils = require_hooks.contextUtils();
	const [SelectDateOS] = require_useComponents.default({ components: ["SelectDateOS"] });
	/**
	* @description: 获取资源代码
	* @param {*}
	* @return {*}
	*/
	const resourceCode = (0, react.useMemo)(() => {
		const { resourceSort } = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.otherParams) || {};
		const { resourceCodes } = require_utils.processResourceList(appointmentBooking.getResourcesList(), resourceSort);
		return (resourceCodes === null || resourceCodes === void 0 ? void 0 : resourceCodes[0]) || "";
	}, []);
	/**
	* @description: 获取资源名称
	* @param {*} useMemo
	* @return {*}
	*/
	const currentResourceName = (0, react.useMemo)(() => {
		var _currentSelectedResou;
		const currentResource = currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou = currentSelectedResources[0]) === null || _currentSelectedResou === void 0 ? void 0 : _currentSelectedResou.currentSelectedResource;
		const resourceItem = (currentResource === null || currentResource === void 0 ? void 0 : currentResource.resourceItem) || {};
		return require_utils.getResourceTitle(appointmentBooking, resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.code, utils, resourceItem);
	}, [currentSelectedResources]);
	/**
	* @description: 跳转到服务步骤
	* @param {any} step
	* @return {*}
	*/
	const onStepChange = () => {
		require_utils.clearDataByStepKey("select-service", appointmentBooking, setTimes);
		const serviceIndex = appointmentBooking.getStepList().findIndex((item) => (item === null || item === void 0 ? void 0 : item.key) === "select-service");
		appointmentBooking.gotoStep(serviceIndex);
	};
	return SelectDateOS ? /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement(SelectDateOS, {
		isTimeSlicing: true,
		currentDate,
		resourceCode,
		resourceName: currentResourceName,
		onDateChange,
		onStepChange,
		times
	})) : null;
};
//#endregion
exports.default = SelectDate;
