const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_useLoginUser = require("../../../../../hooks/useLoginUser.js");
const require_index = require("../../../../../businessModel/SalesModel/Sales/index.js");
const require_index$1 = require("../../../../Sales/Step/index.js");
const require_index$2 = require("../../../../Sales/Customer/index.js");
const require_index$3 = require("../../../../Sales/Event/index.js");
const require_Detail = require("../../../../Sales/Event/Detail.js");
const require_index$4 = require("../../bookingServiceList/index.js");
const require_index$5 = require("../../bookingDetailModal/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/eventBooking/components/Provider/Event/index.tsx
const Event = () => {
	var _data$resourceData2;
	const { eventData, selectEvent, getEventList, getEventListByTitle } = require_index$3.useEvent();
	const { data } = require_index.useSales();
	const { changeAutoOperate } = require_index$1.useStep();
	const { onOpenEventDetail, open } = require_Detail.useEventDetail();
	const [lists, setLists] = (0, react.useState)();
	const customer = require_useLoginUser.default();
	const { appUtils } = require_index$2.useCustomer();
	(0, react.useEffect)(() => {
		var _data$stepData;
		const eventList = (eventData === null || eventData === void 0 ? void 0 : eventData.eventList) || [];
		setLists(eventList);
		if ((eventList === null || eventList === void 0 ? void 0 : eventList.length) === 1 && (data === null || data === void 0 || (_data$stepData = data.stepData) === null || _data$stepData === void 0 ? void 0 : _data$stepData.isAutoOperate)) {
			selectEvent(eventList[0]);
			onOpenEventDetail(eventList[0]);
			changeAutoOperate(false);
		}
	}, [eventData === null || eventData === void 0 ? void 0 : eventData.eventList]);
	(0, react.useEffect)(() => {
		var _data$resourceData, _appUtils$getHistory, _history$location;
		const id = data === null || data === void 0 || (_data$resourceData = data.resourceData) === null || _data$resourceData === void 0 || (_data$resourceData = _data$resourceData.currentResourceItem) === null || _data$resourceData === void 0 ? void 0 : _data$resourceData.id;
		if (!id) return;
		const history = (appUtils === null || appUtils === void 0 || (_appUtils$getHistory = appUtils.getHistory) === null || _appUtils$getHistory === void 0 ? void 0 : _appUtils$getHistory.call(appUtils)) || {};
		const query = history === null || history === void 0 || (_history$location = history.location) === null || _history$location === void 0 ? void 0 : _history$location.query;
		const params = {
			event_item_resource_id: id,
			skip: 1,
			num: 100,
			customer_id: customer === null || customer === void 0 ? void 0 : customer.id,
			open_quotation: 1
		};
		if (query === null || query === void 0 ? void 0 : query.ids) {
			var _query$ids;
			params.ids = query === null || query === void 0 || (_query$ids = query.ids) === null || _query$ids === void 0 ? void 0 : _query$ids.split(",");
		}
		getEventList.run(params);
	}, [data === null || data === void 0 || (_data$resourceData2 = data.resourceData) === null || _data$resourceData2 === void 0 || (_data$resourceData2 = _data$resourceData2.currentResourceItem) === null || _data$resourceData2 === void 0 ? void 0 : _data$resourceData2.id, customer === null || customer === void 0 ? void 0 : customer.id]);
	/**
	* @title: 点击选择event
	* @description:
	* @param {any} item
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-15 22:06
	*/
	const handleClick = (item) => {
		selectEvent(item);
		onOpenEventDetail(item);
	};
	/**
	* @title: 搜索
	* @description:
	* @param {string} value
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-16 10:25
	*/
	const handleSearch = (e) => {
		var _e$target;
		setLists(getEventListByTitle((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value));
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: `event-interface-service-wrap ${(0, _pisell_utils.isMobile)() ? "event-interface-service-mobile-wrap" : ""}` }, /* @__PURE__ */ react.default.createElement(antd.Skeleton, {
		active: true,
		loading: getEventList.loading,
		style: { padding: "16px" }
	}, /* @__PURE__ */ react.default.createElement(require_index$4.default, {
		dataSource: lists,
		showSearch: true,
		showCategory: false,
		showImage: true,
		onClick: handleClick,
		onSearch: handleSearch,
		placeholder: _pisell_utils.locales.getText("pisell2.event.search"),
		isShowEmpty: !getEventList.loading,
		description: _pisell_utils.locales.getText("pisell2.event.empty.event")
	}))), /* @__PURE__ */ react.default.createElement(require_index$5.default, { open }));
};
//#endregion
exports.default = Event;
