function x(o) {
  if (!o || !o.trim())
    return "";
  let t = "", s = 0;
  const r = 2, u = /<\/?[a-zA-Z][^>]*>/g, d = /<!--[\s\S]*?-->/g, f = /<!\[CDATA\[[\s\S]*?\]\]>/g, h = /<!DOCTYPE[^>]*>/gi, a = [];
  let n = o;
  n = n.replace(h, (e) => (a.push(e), `__SPECIAL_${a.length - 1}__`)), n = n.replace(d, (e) => (a.push(e), `__SPECIAL_${a.length - 1}__`)), n = n.replace(f, (e) => (a.push(e), `__SPECIAL_${a.length - 1}__`));
  const C = /* @__PURE__ */ new Set(["img", "br", "hr", "input", "meta", "link", "area", "base", "col", "embed", "source", "track", "wbr"]), S = /* @__PURE__ */ new Set(["a", "span", "strong", "em", "b", "i", "u", "s", "del", "code", "small", "mark", "sub", "sup"]);
  let g = 0, l;
  for (; (l = u.exec(n)) !== null; ) {
    const e = l[0], i = n.substring(g, l.index), p = e.match(/<\/?([a-zA-Z0-9]+)/), m = p ? p[1].toLowerCase() : "", P = e.startsWith("</"), b = e.endsWith("/>") || C.has(m), c = S.has(m);
    i && (c ? t += i : t += " ".repeat(s * r) + i + `
`), P ? c ? t += e : (s = Math.max(0, s - 1), t += " ".repeat(s * r) + e + `
`) : (c ? t && !t.endsWith(`
`) ? t += e : t += " ".repeat(s * r) + e : t += " ".repeat(s * r) + e + `
`, !b && !c && s++), g = l.index + e.length;
  }
  const _ = n.substring(g);
  return _.trim() && (t += " ".repeat(s * r) + _ + `
`), t = t.replace(/__SPECIAL_(\d+)__/g, (e, i) => a[parseInt(i, 10)]), t.trimEnd() + `
`;
}
export {
  x as default
};
//# sourceMappingURL=formatHtml.js.map
