import { __exports as u } from "./index-utilities3.js";
import { __require as c } from "./index-lib.js";
import { __require as x } from "./index-constants.js";
var g;
function k() {
  if (g) return u;
  g = 1;
  for (var o = /* @__PURE__ */ c(), E = x(), _ = E.CASE_SENSITIVE_TAG_NAMES, N = o.Comment, C = o.Element, b = o.ProcessingInstruction, p = o.Text, h = {}, f, m = 0, w = _.length; m < w; m++)
    f = _[m], h[f.toLowerCase()] = f;
  function A(a) {
    return h[a];
  }
  function S(a) {
    for (var r = {}, s, t = 0, n = a.length; t < n; t++)
      s = a[t], r[s.name] = s.value;
    return r;
  }
  function q(a) {
    a = a.toLowerCase();
    var r = A(a);
    return r || a;
  }
  function T(a, r, s) {
    r = r || null;
    for (var t = [], n, l = 0, I = a.length; l < I; l++) {
      var i = a[l], e;
      switch (i.nodeType) {
        case 1:
          n = q(i.nodeName), e = new C(n, S(i.attributes)), e.children = T(
            // template children are on content
            n === "template" ? i.content.childNodes : i.childNodes,
            e
          );
          break;
        case 3:
          e = new p(i.nodeValue);
          break;
        case 8:
          e = new N(i.nodeValue);
          break;
        default:
          continue;
      }
      var v = t[l - 1] || null;
      v && (v.next = e), e.parent = r, e.prev = v, e.next = null, t.push(e);
    }
    return s && (e = new b(
      s.substring(0, s.indexOf(" ")).toLowerCase(),
      s
    ), e.next = t[0] || null, e.parent = r, t.unshift(e), t[1] && (t[1].prev = t[0])), t;
  }
  return u.formatAttributes = S, u.formatDOM = T, u;
}
export {
  k as __require
};
