"use client";
import { useLexicalComposerContext as n } from "../../../node_modules/@lexical/react/LexicalComposerContext.prod.js";
import { SELECTION_CHANGE_COMMAND as m, $getSelection as r, COMMAND_PRIORITY_CRITICAL as f } from "../../../node_modules/lexical/Lexical.prod.js";
import { useEffect as i } from "react";
import { useToolbarContext as C } from "../context/toolbar-context.js";
function c(t) {
  const [s] = n(), { activeEditor: o } = C();
  i(() => o.registerCommand(
    m,
    () => {
      const e = r();
      return e && t(e), !1;
    },
    f
  ), [s, t, o]), i(() => {
    o.getEditorState().read(() => {
      const e = r();
      e && t(e);
    });
  }, [o, t]);
}
export {
  c as useUpdateToolbarHandler
};
