require("../../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../utils.js");
let react = require("react");
//#region src/components/booking/info/service2/hooks/useSelectPet.tsx
const useSelectPet = (state) => {
	var _state$pet2, _state$pet4;
	const isDaysBookingBol = (0, react.useMemo)(() => {
		return require_utils.isDayBooking(state);
	}, [state === null || state === void 0 ? void 0 : state.renderType]);
	/**
	* @title: pets数据
	* @description:
	* @param {any} state
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-03 11:39
	*/
	const petLists = (0, react.useMemo)(() => {
		var _state$bookingConfig, _state$pet;
		const form_id = (state === null || state === void 0 || (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.basic) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.appointment_subject) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.form_id) || 0;
		return (state === null || state === void 0 || (_state$pet = state.pet) === null || _state$pet === void 0 || (_state$pet = _state$pet.value) === null || _state$pet === void 0 ? void 0 : _state$pet[form_id]) || [];
	}, [state === null || state === void 0 || (_state$pet2 = state.pet) === null || _state$pet2 === void 0 ? void 0 : _state$pet2.value]);
	/**
	* @title: pets数据加 open items
	* @description:
	* @param {any} state
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-03 11:40
	*/
	const holderLists = (0, react.useMemo)(() => {
		var _state$pet3;
		if (isDaysBookingBol) return require_utils.formatHolderLists(petLists);
		return (state === null || state === void 0 || (_state$pet3 = state.pet) === null || _state$pet3 === void 0 ? void 0 : _state$pet3.holders) || [];
	}, [
		petLists,
		isDaysBookingBol,
		state === null || state === void 0 || (_state$pet4 = state.pet) === null || _state$pet4 === void 0 ? void 0 : _state$pet4.holders
	]);
	/**
	* @title: 获取pet名称
	* @description:
	* @param {any} state
	* @param {number} id
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-12-03 11:42
	*/
	const getHolderName = (id) => {
		if (!holderLists.length) return "";
		const resource = holderLists.find((d) => d.id === id);
		return resource === null || resource === void 0 ? void 0 : resource.main_field;
	};
	return {
		petLists,
		holderLists,
		getHolderName
	};
};
//#endregion
exports.default = useSelectPet;
