import { jsx, jsxs } from "react/jsx-runtime";
import { useState, useCallback, useEffect, useRef } from "react";
import { Box, Text, useInput } from "ink";
import { getConfig } from "../../../config.js";
import { Verification } from "./Verification.js";
import { activityStore } from "../state/activity-store-instance.js";
function VerifyScreen({ onBack }) {
  const [done, setDone] = useState(false);
  const endRef = useRef(null);
  useEffect(() => {
    const end = activityStore.begin("verify");
    endRef.current = end;
    return () => {
      end();
      endRef.current = null;
    };
  }, []);
  const handleComplete = useCallback((_items) => {
    setDone(true);
    endRef.current?.();
    endRef.current = null;
  }, []);
  useInput((input, key) => {
    if (!done) return;
    if (key.escape || input === "q" || key.return) onBack();
  });
  const dataDir = getConfig().dataDir;
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
    /* @__PURE__ */ jsx(Verification, { dataDir, onComplete: handleComplete }),
    done ? /* @__PURE__ */ jsx(Box, { marginTop: 1, paddingX: 2, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Press enter or q/esc to return" }) }) : null
  ] });
}
export {
  VerifyScreen
};
//# sourceMappingURL=VerifyScreen.js.map