const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../locales/index.js");
const require_index$1 = require("../index.js");
const require_utils = require("./utils.js");
let react = require("react");
react = require_runtime.__toESM(react);
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
require("./index.less");
//#region src/components/virtual-keyboard/Time/index.tsx
const items = [
	{
		value: 1,
		label: "1",
		disabled: false,
		type: "text"
	},
	{
		value: 2,
		label: "2",
		disabled: false,
		type: "text"
	},
	{
		value: 3,
		label: "3",
		disabled: false,
		type: "text"
	},
	{
		value: 4,
		label: "4",
		disabled: false,
		type: "text"
	},
	{
		value: 5,
		label: "5",
		disabled: false,
		type: "text"
	},
	{
		value: 6,
		label: "6",
		disabled: false,
		type: "text"
	},
	{
		value: 7,
		label: "7",
		disabled: false,
		type: "text"
	},
	{
		value: 8,
		label: "8",
		disabled: false,
		type: "text"
	},
	{
		value: 9,
		label: "9",
		disabled: false,
		type: "text"
	},
	{
		value: "now",
		label: require_index.getText("virtual-keyboard-time-now"),
		disabled: false,
		type: "text",
		style: { color: "#7f56d9" }
	},
	{
		value: "0",
		label: "0",
		disabled: false,
		type: "text"
	},
	{
		value: "ok",
		label: require_index.getText("virtual-keyboard-time-ok"),
		disabled: false,
		type: "primary"
	}
];
const VirtualKeyboardTime = (props) => {
	const { onChange, onEnter, style, className, value = "", rightPanel } = props;
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	const res = (0, react.useMemo)(() => {
		return require_utils.formatStringToTime(value);
	}, [value]);
	const _onChange = (current) => {
		if (current === "ok") {
			onEnter === null || onEnter === void 0 || onEnter(require_utils.formatStringToTime(value));
			return;
		}
		if (current === "now") {
			onEnter === null || onEnter === void 0 || onEnter((0, dayjs.default)().format("HH:mm"));
			return;
		}
		let _val = res.valueString + current;
		if (res.valueString.length === 4) _val = current + "";
		if (document.querySelector(".virtual-keyboard-input-select")) _val = current + "";
		onChange === null || onChange === void 0 || onChange(require_utils.formatStringToTime(_val));
	};
	return /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		className,
		style,
		keyboardProps: {
			items,
			onChange: (current) => {
				_onChange(current);
			}
		},
		virtualKeyInputProps: {
			value,
			onChange: (e) => {
				onChange === null || onChange === void 0 || onChange(require_utils.formatStringToTime(e.target.value));
			},
			renderInput: () => {
				return res === null || res === void 0 ? void 0 : res.previewValueArrayDom;
			}
		},
		rightPanel
	});
};
//#endregion
exports.default = VirtualKeyboardTime;
