const {
  entries: Ht,
  setPrototypeOf: wt,
  isFrozen: gn,
  getPrototypeOf: hn,
  getOwnPropertyDescriptor: Tn
} = Object;
let {
  freeze: R,
  seal: O,
  create: De
} = Object, {
  apply: et,
  construct: tt
} = typeof Reflect < "u" && Reflect;
R || (R = function(t) {
  return t;
});
O || (O = function(t) {
  return t;
});
et || (et = function(t, o) {
  for (var l = arguments.length, c = new Array(l > 2 ? l - 2 : 0), f = 2; f < l; f++)
    c[f - 2] = arguments[f];
  return t.apply(o, c);
});
tt || (tt = function(t) {
  for (var o = arguments.length, l = new Array(o > 1 ? o - 1 : 0), c = 1; c < o; c++)
    l[c - 1] = arguments[c];
  return new t(...l);
});
const Re = L(Array.prototype.forEach), bn = L(Array.prototype.lastIndexOf), Ct = L(Array.prototype.pop), se = L(Array.prototype.push), En = L(Array.prototype.splice), we = L(String.prototype.toLowerCase), $e = L(String.prototype.toString), qe = L(String.prototype.match), ce = L(String.prototype.replace), An = L(String.prototype.indexOf), _n = L(String.prototype.trim), C = L(Object.prototype.hasOwnProperty), x = L(RegExp.prototype.test), ue = yn(TypeError);
function L(n) {
  return function(t) {
    t instanceof RegExp && (t.lastIndex = 0);
    for (var o = arguments.length, l = new Array(o > 1 ? o - 1 : 0), c = 1; c < o; c++)
      l[c - 1] = arguments[c];
    return et(n, t, l);
  };
}
function yn(n) {
  return function() {
    for (var t = arguments.length, o = new Array(t), l = 0; l < t; l++)
      o[l] = arguments[l];
    return tt(n, o);
  };
}
function s(n, t) {
  let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : we;
  wt && wt(n, null);
  let l = t.length;
  for (; l--; ) {
    let c = t[l];
    if (typeof c == "string") {
      const f = o(c);
      f !== c && (gn(t) || (t[l] = f), c = f);
    }
    n[c] = !0;
  }
  return n;
}
function vn(n) {
  for (let t = 0; t < n.length; t++)
    C(n, t) || (n[t] = null);
  return n;
}
function I(n) {
  const t = De(null);
  for (const [o, l] of Ht(n))
    C(n, o) && (Array.isArray(l) ? t[o] = vn(l) : l && typeof l == "object" && l.constructor === Object ? t[o] = I(l) : t[o] = l);
  return t;
}
function pe(n, t) {
  for (; n !== null; ) {
    const l = Tn(n, t);
    if (l) {
      if (l.get)
        return L(l.get);
      if (typeof l.value == "function")
        return L(l.value);
    }
    n = hn(n);
  }
  function o() {
    return null;
  }
  return o;
}
const Ot = R(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Xe = R(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ze = R(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Sn = R(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Ke = R(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), xn = R(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Mt = R(["#text"]), Nt = R(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Qe = R(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), It = R(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Le = R(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Rn = O(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Ln = O(/<%[\w\W]*|[\w\W]*%>/gm), Dn = O(/\$\{[\w\W]*/gm), wn = O(/^data-[\-\w.\u00B7-\uFFFF]+$/), Cn = O(/^aria-[\-\w]+$/), Ut = O(
  /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
  // eslint-disable-line no-useless-escape
), On = O(/^(?:\w+script|data):/i), Mn = O(
  /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
  // eslint-disable-line no-control-regex
), zt = O(/^html$/i), Nn = O(/^[a-z][.\w]*(-[.\w]+)+$/i);
var kt = /* @__PURE__ */ Object.freeze({
  __proto__: null,
  ARIA_ATTR: Cn,
  ATTR_WHITESPACE: Mn,
  CUSTOM_ELEMENT: Nn,
  DATA_ATTR: wn,
  DOCTYPE_NAME: zt,
  ERB_EXPR: Ln,
  IS_ALLOWED_URI: Ut,
  IS_SCRIPT_OR_DATA: On,
  MUSTACHE_EXPR: Rn,
  TMPLIT_EXPR: Dn
});
const de = {
  element: 1,
  text: 3,
  // Deprecated
  progressingInstruction: 7,
  comment: 8,
  document: 9
}, In = function() {
  return typeof window > "u" ? null : window;
}, kn = function(t, o) {
  if (typeof t != "object" || typeof t.createPolicy != "function")
    return null;
  let l = null;
  const c = "data-tt-policy-suffix";
  o && o.hasAttribute(c) && (l = o.getAttribute(c));
  const f = "dompurify" + (l ? "#" + l : "");
  try {
    return t.createPolicy(f, {
      createHTML(w) {
        return w;
      },
      createScriptURL(w) {
        return w;
      }
    });
  } catch {
    return console.warn("TrustedTypes policy " + f + " could not be created."), null;
  }
}, Pt = function() {
  return {
    afterSanitizeAttributes: [],
    afterSanitizeElements: [],
    afterSanitizeShadowDOM: [],
    beforeSanitizeAttributes: [],
    beforeSanitizeElements: [],
    beforeSanitizeShadowDOM: [],
    uponSanitizeAttribute: [],
    uponSanitizeElement: [],
    uponSanitizeShadowNode: []
  };
};
function Bt() {
  let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : In();
  const t = (i) => Bt(i);
  if (t.version = "3.3.2", t.removed = [], !n || !n.document || n.document.nodeType !== de.document || !n.Element)
    return t.isSupported = !1, t;
  let {
    document: o
  } = n;
  const l = o, c = l.currentScript, {
    DocumentFragment: f,
    HTMLTemplateElement: w,
    Node: z,
    Element: b,
    NodeFilter: E,
    NamedNodeMap: W = n.NamedNodeMap || n.MozNamedAttrMap,
    HTMLFormElement: j,
    DOMParser: Oe,
    trustedTypes: he
  } = n, re = b.prototype, qt = pe(re, "cloneNode"), Xt = pe(re, "remove"), Zt = pe(re, "nextSibling"), Kt = pe(re, "childNodes"), Te = pe(re, "parentNode");
  if (typeof w == "function") {
    const i = o.createElement("template");
    i.content && i.content.ownerDocument && (o = i.content.ownerDocument);
  }
  let v, oe = "";
  const {
    implementation: Me,
    createNodeIterator: Qt,
    createDocumentFragment: Jt,
    getElementsByTagName: en
  } = o, {
    importNode: tn
  } = l;
  let S = Pt();
  t.isSupported = typeof Ht == "function" && typeof Te == "function" && Me && Me.createHTMLDocument !== void 0;
  const {
    MUSTACHE_EXPR: Ne,
    ERB_EXPR: Ie,
    TMPLIT_EXPR: ke,
    DATA_ATTR: nn,
    ARIA_ATTR: rn,
    IS_SCRIPT_OR_DATA: on,
    ATTR_WHITESPACE: at,
    CUSTOM_ELEMENT: an
  } = kt;
  let {
    IS_ALLOWED_URI: it
  } = kt, h = null;
  const lt = s({}, [...Ot, ...Xe, ...Ze, ...Ke, ...Mt]);
  let A = null;
  const st = s({}, [...Nt, ...Qe, ...It, ...Le]);
  let p = Object.seal(De(null, {
    tagNameCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    },
    attributeNameCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    },
    allowCustomizedBuiltInElements: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: !1
    }
  })), ae = null, be = null;
  const B = Object.seal(De(null, {
    tagCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    },
    attributeCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    }
  }));
  let ct = !0, Pe = !0, ut = !1, pt = !0, $ = !1, Ee = !0, V = !1, Fe = !1, He = !1, q = !1, Ae = !1, _e = !1, dt = !0, mt = !1;
  const ln = "user-content-";
  let Ue = !0, ie = !1, X = {}, M = null;
  const ze = s({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
  let ft = null;
  const gt = s({}, ["audio", "video", "img", "source", "image", "track"]);
  let Be = null;
  const ht = s({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ye = "http://www.w3.org/1998/Math/MathML", ve = "http://www.w3.org/2000/svg", F = "http://www.w3.org/1999/xhtml";
  let Z = F, Ge = !1, We = null;
  const sn = s({}, [ye, ve, F], $e);
  let Se = s({}, ["mi", "mo", "mn", "ms", "mtext"]), xe = s({}, ["annotation-xml"]);
  const cn = s({}, ["title", "style", "font", "a", "script"]);
  let le = null;
  const un = ["application/xhtml+xml", "text/html"], pn = "text/html";
  let g = null, K = null;
  const dn = o.createElement("form"), Tt = function(e) {
    return e instanceof RegExp || e instanceof Function;
  }, je = function() {
    let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    if (!(K && K === e)) {
      if ((!e || typeof e != "object") && (e = {}), e = I(e), le = // eslint-disable-next-line unicorn/prefer-includes
      un.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? pn : e.PARSER_MEDIA_TYPE, g = le === "application/xhtml+xml" ? $e : we, h = C(e, "ALLOWED_TAGS") ? s({}, e.ALLOWED_TAGS, g) : lt, A = C(e, "ALLOWED_ATTR") ? s({}, e.ALLOWED_ATTR, g) : st, We = C(e, "ALLOWED_NAMESPACES") ? s({}, e.ALLOWED_NAMESPACES, $e) : sn, Be = C(e, "ADD_URI_SAFE_ATTR") ? s(I(ht), e.ADD_URI_SAFE_ATTR, g) : ht, ft = C(e, "ADD_DATA_URI_TAGS") ? s(I(gt), e.ADD_DATA_URI_TAGS, g) : gt, M = C(e, "FORBID_CONTENTS") ? s({}, e.FORBID_CONTENTS, g) : ze, ae = C(e, "FORBID_TAGS") ? s({}, e.FORBID_TAGS, g) : I({}), be = C(e, "FORBID_ATTR") ? s({}, e.FORBID_ATTR, g) : I({}), X = C(e, "USE_PROFILES") ? e.USE_PROFILES : !1, ct = e.ALLOW_ARIA_ATTR !== !1, Pe = e.ALLOW_DATA_ATTR !== !1, ut = e.ALLOW_UNKNOWN_PROTOCOLS || !1, pt = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, $ = e.SAFE_FOR_TEMPLATES || !1, Ee = e.SAFE_FOR_XML !== !1, V = e.WHOLE_DOCUMENT || !1, q = e.RETURN_DOM || !1, Ae = e.RETURN_DOM_FRAGMENT || !1, _e = e.RETURN_TRUSTED_TYPE || !1, He = e.FORCE_BODY || !1, dt = e.SANITIZE_DOM !== !1, mt = e.SANITIZE_NAMED_PROPS || !1, Ue = e.KEEP_CONTENT !== !1, ie = e.IN_PLACE || !1, it = e.ALLOWED_URI_REGEXP || Ut, Z = e.NAMESPACE || F, Se = e.MATHML_TEXT_INTEGRATION_POINTS || Se, xe = e.HTML_INTEGRATION_POINTS || xe, p = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Tt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (p.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Tt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (p.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (p.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), $ && (Pe = !1), Ae && (q = !0), X && (h = s({}, Mt), A = De(null), X.html === !0 && (s(h, Ot), s(A, Nt)), X.svg === !0 && (s(h, Xe), s(A, Qe), s(A, Le)), X.svgFilters === !0 && (s(h, Ze), s(A, Qe), s(A, Le)), X.mathMl === !0 && (s(h, Ke), s(A, It), s(A, Le))), C(e, "ADD_TAGS") || (B.tagCheck = null), C(e, "ADD_ATTR") || (B.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? B.tagCheck = e.ADD_TAGS : (h === lt && (h = I(h)), s(h, e.ADD_TAGS, g))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? B.attributeCheck = e.ADD_ATTR : (A === st && (A = I(A)), s(A, e.ADD_ATTR, g))), e.ADD_URI_SAFE_ATTR && s(Be, e.ADD_URI_SAFE_ATTR, g), e.FORBID_CONTENTS && (M === ze && (M = I(M)), s(M, e.FORBID_CONTENTS, g)), e.ADD_FORBID_CONTENTS && (M === ze && (M = I(M)), s(M, e.ADD_FORBID_CONTENTS, g)), Ue && (h["#text"] = !0), V && s(h, ["html", "head", "body"]), h.table && (s(h, ["tbody"]), delete ae.tbody), e.TRUSTED_TYPES_POLICY) {
        if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
          throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
        if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
          throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
        v = e.TRUSTED_TYPES_POLICY, oe = v.createHTML("");
      } else
        v === void 0 && (v = kn(he, c)), v !== null && typeof oe == "string" && (oe = v.createHTML(""));
      R && R(e), K = e;
    }
  }, bt = s({}, [...Xe, ...Ze, ...Sn]), Et = s({}, [...Ke, ...xn]), mn = function(e) {
    let r = Te(e);
    (!r || !r.tagName) && (r = {
      namespaceURI: Z,
      tagName: "template"
    });
    const a = we(e.tagName), u = we(r.tagName);
    return We[e.namespaceURI] ? e.namespaceURI === ve ? r.namespaceURI === F ? a === "svg" : r.namespaceURI === ye ? a === "svg" && (u === "annotation-xml" || Se[u]) : !!bt[a] : e.namespaceURI === ye ? r.namespaceURI === F ? a === "math" : r.namespaceURI === ve ? a === "math" && xe[u] : !!Et[a] : e.namespaceURI === F ? r.namespaceURI === ve && !xe[u] || r.namespaceURI === ye && !Se[u] ? !1 : !Et[a] && (cn[a] || !bt[a]) : !!(le === "application/xhtml+xml" && We[e.namespaceURI]) : !1;
  }, N = function(e) {
    se(t.removed, {
      element: e
    });
    try {
      Te(e).removeChild(e);
    } catch {
      Xt(e);
    }
  }, Y = function(e, r) {
    try {
      se(t.removed, {
        attribute: r.getAttributeNode(e),
        from: r
      });
    } catch {
      se(t.removed, {
        attribute: null,
        from: r
      });
    }
    if (r.removeAttribute(e), e === "is")
      if (q || Ae)
        try {
          N(r);
        } catch {
        }
      else
        try {
          r.setAttribute(e, "");
        } catch {
        }
  }, At = function(e) {
    let r = null, a = null;
    if (He)
      e = "<remove></remove>" + e;
    else {
      const d = qe(e, /^[\r\n\t ]+/);
      a = d && d[0];
    }
    le === "application/xhtml+xml" && Z === F && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
    const u = v ? v.createHTML(e) : e;
    if (Z === F)
      try {
        r = new Oe().parseFromString(u, le);
      } catch {
      }
    if (!r || !r.documentElement) {
      r = Me.createDocument(Z, "template", null);
      try {
        r.documentElement.innerHTML = Ge ? oe : u;
      } catch {
      }
    }
    const y = r.body || r.documentElement;
    return e && a && y.insertBefore(o.createTextNode(a), y.childNodes[0] || null), Z === F ? en.call(r, V ? "html" : "body")[0] : V ? r.documentElement : y;
  }, _t = function(e) {
    return Qt.call(
      e.ownerDocument || e,
      e,
      // eslint-disable-next-line no-bitwise
      E.SHOW_ELEMENT | E.SHOW_COMMENT | E.SHOW_TEXT | E.SHOW_PROCESSING_INSTRUCTION | E.SHOW_CDATA_SECTION,
      null
    );
  }, Ve = function(e) {
    return e instanceof j && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof W) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
  }, yt = function(e) {
    return typeof z == "function" && e instanceof z;
  };
  function H(i, e, r) {
    Re(i, (a) => {
      a.call(t, e, r, K);
    });
  }
  const vt = function(e) {
    let r = null;
    if (H(S.beforeSanitizeElements, e, null), Ve(e))
      return N(e), !0;
    const a = g(e.nodeName);
    if (H(S.uponSanitizeElement, e, {
      tagName: a,
      allowedTags: h
    }), Ee && e.hasChildNodes() && !yt(e.firstElementChild) && x(/<[/\w!]/g, e.innerHTML) && x(/<[/\w!]/g, e.textContent) || e.nodeType === de.progressingInstruction || Ee && e.nodeType === de.comment && x(/<[/\w]/g, e.data))
      return N(e), !0;
    if (!(B.tagCheck instanceof Function && B.tagCheck(a)) && (!h[a] || ae[a])) {
      if (!ae[a] && xt(a) && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, a) || p.tagNameCheck instanceof Function && p.tagNameCheck(a)))
        return !1;
      if (Ue && !M[a]) {
        const u = Te(e) || e.parentNode, y = Kt(e) || e.childNodes;
        if (y && u) {
          const d = y.length;
          for (let D = d - 1; D >= 0; --D) {
            const U = qt(y[D], !0);
            U.__removalCount = (e.__removalCount || 0) + 1, u.insertBefore(U, Zt(e));
          }
        }
      }
      return N(e), !0;
    }
    return e instanceof b && !mn(e) || (a === "noscript" || a === "noembed" || a === "noframes") && x(/<\/no(script|embed|frames)/i, e.innerHTML) ? (N(e), !0) : ($ && e.nodeType === de.text && (r = e.textContent, Re([Ne, Ie, ke], (u) => {
      r = ce(r, u, " ");
    }), e.textContent !== r && (se(t.removed, {
      element: e.cloneNode()
    }), e.textContent = r)), H(S.afterSanitizeElements, e, null), !1);
  }, St = function(e, r, a) {
    if (be[r] || dt && (r === "id" || r === "name") && (a in o || a in dn))
      return !1;
    if (!(Pe && !be[r] && x(nn, r))) {
      if (!(ct && x(rn, r))) {
        if (!(B.attributeCheck instanceof Function && B.attributeCheck(r, e))) {
          if (!A[r] || be[r]) {
            if (
              // First condition does a very basic check if a) it's basically a valid custom element tagname AND
              // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
              // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
              !(xt(e) && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, e) || p.tagNameCheck instanceof Function && p.tagNameCheck(e)) && (p.attributeNameCheck instanceof RegExp && x(p.attributeNameCheck, r) || p.attributeNameCheck instanceof Function && p.attributeNameCheck(r, e)) || // Alternative, second condition checks if it's an `is`-attribute, AND
              // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
              r === "is" && p.allowCustomizedBuiltInElements && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, a) || p.tagNameCheck instanceof Function && p.tagNameCheck(a)))
            ) return !1;
          } else if (!Be[r]) {
            if (!x(it, ce(a, at, ""))) {
              if (!((r === "src" || r === "xlink:href" || r === "href") && e !== "script" && An(a, "data:") === 0 && ft[e])) {
                if (!(ut && !x(on, ce(a, at, "")))) {
                  if (a)
                    return !1;
                }
              }
            }
          }
        }
      }
    }
    return !0;
  }, xt = function(e) {
    return e !== "annotation-xml" && qe(e, an);
  }, Rt = function(e) {
    H(S.beforeSanitizeAttributes, e, null);
    const {
      attributes: r
    } = e;
    if (!r || Ve(e))
      return;
    const a = {
      attrName: "",
      attrValue: "",
      keepAttr: !0,
      allowedAttributes: A,
      forceKeepAttr: void 0
    };
    let u = r.length;
    for (; u--; ) {
      const y = r[u], {
        name: d,
        namespaceURI: D,
        value: U
      } = y, Q = g(d), Ye = U;
      let _ = d === "value" ? Ye : _n(Ye);
      if (a.attrName = Q, a.attrValue = _, a.keepAttr = !0, a.forceKeepAttr = void 0, H(S.uponSanitizeAttribute, e, a), _ = a.attrValue, mt && (Q === "id" || Q === "name") && (Y(d, e), _ = ln + _), Ee && x(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, _)) {
        Y(d, e);
        continue;
      }
      if (Q === "attributename" && qe(_, "href")) {
        Y(d, e);
        continue;
      }
      if (a.forceKeepAttr)
        continue;
      if (!a.keepAttr) {
        Y(d, e);
        continue;
      }
      if (!pt && x(/\/>/i, _)) {
        Y(d, e);
        continue;
      }
      $ && Re([Ne, Ie, ke], (Dt) => {
        _ = ce(_, Dt, " ");
      });
      const Lt = g(e.nodeName);
      if (!St(Lt, Q, _)) {
        Y(d, e);
        continue;
      }
      if (v && typeof he == "object" && typeof he.getAttributeType == "function" && !D)
        switch (he.getAttributeType(Lt, Q)) {
          case "TrustedHTML": {
            _ = v.createHTML(_);
            break;
          }
          case "TrustedScriptURL": {
            _ = v.createScriptURL(_);
            break;
          }
        }
      if (_ !== Ye)
        try {
          D ? e.setAttributeNS(D, d, _) : e.setAttribute(d, _), Ve(e) ? N(e) : Ct(t.removed);
        } catch {
          Y(d, e);
        }
    }
    H(S.afterSanitizeAttributes, e, null);
  }, fn = function i(e) {
    let r = null;
    const a = _t(e);
    for (H(S.beforeSanitizeShadowDOM, e, null); r = a.nextNode(); )
      H(S.uponSanitizeShadowNode, r, null), vt(r), Rt(r), r.content instanceof f && i(r.content);
    H(S.afterSanitizeShadowDOM, e, null);
  };
  return t.sanitize = function(i) {
    let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = null, a = null, u = null, y = null;
    if (Ge = !i, Ge && (i = "<!-->"), typeof i != "string" && !yt(i))
      if (typeof i.toString == "function") {
        if (i = i.toString(), typeof i != "string")
          throw ue("dirty is not a string, aborting");
      } else
        throw ue("toString is not a function");
    if (!t.isSupported)
      return i;
    if (Fe || je(e), t.removed = [], typeof i == "string" && (ie = !1), ie) {
      if (i.nodeName) {
        const U = g(i.nodeName);
        if (!h[U] || ae[U])
          throw ue("root node is forbidden and cannot be sanitized in-place");
      }
    } else if (i instanceof z)
      r = At("<!---->"), a = r.ownerDocument.importNode(i, !0), a.nodeType === de.element && a.nodeName === "BODY" || a.nodeName === "HTML" ? r = a : r.appendChild(a);
    else {
      if (!q && !$ && !V && // eslint-disable-next-line unicorn/prefer-includes
      i.indexOf("<") === -1)
        return v && _e ? v.createHTML(i) : i;
      if (r = At(i), !r)
        return q ? null : _e ? oe : "";
    }
    r && He && N(r.firstChild);
    const d = _t(ie ? i : r);
    for (; u = d.nextNode(); )
      vt(u), Rt(u), u.content instanceof f && fn(u.content);
    if (ie)
      return i;
    if (q) {
      if (Ae)
        for (y = Jt.call(r.ownerDocument); r.firstChild; )
          y.appendChild(r.firstChild);
      else
        y = r;
      return (A.shadowroot || A.shadowrootmode) && (y = tn.call(l, y, !0)), y;
    }
    let D = V ? r.outerHTML : r.innerHTML;
    return V && h["!doctype"] && r.ownerDocument && r.ownerDocument.doctype && r.ownerDocument.doctype.name && x(zt, r.ownerDocument.doctype.name) && (D = "<!DOCTYPE " + r.ownerDocument.doctype.name + `>
` + D), $ && Re([Ne, Ie, ke], (U) => {
      D = ce(D, U, " ");
    }), v && _e ? v.createHTML(D) : D;
  }, t.setConfig = function() {
    let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    je(i), Fe = !0;
  }, t.clearConfig = function() {
    K = null, Fe = !1;
  }, t.isValidAttribute = function(i, e, r) {
    K || je({});
    const a = g(i), u = g(e);
    return St(a, u, r);
  }, t.addHook = function(i, e) {
    typeof e == "function" && se(S[i], e);
  }, t.removeHook = function(i, e) {
    if (e !== void 0) {
      const r = bn(S[i], e);
      return r === -1 ? void 0 : En(S[i], r, 1)[0];
    }
    return Ct(S[i]);
  }, t.removeHooks = function(i) {
    S[i] = [];
  }, t.removeAllHooks = function() {
    S = Pt();
  }, t;
}
var Pn = Bt();
let m = null, P = null, J = null, T = null, ee = "", te = "", me = "insert", fe = null, k = null, Ce = null;
function Gt(n, t) {
  if (t === n.innerHTML) return;
  const o = window.execEditorCommand || window.executeEditorCommand;
  if (typeof o == "function")
    try {
      o("recordDomTransaction", n, t, n.innerHTML);
    } catch {
    }
}
function Fn(n) {
  if (!n) return null;
  let t = n.startContainer;
  for (; t && t !== document.body; ) {
    if (t.nodeType === Node.ELEMENT_NODE) {
      const o = t;
      if (o.getAttribute("contenteditable") === "true")
        return o;
    }
    t = t.parentNode;
  }
  return null;
}
const Hn = [
  {
    id: "formal-letter",
    name: "Formal Letter",
    category: "Letters",
    description: "Professional business letter template",
    html: `<p><strong>{{ Company Name }}</strong></p>
<p>{{ Today }}</p>
<p>Dear {{ first_name }} {{ last_name }},</p>
<p>I hope this letter finds you well. [Your letter content here]</p>
<p>Thank you for your time and consideration.</p>
<p>Sincerely,<br>Your Name</p>`
  },
  {
    id: "meeting-notes",
    name: "Meeting Notes",
    category: "Notes",
    description: "Template for meeting notes with attendees and action items",
    html: `<h2>Meeting Notes - {{ today }}</h2>
<p><strong>Attendees:</strong> [List attendees]</p>
<p><strong>Agenda:</strong></p>
<ul>
  <li>[Item 1]</li>
  <li>[Item 2]</li>
  <li>[Item 3]</li>
</ul>
<p><strong>Action Items:</strong></p>
<ul>
  <li>[Owner]: [Task] - [Due Date]</li>
</ul>
<p><strong>Next Meeting:</strong> [Date]</p>`
  },
  {
    id: "proposal",
    name: "Project Proposal",
    category: "Business",
    description: "Structured project proposal template",
    html: `<h1>Project Proposal</h1>
<h2>Executive Summary</h2>
<p>[Summary of the proposal]</p>
<h2>Objectives</h2>
<ul>
  <li>[Objective 1]</li>
  <li>[Objective 2]</li>
</ul>
<h2>Scope</h2>
<p>[Project scope details]</p>
<h2>Timeline</h2>
<p>[Project timeline]</p>
<h2>Budget</h2>
<p>[Budget details]</p>
<h2>Contact</h2>
<p>{{ first_name }} {{ last_name }}<br>{{ email }}<br>{{ phone }}</p>`
  },
  {
    id: "faq",
    name: "FAQ Template",
    category: "Documentation",
    description: "FAQ document structure",
    html: `<h1>Frequently Asked Questions</h1>
<h2>General Questions</h2>
<h3>Q: What is this about?</h3>
<p>A: [Answer here]</p>
<h3>Q: Who should use this?</h3>
<p>A: [Answer here]</p>
<h2>Technical Questions</h2>
<h3>Q: How do I get started?</h3>
<p>A: [Answer here]</p>
<h3>Q: What are the requirements?</h3>
<p>A: [Answer here]</p>`
  }
];
let ne = [...Hn];
const Wt = () => ne, Zn = (n) => ne.filter((t) => t.category === n), jt = () => {
  const n = new Set(ne.map((t) => t.category));
  return Array.from(n);
}, Un = (n) => {
  const t = n.toLowerCase();
  return ne.filter(
    (o) => o.name.toLowerCase().includes(t) || o.description?.toLowerCase().includes(t) || o.tags?.some((l) => l.toLowerCase().includes(t))
  );
}, Vt = (n) => Pn.sanitize(n, {
  ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
  ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
}), Kn = (n) => ne.some((t) => t.id === n.id) ? (console.warn(`Template with ID ${n.id} already exists`), !1) : (ne.push(n), !0), Qn = (n) => !!(n.id && n.name && n.category && n.html && n.html.trim().length > 0);
function zn(n) {
  P = document.createElement("div"), P.className = "rte-dialog-overlay", Wn(n) && P.classList.add("rte-ui-theme-dark"), P.addEventListener("click", () => G()), m = document.createElement("div"), m.className = "rte-dialog rte-template-dialog", m.addEventListener("click", (o) => o.stopPropagation());
  const t = jt();
  t.length > 0 && !ee && (ee = t[0]), ge(), P.appendChild(m), document.body.appendChild(P), Bn(), Xn();
}
function Bn() {
  Yt(), fe = (n) => {
    n.key === "Escape" && (!P || !m || (n.preventDefault(), n.stopPropagation(), G()));
  }, document.addEventListener("keydown", fe, !0);
}
function Yt() {
  fe && (document.removeEventListener("keydown", fe, !0), fe = null);
}
const Gn = '[data-theme="dark"], .dark, .editora-theme-dark', nt = () => {
  const n = window.getSelection();
  if (!n || n.rangeCount === 0) return null;
  const t = n.anchorNode;
  return (t instanceof HTMLElement ? t : t?.parentElement)?.closest(
    ".rte-content, .editora-content"
  ) || null;
}, Wn = (n) => {
  const t = n || nt();
  return t ? !!t.closest(Gn) : !1;
};
function rt() {
  const n = Fn(J);
  if (n) return n;
  if (Ce?.isConnected) return Ce;
  const t = nt();
  return t || document.querySelector(".rte-content, .editora-content");
}
function ge() {
  if (!m) return;
  const n = jt(), t = ot();
  m.innerHTML = `
    <div class="rte-dialog-header">
      <h2>Insert Template</h2>
      <button class="rte-dialog-close" aria-label="Close">✕</button>
    </div>

    <div class="rte-dialog-body">
      <!-- Search -->
      <input
        type="text"
        placeholder="Search templates..."
        value="${te}"
        class="rte-input rte-template-search"
        aria-label="Search templates"
      />

      <!-- Category Tabs -->
      <div class="rte-tabs">
        ${n.map((o) => `
          <button class="rte-tab ${ee === o ? "active" : ""}" data-category="${o}">
            ${o}
          </button>
        `).join("")}
      </div>

      <!-- Template List -->
      <div class="rte-template-list">
        ${t.length > 0 ? t.map((o) => `
          <div
            class="rte-template-item ${T?.id === o.id ? "selected" : ""}"
            data-template-id="${o.id}"
          >
            <div class="template-name">${o.name}</div>
            ${o.description ? `<div class="template-description">${o.description}</div>` : ""}
          </div>
        `).join("") : '<div class="rte-empty-state">No templates found</div>'}
      </div>

      <!-- Preview -->
      ${T ? `
        <div class="rte-template-preview">
          <strong>Preview:</strong>
          <div class="template-preview-content">${T.html}</div>
        </div>
      ` : ""}

      <!-- Insert Mode Toggle -->
      <div class="rte-insert-mode">
        <label>
          <input type="radio" name="insertMode" value="insert" ${me === "insert" ? "checked" : ""} />
          Insert at cursor
        </label>
        <label>
          <input type="radio" name="insertMode" value="replace" ${me === "replace" ? "checked" : ""} />
          Replace document
        </label>
      </div>
    </div>

    <div class="rte-dialog-footer">
      <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
      <button class="rte-button-primary rte-insert-btn" ${T ? "" : "disabled"}>
        ${me === "insert" ? "Insert" : "Replace"}
      </button>
    </div>
  `, Vn();
}
function jn() {
  if (!m) return;
  m.innerHTML = `
    <div class="rte-dialog-header">
      <h2>Replace Document?</h2>
    </div>
    <div class="rte-dialog-body">
      <p>This will replace your current document content. Continue?</p>
    </div>
    <div class="rte-dialog-footer">
      <button class="rte-button-secondary rte-cancel-warning-btn">Cancel</button>
      <button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
    </div>
  `;
  const n = m.querySelector(".rte-cancel-warning-btn"), t = m.querySelector(".rte-confirm-replace-btn");
  n?.addEventListener("click", () => ge()), t?.addEventListener("click", () => Yn());
}
function ot() {
  const n = Wt();
  return te.trim() ? Un(te) : ee ? n.filter((t) => t.category === ee) : n;
}
function Vn() {
  if (!m) return;
  m.querySelector(".rte-dialog-close")?.addEventListener("click", () => G()), m.querySelector(".rte-cancel-btn")?.addEventListener("click", () => G()), m.querySelector(".rte-insert-btn")?.addEventListener("click", () => Je());
  const l = m.querySelector(".rte-template-search");
  l?.addEventListener("input", (b) => {
    k !== null && cancelAnimationFrame(k), te = b.target.value, k = requestAnimationFrame(() => {
      k = null, Ft();
    });
  }), l?.addEventListener("keydown", (b) => {
    b.key === "Enter" && T ? Je() : b.key === "Escape" && G();
  }), m.querySelector(".rte-tabs")?.addEventListener("click", (b) => {
    const W = b.target.closest(".rte-tab");
    if (!W) return;
    const j = W.getAttribute("data-category");
    j && (ee = j, te = "", k !== null && (cancelAnimationFrame(k), k = null), Ft());
  });
  const f = m.querySelector(".rte-template-list"), w = (b) => {
    const W = b.target.closest(".rte-template-item");
    if (!W) return null;
    const j = W.getAttribute("data-template-id");
    return j && Wt().find((Oe) => Oe.id === j) || null;
  };
  f?.addEventListener("click", (b) => {
    const E = w(b);
    E && (T = E, ge());
  }), f?.addEventListener("dblclick", (b) => {
    const E = w(b);
    E && (T = E, Je());
  }), m.querySelector(".rte-insert-mode")?.addEventListener("change", (b) => {
    const E = b.target;
    !E || E.name !== "insertMode" || (me = E.value, ge());
  });
}
function Ft() {
  const n = ot();
  n.length > 0 ? (!T || !n.find((t) => t.id === T.id)) && (T = n[0]) : T = null, ge();
}
function Je() {
  if (T)
    if (me === "replace") {
      if (rt()?.innerHTML?.trim()) {
        jn();
        return;
      }
      $t(T), G();
    } else
      $n(T), G();
}
function Yn() {
  T && ($t(T), G());
}
function $n(n) {
  const t = window.getSelection();
  if (!t) return;
  const o = rt();
  if (!o) return;
  if (J)
    t.removeAllRanges(), t.addRange(J);
  else {
    const z = document.createRange();
    z.selectNodeContents(o), z.collapse(!1), t.removeAllRanges(), t.addRange(z);
  }
  if (t.rangeCount === 0) return;
  const l = t.getRangeAt(0), c = o?.innerHTML ?? "", f = document.createRange().createContextualFragment(Vt(n.html));
  l.deleteContents(), l.insertNode(f);
  const w = document.createRange();
  w.setStartAfter(l.endContainer), w.collapse(!0), t.removeAllRanges(), t.addRange(w), o && (Gt(o, c), o.dispatchEvent(new Event("input", { bubbles: !0 })));
}
function $t(n) {
  const t = rt();
  if (t) {
    const o = t.innerHTML;
    t.innerHTML = Vt(n.html), Gt(t, o), t.dispatchEvent(new Event("input", { bubbles: !0 }));
  }
}
function G() {
  Yt(), k !== null && (cancelAnimationFrame(k), k = null), P && (P.remove(), P = null), m = null, J = null, te = "", Ce = null;
}
function qn(n) {
  const t = window.getSelection();
  t && t.rangeCount > 0 ? J = t.getRangeAt(0).cloneRange() : J = null;
  const o = ot();
  o.length > 0 && !T && (T = o[0]);
  const l = n?.contentElement instanceof HTMLElement ? n.contentElement : nt();
  Ce = l || null, zn(l);
}
function Xn() {
  if (typeof document > "u") return;
  const n = "template-plugin-dialog-styles";
  if (document.getElementById(n)) return;
  const t = document.createElement("style");
  t.id = n, t.textContent = `
    .rte-dialog-overlay {
      --rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);
      --rte-tmpl-dialog-bg: #fff;
      --rte-tmpl-dialog-text: #101828;
      --rte-tmpl-border: #d6dbe4;
      --rte-tmpl-subtle-bg: #f7f9fc;
      --rte-tmpl-subtle-hover: #eef2f7;
      --rte-tmpl-muted-text: #5f6b7d;
      --rte-tmpl-accent: #1976d2;
      --rte-tmpl-accent-strong: #1565c0;
      --rte-tmpl-ring: rgba(31, 117, 254, 0.18);
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: var(--rte-tmpl-overlay-bg);
      backdrop-filter: blur(2px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10000;
      padding: 16px;
      box-sizing: border-box;
    }
    .rte-dialog-overlay.rte-ui-theme-dark {
      --rte-tmpl-overlay-bg: rgba(2, 8, 20, 0.72);
      --rte-tmpl-dialog-bg: #202938;
      --rte-tmpl-dialog-text: #e8effc;
      --rte-tmpl-border: #49566c;
      --rte-tmpl-subtle-bg: #2a3444;
      --rte-tmpl-subtle-hover: #344256;
      --rte-tmpl-muted-text: #a5b1c5;
      --rte-tmpl-accent: #58a6ff;
      --rte-tmpl-accent-strong: #4598f4;
      --rte-tmpl-ring: rgba(88, 166, 255, 0.22);
    }
    .rte-template-dialog {
      background: var(--rte-tmpl-dialog-bg);
      color: var(--rte-tmpl-dialog-text);
      border: 1px solid var(--rte-tmpl-border);
      border-radius: 12px;
      box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
      width: 600px;
      max-height: 700px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .rte-dialog-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 16px 20px;
      border-bottom: 1px solid var(--rte-tmpl-border);
      background: linear-gradient(180deg, rgba(127, 154, 195, 0.08) 0%, rgba(127, 154, 195, 0) 100%);
    }
    .rte-dialog-header h2 {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
      color: var(--rte-tmpl-dialog-text);
    }
    .rte-dialog-close {
      background: none;
      border: none;
      font-size: 24px;
      cursor: pointer;
      color: var(--rte-tmpl-muted-text);
      padding: 0;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      transition: background-color 0.16s ease, color 0.16s ease;
    }
    .rte-dialog-close:hover {
      background-color: var(--rte-tmpl-subtle-hover);
      color: var(--rte-tmpl-dialog-text);
    }
    .rte-dialog-body {
      padding: 20px;
      flex: 1;
      overflow-y: auto;
    }
    .rte-input {
      width: 100%;
      padding: 8px 12px;
      border: 1px solid var(--rte-tmpl-border);
      border-radius: 4px;
      font-size: 14px;
      box-sizing: border-box;
      background: var(--rte-tmpl-subtle-bg);
      color: var(--rte-tmpl-dialog-text);
    }
    .rte-input:focus {
      outline: none;
      border-color: var(--rte-tmpl-accent);
    }
    .rte-tabs {
      display: flex;
      gap: 8px;
      margin-top: 12px;
      border-bottom: 1px solid var(--rte-tmpl-border);
      padding-bottom: 8px;
    }
    .rte-tab {
      padding: 6px 12px;
      border: none;
      background: none;
      cursor: pointer;
      font-size: 14px;
      color: var(--rte-tmpl-muted-text);
      border-bottom: 2px solid transparent;
      transition: all 0.2s;
    }
    .rte-tab:hover {
      color: var(--rte-tmpl-dialog-text);
    }
    .rte-tab.active {
      color: var(--rte-tmpl-accent);
      border-bottom-color: var(--rte-tmpl-accent);
      font-weight: 600;
    }
    .rte-template-list {
      border: 1px solid var(--rte-tmpl-border);
      border-radius: 4px;
      max-height: 250px;
      overflow-y: auto;
      margin: 12px 0;
      background: var(--rte-tmpl-subtle-bg);
    }
    .rte-template-item {
      padding: 12px;
      border-bottom: 1px solid var(--rte-tmpl-border);
      cursor: pointer;
      transition: background-color 0.2s;
      background: none;
    }
    .rte-template-item:last-child {
      border-bottom: none;
    }
    .rte-template-item:hover,
    .rte-template-item.selected {
      background-color: var(--rte-tmpl-subtle-hover);
    }
    .template-name {
      font-weight: 600;
      color: var(--rte-tmpl-dialog-text);
      margin-bottom: 4px;
    }
    .template-description {
      font-size: 12px;
      color: var(--rte-tmpl-muted-text);
    }
    .rte-template-preview {
      padding: 12px;
      background-color: var(--rte-tmpl-subtle-bg);
      border: 1px solid var(--rte-tmpl-border);
      border-radius: 4px;
      margin-top: 12px;
      max-height: 200px;
      overflow-y: auto;
    }
    .template-preview-content {
      font-size: 13px;
      line-height: 1.5;
      margin-top: 8px;
    }
    .template-preview-content * {
      margin: 4px 0;
    }
    .rte-insert-mode {
      margin-top: 12px;
      padding: 12px;
      background-color: var(--rte-tmpl-subtle-bg);
      border-radius: 4px;
      display: flex;
      gap: 16px;
    }
    .rte-insert-mode label {
      display: flex;
      align-items: center;
      cursor: pointer;
      font-size: 14px;
    }
    .rte-insert-mode input {
      margin-right: 6px;
      cursor: pointer;
    }
    .rte-empty-state {
      padding: 40px;
      text-align: center;
      color: var(--rte-tmpl-muted-text);
      font-size: 14px;
    }
    .rte-dialog-footer {
      padding: 16px 20px;
      border-top: 1px solid var(--rte-tmpl-border);
      background: var(--rte-tmpl-subtle-bg);
      display: flex;
      justify-content: flex-end;
      gap: 12px;
    }
    .rte-button-primary {
      padding: 8px 16px;
      border: none;
      border-radius: 4px;
      font-size: 14px;
      cursor: pointer;
      background-color: var(--rte-tmpl-accent);
      color: white;
      transition: all 0.2s;
    }
    .rte-button-primary:hover:not([disabled]) {
      background-color: var(--rte-tmpl-accent-strong);
    }
    .rte-button-primary[disabled] {
      opacity: 0.5;
      cursor: not-allowed;
    }
    .rte-button-secondary {
      padding: 8px 16px;
      border: 1px solid var(--rte-tmpl-border);
      border-radius: 4px;
      font-size: 14px;
      cursor: pointer;
      background-color: var(--rte-tmpl-subtle-bg);
      color: var(--rte-tmpl-dialog-text);
      transition: all 0.2s;
    }
    .rte-button-secondary:hover {
      background-color: var(--rte-tmpl-subtle-hover);
    }
  `, document.head.appendChild(t);
}
const Jn = () => ({
  name: "template",
  toolbar: [
    {
      label: "Template",
      command: "insertTemplate",
      icon: '<svg width="24px" height="24px" 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 fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'
    }
  ],
  commands: {
    insertTemplate: (n, t) => (qn(t), !0)
  },
  keymap: {}
});
export {
  Hn as PREDEFINED_TEMPLATES,
  Jn as TemplatePlugin,
  Kn as addCustomTemplate,
  Wt as getAllTemplates,
  jt as getTemplateCategories,
  Zn as getTemplatesByCategory,
  Vt as sanitizeTemplate,
  Un as searchTemplates,
  Qn as validateTemplate
};
