const o = ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "LI", "BLOCKQUOTE"], i = () => ({
  name: "direction",
  toolbar: [
    {
      label: "Left to Right",
      command: "setDirectionLTR",
      icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
      shortcut: "Mod-Shift-l"
    },
    {
      label: "Right to Left",
      command: "setDirectionRTL",
      icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
      shortcut: "Mod-Shift-r"
    }
  ],
  commands: {
    setDirectionLTR: () => {
      try {
        const t = window.getSelection();
        if (!t || t.rangeCount === 0) return !1;
        let e = t.getRangeAt(0).commonAncestorContainer;
        for (e && e.nodeType === Node.TEXT_NODE && (e = e.parentElement); e && e !== document.body; ) {
          const r = e;
          if (r.tagName && o.includes(r.tagName))
            return r.removeAttribute("dir"), !0;
          e = r.parentElement;
        }
        return !1;
      } catch (t) {
        return console.error("Failed to set LTR direction:", t), !1;
      }
    },
    setDirectionRTL: () => {
      try {
        const t = window.getSelection();
        if (!t || t.rangeCount === 0) return !1;
        let e = t.getRangeAt(0).commonAncestorContainer;
        for (e && e.nodeType === Node.TEXT_NODE && (e = e.parentElement); e && e !== document.body; ) {
          const r = e;
          if (r.tagName && o.includes(r.tagName))
            return r.setAttribute("dir", "rtl"), !0;
          e = r.parentElement;
        }
        return !1;
      } catch (t) {
        return console.error("Failed to set RTL direction:", t), !1;
      }
    }
  },
  keymap: {
    "Mod-Shift-l": "setDirectionLTR",
    "Mod-Shift-r": "setDirectionRTL"
  }
});
export {
  i as DirectionPlugin
};
//# sourceMappingURL=DirectionPlugin.native-Be7wCzkI.mjs.map
