const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../../../components/ticketBooking/utils/index.js");
const require_utils = require("../../../components/booking/utils.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
//#region src/plus/salesSdk/bookingEditService/buildEditProductDetailPayload.ts
/**
* 从资源编辑抽屉内的 cacheItem 构造 `openProductDetail` 入参（对齐 Info2 editService handleEdit）。
*
* @example
* const payload = buildEditProductDetailPayload({
*   cacheItem,
*   bookingState,
*   formValues: form.getFieldsValue(),
* });
* const detailResult = await uiHosts.openProductDetail?.(payload);
*/
function buildEditProductDetailPayload(options) {
	var _bookingState$date$va, _bookingState$date, _bookingState$date$fo, _cacheItem$_extend4, _formValues$quantity, _cacheItem$_extend5, _options$customerId, _bookingState$client;
	const { cacheItem, bookingState, formValues } = options;
	const isSession = require_utils.isSessionProduct(cacheItem);
	const date = (_bookingState$date$va = (_bookingState$date = bookingState.date) === null || _bookingState$date === void 0 || (_bookingState$date = _bookingState$date.value) === null || _bookingState$date === void 0 || (_bookingState$date$fo = _bookingState$date.format) === null || _bookingState$date$fo === void 0 ? void 0 : _bookingState$date$fo.call(_bookingState$date, "YYYY-MM-DD")) !== null && _bookingState$date$va !== void 0 ? _bookingState$date$va : (0, dayjs.default)().format("YYYY-MM-DD");
	const sessionValue = {};
	if (isSession) {
		var _cacheItem$_extend, _cacheItem$_extend2, _cacheItem$_extend3;
		sessionValue.startEndTime = {
			startDate: cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date,
			endDate: cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.end_date,
			duration: cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.duration
		};
	}
	return {
		item: cacheItem,
		productData: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, cacheItem), {}, { initValue: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.other), sessionValue), {}, { quantity: (_formValues$quantity = formValues.quantity) !== null && _formValues$quantity !== void 0 ? _formValues$quantity : cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.quantity }) }),
		showConfig: {
			option: true,
			session: isSession,
			variant: true,
			package: true,
			number: require_index.getIsShowNumber(cacheItem, bookingState)
		},
		isOnlySession: require_utils.getIsOnlySession(cacheItem),
		isEject: require_utils.getIsEject(cacheItem, "detail") ? 1 : 0,
		customerId: (_options$customerId = options.customerId) !== null && _options$customerId !== void 0 ? _options$customerId : (_bookingState$client = bookingState.client) === null || _bookingState$client === void 0 || (_bookingState$client = _bookingState$client.value) === null || _bookingState$client === void 0 ? void 0 : _bookingState$client.id,
		date
	};
}
//#endregion
exports.buildEditProductDetailPayload = buildEditProductDetailPayload;
