const c = () => ({
  name: "document-manager",
  toolbar: [
    {
      label: "Import Word",
      command: "importWord",
      icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',
      type: "button"
    },
    {
      label: "Export Word",
      command: "exportWord",
      icon: '<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
      type: "button"
    },
    {
      label: "Export PDF",
      command: "exportPdf",
      icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
      type: "button"
    }
  ],
  commands: {
    importWord: () => {
      const l = () => {
        const e = window.getSelection();
        if (e && e.rangeCount > 0) {
          let r = e.getRangeAt(0).startContainer;
          for (; r && r !== document.body; ) {
            if (r.nodeType === Node.ELEMENT_NODE) {
              const d = r;
              if (d.getAttribute("contenteditable") === "true")
                return d;
            }
            r = r.parentNode;
          }
        }
        const n = document.activeElement;
        if ((n == null ? void 0 : n.getAttribute("contenteditable")) === "true")
          return n;
        const o = n == null ? void 0 : n.closest('[contenteditable="true"]');
        return o || document.querySelector('[contenteditable="true"]');
      }, t = document.createElement("input");
      return t.type = "file", t.accept = ".docx", t.onchange = async (e) => {
        var o;
        const n = (o = e.target.files) == null ? void 0 : o[0];
        if (n)
          try {
            const r = l();
            if (r) {
              const { importFromWord: d } = await import("./documentManager-vQ1VkbUY.mjs"), a = await d(n);
              r.innerHTML = a, r.dispatchEvent(new Event("input", { bubbles: !0 }));
            }
          } catch (r) {
            console.error("Import failed:", r), alert("Failed to import Word document. Please check the console for details.");
          }
      }, t.click(), !0;
    },
    exportWord: async () => {
      const l = () => {
        const t = window.getSelection();
        if (t && t.rangeCount > 0) {
          let o = t.getRangeAt(0).startContainer;
          for (; o && o !== document.body; ) {
            if (o.nodeType === Node.ELEMENT_NODE && o.getAttribute("contenteditable") === "true")
              return o;
            o = o.parentNode;
          }
        }
        const e = document.activeElement;
        return (e == null ? void 0 : e.getAttribute("contenteditable")) === "true" ? e : (e == null ? void 0 : e.closest('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
      };
      try {
        const t = l();
        if (t) {
          const e = t.innerHTML, { exportToWord: n } = await import("./documentManager-vQ1VkbUY.mjs");
          await n(e, "document.docx");
        }
        return !0;
      } catch (t) {
        return console.error("Export failed:", t), alert("Failed to export to Word. Please check the console for details."), !1;
      }
    },
    exportPdf: async () => {
      const l = () => {
        const t = window.getSelection();
        if (t && t.rangeCount > 0) {
          let o = t.getRangeAt(0).startContainer;
          for (; o && o !== document.body; ) {
            if (o.nodeType === Node.ELEMENT_NODE && o.getAttribute("contenteditable") === "true")
              return o;
            o = o.parentNode;
          }
        }
        const e = document.activeElement;
        return (e == null ? void 0 : e.getAttribute("contenteditable")) === "true" ? e : (e == null ? void 0 : e.closest('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
      };
      try {
        const t = l();
        if (t) {
          const e = t.innerHTML, { exportToPdf: n } = await import("./documentManager-vQ1VkbUY.mjs");
          await n(e, "document.pdf", t);
        } else
          console.error("PDF Export: No editor element found"), alert("No active editor found. Please click in the editor area first.");
        return !0;
      } catch (t) {
        return console.error("PDF Export: Export failed:", t), alert("Failed to export to PDF. Please check the console for details."), !1;
      }
    }
  },
  keymap: {}
});
export {
  c as DocumentManagerPlugin
};
//# sourceMappingURL=DocumentManagerPlugin.native-C2cs_1w4.mjs.map
