import useEngineContext from "../../hooks/useEngineContext.js";
import locales_default from "./locales.js";
import React, { useEffect, useRef, useState } from "react";
import { locales } from "@pisell/utils";
import { Button, Input, PisellModal } from "@pisell/materials";
import "./index.less";
//#region src/plus/noteModal/AddTempModal.tsx
const AddTempModal = ({ open, onCancel, onConfirm }) => {
	var _context$engine;
	const context = useEngineContext();
	locales.init(locales_default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
	const [inputValue, setInputValue] = useState("");
	const inputRef = useRef(null);
	useEffect(() => {
		if (open) setTimeout(() => {
			var _inputRef$current;
			(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
		}, 100);
	}, [open]);
	const handleAddTemplate = () => {
		onConfirm(inputValue);
	};
	return /* @__PURE__ */ React.createElement(PisellModal, {
		open,
		headerDivider: false,
		title: locales.getText("pisell2.text.note.modal.add.template.title"),
		onCancel,
		footer: null,
		width: 680,
		centered: true,
		destroyOnClose: true,
		wrapClassName: "pisell-add-temp-modal"
	}, /* @__PURE__ */ React.createElement("div", { className: "template-modal-content" }, /* @__PURE__ */ React.createElement("div", { className: "template-input-section" }, /* @__PURE__ */ React.createElement(Input, {
		value: inputValue,
		onChange: (e) => setInputValue(e.target.value),
		className: "template-input",
		ref: inputRef
	}), /* @__PURE__ */ React.createElement(Button, {
		type: "primary",
		onClick: handleAddTemplate,
		className: "template-confirm-btn",
		disabled: !inputValue
	}, locales.getText("pisell2.text.note.modal.btn.confirm")))));
};
//#endregion
export { AddTempModal as default };
