"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Application = exports.MinistoreContext = void 0;
const tslib_1 = require("tslib");
const ink_1 = require("ink");
const react_1 = tslib_1.__importStar(require("react"));
const readline_1 = require("readline");
exports.MinistoreContext = react_1.default.createContext(null);
const Application = ({ children }) => {
    const { stdin, setRawMode } = (0, ink_1.useStdin)();
    (0, react_1.useEffect)(() => {
        setRawMode && setRawMode(true);
        stdin && (0, readline_1.emitKeypressEvents)(stdin);
    }, [stdin, setRawMode]);
    const [data, setData] = (0, react_1.useState)(new Map());
    const ministore = (0, react_1.useMemo)(() => ({
        getAll: () => data,
        get: (key) => data.get(key),
        set: (key, value) => setData(new Map([...data, [key, value]])),
    }), [data, setData]);
    return react_1.default.createElement(exports.MinistoreContext.Provider, { value: ministore, children: children });
};
exports.Application = Application;
