import { __exports as a } from "./index-LexicalLinkPlugin.prod2.js";
import { __require as m } from "./index-LexicalLink2.js";
import { __require as p } from "./index-LexicalComposerContext2.js";
import { __require as c } from "./index-LexicalUtils.js";
import { __require as d } from "./index-Lexical.js";
import C from "react";
var s;
function D() {
  if (s) return a;
  s = 1;
  var r = m(), _ = p(), f = c(), t = d(), g = C;
  return a.LinkPlugin = function({ validateUrl: i }) {
    let [o] = _.useLexicalComposerContext();
    return g.useEffect(() => {
      if (!o.hasNodes([r.LinkNode])) throw Error("LinkPlugin: LinkNode not registered on editor");
      return f.mergeRegister(o.registerCommand(r.TOGGLE_LINK_COMMAND, (e) => {
        if (e === null) return r.toggleLink(e), !0;
        if (typeof e == "string") return i === void 0 || i(e) ? (r.toggleLink(e), !0) : !1;
        let { url: l, target: n, rel: u, title: L } = e;
        return r.toggleLink(l, { rel: u, target: n, title: L }), !0;
      }, t.COMMAND_PRIORITY_LOW), i !== void 0 ? o.registerCommand(
        t.PASTE_COMMAND,
        (e) => {
          let l = t.$getSelection();
          if (!t.$isRangeSelection(l) || l.isCollapsed() || !(e instanceof ClipboardEvent) || e.clipboardData == null) return !1;
          let n = e.clipboardData.getData("text");
          return i(n) ? l.getNodes().some((u) => t.$isElementNode(u)) ? !1 : (o.dispatchCommand(r.TOGGLE_LINK_COMMAND, n), e.preventDefault(), !0) : !1;
        },
        t.COMMAND_PRIORITY_LOW
      ) : () => {
      });
    }, [o, i]), null;
  }, a;
}
export {
  D as __require
};
