const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../../utils/index.js");
const require_useActions = require("./hooks/useActions.js");
const require_useSalesGridPhoneLayout = require("./hooks/useSalesGridPhoneLayout.js");
const require_useReservationPhoneGridInfiniteData = require("../pisellReservation/hooks/useReservationPhoneGridInfiniteData.js");
const require_booking = require("../pisellSalesManagement/config/booking.js");
const require_serve = require("./serve.js");
const require_applySalesPhoneGridColumns = require("./mobileTable/applySalesPhoneGridColumns.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let ahooks = require("ahooks");
require("./PisellSalesGrid.less");
//#region src/plus/pisellSalesGrid/PisellSalesGrid.tsx
const _excluded = ["filter"], _excluded2 = ["filter"];
/**
* 根据 currentPerspective 从 perspectives 中取当前 Perspective 配置，未找到时回退到第一项或空配置。
*/
function getCurrentPerspectiveConfig(perspectives, currentPerspective) {
	const found = perspectives.find((p) => p.key === currentPerspective);
	if (found) return found;
	if (perspectives.length > 0) return perspectives[0];
}
function getDefaultSearchParams(currentPerspective) {
	if (currentPerspective === "monitor") return { filter: { values: {
		order_payment_status: require_booking.defaultPaymentStatusKeys,
		booking_time_start_between: [(0, dayjs.default)().startOf("day"), (0, dayjs.default)().endOf("day")]
	} } };
	return {
		filter: { values: {
			payment_status: require_booking.defaultPaymentStatusKeys,
			orderDate: [(0, dayjs.default)(), (0, dayjs.default)()]
		} },
		sort: "created_at:desc"
	};
}
const SEARCH_PARAMS_STORAGE_PREFIX = "pisell_sales_grid_search_params_";
/**
* 序列化 searchParams，将 dayjs 对象转换为 ISO 字符串
*/
function serializeSearchParams(params) {
	return JSON.stringify(params, (key, value) => {
		if (dayjs.default.isDayjs(value)) return {
			__isDayjs: true,
			value: value.toISOString()
		};
		return value;
	});
}
/**
* 反序列化 searchParams，将 ISO 字符串还原为 dayjs 对象
*/
function deserializeSearchParams(str) {
	return JSON.parse(str, (key, value) => {
		if (value && typeof value === "object" && value.__isDayjs) return (0, dayjs.default)(value.value);
		return value;
	});
}
/**
* 分页「每页条数」Select：禁用搜索输入，仅允许从下拉选项中选择。
* antd 5.10 内置 MiniSelect / MiddleSelect 默认 showSearch=true，会让用户在 Select 里键盘输入；
* 通过 selectComponentClass 覆盖为 showSearch=false 的 Select。
*
* 注意：showSearch={false} 写在 {...props} 之后，确保不会被外部覆盖；其余 prop（value/onChange/
* size/getPopupContainer/options 等）由 antd Pagination 透传，无需再手动透传。
*/
const PaginationSizeChangerSelect = react.default.forwardRef((props, ref) => /* @__PURE__ */ react.default.createElement(antd.Select, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
	ref,
	showSearch: false
})));
PaginationSizeChangerSelect.Option = antd.Select.Option;
/** 默认的 SalesGrid 分页透传配置：去掉 Select 输入 + 给出明确的可选条数 */
const DEFAULT_PAGINATION_CONFIG = {
	selectComponentClass: PaginationSizeChangerSelect,
	showSizeChanger: true,
	pageSizeOptions: [
		"10",
		"20",
		"50",
		"100"
	]
};
/**
* 从 sessionStorage 获取存储的 searchParams。
* 默认不还原 filter（仅还原 sort、keyword 等），调用方需与 getDefaultSearchParams 合并以得到默认筛选项。
*/
function getStoredSearchParams(id) {
	try {
		const stored = sessionStorage.getItem(`${SEARCH_PARAMS_STORAGE_PREFIX}${id}`);
		if (stored) {
			const normalized = deserializeSearchParams(stored);
			if (normalized && typeof normalized === "object") {
				const _ref = normalized, { filter: _f } = _ref;
				return require_objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
			}
			return normalized;
		}
	} catch (e) {
		console.warn("Failed to get stored search params:", e);
	}
	return null;
}
/**
* 将 searchParams 存储到 sessionStorage。
* 默认只存排序、关键词等，不存 filter；列显示隐藏由 RecordBoard 侧单独持久化。
*/
function saveSearchParams(id, params) {
	try {
		let toStore;
		{
			const { filter: _f } = params;
			toStore = require_objectWithoutProperties._objectWithoutProperties(params, _excluded2);
		}
		sessionStorage.setItem(`${SEARCH_PARAMS_STORAGE_PREFIX}${id}`, serializeSearchParams(toStore));
	} catch (e) {
		console.warn("Failed to save search params:", e);
	}
}
/**
* 将 columnRenderers 按列 type 合并进 grid.columns（同 type 覆盖原有 render）。
*/
function mergeColumnRenderersIntoGrid(gridConfig, columnRenderers) {
	if (!(columnRenderers === null || columnRenderers === void 0 ? void 0 : columnRenderers.length) || !Array.isArray(gridConfig.columns)) return gridConfig;
	const byType = new Map(columnRenderers.map((r) => [r.type, r.render]));
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, gridConfig), {}, { columns: gridConfig.columns.map((col) => {
		const t = col === null || col === void 0 ? void 0 : col.type;
		if (t != null && byType.has(t)) {
			const renderCell = byType.get(t);
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, col), {}, { render: (value, record, index) => renderCell(value, record, index) });
		}
		return col;
	}) });
}
const PisellSalesGrid = (props) => {
	var _context$appHelper, _getBookingList$data2, _getOrderList$data2, _getBookingList$data3, _getOrderList$data3, _currentConfig$childC5, _recordBoardGridProps, _recordBoardGridProps2, _currentConfig$childC6, _currentConfig$childC7, _currentConfig$childC8, _currentConfig$childC9;
	const { perspectives, currentPerspective, className, style, extParams, __id, data: propsData, loading: propsLoading, total: propsTotal, pagination: propsPagination, onPageChange: propsOnPageChange, searchParams: propsSearchParams, onSearch: propsOnSearch, onReset: propsOnReset, selectedKeys: propsSelectedKeys, selectedRows: propsSelectedRows, onSelectionChange: propsOnSelectionChange, rowKey: propsRowKey, onRefresh: propsOnRefresh, refreshAsync: propsRefreshAsync, columnRenderers, enableScanner } = props;
	const context = require_useEngineContext.default();
	const utils = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	require_index.request.setRequest(utils === null || utils === void 0 ? void 0 : utils.request);
	const isControlledData = propsData !== void 0;
	const [selectedKeys, setSelectedKeys] = (0, react.useState)([]);
	const [selectedRows, setSelectedRows] = (0, react.useState)([]);
	const [pagination, setPagination] = (0, react.useState)({
		pageNumber: 1,
		pageSize: 50
	});
	const [searchParams, setSearchParams] = (0, react.useState)(() => {
		const defaultParams = getDefaultSearchParams(currentPerspective);
		if (__id) {
			const stored = getStoredSearchParams(__id);
			if (stored) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, defaultParams), stored);
		}
		return defaultParams;
	});
	const [pendingScanSearch, setPendingScanSearch] = (0, react.useState)(null);
	const onSelectionChange = (0, react.useCallback)((keys, rows) => {
		setSelectedKeys(keys);
		setSelectedRows(rows);
	}, []);
	const onPageChange = (0, react.useCallback)((pageNumber, pageSize) => {
		if (pageNumber < 1 || pageSize < 1) return;
		setPagination({
			pageNumber,
			pageSize
		});
	}, []);
	const onSearch = (0, react.useCallback)((params) => {
		setSearchParams(params || {});
		setPagination((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev), {}, { pageNumber: 1 }));
	}, []);
	const onReset = (0, react.useCallback)(() => {
		setSearchParams(getDefaultSearchParams(currentPerspective));
		setPagination((prev) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, prev), {}, { pageNumber: 1 }));
	}, [currentPerspective]);
	(0, react.useEffect)(() => {
		if (__id) saveSearchParams(__id, searchParams);
	}, [__id, searchParams]);
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	const _getBookingList = (0, ahooks.useRequest)(require_serve.getBookingList, { manual: true });
	const _getOrderList = (0, ahooks.useRequest)(require_serve.getOrderList, { manual: true });
	const requestParams = (0, react.useMemo)(() => {
		const { keyword, filter, sort } = searchParams;
		const filterVals = (filter === null || filter === void 0 ? void 0 : filter.values) || {};
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
			keyword,
			sort
		}, filterVals), {}, {
			skip: pagination.pageNumber,
			num: pagination.pageSize
		});
	}, [
		searchParams,
		pagination.pageNumber,
		pagination.pageSize
	]);
	const actions = require_useActions.default({
		onRefresh: (0, react.useCallback)((keys) => {
			if (propsOnRefresh) {
				propsOnRefresh(keys);
				return;
			}
			if (currentPerspective === "monitor") {
				_getBookingList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {}));
				return;
			}
			_getOrderList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {}));
		}, [
			currentPerspective,
			requestParams,
			_getBookingList,
			_getOrderList,
			propsOnRefresh
		]),
		onClearSelection: (0, react.useCallback)(() => {
			setSelectedKeys([]);
			setSelectedRows([]);
			propsOnSelectionChange === null || propsOnSelectionChange === void 0 || propsOnSelectionChange([], []);
		}, [propsOnSelectionChange])
	});
	const isPhoneLayout = require_useSalesGridPhoneLayout.useSalesGridPhoneLayout();
	const gridPagination = (0, react.useMemo)(() => isControlledData && propsPagination ? propsPagination : pagination, [
		isControlledData,
		propsPagination,
		pagination
	]);
	const gridSearchParams = (0, react.useMemo)(() => isControlledData && propsSearchParams !== void 0 ? propsSearchParams : searchParams, [
		isControlledData,
		propsSearchParams,
		searchParams
	]);
	const rawGridData = (0, react.useMemo)(() => {
		var _getBookingList$data, _getOrderList$data;
		if (isControlledData) return propsData !== null && propsData !== void 0 ? propsData : [];
		return currentPerspective === "monitor" ? ((_getBookingList$data = _getBookingList.data) === null || _getBookingList$data === void 0 ? void 0 : _getBookingList$data.list) || [] : ((_getOrderList$data = _getOrderList.data) === null || _getOrderList$data === void 0 ? void 0 : _getOrderList$data.list) || [];
	}, [
		isControlledData,
		propsData,
		currentPerspective,
		(_getBookingList$data2 = _getBookingList.data) === null || _getBookingList$data2 === void 0 ? void 0 : _getBookingList$data2.list,
		(_getOrderList$data2 = _getOrderList.data) === null || _getOrderList$data2 === void 0 ? void 0 : _getOrderList$data2.list
	]);
	const phoneGridInfiniteData = require_useReservationPhoneGridInfiniteData.useReservationPhoneGridInfiniteData({
		enabled: isPhoneLayout,
		isInternalListData: true,
		rowKey: propsRowKey !== null && propsRowKey !== void 0 ? propsRowKey : "id",
		data: rawGridData,
		pagination: gridPagination,
		searchParams: gridSearchParams
	});
	const recordBoardListData = isPhoneLayout ? phoneGridInfiniteData : rawGridData;
	const isRecordBoardLoading = isControlledData ? propsLoading !== null && propsLoading !== void 0 ? propsLoading : false : currentPerspective === "monitor" ? _getBookingList.loading : _getOrderList.loading;
	const recordBoardTotal = isControlledData ? propsTotal : currentPerspective === "monitor" ? (_getBookingList$data3 = _getBookingList.data) === null || _getBookingList$data3 === void 0 ? void 0 : _getBookingList$data3.count : (_getOrderList$data3 = _getOrderList.data) === null || _getOrderList$data3 === void 0 ? void 0 : _getOrderList$data3.count;
	const batchActionConfig = (0, react.useMemo)(() => {
		return { actions };
	}, [actions]);
	(0, react.useEffect)(() => {
		if (isControlledData) return;
		if (currentPerspective === "monitor") _getBookingList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {}));
		else _getOrderList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {}));
	}, [
		isControlledData,
		currentPerspective,
		requestParams,
		extParams === null || extParams === void 0 ? void 0 : extParams.list,
		_getBookingList,
		_getOrderList
	]);
	/**
	* 运行时上下文：根据当前 perspective 绑定对应的 refresh / refreshAsync，
	* 传入 perspective 的 getChildComponentProps 工厂函数。
	* 受控数据时优先使用父组件传入的 onRefresh / refreshAsync。
	*/
	const runtimeContext = (0, react.useMemo)(() => {
		if (isControlledData && propsOnRefresh) return {
			refresh: propsOnRefresh,
			refreshAsync: propsRefreshAsync !== null && propsRefreshAsync !== void 0 ? propsRefreshAsync : (() => Promise.resolve()),
			currentPerspective
		};
		return {
			refresh: currentPerspective === "monitor" ? () => _getBookingList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {})) : () => _getOrderList.run(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {})),
			refreshAsync: currentPerspective === "monitor" ? () => _getBookingList.runAsync(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {})) : () => _getOrderList.runAsync(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, requestParams), (extParams === null || extParams === void 0 ? void 0 : extParams.list) || {})),
			currentPerspective
		};
	}, [
		isControlledData,
		propsOnRefresh,
		propsRefreshAsync,
		currentPerspective,
		_getBookingList,
		_getOrderList,
		requestParams,
		extParams
	]);
	/**
	* 解析当前 perspective 配置：
	* - 若 perspective 提供了 getChildComponentProps 工厂，调用它并注入 runtimeContext；
	* - 否则回退到静态 childComponentProps（向后兼容）。
	*/
	const currentConfig = (0, react.useMemo)(() => {
		const raw = getCurrentPerspectiveConfig(perspectives, currentPerspective);
		if (!raw) return void 0;
		if (typeof raw.getChildComponentProps === "function") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, raw), {}, { childComponentProps: raw.getChildComponentProps(runtimeContext) });
		return raw;
	}, [
		perspectives,
		currentPerspective,
		runtimeContext
	]);
	const recordBoardGridProps = (0, react.useMemo)(() => {
		var _currentConfig$childC, _currentConfig$childC2;
		const gridConfig = mergeColumnRenderersIntoGrid((_currentConfig$childC = currentConfig === null || currentConfig === void 0 || (_currentConfig$childC2 = currentConfig.childComponentProps) === null || _currentConfig$childC2 === void 0 ? void 0 : _currentConfig$childC2.grid) !== null && _currentConfig$childC !== void 0 ? _currentConfig$childC : {}, columnRenderers);
		const scrollBase = gridConfig.scroll != null && typeof gridConfig.scroll === "object" ? require_objectSpread2._objectSpread2({}, gridConfig.scroll) : {};
		const keys = isControlledData && propsSelectedKeys !== void 0 ? propsSelectedKeys : selectedKeys;
		const rows = isControlledData && propsSelectedRows !== void 0 ? propsSelectedRows : selectedRows;
		const onSel = isControlledData && propsOnSelectionChange ? propsOnSelectionChange : onSelectionChange;
		const phoneGridOverrides = isPhoneLayout ? {
			size: "small",
			tableLayout: "fixed",
			infiniteScroll: true,
			scroll: require_applySalesPhoneGridColumns.buildSalesPhoneGridScroll(scrollBase),
			rowSelection: require_applySalesPhoneGridColumns.buildSalesPhoneRowSelection(gridConfig.rowSelection),
			className: require_applySalesPhoneGridColumns.mergeSalesPhoneGridClassName(typeof gridConfig.className === "string" ? gridConfig.className : void 0),
			columns: require_applySalesPhoneGridColumns.applySalesPhoneGridColumns(gridConfig.columns)
		} : {};
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, gridConfig), phoneGridOverrides), {}, {
			selectedKeys: keys,
			selectedRows: rows,
			onSelectionChange: onSel
		});
	}, [
		currentConfig,
		isControlledData,
		propsSelectedKeys,
		propsSelectedRows,
		propsOnSelectionChange,
		selectedKeys,
		selectedRows,
		onSelectionChange,
		columnRenderers,
		isPhoneLayout
	]);
	const mergedToolBar = (0, react.useMemo)(() => {
		var _currentConfig$childC3;
		const base = currentConfig === null || currentConfig === void 0 || (_currentConfig$childC3 = currentConfig.childComponentProps) === null || _currentConfig$childC3 === void 0 ? void 0 : _currentConfig$childC3.toolBar;
		const wrapSearchConfig = (searchConfig) => {
			if (searchConfig === false) return false;
			const searchProps = typeof searchConfig === "object" && searchConfig !== null ? searchConfig : {};
			const originalOnScan = typeof searchProps.onScan === "function" ? searchProps.onScan : void 0;
			const originalOnScannerData = typeof searchProps.onScannerData === "function" ? searchProps.onScannerData : void 0;
			/** 上层（如 PisellSalesManagement 基于 context.isActive）覆盖 enableScanner；显式 false 时上层关闭，否则尊重 search 配置原值 */
			const mergedEnableScanner = typeof enableScanner === "boolean" ? enableScanner : searchProps.enableScanner;
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, searchProps), {}, {
				enableScanner: mergedEnableScanner,
				onScan: (code) => {
					setPendingScanSearch({
						keyword: code,
						hasRequested: false
					});
					originalOnScan === null || originalOnScan === void 0 || originalOnScan(code);
				},
				onScannerData: (payload) => {
					const keyword = typeof (payload === null || payload === void 0 ? void 0 : payload.code) === "string" ? payload.code : "";
					if (keyword) setPendingScanSearch({
						keyword,
						hasRequested: false
					});
					originalOnScannerData === null || originalOnScannerData === void 0 || originalOnScannerData(payload);
				}
			});
		};
		if (!base) return { search: wrapSearchConfig(void 0) };
		if (!isPhoneLayout) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, base), {}, { search: wrapSearchConfig(base.search) });
		const narrowClasses = (0, classnames.default)(typeof base.className === "string" ? base.className : void 0, "pisell-record-board-toolbar--narrow-stack", "pisell-sales-grid-mobile-toolbar");
		if (base.filter === false) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, base), {}, {
			search: wrapSearchConfig(base.search),
			toolbarDensity: "compact-narrow",
			className: narrowClasses
		});
		const baseFilter = typeof base.filter === "object" && base.filter !== null ? base.filter : {};
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, base), {}, {
			search: wrapSearchConfig(base.search),
			toolbarDensity: "compact-narrow",
			filter: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, baseFilter), {}, { phoneLayout: true }),
			className: narrowClasses
		});
	}, [
		currentConfig,
		isPhoneLayout,
		enableScanner
	]);
	(0, react.useEffect)(() => {
		if (!pendingScanSearch) return;
		if (isRecordBoardLoading) {
			if (!pendingScanSearch.hasRequested) setPendingScanSearch(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, pendingScanSearch), {}, { hasRequested: true }));
			return;
		}
		if (!pendingScanSearch.hasRequested) return;
		if ((gridSearchParams === null || gridSearchParams === void 0 ? void 0 : gridSearchParams.keyword) !== pendingScanSearch.keyword) {
			setPendingScanSearch(null);
			return;
		}
		const list = Array.isArray(recordBoardListData) ? recordBoardListData : [];
		const total = typeof recordBoardTotal === "number" ? recordBoardTotal : list.length;
		if (list.length !== 1 || total !== 1) {
			setPendingScanSearch(null);
			return;
		}
		const onRow = recordBoardGridProps.onRow;
		if (typeof onRow !== "function") {
			setPendingScanSearch(null);
			return;
		}
		const rowHandlers = onRow(list[0], 0);
		if (typeof (rowHandlers === null || rowHandlers === void 0 ? void 0 : rowHandlers.onClick) === "function") rowHandlers.onClick({});
		setPendingScanSearch(null);
	}, [
		pendingScanSearch,
		isRecordBoardLoading,
		gridSearchParams === null || gridSearchParams === void 0 ? void 0 : gridSearchParams.keyword,
		recordBoardListData,
		recordBoardTotal,
		recordBoardGridProps
	]);
	/**
	* 分页透传配置：默认禁用每页条数 Select 的搜索输入；保留 perspective.childComponentProps.pagination 的可覆盖能力。
	*/
	const paginationConfig = (0, react.useMemo)(() => {
		var _currentConfig$childC4;
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, DEFAULT_PAGINATION_CONFIG), currentConfig === null || currentConfig === void 0 || (_currentConfig$childC4 = currentConfig.childComponentProps) === null || _currentConfig$childC4 === void 0 ? void 0 : _currentConfig$childC4.pagination);
	}, [currentConfig === null || currentConfig === void 0 || (_currentConfig$childC5 = currentConfig.childComponentProps) === null || _currentConfig$childC5 === void 0 ? void 0 : _currentConfig$childC5.pagination]);
	/** 预约 Monitor 列序变更时 bump 专用 key，避免沿用旧 `column_order`；订单视角仍用 `__id` */
	const recordBoardColumnStorageKey = (0, react.useMemo)(() => {
		if (currentPerspective === "monitor") {
			var _resolveBookingMonito;
			return (_resolveBookingMonito = require_booking.resolveBookingMonitorColumnStorageKey(__id)) !== null && _resolveBookingMonito !== void 0 ? _resolveBookingMonito : __id;
		}
		return __id;
	}, [__id, currentPerspective]);
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-sales-grid", isPhoneLayout && "pisell-sales-grid--phone", className),
		style: require_objectSpread2._objectSpread2({
			height: "100%",
			minHeight: 0,
			display: "flex",
			flexDirection: "column"
		}, style)
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard, {
		key: currentPerspective,
		__id,
		columnVisibilityStorageKey: recordBoardColumnStorageKey,
		layoutType: "grid",
		layoutVariant: isPhoneLayout ? "phone" : "default",
		rowKey: propsRowKey !== null && propsRowKey !== void 0 ? propsRowKey : "id",
		data: recordBoardListData,
		loading: isRecordBoardLoading,
		total: recordBoardTotal !== null && recordBoardTotal !== void 0 ? recordBoardTotal : 0,
		pagination: gridPagination,
		onPageChange: isControlledData && propsOnPageChange ? propsOnPageChange : onPageChange,
		searchParams: gridSearchParams,
		onSearch: isControlledData && propsOnSearch ? propsOnSearch : onSearch,
		onReset: isControlledData && propsOnReset ? propsOnReset : onReset,
		fillHeight: (_recordBoardGridProps = (_recordBoardGridProps2 = recordBoardGridProps.scroll) === null || _recordBoardGridProps2 === void 0 ? void 0 : _recordBoardGridProps2.autoCalc) !== null && _recordBoardGridProps !== void 0 ? _recordBoardGridProps : true,
		grid: recordBoardGridProps,
		toolBar: mergedToolBar,
		paginationConfig,
		search: currentConfig === null || currentConfig === void 0 || (_currentConfig$childC6 = currentConfig.childComponentProps) === null || _currentConfig$childC6 === void 0 ? void 0 : _currentConfig$childC6.search,
		batchActionBar: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, batchActionConfig), currentConfig === null || currentConfig === void 0 || (_currentConfig$childC7 = currentConfig.childComponentProps) === null || _currentConfig$childC7 === void 0 ? void 0 : _currentConfig$childC7.batchActionBar),
		floorMap: currentConfig === null || currentConfig === void 0 || (_currentConfig$childC8 = currentConfig.childComponentProps) === null || _currentConfig$childC8 === void 0 ? void 0 : _currentConfig$childC8.floorMap,
		defaultBodyView: currentConfig === null || currentConfig === void 0 || (_currentConfig$childC9 = currentConfig.childComponentProps) === null || _currentConfig$childC9 === void 0 ? void 0 : _currentConfig$childC9.defaultBodyView
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard.ShellFrame, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellRecordBoard.GridLayout, null))));
};
PisellSalesGrid.displayName = "PisellSalesGrid";
//#endregion
exports.default = PisellSalesGrid;
