import { jsx as o, jsxs as l, Fragment as $ } from "react/jsx-runtime";
import { LexicalComposer as at } from "@lexical/react/LexicalComposer";
import { ListPlugin as st } from "@lexical/react/LexicalListPlugin";
import { HorizontalRulePlugin as lt } from "@lexical/react/LexicalHorizontalRulePlugin";
import { ClearEditorPlugin as ct } from "@lexical/react/LexicalClearEditorPlugin";
import { RichTextPlugin as dt } from "@lexical/react/LexicalRichTextPlugin";
import { HistoryPlugin as mt } from "@lexical/react/LexicalHistoryPlugin";
import { TablePlugin as ut } from "@lexical/react/LexicalTablePlugin";
import { CheckListPlugin as ht } from "@lexical/react/LexicalCheckListPlugin";
import { MarkdownShortcutPlugin as _t } from "@lexical/react/LexicalMarkdownShortcutPlugin";
import { TRANSFORMERS as pt } from "@lexical/markdown";
import * as oe from "react";
import { Suspense as gt, useRef as O, useState as p, useCallback as P, useEffect as E, useMemo as ie, createContext as ft } from "react";
import { LexicalErrorBoundary as Nt } from "@lexical/react/LexicalErrorBoundary";
import { CodeNode as Ct, CodeHighlightNode as bt, $isCodeNode as me, CODE_LANGUAGE_MAP as Et, getLanguageFriendlyName as yt, CODE_LANGUAGE_FRIENDLY_NAME_MAP as Tt, $createCodeNode as ue, registerCodeHighlighting as wt } from "@lexical/code";
import { AutoLinkNode as At, LinkNode as Pt, $isLinkNode as he, TOGGLE_LINK_COMMAND as _e } from "@lexical/link";
import { ListNode as Te, ListItemNode as kt, $isListNode as It, INSERT_UNORDERED_LIST_COMMAND as xt, REMOVE_LIST_COMMAND as X, INSERT_ORDERED_LIST_COMMAND as Dt, INSERT_CHECK_LIST_COMMAND as St } from "@lexical/list";
import { MarkNode as Ot } from "@lexical/mark";
import { OverflowNode as Mt } from "@lexical/overflow";
import { HorizontalRuleNode as Rt, INSERT_HORIZONTAL_RULE_COMMAND as Lt } from "@lexical/react/LexicalHorizontalRuleNode";
import { HeadingNode as vt, QuoteNode as $t, DRAG_DROP_PASTE as Bt, $isHeadingNode as pe, $isQuoteNode as Ft, $createHeadingNode as Ut, $createQuoteNode as Ht } from "@lexical/rich-text";
import { TableNode as Gt, TableCellNode as Kt, TableRowNode as Wt, INSERT_TABLE_COMMAND as Jt, $isTableNode as ge, $isTableSelection as J } from "@lexical/table";
import { TextNode as jt, $applyNodeReplacement as we, DecoratorNode as Yt, createEditor as zt, createCommand as Ae, $insertNodes as Pe, $isRootOrShadowRoot as ke, $createParagraphNode as re, COMMAND_PRIORITY_EDITOR as Zt, DRAGSTART_COMMAND as Vt, COMMAND_PRIORITY_HIGH as fe, DRAGOVER_COMMAND as Qt, COMMAND_PRIORITY_LOW as Ie, DROP_COMMAND as qt, $createRangeSelection as Xt, $setSelection as en, $getSelection as S, $isNodeSelection as tn, $isRangeSelection as v, SELECTION_CHANGE_COMMAND as nn, COMMAND_PRIORITY_CRITICAL as ee, CAN_UNDO_COMMAND as on, CAN_REDO_COMMAND as rn, $isTextNode as an, $getNodeByKey as sn, UNDO_COMMAND as ln, REDO_COMMAND as cn, FORMAT_ELEMENT_COMMAND as j, OUTDENT_CONTENT_COMMAND as dn, INDENT_CONTENT_COMMAND as mn, FORMAT_TEXT_COMMAND as L, $getRoot as un } from "lexical";
import { BlockWithAlignableContents as xe } from "@lexical/react/LexicalBlockWithAlignableContents";
import { DecoratorBlockNode as De, $isDecoratorBlockNode as hn } from "@lexical/react/LexicalDecoratorBlockNode";
import { useLexicalComposerContext as K } from "@lexical/react/LexicalComposerContext";
import { mergeRegister as Se, $wrapNodeInElement as _n, mediaFileReader as pn, isMimeType as gn, $findMatchingParent as Ne, $getNearestNodeOfType as fn, $getNearestBlockElementAncestorOrThrow as Nn } from "@lexical/utils";
import { LinkPlugin as Cn } from "@lexical/react/LexicalLinkPlugin";
import { $isAtNodeEnd as Ce, $isParentElementRTL as bn, $setBlocksType as Y } from "@lexical/selection";
import { createPortal as Oe } from "react-dom";
import { ContentEditable as En } from "@lexical/react/LexicalContentEditable";
import { AutoLinkPlugin as yn, createLinkMatcherWithRegExp as be } from "@lexical/react/LexicalAutoLinkPlugin";
import { OnChangePlugin as Tn } from "@lexical/react/LexicalOnChangePlugin";
import { $generateNodesFromDOM as wn, $generateHtmlFromNodes as An } from "@lexical/html";
class z extends jt {
  __className;
  static getType() {
    return "emoji";
  }
  static clone(e) {
    return new z(e.__className, e.__text, e.__key);
  }
  constructor(e, t, i) {
    super(t, i), this.__className = e;
  }
  createDOM(e) {
    const t = document.createElement("span"), i = super.createDOM(e);
    return t.className = this.__className, i.className = "emoji-inner", t.appendChild(i), t;
  }
  updateDOM(e, t, i) {
    const r = t.firstChild;
    return r === null ? !0 : (super.updateDOM(e, r, i), !1);
  }
  static importJSON(e) {
    const t = Pn(
      e.className,
      e.text
    );
    return t.setFormat(e.format), t.setDetail(e.detail), t.setMode(e.mode), t.setStyle(e.style), t;
  }
  exportJSON() {
    return {
      ...super.exportJSON(),
      className: this.getClassName(),
      type: "emoji"
    };
  }
  getClassName() {
    return this.getLatest().__className;
  }
}
function Pn(n, e) {
  const t = new z(n, e).setMode("token");
  return we(t);
}
const kn = oe.lazy(
  // @ts-ignore
  () => import("./InlineImageComponent-C0XL3-Gt.js")
);
function In(n) {
  if (n) {
    const { alt: e, src: t, width: i, height: r } = n;
    return { node: ae({ altText: e, height: r, src: t, width: i }) };
  }
  return null;
}
class H extends Yt {
  __src;
  __altText;
  __width;
  __height;
  __showCaption;
  __caption;
  __position;
  static getType() {
    return "inline-image";
  }
  static clone(e) {
    return new H(
      e.__src,
      e.__altText,
      e.__position,
      e.__width,
      e.__height,
      e.__showCaption,
      e.__caption,
      e.__key
    );
  }
  static importJSON(e) {
    const { altText: t, height: i, width: r, caption: a, src: s, showCaption: c, position: u } = e, h = ae({
      altText: t,
      height: i,
      showCaption: c,
      src: s,
      width: r,
      position: u
    }), g = h.__caption, d = g.parseEditorState(a.editorState);
    return d.isEmpty() || g.setEditorState(d), h;
  }
  static importDOM() {
    return {
      img: (e) => ({
        conversion: In,
        priority: 0
      })
    };
  }
  constructor(e, t, i, r, a, s, c, u) {
    super(u), this.__src = e, this.__altText = t, this.__width = r || "inherit", this.__height = a || "inherit", this.__showCaption = s || !1, this.__caption = c || zt(), this.__position = i;
  }
  exportDOM() {
    const e = document.createElement("img");
    return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.setAttribute("width", this.__width.toString()), e.setAttribute("height", this.__height.toString()), { element: e };
  }
  exportJSON() {
    return {
      altText: this.getAltText(),
      caption: this.__caption.toJSON(),
      height: this.__height === "inherit" ? 0 : this.__height,
      showCaption: this.__showCaption,
      src: this.getSrc(),
      type: "inline-image",
      version: 1,
      width: this.__width === "inherit" ? 0 : this.__width,
      position: this.__position
    };
  }
  getSrc() {
    return this.__src;
  }
  getAltText() {
    return this.__altText;
  }
  setAltText(e) {
    const t = this.getWritable();
    t.__altText = e;
  }
  setWidthAndHeight(e, t) {
    const i = this.getWritable();
    i.__width = e, i.__height = t;
  }
  getShowCaption() {
    return this.__showCaption;
  }
  setShowCaption(e) {
    const t = this.getWritable();
    t.__showCaption = e;
  }
  getPosition() {
    return this.__position;
  }
  setPosition(e) {
    const t = this.getWritable();
    t.__position = e;
  }
  update(e) {
    const t = this.getWritable(), { altText: i, showCaption: r, position: a } = e;
    i !== void 0 && (t.__altText = i), r !== void 0 && (t.__showCaption = r), a !== void 0 && (t.__position = a);
  }
  // View
  createDOM(e) {
    const t = document.createElement("span"), r = `${e.theme.image} position-${this.__position}`;
    return r !== void 0 && (t.className = r), t;
  }
  updateDOM(e, t, i) {
    const r = this.__position;
    if (r !== e.__position) {
      const a = `${i.theme.image} position-${r}`;
      a !== void 0 && (t.className = a);
    }
    return !1;
  }
  decorate() {
    return /* @__PURE__ */ o(gt, { fallback: null, children: /* @__PURE__ */ o(
      kn,
      {
        src: this.__src,
        altText: this.__altText,
        width: this.__width,
        height: this.__height,
        nodeKey: this.getKey(),
        showCaption: this.__showCaption,
        caption: this.__caption,
        position: this.__position
      }
    ) });
  }
}
function ae({
  altText: n,
  position: e,
  height: t,
  src: i,
  width: r,
  showCaption: a,
  caption: s,
  key: c
}) {
  return we(
    new H(
      i,
      n,
      e,
      r,
      t,
      a,
      s,
      c
    )
  );
}
function xn(n) {
  return n instanceof H;
}
const Dn = "https://platform.twitter.com/widgets.js";
function Sn(n) {
  const e = n.getAttribute("data-lexical-tweet-id");
  return e ? { node: Me(e) } : null;
}
let Ee = !0;
function On({
  className: n,
  format: e,
  loadingComponent: t,
  nodeKey: i,
  onError: r,
  onLoad: a,
  tweetID: s
}) {
  const c = O(null), u = O(""), [h, g] = p(!1), d = P(async () => {
    try {
      await window.twttr.widgets.createTweet(s, c.current), g(!1), Ee = !1, a && a();
    } catch (_) {
      r && r(String(_));
    }
  }, [r, a, s]);
  return E(() => {
    if (s !== u.current) {
      if (g(!0), Ee) {
        const _ = document.createElement("script");
        _.src = Dn, _.async = !0, document.body?.appendChild(_), _.onload = d, r && (_.onerror = r);
      } else
        d();
      u && (u.current = s);
    }
  }, [d, r, s]), /* @__PURE__ */ l(
    xe,
    {
      className: n,
      format: e,
      nodeKey: i,
      children: [
        h ? t : null,
        /* @__PURE__ */ o(
          "div",
          {
            style: { display: "inline-block", width: "550px" },
            ref: c
          }
        )
      ]
    }
  );
}
class Z extends De {
  __id;
  static getType() {
    return "tweet";
  }
  static clone(e) {
    return new Z(e.__id, e.__format, e.__key);
  }
  static importJSON(e) {
    const t = Me(e.id);
    return t.setFormat(e.format), t;
  }
  exportJSON() {
    return {
      ...super.exportJSON(),
      id: this.getId(),
      type: "tweet",
      version: 1
    };
  }
  static importDOM() {
    return {
      div: (e) => e.hasAttribute("data-lexical-tweet-id") ? {
        conversion: Sn,
        priority: 2
      } : null
    };
  }
  exportDOM() {
    const e = document.createElement("div");
    e.setAttribute("data-lexical-tweet-id", this.__id);
    const t = document.createTextNode(this.getTextContent());
    return e.append(t), { element: e };
  }
  constructor(e, t, i) {
    super(t, i), this.__id = e;
  }
  getId() {
    return this.__id;
  }
  getTextContent(e, t) {
    return `https://twitter.com/i/web/status/${this.__id}`;
  }
  decorate(e, t) {
    const i = t.theme.embedBlock || {}, r = {
      base: i.base || "",
      focus: i.focus || ""
    };
    return /* @__PURE__ */ o(
      On,
      {
        className: r,
        format: this.__format,
        loadingComponent: "Loading...",
        nodeKey: this.getKey(),
        tweetID: this.__id
      }
    );
  }
  isInline() {
    return !1;
  }
}
function Me(n) {
  return new Z(n);
}
function Mn({
  className: n,
  format: e,
  nodeKey: t,
  videoID: i
}) {
  return /* @__PURE__ */ o(
    xe,
    {
      className: n,
      format: e,
      nodeKey: t,
      children: /* @__PURE__ */ o(
        "iframe",
        {
          width: "560",
          height: "315",
          src: `https://www.youtube-nocookie.com/embed/${i}`,
          frameBorder: "0",
          allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
          allowFullScreen: !0,
          title: "YouTube video"
        }
      )
    }
  );
}
function Rn(n) {
  const e = n.getAttribute("data-lexical-youtube");
  return e ? { node: Re(e) } : null;
}
class V extends De {
  __id;
  static getType() {
    return "youtube";
  }
  static clone(e) {
    return new V(e.__id, e.__format, e.__key);
  }
  static importJSON(e) {
    const t = Re(e.videoID);
    return t.setFormat(e.format), t;
  }
  exportJSON() {
    return {
      ...super.exportJSON(),
      type: "youtube",
      version: 1,
      videoID: this.__id
    };
  }
  constructor(e, t, i) {
    super(t, i), this.__id = e;
  }
  exportDOM() {
    const e = document.createElement("iframe");
    return e.setAttribute("data-lexical-youtube", this.__id), e.setAttribute("width", "560"), e.setAttribute("height", "315"), e.setAttribute(
      "src",
      `https://www.youtube-nocookie.com/embed/${this.__id}`
    ), e.setAttribute("frameborder", "0"), e.setAttribute(
      "allow",
      "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
    ), e.setAttribute("allowfullscreen", "true"), e.setAttribute("title", "YouTube video"), { element: e };
  }
  static importDOM() {
    return {
      iframe: (e) => e.hasAttribute("data-lexical-youtube") ? {
        conversion: Rn,
        priority: 1
      } : null
    };
  }
  updateDOM() {
    return !1;
  }
  getId() {
    return this.__id;
  }
  getTextContent(e, t) {
    return `https://www.youtube.com/watch?v=${this.__id}`;
  }
  decorate(e, t) {
    const i = t.theme.embedBlock || {}, r = {
      base: i.base || "",
      focus: i.focus || ""
    };
    return /* @__PURE__ */ o(
      Mn,
      {
        className: r,
        format: this.__format,
        nodeKey: this.getKey(),
        videoID: this.__id
      }
    );
  }
  isInline() {
    return !1;
  }
}
function Re(n) {
  return new V(n);
}
const Ln = [
  vt,
  Te,
  kt,
  $t,
  Ct,
  Gt,
  Kt,
  Wt,
  bt,
  At,
  Pt,
  Mt,
  H,
  z,
  Rt,
  Z,
  V,
  Ot
], vn = {
  blockCursor: "PlaygroundEditorTheme__blockCursor",
  characterLimit: "PlaygroundEditorTheme__characterLimit",
  code: "PlaygroundEditorTheme__code",
  codeHighlight: {
    atrule: "PlaygroundEditorTheme__tokenAttr",
    attr: "PlaygroundEditorTheme__tokenAttr",
    boolean: "PlaygroundEditorTheme__tokenProperty",
    builtin: "PlaygroundEditorTheme__tokenSelector",
    cdata: "PlaygroundEditorTheme__tokenComment",
    char: "PlaygroundEditorTheme__tokenSelector",
    class: "PlaygroundEditorTheme__tokenFunction",
    "class-name": "PlaygroundEditorTheme__tokenFunction",
    comment: "PlaygroundEditorTheme__tokenComment",
    constant: "PlaygroundEditorTheme__tokenProperty",
    deleted: "PlaygroundEditorTheme__tokenProperty",
    doctype: "PlaygroundEditorTheme__tokenComment",
    entity: "PlaygroundEditorTheme__tokenOperator",
    function: "PlaygroundEditorTheme__tokenFunction",
    important: "PlaygroundEditorTheme__tokenVariable",
    inserted: "PlaygroundEditorTheme__tokenSelector",
    keyword: "PlaygroundEditorTheme__tokenAttr",
    namespace: "PlaygroundEditorTheme__tokenVariable",
    number: "PlaygroundEditorTheme__tokenProperty",
    operator: "PlaygroundEditorTheme__tokenOperator",
    prolog: "PlaygroundEditorTheme__tokenComment",
    property: "PlaygroundEditorTheme__tokenProperty",
    punctuation: "PlaygroundEditorTheme__tokenPunctuation",
    regex: "PlaygroundEditorTheme__tokenVariable",
    selector: "PlaygroundEditorTheme__tokenSelector",
    string: "PlaygroundEditorTheme__tokenSelector",
    symbol: "PlaygroundEditorTheme__tokenProperty",
    tag: "PlaygroundEditorTheme__tokenProperty",
    url: "PlaygroundEditorTheme__tokenOperator",
    variable: "PlaygroundEditorTheme__tokenVariable"
  },
  embedBlock: {
    base: "PlaygroundEditorTheme__embedBlock",
    focus: "PlaygroundEditorTheme__embedBlockFocus"
  },
  hashtag: "PlaygroundEditorTheme__hashtag",
  heading: {
    h1: "PlaygroundEditorTheme__h1",
    h2: "PlaygroundEditorTheme__h2",
    h3: "PlaygroundEditorTheme__h3",
    h4: "PlaygroundEditorTheme__h4",
    h5: "PlaygroundEditorTheme__h5",
    h6: "PlaygroundEditorTheme__h6"
  },
  image: "editor-image",
  indent: "PlaygroundEditorTheme__indent",
  link: "PlaygroundEditorTheme__link",
  list: {
    listitem: "PlaygroundEditorTheme__listItem",
    listitemChecked: "PlaygroundEditorTheme__listItemChecked",
    listitemUnchecked: "PlaygroundEditorTheme__listItemUnchecked",
    nested: {
      listitem: "PlaygroundEditorTheme__nestedListItem"
    },
    olDepth: [
      "PlaygroundEditorTheme__ol1",
      "PlaygroundEditorTheme__ol2",
      "PlaygroundEditorTheme__ol3",
      "PlaygroundEditorTheme__ol4",
      "PlaygroundEditorTheme__ol5"
    ],
    ul: "PlaygroundEditorTheme__ul"
  },
  ltr: "PlaygroundEditorTheme__ltr",
  mark: "PlaygroundEditorTheme__mark",
  markOverlap: "PlaygroundEditorTheme__markOverlap",
  paragraph: "PlaygroundEditorTheme__paragraph",
  quote: "PlaygroundEditorTheme__quote",
  rtl: "PlaygroundEditorTheme__rtl",
  table: "PlaygroundEditorTheme__table",
  tableAddColumns: "PlaygroundEditorTheme__tableAddColumns",
  tableAddRows: "PlaygroundEditorTheme__tableAddRows",
  tableCell: "PlaygroundEditorTheme__tableCell",
  tableCellActionButton: "PlaygroundEditorTheme__tableCellActionButton",
  tableCellActionButtonContainer: "PlaygroundEditorTheme__tableCellActionButtonContainer",
  tableCellEditing: "PlaygroundEditorTheme__tableCellEditing",
  tableCellHeader: "PlaygroundEditorTheme__tableCellHeader",
  tableCellPrimarySelected: "PlaygroundEditorTheme__tableCellPrimarySelected",
  tableCellResizer: "PlaygroundEditorTheme__tableCellResizer",
  tableCellSelected: "PlaygroundEditorTheme__tableCellSelected",
  tableCellSortedIndicator: "PlaygroundEditorTheme__tableCellSortedIndicator",
  tableResizeRuler: "PlaygroundEditorTheme__tableCellResizeRuler",
  tableSelected: "PlaygroundEditorTheme__tableSelected",
  text: {
    bold: "PlaygroundEditorTheme__textBold",
    code: "PlaygroundEditorTheme__textCode",
    italic: "PlaygroundEditorTheme__textItalic",
    strikethrough: "PlaygroundEditorTheme__textStrikethrough",
    subscript: "PlaygroundEditorTheme__textSubscript",
    superscript: "PlaygroundEditorTheme__textSuperscript",
    underline: "PlaygroundEditorTheme__textUnderline",
    underlineStrikethrough: "PlaygroundEditorTheme__textUnderlineStrikethrough"
  }
}, Q = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
function $n(...n) {
  return n.filter(Boolean).join(" ");
}
function Le({
  "data-test-id": n,
  children: e,
  className: t,
  onClick: i,
  disabled: r,
  small: a,
  title: s
}) {
  return /* @__PURE__ */ o(
    "button",
    {
      disabled: r,
      className: $n(
        "Button__root",
        r && "Button__disabled",
        a && "Button__small",
        t
      ),
      onClick: i,
      title: s,
      "aria-label": s,
      ...n && { "data-test-id": n },
      children: e
    }
  );
}
function ve({
  "data-test-id": n,
  children: e
}) {
  return /* @__PURE__ */ o("div", { className: "DialogActions", "data-test-id": n, children: e });
}
function Bn({
  accept: n,
  label: e,
  onChange: t,
  "data-test-id": i
}) {
  return /* @__PURE__ */ l("div", { className: "Input__wrapper", children: [
    /* @__PURE__ */ o("label", { className: "Input__label", children: e }),
    /* @__PURE__ */ o(
      "input",
      {
        type: "file",
        accept: n,
        className: "Input__input",
        onChange: (r) => t(r.target.files),
        "data-test-id": i
      }
    )
  ] });
}
function te({
  label: n,
  value: e,
  onChange: t,
  placeholder: i = "",
  "data-test-id": r,
  type: a = "text"
}) {
  return /* @__PURE__ */ l("div", { className: "Input__wrapper", children: [
    /* @__PURE__ */ o("label", { className: "Input__label", children: n }),
    /* @__PURE__ */ o(
      "input",
      {
        type: a,
        className: "Input__input",
        placeholder: i,
        value: e,
        onChange: (s) => {
          t(s.target.value);
        },
        "data-test-id": r
      }
    )
  ] });
}
function Fn({
  children: n,
  label: e,
  className: t,
  ...i
}) {
  return /* @__PURE__ */ l("div", { className: "Input__wrapper", children: [
    /* @__PURE__ */ o("label", { style: { marginTop: "-1em" }, className: "Input__label", children: e }),
    /* @__PURE__ */ o("select", { ...i, className: t || "select", children: n })
  ] });
}
const Un = (n) => Q ? (n || window).getSelection() : null, q = Ae("INSERT_INLINE_IMAGE_COMMAND");
function Hn({
  activeEditor: n,
  onClose: e
}) {
  const t = O(!1), [i, r] = p(""), [a, s] = p(""), [c, u] = p(!1), [h, g] = p("left"), d = i === "", _ = (T) => {
    u(T.target.checked);
  }, b = (T) => {
    g(T.target.value);
  }, M = (T) => {
    const I = new FileReader();
    I.onload = function() {
      return typeof I.result == "string" && r(I.result), "";
    }, T !== null && I.readAsDataURL(T[0]);
  };
  E(() => {
    t.current = !1;
    const T = (I) => {
      t.current = I.altKey;
    };
    return document.addEventListener("keydown", T), () => {
      document.removeEventListener("keydown", T);
    };
  }, [n]);
  const k = () => {
    const T = { altText: a, src: i, showCaption: c, position: h };
    n.dispatchCommand(q, T), e();
  };
  return /* @__PURE__ */ l($, { children: [
    /* @__PURE__ */ o("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ o(
      Bn,
      {
        label: "Image Upload",
        onChange: M,
        accept: "image/*",
        "data-test-id": "image-modal-file-upload"
      }
    ) }),
    /* @__PURE__ */ o("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ o(
      te,
      {
        label: "Alt Text",
        placeholder: "Descriptive alternative text",
        onChange: s,
        value: a,
        "data-test-id": "image-modal-alt-text-input"
      }
    ) }),
    /* @__PURE__ */ l(Fn, { style: { marginBottom: "1em", width: "290px" }, label: "Position", name: "position", id: "position-select", onChange: b, children: [
      /* @__PURE__ */ o("option", { value: "left", children: "Left" }),
      /* @__PURE__ */ o("option", { value: "right", children: "Right" }),
      /* @__PURE__ */ o("option", { value: "full", children: "Full Width" })
    ] }),
    /* @__PURE__ */ l("div", { className: "Input__wrapper", children: [
      /* @__PURE__ */ o("input", { id: "caption", type: "checkbox", checked: c, onChange: _ }),
      /* @__PURE__ */ o("label", { htmlFor: "caption", children: "Show Caption" })
    ] }),
    /* @__PURE__ */ o(ve, { children: /* @__PURE__ */ o(
      Le,
      {
        "data-test-id": "image-modal-file-upload-btn",
        disabled: d,
        onClick: () => k(),
        children: "Confirm"
      }
    ) })
  ] });
}
function Gn({
  captionsEnabled: n
}) {
  const [e] = K();
  return E(() => {
    if (!e.hasNodes([H]))
      throw new Error("ImagesPlugin: ImageNode not registered on editor");
    return Se(
      e.registerCommand(
        q,
        (t) => {
          const i = ae(t);
          return Pe([i]), ke(i.getParentOrThrow()) && _n(i, re).selectEnd(), !0;
        },
        Zt
      ),
      e.registerCommand(
        Vt,
        (t) => Wn(t),
        fe
      ),
      e.registerCommand(
        Qt,
        (t) => Jn(t),
        Ie
      ),
      e.registerCommand(
        qt,
        (t) => jn(t, e),
        fe
      )
    );
  }, [n, e]), null;
}
const Kn = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", $e = document.createElement("img");
$e.src = Kn;
function Wn(n) {
  const e = se();
  if (!e)
    return !1;
  const t = n.dataTransfer;
  return t ? (t.setData("text/plain", "_"), t.setDragImage($e, 0, 0), t.setData(
    "application/x-lexical-drag",
    JSON.stringify({
      data: {
        altText: e.__altText,
        caption: e.__caption,
        height: e.__height,
        key: e.getKey(),
        showCaption: e.__showCaption,
        src: e.__src,
        width: e.__width
      },
      type: "image"
    })
  ), !0) : !1;
}
function Jn(n) {
  return se() ? (Be(n) || n.preventDefault(), !0) : !1;
}
function jn(n, e) {
  const t = se();
  if (!t)
    return !1;
  const i = Yn(n);
  if (!i)
    return !1;
  if (n.preventDefault(), Be(n)) {
    const r = zn(n);
    t.remove();
    const a = Xt();
    r != null && a.applyDOMRange(r), en(a), e.dispatchCommand(q, i);
  }
  return !0;
}
function se() {
  const n = S();
  if (!tn(n))
    return null;
  const t = n.getNodes()[0];
  return xn(t) ? t : null;
}
function Yn(n) {
  const e = n.dataTransfer?.getData("application/x-lexical-drag");
  if (!e)
    return null;
  const { type: t, data: i } = JSON.parse(e);
  return t !== "image" ? null : i;
}
function Be(n) {
  const e = n.target;
  return !!(e && e instanceof HTMLElement && !e.closest("code, span.editor-image") && e.parentElement && e.parentElement.closest("div.ContentEditable__root"));
}
function zn(n) {
  let e;
  const t = n.target, i = t == null ? null : t.nodeType === 9 ? t.defaultView : t.ownerDocument.defaultView, r = Un(i);
  if (document.caretRangeFromPoint)
    e = document.caretRangeFromPoint(n.clientX, n.clientY);
  else if (n.rangeParent && r !== null)
    r.collapse(n.rangeParent, n.rangeOffset || 0), e = r.getRangeAt(0);
  else
    throw Error("Cannot get the selection when dragging");
  return e;
}
const ye = [
  "image/",
  "image/heic",
  "image/heif",
  "image/gif",
  "image/webp"
];
function Zn() {
  const [n] = K();
  return E(() => n.registerCommand(
    Bt,
    (e) => ((async () => {
      const t = await pn(
        e,
        [ye].flatMap((i) => i)
      );
      for (const { file: i, result: r } of t)
        gn(i, ye) && n.dispatchCommand(q, {
          altText: i.name,
          src: r
        });
    })(), !0),
    Ie
  ), [n]), null;
}
function Vn(n) {
  const e = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi, t = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
  return n = String(n).trim(), n.match(e) || n.match(t) ? n : "https://";
}
const Qn = new RegExp(
  /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/
);
function qn(n) {
  return n === "https://" || Qn.test(n);
}
function Xn() {
  return /* @__PURE__ */ o(Cn, { validateUrl: qn });
}
const eo = Q && "documentMode" in document ? document.documentMode : null, D = Q && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
Q && "InputEvent" in window && !eo && "getTargetRanges" in new window.InputEvent("input");
function to({
  onClose: n,
  children: e,
  title: t,
  closeOnClickOutside: i
}) {
  const r = O(null);
  return E(() => {
    r.current !== null && r.current.focus();
  }, []), E(() => {
    let a = null;
    const s = (h) => {
      h.keyCode === 27 && n();
    }, c = (h) => {
      const g = h.target;
      r.current !== null && !r.current.contains(g) && i && n();
    }, u = r.current;
    return u !== null && (a = u.parentElement, a !== null && a.addEventListener("click", c)), window.addEventListener("keydown", s), () => {
      window.removeEventListener("keydown", s), a !== null && a?.removeEventListener("click", c);
    };
  }, [i, n]), /* @__PURE__ */ o("div", { className: "Modal__overlay", role: "dialog", children: /* @__PURE__ */ l("div", { className: "Modal__modal", tabIndex: -1, ref: r, children: [
    /* @__PURE__ */ o("h2", { className: "Modal__title", children: t }),
    /* @__PURE__ */ o(
      "button",
      {
        className: "Modal__closeButton",
        "aria-label": "Close modal",
        type: "button",
        onClick: n,
        children: "X"
      }
    ),
    /* @__PURE__ */ o("div", { className: "Modal__content", children: e })
  ] }) });
}
function no({
  onClose: n,
  children: e,
  title: t,
  closeOnClickOutside: i = !1
}) {
  return Oe(
    /* @__PURE__ */ o(
      to,
      {
        onClose: n,
        title: t,
        closeOnClickOutside: i,
        children: e
      }
    ),
    document.body
  );
}
function oo() {
  const [n, e] = p(null), t = P(() => {
    e(null);
  }, []), i = ie(() => {
    if (n === null)
      return null;
    const { title: a, content: s, closeOnClickOutside: c } = n;
    return /* @__PURE__ */ o(
      no,
      {
        onClose: t,
        title: a,
        closeOnClickOutside: c,
        children: s
      }
    );
  }, [n, t]), r = P(
    (a, s, c = !1) => {
      e({
        closeOnClickOutside: c,
        content: s(t),
        title: a
      });
    },
    [t]
  );
  return [i, r];
}
const Fe = oe.createContext(null);
function f({
  children: n,
  className: e,
  onClick: t,
  title: i
}) {
  const r = O(null), a = oe.useContext(Fe);
  if (a === null)
    throw new Error("DropDownItem must be used within a DropDown");
  const { registerItem: s } = a;
  return E(() => {
    r && r.current && s(r);
  }, [r, s]), /* @__PURE__ */ o(
    "button",
    {
      className: e,
      onClick: t,
      ref: r,
      title: i,
      type: "button",
      children: n
    }
  );
}
function io({
  children: n,
  dropDownRef: e,
  onClose: t
}) {
  const [i, r] = p(), [a, s] = p(), c = P(
    (g) => {
      r((d) => d ? [...d, g] : [g]);
    },
    [r]
  ), u = (g) => {
    if (!i) return;
    const d = g.key;
    ["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(d) && g.preventDefault(), d === "Escape" || d === "Tab" ? t() : d === "ArrowUp" ? s((_) => {
      if (!_) return i[0];
      const b = i.indexOf(_) - 1;
      return i[b === -1 ? i.length - 1 : b];
    }) : d === "ArrowDown" && s((_) => _ ? i[i.indexOf(_) + 1] : i[0]);
  }, h = ie(
    () => ({
      registerItem: c
    }),
    [c]
  );
  return E(() => {
    i && !a && s(i[0]), a && a.current && a.current.focus();
  }, [i, a]), /* @__PURE__ */ o(Fe.Provider, { value: h, children: /* @__PURE__ */ o("div", { className: "dropdown", ref: e, onKeyDown: u, children: n }) });
}
function U({
  disabled: n = !1,
  buttonLabel: e,
  buttonAriaLabel: t,
  buttonClassName: i,
  buttonIconClassName: r,
  children: a,
  stopCloseOnClickSelf: s
}) {
  const c = O(null), u = O(null), [h, g] = p(!1), d = () => {
    g(!1), u && u.current && u.current.focus();
  };
  return E(() => {
    const _ = u.current, b = c.current;
    if (h && _ !== null && b !== null) {
      const { top: M, left: k } = _.getBoundingClientRect();
      b.style.top = `${M + 40}px`, b.style.left = `${Math.min(
        k,
        window.innerWidth - b.offsetWidth - 20
      )}px`;
    }
  }, [c, u, h]), E(() => {
    const _ = u.current;
    if (_ !== null && h) {
      const b = (M) => {
        const k = M.target;
        s && c.current && c.current.contains(k) || _.contains(k) || g(!1);
      };
      return document.addEventListener("click", b), () => {
        document.removeEventListener("click", b);
      };
    }
  }, [c, u, h, s]), /* @__PURE__ */ l($, { children: [
    /* @__PURE__ */ l(
      "button",
      {
        disabled: n,
        "aria-label": t || e,
        className: i,
        onClick: () => g(!h),
        ref: u,
        children: [
          r && /* @__PURE__ */ o("span", { className: r }),
          e && /* @__PURE__ */ o("span", { className: "text dropdown-button-text", children: e }),
          /* @__PURE__ */ o("i", { className: "chevron-down" })
        ]
      }
    ),
    h && Oe(
      /* @__PURE__ */ o(io, { dropDownRef: c, onClose: d, children: a }),
      document.body
    )
  ] });
}
function ro(n) {
  const e = n.anchor, t = n.focus, i = n.anchor.getNode(), r = n.focus.getNode();
  return i === r ? i : n.isBackward() ? Ce(t) ? i : r : Ce(e) ? i : r;
}
Ae("INSERT_NEW_TABLE_COMMAND");
ft({
  cellEditorConfig: null,
  cellEditorPlugins: null,
  set: () => {
  }
});
function ao({
  activeEditor: n,
  onClose: e
}) {
  const [t, i] = p("5"), [r, a] = p("5"), [s, c] = p(!0);
  return E(() => {
    const h = Number(t), g = Number(r);
    h && h > 0 && h <= 500 && g && g > 0 && g <= 50 ? c(!1) : c(!0);
  }, [t, r]), /* @__PURE__ */ l($, { children: [
    /* @__PURE__ */ o(
      te,
      {
        placeholder: "# of rows (1-500)",
        label: "Rows",
        onChange: i,
        value: t,
        "data-test-id": "table-modal-rows",
        type: "number"
      }
    ),
    /* @__PURE__ */ o(
      te,
      {
        placeholder: "# of columns (1-50)",
        label: "Columns",
        onChange: a,
        value: r,
        "data-test-id": "table-modal-columns",
        type: "number"
      }
    ),
    /* @__PURE__ */ o(ve, { "data-test-id": "table-model-confirm-insert", children: /* @__PURE__ */ o(Le, { disabled: s, onClick: () => {
      n.dispatchCommand(Jt, {
        columns: r,
        rows: t
      }), e();
    }, children: "Confirm" }) })
  ] });
}
const ne = {
  bullet: "Bulleted List",
  check: "Check List",
  code: "Code Block",
  h1: "Heading 1",
  h2: "Heading 2",
  h3: "Heading 3",
  h4: "Heading 4",
  h5: "Heading 5",
  h6: "Heading 6",
  number: "Numbered List",
  paragraph: "Normal",
  quote: "Quote"
};
function so() {
  const n = [];
  for (const [e, t] of Object.entries(
    Tt
  ))
    n.push([e, t]);
  return n;
}
const lo = so();
function A(n) {
  return n ? "active dropdown-item-active" : "";
}
function co({
  editor: n,
  blockType: e,
  rootType: t,
  disabled: i = !1
}) {
  const r = () => {
    n.update(() => {
      const d = S();
      (v(d) || J(d)) && Y(d, () => re());
    });
  }, a = (d) => {
    e !== d && n.update(() => {
      const _ = S();
      (v(_) || J(_)) && Y(_, () => Ut(d));
    });
  }, s = () => {
    e !== "bullet" ? n.dispatchCommand(xt, void 0) : n.dispatchCommand(X, void 0);
  }, c = () => {
    e !== "check" ? n.dispatchCommand(St, void 0) : n.dispatchCommand(X, void 0);
  }, u = () => {
    e !== "number" ? n.dispatchCommand(Dt, void 0) : n.dispatchCommand(X, void 0);
  }, h = () => {
    e !== "quote" && n.update(() => {
      const d = S();
      (v(d) || J(d)) && Y(d, () => Ht());
    });
  }, g = () => {
    e !== "code" && n.update(() => {
      let d = S();
      if (v(d) || J(d))
        if (d.isCollapsed())
          Y(d, () => ue());
        else {
          const _ = d.getTextContent(), b = ue();
          d.insertNodes([b]), d = S(), v(d) && d.insertRawText(_);
        }
    });
  };
  return /* @__PURE__ */ l(
    U,
    {
      disabled: i,
      buttonClassName: "toolbar-item block-controls",
      buttonIconClassName: "icon block-type " + e,
      buttonLabel: ne[e],
      buttonAriaLabel: "Formatting options for text style",
      children: [
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "paragraph"),
            onClick: r,
            children: [
              /* @__PURE__ */ o("i", { className: "icon paragraph" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Normal" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "h1"),
            onClick: () => a("h1"),
            children: [
              /* @__PURE__ */ o("i", { className: "icon h1" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Heading 1" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "h2"),
            onClick: () => a("h2"),
            children: [
              /* @__PURE__ */ o("i", { className: "icon h2" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Heading 2" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "h3"),
            onClick: () => a("h3"),
            children: [
              /* @__PURE__ */ o("i", { className: "icon h3" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Heading 3" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "bullet"),
            onClick: s,
            children: [
              /* @__PURE__ */ o("i", { className: "icon bullet-list" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Bullet List" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "number"),
            onClick: u,
            children: [
              /* @__PURE__ */ o("i", { className: "icon numbered-list" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Numbered List" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "check"),
            onClick: c,
            children: [
              /* @__PURE__ */ o("i", { className: "icon check-list" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Check List" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "quote"),
            onClick: h,
            children: [
              /* @__PURE__ */ o("i", { className: "icon quote" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Quote" })
            ]
          }
        ),
        /* @__PURE__ */ l(
          f,
          {
            className: "item " + A(e === "code"),
            onClick: g,
            children: [
              /* @__PURE__ */ o("i", { className: "icon code" }),
              /* @__PURE__ */ o("span", { className: "text", children: "Code Block" })
            ]
          }
        )
      ]
    }
  );
}
function F() {
  return /* @__PURE__ */ o("div", { className: "divider" });
}
function mo() {
  const [n] = K(), [e, t] = p(n), [i, r] = p("paragraph"), [a, s] = p("root"), [c, u] = p(
    null
  ), [h, g] = p(!1), [d, _] = p(!1), [b, M] = p(!1), [k, T] = p(!1), [I, Ue] = p(!1), [He, Ge] = p(!1), [Ke, We] = p(!1), [Je, je] = p(!1), [Ye, ze] = p(!1), [Ze, Ve] = p(!1), [Qe, le] = oo(), [ce, qe] = p(!1), [de, Xe] = p(""), [w, et] = p(() => n.isEditable()), W = P(() => {
    const m = S();
    if (v(m)) {
      const C = m.anchor.getNode();
      let y = C.getKey() === "root" ? C : Ne(C, (R) => {
        const x = R.getParent();
        return x !== null && ke(x);
      });
      y === null && (y = C.getTopLevelElementOrThrow());
      const G = y.getKey(), N = e.getElementByKey(G);
      _(m.hasFormat("bold")), M(m.hasFormat("italic")), T(m.hasFormat("underline")), Ue(m.hasFormat("strikethrough")), Ge(m.hasFormat("subscript")), We(m.hasFormat("superscript")), je(m.hasFormat("code")), qe(bn(m));
      const B = ro(m), it = B.getParent();
      he(it) || he(B) ? g(!0) : g(!1);
      const rt = Ne(B, ge);
      if (ge(rt) ? s("table") : s("root"), N !== null)
        if (u(G), It(y)) {
          const R = fn(
            C,
            Te
          ), x = R ? R.getListType() : y.getListType();
          r(x);
        } else {
          const R = pe(y) ? y.getTag() : y.getType();
          if (R in ne && r(R), me(y)) {
            const x = y.getLanguage();
            Xe(
              x ? Et[x] || x : ""
            );
            return;
          }
        }
    }
  }, [e]);
  E(() => n.registerCommand(
    nn,
    (m, C) => (W(), t(C), !1),
    ee
  ), [n, W]), E(() => Se(
    n.registerEditableListener((m) => {
      et(m);
    }),
    e.registerUpdateListener(({ editorState: m }) => {
      m.read(() => {
        W();
      });
    }),
    e.registerCommand(
      on,
      (m) => (ze(m), !1),
      ee
    ),
    e.registerCommand(
      rn,
      (m) => (Ve(m), !1),
      ee
    )
  ), [W, e, n]);
  const tt = P(() => {
    e.update(() => {
      const m = S();
      if (v(m)) {
        const C = m.anchor, y = m.focus, G = m.getNodes();
        if (C.key === y.key && C.offset === y.offset)
          return;
        G.forEach((N, B) => {
          an(N) ? (B === 0 && C.offset !== 0 && (N = N.splitText(C.offset)[1] || N), B === G.length - 1 && (N = N.splitText(y.offset)[0] || N), N.__style !== "" && N.setStyle(""), N.__format !== 0 && (N.setFormat(0), Nn(N).setFormat(""))) : pe(N) || Ft(N) ? N.replace(re(), !0) : hn(N) && N.setFormat("");
        });
      }
    });
  }, [e]), nt = P(() => {
    h ? n.dispatchCommand(_e, null) : n.dispatchCommand(_e, Vn("https://"));
  }, [n, h]), ot = P(
    (m) => {
      e.update(() => {
        if (c !== null) {
          const C = sn(c);
          me(C) && C.setLanguage(m);
        }
      });
    },
    [e, c]
  );
  return /* @__PURE__ */ l("div", { className: "toolbar", children: [
    /* @__PURE__ */ o(
      "button",
      {
        disabled: !Ye || !w,
        onClick: () => {
          e.dispatchCommand(ln, void 0);
        },
        title: D ? "Undo (⌘Z)" : "Undo (Ctrl+Z)",
        type: "button",
        className: "toolbar-item spaced",
        "aria-label": "Undo",
        children: /* @__PURE__ */ o("i", { className: "format undo" })
      }
    ),
    /* @__PURE__ */ o(
      "button",
      {
        disabled: !Ze || !w,
        onClick: () => {
          e.dispatchCommand(cn, void 0);
        },
        title: D ? "Redo (⌘Y)" : "Redo (Ctrl+Y)",
        type: "button",
        className: "toolbar-item",
        "aria-label": "Redo",
        children: /* @__PURE__ */ o("i", { className: "format redo" })
      }
    ),
    /* @__PURE__ */ o(F, {}),
    i in ne && e === n && /* @__PURE__ */ l($, { children: [
      /* @__PURE__ */ o(
        co,
        {
          disabled: !w,
          blockType: i,
          rootType: a,
          editor: n
        }
      ),
      /* @__PURE__ */ o(F, {}),
      /* @__PURE__ */ l(
        U,
        {
          disabled: !w,
          buttonLabel: "Align",
          buttonIconClassName: "icon left-align",
          buttonClassName: "toolbar-item spaced alignment",
          buttonAriaLabel: "Formatting options for text alignment",
          children: [
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(j, "left");
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon left-align" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Left Align" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(j, "center");
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon center-align" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Center Align" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(j, "right");
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon right-align" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Right Align" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(j, "justify");
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon justify-align" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Justify Align" })
                ]
              }
            ),
            /* @__PURE__ */ o(F, {}),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(dn, void 0);
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon " + (ce ? "indent" : "outdent") }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Outdent" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(mn, void 0);
                },
                className: "item",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon " + (ce ? "outdent" : "indent") }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Indent" })
                ]
              }
            )
          ]
        }
      ),
      /* @__PURE__ */ o(F, {})
    ] }),
    i === "code" ? /* @__PURE__ */ o(
      U,
      {
        disabled: !w,
        buttonClassName: "toolbar-item code-language",
        buttonLabel: yt(de),
        buttonAriaLabel: "Select language",
        children: lo.map(([m, C]) => /* @__PURE__ */ o(
          f,
          {
            className: `item ${A(
              m === de
            )}`,
            onClick: () => ot(m),
            children: /* @__PURE__ */ o("span", { className: "text", children: C })
          },
          m
        ))
      }
    ) : /* @__PURE__ */ l($, { children: [
      /* @__PURE__ */ o(
        "button",
        {
          disabled: !w,
          onClick: () => {
            e.dispatchCommand(L, "bold");
          },
          className: "toolbar-item spaced " + (d ? "active" : ""),
          title: D ? "Bold (⌘B)" : "Bold (Ctrl+B)",
          type: "button",
          "aria-label": `Format text as bold. Shortcut: ${D ? "⌘B" : "Ctrl+B"}`,
          children: /* @__PURE__ */ o("i", { className: "format bold" })
        }
      ),
      /* @__PURE__ */ o(
        "button",
        {
          disabled: !w,
          onClick: () => {
            e.dispatchCommand(L, "italic");
          },
          className: "toolbar-item spaced " + (b ? "active" : ""),
          title: D ? "Italic (⌘I)" : "Italic (Ctrl+I)",
          type: "button",
          "aria-label": `Format text as italics. Shortcut: ${D ? "⌘I" : "Ctrl+I"}`,
          children: /* @__PURE__ */ o("i", { className: "format italic" })
        }
      ),
      /* @__PURE__ */ o(
        "button",
        {
          disabled: !w,
          onClick: () => {
            e.dispatchCommand(L, "underline");
          },
          className: "toolbar-item spaced " + (k ? "active" : ""),
          title: D ? "Underline (⌘U)" : "Underline (Ctrl+U)",
          type: "button",
          "aria-label": `Format text to underlined. Shortcut: ${D ? "⌘U" : "Ctrl+U"}`,
          children: /* @__PURE__ */ o("i", { className: "format underline" })
        }
      ),
      /* @__PURE__ */ o(
        "button",
        {
          disabled: !w,
          onClick: () => {
            e.dispatchCommand(L, "code");
          },
          className: "toolbar-item spaced " + (Je ? "active" : ""),
          title: "Insert code block",
          type: "button",
          "aria-label": "Insert code block",
          children: /* @__PURE__ */ o("i", { className: "format code" })
        }
      ),
      /* @__PURE__ */ o(
        "button",
        {
          disabled: !w,
          onClick: nt,
          className: "toolbar-item spaced " + (h ? "active" : ""),
          "aria-label": "Insert link",
          title: "Insert link",
          type: "button",
          children: /* @__PURE__ */ o("i", { className: "format link" })
        }
      ),
      /* @__PURE__ */ l(
        U,
        {
          disabled: !w,
          buttonClassName: "toolbar-item spaced",
          buttonLabel: "",
          buttonAriaLabel: "Formatting options for additional text styles",
          buttonIconClassName: "icon dropdown-more",
          children: [
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(
                    L,
                    "strikethrough"
                  );
                },
                className: "item " + A(I),
                title: "Strikethrough",
                "aria-label": "Format text with a strikethrough",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon strikethrough" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Strikethrough" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(L, "subscript");
                },
                className: "item " + A(He),
                title: "Subscript",
                "aria-label": "Format text with a subscript",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon subscript" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Subscript" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: () => {
                  e.dispatchCommand(
                    L,
                    "superscript"
                  );
                },
                className: "item " + A(Ke),
                title: "Superscript",
                "aria-label": "Format text with a superscript",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon superscript" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Superscript" })
                ]
              }
            ),
            /* @__PURE__ */ l(
              f,
              {
                onClick: tt,
                className: "item",
                title: "Clear text formatting",
                "aria-label": "Clear all text formatting",
                children: [
                  /* @__PURE__ */ o("i", { className: "icon clear" }),
                  /* @__PURE__ */ o("span", { className: "text", children: "Clear Formatting" })
                ]
              }
            )
          ]
        }
      ),
      a === "table" && /* @__PURE__ */ l($, { children: [
        /* @__PURE__ */ o(F, {}),
        /* @__PURE__ */ o(
          U,
          {
            disabled: !w,
            buttonClassName: "toolbar-item spaced",
            buttonLabel: "Table",
            buttonAriaLabel: "Open table toolkit",
            buttonIconClassName: "icon table secondary",
            children: /* @__PURE__ */ o(
              f,
              {
                onClick: () => {
                },
                className: "item",
                children: /* @__PURE__ */ o("span", { className: "text", children: "Table" })
              }
            )
          }
        )
      ] }),
      e === n && /* @__PURE__ */ l($, { children: [
        /* @__PURE__ */ o(F, {}),
        /* @__PURE__ */ l(
          U,
          {
            disabled: !w,
            buttonClassName: "toolbar-item spaced",
            buttonLabel: "Insert",
            buttonAriaLabel: "Insert specialized editor node",
            buttonIconClassName: "icon plus",
            children: [
              /* @__PURE__ */ l(
                f,
                {
                  onClick: () => {
                    e.dispatchCommand(
                      Lt,
                      void 0
                    );
                  },
                  className: "item",
                  children: [
                    /* @__PURE__ */ o("i", { className: "icon horizontal-rule" }),
                    /* @__PURE__ */ o("span", { className: "text", children: "Horizontal Rule" })
                  ]
                }
              ),
              /* @__PURE__ */ l(
                f,
                {
                  onClick: () => {
                    le("Insert Inline Image", (m) => /* @__PURE__ */ o(
                      Hn,
                      {
                        activeEditor: e,
                        onClose: m
                      }
                    ));
                  },
                  className: "item",
                  children: [
                    /* @__PURE__ */ o("i", { className: "icon image" }),
                    /* @__PURE__ */ o("span", { className: "text", children: "Inline Image" })
                  ]
                }
              ),
              /* @__PURE__ */ l(
                f,
                {
                  onClick: () => {
                    le("Insert Table", (m) => /* @__PURE__ */ o(
                      ao,
                      {
                        activeEditor: e,
                        onClose: m
                      }
                    ));
                  },
                  className: "item",
                  children: [
                    /* @__PURE__ */ o("i", { className: "icon table" }),
                    /* @__PURE__ */ o("span", { className: "text", children: "Table" })
                  ]
                }
              )
            ]
          }
        )
      ] })
    ] }),
    Qe
  ] });
}
function uo({
  className: n
}) {
  return /* @__PURE__ */ o(En, { className: n || "ContentEditable__root" });
}
function ho({
  children: n,
  className: e
}) {
  return /* @__PURE__ */ o("div", { className: e || "Placeholder__root", children: n });
}
const _o = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/, po = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/, go = [
  be(_o, (n) => n.startsWith("http") ? n : `https://${n}`),
  be(po, (n) => `mailto:${n}`)
];
function fo() {
  return /* @__PURE__ */ o(yn, { matchers: go });
}
function No() {
  const [n] = K();
  return E(() => wt(n), [n]), null;
}
function Co({ value: n, onChange: e }) {
  const [t] = K(), i = O("");
  return E(() => {
    n !== i.current && (t.update(() => {
      const s = new DOMParser().parseFromString(n || "<p></p>", "text/html"), c = wn(t, s), u = un();
      u.clear(), u.selectStart(), Pe(c);
    }), i.current = n);
  }, [n, t]), /* @__PURE__ */ o(Tn, { onChange: (a, s) => {
    a.read(() => {
      const c = An(s);
      c !== i.current && (i.current = c, e(c));
    });
  } });
}
function Xo({ value: n, onChange: e, disabled: t = !1, placeholder: i = "Enter some rich text..." }) {
  const r = ie(
    () => ({
      theme: vn,
      onError(s) {
        throw s;
      },
      nodes: [...Ln],
      editable: !t
    }),
    [t]
  ), a = P(
    (s) => {
      !t && e && e(s);
    },
    [t, e]
  );
  return /* @__PURE__ */ o(at, { initialConfig: r, children: /* @__PURE__ */ l("div", { className: `editor-shell ${t ? "readonly" : ""}`, children: [
    !t && /* @__PURE__ */ o(mo, {}),
    /* @__PURE__ */ l("div", { className: "editor-container tree-view", children: [
      /* @__PURE__ */ o(ct, {}),
      !t && /* @__PURE__ */ o(fo, {}),
      !t && /* @__PURE__ */ o(Gn, {}),
      !t && /* @__PURE__ */ o(ht, {}),
      /* @__PURE__ */ o(
        dt,
        {
          contentEditable: /* @__PURE__ */ o("div", { className: "editor-scroller", children: /* @__PURE__ */ o("div", { className: "editor", children: /* @__PURE__ */ o(uo, {}) }) }),
          placeholder: t ? null : /* @__PURE__ */ o(ho, { children: i }),
          ErrorBoundary: Nt
        }
      ),
      /* @__PURE__ */ o(Co, { value: n, onChange: a }),
      !t && /* @__PURE__ */ o(mt, {}),
      !t && /* @__PURE__ */ o(Zn, {}),
      !t && /* @__PURE__ */ o(st, {}),
      !t && /* @__PURE__ */ o(No, {}),
      !t && /* @__PURE__ */ o(ut, { hasCellMerge: !0, hasCellBackgroundColor: !0 }),
      !t && /* @__PURE__ */ o(lt, {}),
      !t && /* @__PURE__ */ o(Xn, {}),
      !t && /* @__PURE__ */ o(_t, { transformers: pt })
    ] })
  ] }) }, i);
}
export {
  xn as $,
  Le as B,
  ve as D,
  Xo as E,
  Xn as L,
  ho as P,
  Fn as S,
  te as T,
  uo as a,
  ro as g,
  Vn as s,
  oo as u
};
