const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../../../../locales/index.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_index$1 = require("../../../../../date-picker/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
//#region src/components/table/Table/fields/oldRangePicker/Edit/index.tsx
const _excluded = [
	"value",
	"onChange",
	"onPressEnter",
	"onBlur",
	"style",
	"bordered",
	"presets",
	"showTime",
	"format"
];
const { OldRangePicker: RangePicker } = require_index$1.default;
const defaultFormat = "YYYY-MM-DD HH:mm:ss";
const Edit = (props, ref) => {
	const { value, onChange, onPressEnter, onBlur, style, bordered, presets, showTime, format } = props, others = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const dayjsVal = (0, react.useMemo)(() => {
		if ((0, _pisell_utils.isString)(value)) return (0, dayjs.default)(value);
		if ((0, _pisell_utils.isArr)(value)) {
			if (value.some((item) => !item)) return [];
			return value.map((item) => (0, dayjs.default)(item));
		}
		return value;
	}, [value]);
	const rangePresets = [
		{
			label: require_index.getText("table-action-range-picker-presets-today"),
			value: [(0, dayjs.default)().startOf("day"), (0, dayjs.default)().endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-yesterday"),
			value: [(0, dayjs.default)().add(-1, "d").startOf("day"), (0, dayjs.default)().add(-1, "d").endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-last-3-day"),
			value: [(0, dayjs.default)().add(-3, "d").startOf("day"), (0, dayjs.default)().endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-last-7-day"),
			value: [(0, dayjs.default)().add(-7, "d").startOf("day"), (0, dayjs.default)().endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-last-14-day"),
			value: [(0, dayjs.default)().add(-14, "d").startOf("day"), (0, dayjs.default)().endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-last-30-day"),
			value: [(0, dayjs.default)().add(-30, "d").startOf("day"), (0, dayjs.default)().endOf("day")]
		},
		{
			label: require_index.getText("table-action-range-picker-presets-last-90-day"),
			value: [(0, dayjs.default)().add(-90, "d").startOf("day"), (0, dayjs.default)().endOf("day")]
		}
	];
	const _showTime = (0, react.useMemo)(() => {
		if ((0, _pisell_utils.isBoolean)(showTime)) return showTime;
		else if (typeof showTime === "object") return showTime;
		return true;
	}, [showTime]);
	return /* @__PURE__ */ react.default.createElement(RangePicker, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, others), {}, {
		format,
		showTime: _showTime,
		presets: presets || rangePresets,
		ref,
		value: dayjsVal,
		onChange: (date) => {
			onChange === null || onChange === void 0 || onChange(date === null || date === void 0 ? void 0 : date.map((item) => {
				var _item$format;
				return (item === null || item === void 0 || (_item$format = item.format) === null || _item$format === void 0 ? void 0 : _item$format.call(item, defaultFormat)) || null;
			}));
		},
		onPressEnter,
		onBlur,
		style: require_objectSpread2._objectSpread2({ width: "220px" }, style),
		bordered,
		onClick: (e) => e.stopPropagation(),
		panelRender: (dom) => {
			return /* @__PURE__ */ react.default.createElement("div", { onClick: (e) => e.stopPropagation() }, dom);
		}
	}));
};
var Edit_default = (0, react.forwardRef)(Edit);
//#endregion
exports.default = Edit_default;
