"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaretBottomOverlay = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const FormattingsManagePane_1 = require("../../../formatting/FormattingsManagePane");
const BottomPanePortal_1 = require("../../util/BottomPanePortal");
const context_1 = require("../../../context");
const isDirectCaretPlacement = (event) => {
    if (event && event.type === 'cursor') {
        const detail = event.detail;
        const at = detail.at;
        if (Array.isArray(at) && at.length === 1 && typeof at[0] === 'number')
            return true;
        const move = detail.move;
        if (Array.isArray(move) &&
            move.length === 1 &&
            Array.isArray(move[0]) &&
            move[0][0] === 'focus' &&
            typeof move[0][1] === 'number')
            return true;
    }
    return false;
};
const CaretBottomOverlay = (props) => {
    const { fwd, bwd } = props;
    const inline = fwd || bwd;
    const { toolbar } = (0, context_1.useToolbarPlugin)();
    if (!inline)
        return;
    if (!isDirectCaretPlacement(toolbar.lastEvent))
        return;
    return (React.createElement(BottomPanePortal_1.BottomPanePortal, null,
        React.createElement(FormattingsManagePane_1.FormattingsManagePane, { inline: inline })));
};
exports.CaretBottomOverlay = CaretBottomOverlay;
//# sourceMappingURL=index.js.map