"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { TableExtension } from "@lexical/table";
import { configExtension, declarePeerDependency, defineExtension } from "lexical";
import { OPEN_TABLE_MODAL_COMMAND } from "../../plugins/table-plugin/index.js";
import { useToolbarActiveEditor } from "../../plugins/toolbar-plugin/toolbar-active-editor.js";
import { DropDownItem } from "../../ui/dropdown.js";
import { BylineFloatingUIExtension } from "../byline-floating-ui/byline-floating-ui-extension.js";
import { BylineToolbarExtension } from "../byline-toolbar/byline-toolbar-extension.js";
import { TableActionMenuPlugin } from "./table-action-menu-plugin/index.js";
function TableInsertItem() {
    const editor = useToolbarActiveEditor();
    return /*#__PURE__*/ jsxs(DropDownItem, {
        onClick: ()=>{
            editor.dispatchCommand(OPEN_TABLE_MODAL_COMMAND, null);
        },
        className: "item",
        children: [
            /*#__PURE__*/ jsx("i", {
                className: "icon table"
            }),
            /*#__PURE__*/ jsx("span", {
                className: "text",
                children: "Table"
            })
        ]
    });
}
const table_extension_TableExtension = defineExtension({
    name: '@byline/richtext-lexical/Table',
    dependencies: [
        configExtension(TableExtension, {
            hasCellMerge: true,
            hasCellBackgroundColor: true
        })
    ],
    peerDependencies: [
        declarePeerDependency(BylineToolbarExtension.name, {
            items: [
                {
                    id: '@byline/richtext-lexical/Table/insert',
                    placement: 'insert-menu',
                    order: 50,
                    node: /*#__PURE__*/ jsx(TableInsertItem, {})
                }
            ]
        }),
        declarePeerDependency(BylineFloatingUIExtension.name, {
            items: [
                {
                    id: '@byline/richtext-lexical/Table/action-menu',
                    Component: TableActionMenuPlugin
                }
            ]
        })
    ]
});
export { table_extension_TableExtension as TableExtension };
