import { webNamespaces as m } from "../../../../web-namespaces@2.0.1/node_modules/web-namespaces/index.es.js";
import { s as l, h as N } from "../../../../hastscript@9.0.1/node_modules/hastscript/lib/index.es.js";
function v(t, n) {
  return i(t, {}) || { type: "root", children: [] };
}
function i(t, n) {
  const e = p(t, n);
  return e && n.afterTransform && n.afterTransform(t, e), e;
}
function p(t, n) {
  switch (t.nodeType) {
    case 1:
      return x(
        /** @type {Element} */
        t,
        n
      );
    // Ignore: Attr (2).
    case 3:
      return g(
        /** @type {Text} */
        t
      );
    // Ignore: CDATA (4).
    // Removed: Entity reference (5)
    // Removed: Entity (6)
    // Ignore: Processing instruction (7).
    case 8:
      return y(
        /** @type {Comment} */
        t
      );
    case 9:
      return d(
        /** @type {Document} */
        t,
        n
      );
    case 10:
      return h();
    case 11:
      return d(
        /** @type {DocumentFragment} */
        t,
        n
      );
    default:
      return;
  }
}
function d(t, n) {
  return { type: "root", children: f(t, n) };
}
function h() {
  return { type: "doctype" };
}
function g(t) {
  return { type: "text", value: t.nodeValue || "" };
}
function y(t) {
  return { type: "comment", value: t.nodeValue || "" };
}
function x(t, n) {
  const e = t.namespaceURI, r = e === m.svg ? l : N, o = e === m.html ? t.tagName.toLowerCase() : t.tagName, c = (
    // @ts-expect-error: DOM types are wrong, content can exist.
    e === m.html && o === "template" ? t.content : t
  ), s = t.getAttributeNames(), a = {};
  let u = -1;
  for (; ++u < s.length; )
    a[s[u]] = t.getAttribute(s[u]) || "";
  return r(o, a, f(c, n));
}
function f(t, n) {
  const e = t.childNodes, r = [];
  let o = -1;
  for (; ++o < e.length; ) {
    const c = i(e[o], n);
    c !== void 0 && r.push(c);
  }
  return r;
}
export {
  v as fromDom
};
//# sourceMappingURL=index.es.js.map
