import { jsx as o } from "react/jsx-runtime";
import { useEditorRef as w } from "@udecode/plate-core";
import { useEditorResizeContext as W } from "../../context/EditorResizeContext.es.js";
import { useRichTextEditorContext as G } from "../../context/RichTextEditorContext.es.js";
import { EditorPositioningWrapper as b } from "../EditorPositioningWrapper/index.es.js";
import { ButtonGroupWrapper as g } from "./ButtonGroupWrapper.es.js";
import { getButtonGroupWidths as R, getButtonGroupsPerRow as E } from "./utils.es.js";
const N = ({ toolbarButtons: d, editorId: t, toolbarWidth: r }) => {
  const m = w(t), { editorWidth: i } = W(), { position: e } = G(), u = r || i || 0, c = R(d.at(e)), n = E(u, c), a = b[e];
  return /* @__PURE__ */ o(
    a.ToolbarWrapper,
    {
      editorWidth: i,
      toolbarWidth: r,
      toolbarButtonGroups: n,
      children: n.map((l, f) => /* @__PURE__ */ o("div", { className: "tw-divide-x tw-divide-line tw-flex tw-w-full", children: l.map(({ group: x, index: p }) => /* @__PURE__ */ o(g, { index: p, children: x.map((s, h) => /* @__PURE__ */ o(
        s.button,
        {
          editor: m,
          editorId: t,
          id: s.id
        },
        h.toString()
      )) }, p)) }, f))
    }
  );
};
export {
  N as Toolbar
};
//# sourceMappingURL=index.es.js.map
