"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var open_link_modal_exports = {};
__export(open_link_modal_exports, {
  openLinkModal: () => openLinkModal
});
module.exports = __toCommonJS(open_link_modal_exports);
var import_tiptap = require("./../../tiptap/index.js");
var import_constants = require("./constants.js");
var import_link_modal = require("./open-link-modal/link-modal.js");
const openLinkModal = ({
  editor,
  initialValue,
  modalService,
  onClickOutside,
  onSave,
  onSaveMultiple,
  onUnlink,
  placement,
  referenceElement: argReferenceElement,
  returnFocusToEditor,
  enabledLinkTypes
}) => {
  const referenceElement = argReferenceElement ? argReferenceElement : editor ? {
    getBoundingClientRect: () => (0, import_tiptap.posToDOMRect)(
      editor.view,
      editor.view.state.selection.from,
      editor.view.state.selection.to
    )
  } : null;
  modalService.openModal({
    Component: import_link_modal.LinkModal,
    componentProps: {
      initialValue,
      enabledLinkTypes,
      onClose: () => modalService.closeModal(import_constants.LINK_MODAL_ID),
      onSaveMultiple,
      onSave,
      onUnlink
    },
    disableArrowNavigation: true,
    dragHandleSelector: "[data-drag-handler]",
    enableDrag: true,
    id: import_constants.LINK_MODAL_ID,
    layout: {
      desktop: referenceElement ? "floating" : "dialog",
      //TODO: get layout value directly
      mobile: "fullscreen"
    },
    noPadding: true,
    ...referenceElement && {
      positioning: { placement: placement ?? "bottom", referenceElement }
    },
    withTransition: true,
    ...onClickOutside ? { onClickOutside } : {},
    returnFocusToEditor
  });
};
//# sourceMappingURL=open-link-modal.js.map
