const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../../utils/index.js");
const require_locales = require("./locales.js");
const require_hooks = require("./hooks.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/pinModal/index.tsx
const PinModal = (props, ref) => {
	var _context$engine, _context$appHelper;
	const context = require_useEngineContext.default();
	_pisell_utils.locales.init(require_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");
	require_index.request.setRequest(context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.request);
	const [visible, setVisible] = (0, react.useState)(false);
	const { pin, lastUpdateTime, getPin, resetPin, resetPinLoading } = require_hooks.usePin();
	const walletDetailIdRef = (0, react.useRef)();
	const onOpen = (wallet_detail_id) => {
		walletDetailIdRef.current = wallet_detail_id;
		getPin(wallet_detail_id);
		setVisible(true);
	};
	const onHide = () => {
		walletDetailIdRef.current = void 0;
		setVisible(false);
	};
	const onResetPin = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
			if (!walletDetailIdRef.current || resetPinLoading) return;
			resetPin(walletDetailIdRef.current);
		});
		return function onResetPin() {
			return _ref.apply(this, arguments);
		};
	}();
	(0, react.useImperativeHandle)(ref, () => ({
		open: onOpen,
		hide: onHide
	}));
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		title: _pisell_utils.locales.getText("pisell2.pin.modal.title"),
		open: visible,
		okText: _pisell_utils.locales.getText("pisell2.pin.modal.reset.pin"),
		onOk: onResetPin,
		cancelText: _pisell_utils.locales.getText("pisell2.pin.modal.cancel"),
		onCancel: onHide,
		okButtonProps: { loading: resetPinLoading },
		destroyOnClose: true,
		mobileModalHeight: "auto"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pin-modal" }, /* @__PURE__ */ react.default.createElement("div", { className: "pin-modal-content" }, /* @__PURE__ */ react.default.createElement("span", { className: "pin-modal-content-label" }, _pisell_utils.locales.getText("pisell2.pin.modal.label")), /* @__PURE__ */ react.default.createElement("span", { className: "pin-modal-content-code" }, pin)), /* @__PURE__ */ react.default.createElement("span", { className: "pin-modal-content-desc" }, _pisell_utils.locales.getText("pisell2.pin.modal.desc")), /* @__PURE__ */ react.default.createElement("span", { className: "pin-modal-content-time" }, _pisell_utils.locales.getText("pisell2.pin.modal.time"), lastUpdateTime)));
};
var pinModal_default = (0, react.forwardRef)(PinModal);
//#endregion
exports.default = pinModal_default;
