const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_miniRedux = require("../../utils/miniRedux.js");
//#region src/components/table/model.tsx
const defaultState = {
	tableId: "",
	localPagination: false,
	dataSource: [],
	originDataSource: [],
	defaultColumns: [],
	originColumns: [],
	originColumnsMap: /* @__PURE__ */ new Map(),
	currentCell: null,
	quickFilter: [],
	otherFilter: [],
	utils: {},
	isTerminal: false,
	setting: {
		field: { edit: 0 },
		data: { edit: 0 }
	},
	tableWidth: 700,
	currentDataSource: [],
	originResultDataSource: []
};
const { Provider, Context } = require_miniRedux.default({
	namespace: "state",
	state: defaultState,
	reducers: {
		setDataSource(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { dataSource: payload });
		},
		setOriginDataSource(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { originDataSource: payload });
		},
		setDefaultColumns(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { defaultColumns: payload.map((d) => formatColumn(d)) });
		},
		setOriginColumns(state, payload) {
			const originColumns = payload.map((d) => formatColumn(d));
			const originColumnsMap = new Map(originColumns.map((item) => [item.key, item]));
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, {
				originColumns,
				originColumnsMap
			});
		},
		setCurrentCell(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { currentCell: payload });
		},
		setQuickFilter(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { quickFilter: payload });
		},
		setUtils(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { utils: payload });
		},
		setIsTerminal(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { isTerminal: payload });
		},
		syncStorage(state, payload) {
			return require_objectSpread2._objectSpread2({}, state);
		},
		init(state, payload) {
			return require_objectSpread2._objectSpread2({}, state);
		},
		setOtherFilter(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { otherFilter: payload });
		},
		setTableId(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { tableId: payload });
		},
		setLocalPagination(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { localPagination: payload });
		},
		setTableWidth(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { tableWidth: payload });
		},
		setCurrentDataSource(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { currentDataSource: payload });
		},
		setOriginResultDataSource(state, payload) {
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, state), {}, { originResultDataSource: payload });
		}
	}
});
const formatColumn = (item) => {
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_objectSpread2._objectSpread2({
		editable: true,
		field_type: "text",
		lock: true
	}, item.other || {})), item);
};
//#endregion
exports.Context = Context;
exports.Provider = Provider;
exports.formatColumn = formatColumn;
