{"version":3,"file":"html-Ju5dxl8_.cjs","names":["decode","parse","h"],"sources":["../src/encoding.ts","../src/h.ts","../src/style.ts","../src/vcss.ts","../src/vdom.ts","../src/utils.ts","../src/html.ts"],"sourcesContent":["// import { decode } from './encoding-he'\nimport { decodeHTML as decode } from 'entities'\n\nconst ESCAPE: Record<string, string> = {\n  '&': '&amp;',\n  '<': '&lt;',\n  '>': '&gt;',\n  '\\'': '&apos;',\n  '\"': '&quot;',\n  '\\xA0': '&nbsp;',\n  '\\xAD': '&shy;',\n}\nconst ESCAPE_RE = /[&<>'\"\\xA0\\xAD]/\nconst ESCAPE_RE_GLOBAL = /[&<>'\"\\xA0\\xAD]/g\n\nexport function escapeHTML(text: string) {\n  // One pass instead of one per character, and most texts need no escaping\n  return ESCAPE_RE.test(text)\n    ? text.replace(ESCAPE_RE_GLOBAL, c => ESCAPE[c]!)\n    : text\n}\n\n// encode(text, {\n//   useNamedReferences: true,\n// })\n\nexport const unescapeHTML = (html: string) => decode(html)\n\n/**\n * URLs that would run script when clicked or loaded. A blocklist on purpose:\n * everything else (relative paths, `cid:` images in mails, custom app schemes)\n * passes as before. Control characters and whitespace are ignored by browsers\n * inside the scheme (`java\\tscript:`), so they are ignored here as well.\n */\nexport function isUnsafeUrl(url: string, allowDataImage = false): boolean {\n  // eslint-disable-next-line no-control-regex\n  const scheme = url.replace(/[\\x00-\\x20\\x7F]/g, '').match(/^([a-z][a-z0-9+.-]*):/i)?.[1]?.toLowerCase()\n  if (scheme === 'javascript' || scheme === 'vbscript')\n    return true\n  if (scheme === 'data')\n    return !(allowDataImage && /^\\s*data:image\\//i.test(url))\n  return false\n}\n","import type { VDocument, VDocumentFragment, VElement } from './vdom'\n\n/*\n * Abstraction for h/jsx like DOM descriptions.\n * It is used in DOM, VDOM\n *\n */\n\ninterface Context {\n  h?: any\n  document: VDocument | VDocumentFragment\n}\n\nfunction _h(\n  context: Context,\n  tag: string | ((a0: any) => VDocumentFragment | VElement),\n  attrs: object,\n  children: any[],\n): VDocumentFragment | VElement {\n  if (typeof tag === 'function') {\n    return tag({\n      props: { ...attrs, children },\n      attrs,\n      children,\n      h: context.h,\n      context,\n    })\n  }\n  else {\n    let isElement = true\n    let el: VDocumentFragment | VElement\n    if (tag) {\n      if (tag.toLowerCase() === 'fragment') {\n        el = context.document.createDocumentFragment()\n        isElement = false\n      }\n      else { el = context.document.createElement(tag) }\n    }\n    else {\n      el = context.document.createElement('div')\n    }\n    if (attrs && isElement) {\n      const element = el as VElement\n      for (const [key, value] of Object.entries(attrs)) {\n        const compareKey = key.toLowerCase()\n        if (compareKey === 'classname') {\n          element.className = value\n        }\n        else if (compareKey === 'on') {\n          for (const [name, v] of Object.entries(value)) {\n            element.setAttribute(`on${name}`, String(v))\n          }\n        }\n        else if (value !== false && value != null) {\n          element.setAttribute(key, value === true\n            ? key\n            : value.toString())\n        }\n      }\n    }\n    if (children) {\n      for (const childOuter of children) {\n        const cc = Array.isArray(childOuter)\n          ? childOuter\n          : [childOuter]\n        for (const child of cc) {\n          if (child !== false && child != null) {\n            if (typeof child !== 'object') {\n              el.appendChild(context.document.createTextNode(child.toString()))\n            }\n            else {\n              el.appendChild(child)\n            }\n          }\n        }\n      }\n    }\n    return el\n  }\n}\n\nexport function hArgumentParser(\n  tag: string | ((props: any) => VDocumentFragment | VElement),\n  attrs?: Record<string, unknown> | unknown[] | null,\n  ...childrenInput: unknown[]\n): { tag: string | ((props: any) => VDocumentFragment | VElement), attrs: Record<string, unknown>, children: unknown[] } {\n  let children: unknown[] = childrenInput\n\n  if (typeof tag === 'object' && tag !== null) {\n    // If tag is an object, treat as fragment-like\n    children = (tag as any).children\n    attrs = (tag as any).attrs\n    tag = 'fragment'\n  }\n\n  if (Array.isArray(attrs)) {\n    children = [attrs]\n    attrs = {}\n  }\n  else if (attrs) {\n    if ((attrs as Record<string, unknown>).attrs) {\n      const attrsObj = (attrs as Record<string, unknown>).attrs\n      attrs = {\n        ...(typeof attrsObj === 'object' && attrsObj !== null\n          ? attrsObj\n          : {}),\n        ...attrs,\n      }\n      delete (attrs as Record<string, unknown>).attrs\n    }\n  }\n  else {\n    attrs = {}\n  }\n\n  return {\n    tag,\n    attrs: attrs ?? {},\n    children:\n      typeof children[0] === 'string'\n        ? children\n        : children.flat(Number.POSITIVE_INFINITY),\n  }\n}\n\nexport function hFactory(context: Context) {\n  // let context = { document }\n  context.h = function h(itag: any, iattrs: any, ...ichildren: any[]) {\n    const { tag, attrs, children } = hArgumentParser(itag, iattrs, ichildren)\n    return _h(context, tag, attrs, children)\n  }\n  return context.h\n}\n","function isSpace(c: number) {\n  return c === 32 || (c >= 9 && c <= 13) || (c >= 0xA0 && /\\s/.test(String.fromCharCode(c)))\n}\n\nfunction isNameChar(c: number) {\n  // `[\\w-]`\n  return (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95 || c === 45\n}\n\n/**\n * Declarations of a `style` attribute as `[name, value]` pairs.\n *\n * The same result as `/\\s*([\\w-]+)\\s*:\\s*((url\\(.*?\\)[^;]*|[^;]+))/gi`, which\n * was used before, but linear in the length of the input. The regular\n * expression searched from every position again when no match followed,\n * which took seconds for a `style` of some 10 KB without a colon.\n */\nexport function parseStyleDeclarations(style: string): [string, string][] {\n  const result: [string, string][] = []\n  const length = style.length\n  let pos = 0\n  let noMoreParen = false\n  while (pos < length) {\n    const colon = style.indexOf(':', pos)\n    if (colon < 0)\n      break\n\n    // The name directly before the colon, whitespace in between is allowed\n    let nameEnd = colon\n    while (nameEnd > pos && isSpace(style.charCodeAt(nameEnd - 1)))\n      nameEnd--\n    let nameStart = nameEnd\n    while (nameStart > pos && isNameChar(style.charCodeAt(nameStart - 1)))\n      nameStart--\n    if (nameStart === nameEnd) {\n      pos = colon + 1\n      continue\n    }\n\n    let valueStart = colon + 1\n    while (valueStart < length && isSpace(style.charCodeAt(valueStart)))\n      valueStart++\n\n    let valueEnd = -1\n    // `url(…)` may contain `;`, up to the first `)` on the same line\n    if (!noMoreParen && style.slice(valueStart, valueStart + 4).toLowerCase() === 'url(') {\n      const close = style.indexOf(')', valueStart + 4)\n      if (close < 0) {\n        noMoreParen = true\n      }\n      else if (!/[\\n\\r\\u2028\\u2029]/.test(style.slice(valueStart + 4, close))) {\n        valueEnd = style.indexOf(';', close + 1)\n        if (valueEnd < 0)\n          valueEnd = length\n      }\n    }\n    if (valueEnd < 0) {\n      valueEnd = style.indexOf(';', valueStart)\n      if (valueEnd < 0)\n        valueEnd = length\n      if (valueEnd === valueStart && valueStart === colon + 1) {\n        // `a:;` is no declaration, but `a: ;` is one with an empty value\n        pos = colon + 1\n        continue\n      }\n    }\n\n    result.push([\n      style.slice(nameStart, nameEnd),\n      style.slice(valueStart, valueEnd).trim(),\n    ])\n    pos = valueEnd\n  }\n  return result\n}\n","import type { VElement } from './vdom'\nimport { parse } from 'css-what'\n\n// A `Map`, not an object: `'constructor' in {}` is true, so\n// `querySelector('constructor')` returned `Object` and threw. Limited in size,\n// selectors built from data like `[data-id=\"…\"]` grew it without end.\nconst cache = new Map<string, any>()\nconst CACHE_SIZE = 1000\n\nexport function parseSelector(selector: string) {\n  let parsed = cache.get(selector)\n  if (parsed === undefined) {\n    parsed = parse(selector)\n    if (cache.size >= CACHE_SIZE)\n      cache.delete(cache.keys().next().value!)\n    cache.set(selector, parsed)\n  }\n  return parsed\n}\n\nfunction previousElement(node: VElement): VElement | null {\n  let prev = node.previousSibling\n  while (prev && prev.nodeType !== 1) prev = prev.previousSibling\n  return prev\n}\n\nfunction nextElement(node: VElement): VElement | null {\n  let next = node.nextSibling\n  while (next && next.nodeType !== 1) next = next.nextSibling\n  return next\n}\n\n// Failures known within one `matchSelector` call, as bitmasks over the index\n// in the rule: `matchRule(el, idx)` is false, no ancestor of `el` matches\n// `idx`, no previous sibling of `el` matches `idx`. Without them\n// `span div div div` on deeply nested `div`s tried every combination of\n// ancestors, which took seconds for four `div`s and 200 levels.\nconst failedSelf = new Map<object, number>()\nconst failedAncestors = new Map<object, number>()\nconst failedSiblings = new Map<object, number>()\n\nfunction clearMemo() {\n  if (failedSelf.size)\n    failedSelf.clear()\n  if (failedAncestors.size)\n    failedAncestors.clear()\n  if (failedSiblings.size)\n    failedSiblings.clear()\n}\n\n/** Bit for `idx` in the maps above, 0 for very long selectors, which are not memoized */\nfunction bitFor(idx: number): number {\n  return idx < 30\n    ? 1 << idx\n    : 0\n}\n\nfunction matchRuleMemo(el: VElement, ruleParts: any[], idx: number, bit: number): boolean {\n  if (bit && ((failedSelf.get(el) ?? 0) & bit))\n    return false\n  const result = matchRule(el, ruleParts, idx)\n  if (!result && bit)\n    failedSelf.set(el, (failedSelf.get(el) ?? 0) | bit)\n  return result\n}\n\n/**\n * Is there a node in the chain after `el` (`parentNode` or `previousSibling`)\n * that matches `idx`? A node whose chain is known to fail ends the walk, and\n * all walked nodes are marked as failing, so each node is walked only once.\n */\nfunction matchChain(el: VElement, ruleParts: any[], idx: number, failed: Map<object, number>, ancestors: boolean): boolean {\n  const bit = bitFor(idx)\n  const walked: any[] = [el]\n  let node: any = ancestors\n    ? el.parentNode\n    : el.previousSibling\n  while (node) {\n    if (node.nodeType === 1 && matchRuleMemo(node, ruleParts, idx, bit))\n      return true\n    if (bit && ((failed.get(node) ?? 0) & bit))\n      break\n    walked.push(node)\n    node = ancestors\n      ? node.parentNode\n      : node.previousSibling\n  }\n  if (bit) {\n    for (const n of walked)\n      failed.set(n, (failed.get(n) ?? 0) | bit)\n  }\n  return false\n}\n\n// Module level, not inside `matchSelector`: these were created anew on every\n// call, which showed up in profiles of `querySelectorAll`\nfunction matchRule(el: VElement | null, ruleParts: any[], idx: number): boolean {\n  while (el && el.nodeType !== 1) el = el.parentNode\n  if (!el || idx < 0)\n    return false\n  const part = ruleParts[idx]\n  switch (part.type) {\n    case 'descendant':\n      return matchChain(el, ruleParts, idx - 1, failedAncestors, true)\n    case 'child': {\n      let parent = el.parentNode\n      while (parent && parent.nodeType !== 1) parent = parent.parentNode\n      return !!parent && matchRuleMemo(parent, ruleParts, idx - 1, bitFor(idx - 1))\n    }\n    case 'sibling':\n    case 'general': // general sibling combinator (~)\n      return matchChain(el, ruleParts, idx - 1, failedSiblings, false)\n    case 'adjacent': {\n      let prev = el.previousSibling\n      while (prev && prev.nodeType !== 1) prev = prev.previousSibling\n      return !!prev && matchRuleMemo(prev, ruleParts, idx - 1, bitFor(idx - 1))\n    }\n    default: {\n      if (!matchSimple(el, part))\n        return false\n      if (idx === 0)\n        return true\n      return matchRule(el, ruleParts, idx - 1)\n    }\n  }\n}\n\nfunction matchSimple(element: VElement, part: any): boolean {\n  const { type, name, action, value, data } = part\n  if (type === 'attribute') {\n    const attrValue = element.getAttribute(name)\n    switch (action) {\n      case 'equals': return attrValue === value\n      case 'start': return !!attrValue?.startsWith(value)\n      case 'end': return !!attrValue?.endsWith(value)\n      case 'element':\n        return name === 'class'\n          ? element.classList.contains(value)\n          : !!attrValue?.includes(value)\n      case 'exists': return element.hasAttribute(name)\n      case 'any': return !!attrValue?.includes(value)\n      case 'hyphen': // [attr|=val]\n        return attrValue === value || !!attrValue?.startsWith(`${value}-`)\n      case 'contains': // [attr*=val]\n        return !!attrValue?.includes(value)\n      default: return false\n    }\n  }\n  if (type === 'tag')\n    // Cached on the parsed selector, which is cached itself\n    return element.tagName === (part.upperName ??= name.toUpperCase())\n  if (type === 'universal')\n    return true\n  if (type === 'pseudo') {\n    if (name === 'not') {\n      return !data.some((rules: any) => rules.every((p: any) => matchSimple(element, p)))\n    }\n    const parent = element.parentNode\n    if (!parent || !parent.childNodes)\n      return false\n    // Walk the siblings instead of collecting all element children, which\n    // made `querySelectorAll('p:first-child')` quadratic for wide parents\n    if (name === 'first-child')\n      return !previousElement(element)\n    if (name === 'last-child')\n      return !nextElement(element)\n    if (name === 'nth-child') {\n      // `data` is the argument as string, e.g. `'12'`, not a list\n      const nth = data && data.length > 0\n        ? Number.parseInt(data, 10) - 1\n        : 0\n      if (!(nth >= 0))\n        return false\n      let idx = 0\n      for (let prev = previousElement(element); prev && idx <= nth; prev = previousElement(prev))\n        idx++\n      return idx === nth\n    }\n    return false\n  }\n  return false\n}\n\nexport function matchSelector(\n  selector: string,\n  element: VElement,\n) {\n  for (const rules of parseSelector(selector)) {\n    try {\n      if (matchRule(element, rules, rules.length - 1))\n        return true\n    }\n    finally {\n      // Also so the maps don't keep nodes alive\n      clearMemo()\n    }\n  }\n  return false\n}\n","import { escapeHTML } from './encoding'\nimport { hFactory } from './h'\nimport { htmlVDOM, xmlVDOM } from './html'\nimport { parseStyleDeclarations } from './style'\nimport { matchSelector } from './vcss'\n\n// For node debugging\nconst inspect = Symbol.for('nodejs.util.inspect.custom')\n\nconst B = { fontWeight: 'bold' }\nconst I = { fontStyle: 'italic' }\nconst M = { backgroundColor: 'rgb(255, 250, 165)' }\nconst U = { textDecorations: 'underline' }\nconst S = { textDecorations: 'line-through' }\n// let C = {}\n\nconst DEFAULTS = {\n  b: B,\n  strong: B,\n  em: I,\n  i: I,\n  mark: M,\n  u: U,\n  a: U,\n  s: S,\n  del: S,\n  ins: M,\n  strike: S,\n  // 'code': C,\n  // 'tt': C\n} as any\n\nfunction toCamelCase(s: string): string {\n  return s.toLowerCase().replace(/[^a-z0-9]+(.)/gi, (_m, chr) => chr.toUpperCase())\n}\n\nexport class VNode {\n  static ELEMENT_NODE = 1\n  static TEXT_NODE = 3\n  static CDATA_SECTION_NODE = 4\n  static PROCESSING_INSTRUCTION_NODE = 7\n  static COMMENT_NODE = 8\n  static DOCUMENT_NODE = 9\n  static DOCUMENT_TYPE_NODE = 10\n  static DOCUMENT_FRAGMENT_NODE = 11\n\n  _parentNode: any\n  _childNodes: any[]\n  /** Cached position in the parent's `_childNodes`, only a hint, see `_indexInParent` */\n  _index = -1\n\n  get nodeType(): number {\n    console.error('Subclasses should define nodeType!')\n    return 0\n  }\n\n  get nodeName() {\n    console.error('Subclasses should define nodeName!')\n    return ''\n  }\n\n  get nodeValue(): string | null {\n    return null\n  }\n\n  constructor() {\n    this._parentNode = null\n    this._childNodes = []\n  }\n\n  cloneNode(deep = false) {\n    const Ctor = this.constructor as unknown as new () => this\n    const node = new Ctor()\n    if (deep) {\n      // Iterative, so deeply nested trees don't overflow the call stack.\n      // Subclasses copy their own fields in `cloneNode(false)`.\n      const stack: [VNode, VNode][] = [\n        [this, node],\n      ]\n      while (stack.length) {\n        const [source, target] = stack.pop()!\n        target._childNodes = source._childNodes.map((c) => {\n          const clone = c.cloneNode(false)\n          stack.push([c, clone])\n          return clone\n        })\n        target._fixChildNodesParent()\n      }\n    }\n    return node\n  }\n\n  _fixChildNodesParent() {\n    const nodes = this._childNodes\n    for (let i = 0; i < nodes.length; i++) {\n      nodes[i]._parentNode = this\n      nodes[i]._index = i\n    }\n  }\n\n  /** Position of `node` in `_childNodes` or -1, uses the `_index` hint if valid */\n  _childIndex(node: VNode) {\n    return this._childNodes[node._index] === node\n      ? node._index\n      : this._childNodes.indexOf(node)\n  }\n\n  // The mutations below don't re-index the following siblings, which would\n  // cost O(n) per call. `_indexInParent` repairs stale hints when needed.\n\n  /**\n   * True, and a warning, if `node` is this node or one of its ancestors:\n   * inserting it here would make a node its own ancestor, and walks over the\n   * tree would never end. The DOM throws a HierarchyRequestError then.\n   */\n  _rejectsChild(node: unknown, parent: VNode = this): boolean {\n    if (!(node instanceof VNode))\n      return false\n    // A node without children can only be the parent itself, cheap for parsing\n    if (node === parent || (node._childNodes.length > 0 && node.contains(parent))) {\n      console.warn('Cannot insert a node into itself or one of its descendants', node)\n      return true\n    }\n    return false\n  }\n\n  /** Detach all children, so they don't point to this node anymore */\n  _detachChildren() {\n    for (const child of this._childNodes) {\n      child._parentNode = null\n      child._index = -1\n    }\n    this._childNodes = []\n  }\n\n  /**\n   * Like the DOM: `null` as reference node appends, a fragment inserts its\n   * children. Without a reference node (`undefined`), which is a TypeError in\n   * browsers, zeed-dom inserts at the start, as it always did.\n   */\n  insertBefore(newNode: VNode, node?: VNode | null) {\n    if (node === null)\n      return this.appendChild(newNode)\n    if (newNode === node || this._rejectsChild(newNode))\n      return\n    const nodes = newNode instanceof VDocumentFragment\n      ? [...newNode._childNodes]\n      : [newNode]\n    for (const n of nodes)\n      n.remove()\n    // Unknown reference node: the DOM throws, zeed-dom inserts at the start\n    const index = node\n      ? Math.max(0, this._childIndex(node))\n      : 0\n    this._childNodes.splice(index, 0, ...nodes)\n    for (let i = 0; i < nodes.length; i++) {\n      nodes[i]!._parentNode = this\n      nodes[i]!._index = index + i\n    }\n  }\n\n  appendChild(node: VNode | VNode[] | string | string[] | null | undefined) {\n    if (node == null || this._rejectsChild(node))\n      return\n    // log('appendChild', node, this)\n\n    if (node instanceof VDocument)\n      console.warn('No defined how to append a document to a node!', node)\n\n    if (node instanceof VDocumentFragment) {\n      for (const c of [...node._childNodes]) {\n        // Don't iterate over the original! Do [...el]\n        this.appendChild(c)\n      }\n    }\n    else if (Array.isArray(node)) {\n      for (const c of [...node]) {\n        // Don't iterate over the original! Do [...el]\n        this.appendChild(c)\n      }\n    }\n    else if (node instanceof VNode) {\n      node.remove()\n      node._parentNode = this\n      node._index = this._childNodes.push(node) - 1\n    }\n    else {\n      // Fallback for unknown data\n      try {\n        const text\n          = typeof node === 'string'\n            ? node\n            : JSON.stringify(node, null, 2)\n        const textNode = new VTextNode(text)\n        textNode._parentNode = this\n        textNode._index = this._childNodes.push(textNode) - 1\n      }\n      catch (err) {\n        console.error(`The data ${node} to be added to ${this.render()} is problematic: ${err}`)\n      }\n    }\n  }\n\n  append = this.appendChild\n\n  // The parameter type is kept as it was in 0.19 for API compatibility\n  removeChild(child: { _parentNode: null }) {\n    const node = child as VNode\n    const i = this._childIndex(node)\n    if (i >= 0) {\n      node._parentNode = null\n      node._index = -1\n      // `shift` and `pop` are much faster than `splice` on large arrays in V8\n      if (i === 0)\n        this._childNodes.shift()\n      else if (i === this._childNodes.length - 1)\n        this._childNodes.pop()\n      else\n        this._childNodes.splice(i, 1)\n    }\n  }\n\n  /** Remove node */\n  remove() {\n    this?.parentNode?.removeChild(this)\n    return this\n  }\n\n  /** Replace content of node with text or nodes */\n  replaceChildren(...nodes: any[]) {\n    // Collect in a fragment first like the DOM: removes the nodes from their\n    // parents, including this one, and a node given twice is added once\n    // Check first, moving the nodes into the fragment would change the tree\n    if (nodes.some(n => this._rejectsChild(n)))\n      return\n    const fragment = new VDocumentFragment()\n    for (const n of nodes) {\n      fragment.appendChild(typeof n === 'string'\n        ? new VTextNode(n)\n        : n)\n    }\n    this._detachChildren()\n    this.appendChild(fragment)\n  }\n\n  /** Replace node itself with nodes */\n  replaceWith(...nodes: any[]) {\n    const parent = this._parentNode\n    if (!parent || parent._childIndex(this) < 0 || nodes.some(n => this._rejectsChild(n, parent)))\n      return\n    // Like the DOM: the new nodes go where this node is, or if this node is\n    // one of them, before the first following sibling that is not\n    let next = this.nextSibling\n    while (next && nodes.includes(next))\n      next = next.nextSibling\n    const fragment = new VDocumentFragment()\n    for (const n of nodes) {\n      fragment.appendChild(typeof n === 'string'\n        ? new VTextNode(n)\n        : n)\n    }\n    if (this._parentNode === parent) {\n      parent.insertBefore(fragment, this)\n      parent.removeChild(this)\n    }\n    else {\n      parent.insertBefore(fragment, next)\n    }\n  }\n\n  /**\n   * Position in the parent's child list. `_index` is only a hint: mutations\n   * like `insertBefore` or `removeChild` shift siblings without updating it.\n   * If the hint is stale, all siblings are re-indexed once, so walking the\n   * children with `nextSibling` stays O(n) instead of O(n²).\n   */\n  _indexInParent() {\n    const p = this._parentNode\n    if (!p)\n      return -1\n    const nodes = p._childNodes\n    if (nodes[this._index] === this)\n      return this._index\n    const i = nodes.indexOf(this)\n    if (i >= 0)\n      p._fixChildNodesParent()\n    return i\n  }\n\n  get parentNode() {\n    return this._parentNode\n  }\n\n  get childNodes() {\n    return this._childNodes || []\n  }\n\n  get children() {\n    return (this._childNodes || []).filter<any>(isVElement)\n  }\n\n  get firstChild() {\n    return this._childNodes[0]\n  }\n\n  get lastChild() {\n    return this._childNodes[this._childNodes.length - 1]\n  }\n\n  get nextSibling() {\n    const i = this._indexInParent()\n    if (i >= 0)\n      return this.parentNode.childNodes[i + 1] || null\n    return null\n  }\n\n  get previousSibling() {\n    const i = this._indexInParent()\n    if (i > 0)\n      return this.parentNode.childNodes[i - 1] || null\n    return null\n  }\n\n  get childElementCount() {\n    return this._childNodes.filter(child => child.nodeType === VNode.ELEMENT_NODE).length\n  }\n\n  get firstElementChild() {\n    return this._childNodes.find(child => child.nodeType === VNode.ELEMENT_NODE) || null\n  }\n\n  get lastElementChild() {\n    for (let i = this._childNodes.length - 1; i >= 0; i--) {\n      if (this._childNodes[i].nodeType === VNode.ELEMENT_NODE) {\n        return this._childNodes[i]\n      }\n    }\n    return null\n  }\n\n  /**\n   * Visit this node and all descendants in document order until `fn` returns\n   * true. Iterative, so deeply nested trees don't overflow the call stack.\n   */\n  _walk(fn: (node: VNode) => boolean | void): VNode | undefined {\n    if (fn(this))\n      return this\n    // One list and position per level, so a wide parent costs nothing until\n    // its children are visited\n    const lists: VNode[][] = [this._childNodes]\n    const positions: number[] = [0]\n    while (lists.length) {\n      const top = lists.length - 1\n      const children = lists[top]!\n      const i = positions[top]!\n      if (i >= children.length) {\n        lists.pop()\n        positions.pop()\n        continue\n      }\n      positions[top] = i + 1\n      const node = children[i]!\n      if (fn(node))\n        return node\n      if (node._childNodes.length) {\n        lists.push(node._childNodes)\n        positions.push(0)\n      }\n    }\n  }\n\n  flatten(): VElement[] {\n    const elements: VElement[] = []\n    this._walk((node) => {\n      if (node instanceof VElement)\n        elements.push(node)\n    })\n    return elements\n  }\n\n  flattenNodes(): VNode[] {\n    const nodes: VNode[] = []\n    this._walk((node) => {\n      nodes.push(node)\n    })\n    return nodes\n  }\n\n  render() {\n    return ''\n  }\n\n  get textContent(): string | null {\n    let text = ''\n    this._walk((node) => {\n      if (node.nodeType === VNode.TEXT_NODE)\n        text += node.nodeValue ?? ''\n    })\n    return text\n  }\n\n  set textContent(text) {\n    this._detachChildren()\n    if (text)\n      this.appendChild(new VTextNode(text.toString()))\n  }\n\n  contains(otherNode: VNode | null | undefined) {\n    // Walk up instead of searching the whole subtree. A node whose parent no\n    // longer lists it (e.g. after `innerHTML` was set) is not contained.\n    for (let node = otherNode; node; node = node._parentNode) {\n      if (node === this)\n        return true\n      if (node._parentNode && node._parentNode._childIndex(node) < 0)\n        return false\n    }\n    return false\n  }\n\n  get ownerDocument(): any {\n    const isDocument = (node: VNode) => node.nodeType === VNode.DOCUMENT_NODE || node.nodeType === VNode.DOCUMENT_FRAGMENT_NODE\n    if (isDocument(this))\n      return this\n    for (let node: VNode | null = this._parentNode; node; node = node._parentNode) {\n      if (isDocument(node))\n        return node\n    }\n    return undefined\n  }\n\n  toString(): string {\n    return `${this.nodeName}`\n    // return `${this.nodeName}: ${JSON.stringify(this.nodeValue)}`\n  }\n\n  [inspect]() {\n    return `${this.constructor.name} \"${this.render()}\"`\n  }\n\n  get parentElement() {\n    // DOM spec: parentNode if it is an element, else null\n    const p = this.parentNode\n    return p && p.nodeType === VNode.ELEMENT_NODE\n      ? p\n      : null\n  }\n\n  // insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string) {\n  //   let nodes: VNode[] = []\n  //   try {\n  //     const fragment = parseHTML(text)\n  //     nodes = fragment.childNodes.filter((n: any) => n instanceof VNode)\n  //   } catch (e) {\n  //     // Only fallback if text is not valid HTML\n  //     if (/^\\s*<\\/?[a-zA-Z]/.test(text)) {\n  //       throw new Error('HTML parsing failed in insertAdjacentHTML')\n  //     }\n  //     nodes = [new VTextNode(text)]\n  //   }\n  //   switch (position) {\n  //     case 'beforebegin':\n  //       if (this.parentNode) {\n  //         const idx = this._indexInParent()\n  //         if (idx >= 0) {\n  //           this.parentNode._childNodes.splice(idx, 0, ...nodes)\n  //           this.parentNode._fixChildNodesParent()\n  //         }\n  //       }\n  //       break\n  //     case 'afterbegin':\n  //       this._childNodes.unshift(...nodes)\n  //       this._fixChildNodesParent()\n  //       break\n  //     case 'beforeend':\n  //       this._childNodes.push(...nodes)\n  //       this._fixChildNodesParent()\n  //       break\n  //     case 'afterend':\n  //       if (this.parentNode) {\n  //         const idx = this._indexInParent()\n  //         if (idx >= 0) {\n  //           this.parentNode._childNodes.splice(idx + 1, 0, ...nodes)\n  //           this.parentNode._fixChildNodesParent()\n  //         }\n  //       }\n  //       break\n  //   }\n  // }\n}\n\nexport class VTextNode extends VNode {\n  _text: string\n\n  get nodeType(): number {\n    return VNode.TEXT_NODE\n  }\n\n  get nodeName() {\n    return '#text'\n  }\n\n  get nodeValue(): string | null {\n    return this._text || ''\n  }\n\n  // Like in the DOM, `null` becomes an empty string\n  set nodeValue(text: string | null) {\n    this._text = String(text ?? '')\n  }\n\n  get textContent(): string | null {\n    return this.nodeValue\n  }\n\n  set textContent(text: string | null) {\n    this.nodeValue = text\n  }\n\n  get data(): string {\n    return this._text || ''\n  }\n\n  set data(text: string) {\n    this.nodeValue = text\n  }\n\n  constructor(text = '') {\n    super()\n    this._text = text\n  }\n\n  render() {\n    const parentTagName = this.parentNode?.tagName\n    if (parentTagName === 'SCRIPT' || parentTagName === 'STYLE')\n      return this._text\n\n    return escapeHTML(this._text)\n  }\n\n  cloneNode(deep = false) {\n    const node = super.cloneNode(deep)\n    node._text = this._text\n    return node\n  }\n}\n\nexport class VNodeQuery extends VNode {\n  /** First element in document order, including this one, for which `fn` is true */\n  _findElement(fn: (element: VElement) => boolean): VElement | undefined {\n    return this._walk(node => node instanceof VElement && fn(node)) as VElement | undefined\n  }\n\n  getElementById(name: string) {\n    return this._findElement(e => e._attributes.id === name)\n  }\n\n  getElementsByClassName(name: any) {\n    return this.flatten().filter(e => e.classList.contains(name))\n  }\n\n  matches(selector: string) {\n    return matchSelector(selector, this as any)\n  }\n\n  querySelectorAll(selector: any) {\n    return this.flatten().filter(e => e.matches(selector))\n  }\n\n  querySelector(selector: string) {\n    // Stops at the first match instead of collecting all elements first\n    return this._findElement(e => e.matches(selector))\n  }\n\n  getElementsByName(name: string) {\n    // DOM spec: only elements with a matching name attribute\n    return this.flatten().filter(e => e.getAttribute && e.getAttribute('name') === name)\n  }\n\n  //\n\n  parent(selector: string): any {\n    if (this.matches(selector))\n      return this\n    for (let node: VNodeQuery | null = this.parentNode; node; node = node.parentNode) {\n      if (node.matches(selector))\n        return node\n    }\n    return null\n  }\n\n  handle(selector: any, handler: (arg0: VElement, arg1: number) => void) {\n    let i = 0\n    for (const el of this.querySelectorAll(selector))\n      handler(el, i++)\n  }\n}\n\ninterface Attr {\n  name: string\n  value: string\n}\n\nexport type VElementStyle = Record<string, string> & {\n  get length(): number\n  getPropertyValue: (name: string) => any\n  cssText: string\n}\n\nexport class VElement extends VNodeQuery {\n  _originalTagName: string\n  _nodeName: string\n  _attributes: Record<string, string>\n  _styles: VElementStyle | undefined\n  _dataset: Record<string, string> | undefined\n\n  get nodeType() {\n    return VNode.ELEMENT_NODE\n  }\n\n  get nodeName() {\n    return this._nodeName\n  }\n\n  constructor(name = 'div', attrs = {}) {\n    super()\n    this._originalTagName = name\n    this._nodeName = (name || '').toUpperCase()\n    this._attributes = attrs || {}\n  }\n\n  cloneNode(deep = false) {\n    const node = super.cloneNode(deep)\n    node._originalTagName = this._originalTagName\n    node._nodeName = this._nodeName\n    node._attributes = Object.assign({}, this._attributes)\n    return node\n  }\n\n  get attributes(): Attr[] {\n    return Object.entries(this._attributes).map(([name, value]): Attr => ({ name, value }))\n    // return this._attributes\n  }\n\n  get attributesObject() {\n    return { ...this._attributes }\n  }\n\n  _findAttributeName(name: string) {\n    const search = name.toLowerCase()\n    return (\n      Object.keys(this._attributes).find(\n        name => search === name.toLowerCase(),\n      ) || null\n    )\n  }\n\n  setAttribute(name: string, value: any) {\n    this.removeAttribute(name)\n    if (value != null && value !== false) {\n      this._attributes[name] = value\n    }\n    this._styles = undefined\n    this._dataset = undefined\n  }\n\n  getAttribute(name: string): string | null {\n    const originalName = this._findAttributeName(name)\n    const value = originalName ? this._attributes[originalName] : null\n    if (value == null)\n      return null\n    else if (typeof value === 'string')\n      return value\n    else\n      return ''\n  }\n\n  removeAttribute(name: string | number) {\n    const originalName = this._findAttributeName(String(name))\n    if (originalName) {\n      delete this._attributes[originalName]\n      this._styles = undefined\n      this._dataset = undefined\n    }\n  }\n\n  hasAttribute(name: any) {\n    const originalName = this._findAttributeName(name)\n    return originalName\n      ? this._attributes[originalName] != null\n      : false\n  }\n\n  /// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style\n  get style(): VElementStyle {\n    if (this._styles == null) {\n      // const styles = Object.assign({}, DEFAULTS[this.tagName.toLowerCase()] || {})\n\n      const styles: Record<string, string> = {}\n      let count = 0\n\n      const styleString = this.getAttribute('style')\n      if (styleString) {\n        // `url(…)` may contain `;`, see https://github.com/holtwick/zeed-dom/issues/12#issuecomment-2148998665\n        for (const [name, value] of parseStyleDeclarations(styleString)) {\n          ++count\n          styles[name] = value\n          styles[toCamelCase(name)] = value\n        }\n      }\n      this._styles = {\n        get length(): number {\n          return count\n        },\n        getPropertyValue(name: string) {\n          return styles[name]\n        },\n\n        ...DEFAULTS[this.tagName.toLowerCase()],\n        ...styles,\n      }\n      // ProseMirror's DOMSerializer sets inline styles this way. Not\n      // enumerable, so it doesn't show up next to the style properties.\n      Object.defineProperty(this._styles, 'cssText', {\n        get: () => this.getAttribute('style') ?? '',\n        set: (value: string) => this.setAttribute('style', String(value ?? '')),\n      })\n    }\n    return this._styles!\n  }\n\n  /// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset\n  get dataset() {\n    if (this._dataset == null) {\n      const dataset: Record<string, string> = {}\n      for (const [key, value] of Object.entries(this._attributes)) {\n        if (key.startsWith('data-')) {\n          dataset[key.slice(5)] = value\n          dataset[toCamelCase(key.slice(5))] = value\n        }\n      }\n      this._dataset = dataset\n    }\n    return this._dataset\n  }\n\n  get tagName() {\n    return this._nodeName\n  }\n\n  /** Private function to easily change the tagName */\n  setTagName(name: string) {\n    this._originalTagName = name\n    this._nodeName = name.toUpperCase()\n  }\n\n  get id(): string | null {\n    return this._attributes.id || null\n  }\n\n  set id(value: string | null) {\n    if (value == null)\n      delete this._attributes.id\n    else this._attributes.id = value\n  }\n\n  get src(): string | null {\n    return this._attributes.src\n  }\n\n  set src(value: string | null) {\n    if (value == null)\n      delete this._attributes.src\n    else this._attributes.src = value\n  }\n\n  //\n\n  getElementsByTagName(name: string) {\n    name = name.toUpperCase()\n    const elements = this.flatten()\n    if (name !== '*')\n      return elements.filter(e => e.tagName === name)\n\n    return elements\n  }\n\n  // html\n\n  setInnerHTML(_html: string) {\n    // throw new Error('setInnerHTML is not implemented; see vdomparser for an example')\n  }\n\n  insertAdjacentHTML(\n    position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend',\n    text: string,\n  ) {\n    // throw new Error('setInnerHTML is not implemented; see vdomparser for an example')\n  }\n\n  get innerHTML() {\n    // htmlVDOM, NOT html: element renders pass their already-rendered children\n    // as one string; `html()` routes that through hArgumentParser's array\n    // branch, which escapes text AGAIN (double-escaping `&lt;` to `&amp;lt;`\n    // inside nested elements). outerHTML below uses the same correct path.\n    return this._childNodes.map(c => c.render(htmlVDOM)).join('')\n  }\n\n  set innerHTML(html) {\n    this.setInnerHTML(html)\n  }\n\n  get outerHTML() {\n    return this.render(htmlVDOM)\n  }\n\n  // class\n\n  get className(): string {\n    return this._attributes.class || ''\n  }\n\n  set className(name: string | string[]) {\n    if (Array.isArray(name)) {\n      name = name.filter(n => !!n).join(' ')\n    }\n    else if (typeof name === 'object') {\n      name = Object.entries(name)\n        .filter(([_k, v]) => !!v)\n        .map(([k, _v]) => k)\n        .join(' ')\n    }\n    this._attributes.class = name\n  }\n\n  get classList() {\n    const classNames = String(this.className ?? '').trim().split(/\\s+/g).filter(Boolean)\n    return {\n      get length() {\n        return classNames.length\n      },\n      [Symbol.iterator]() {\n        return classNames[Symbol.iterator]()\n      },\n      contains(s: any) {\n        return classNames.includes(s)\n      },\n      add: (s: any) => {\n        if (!classNames.includes(s)) {\n          classNames.push(s)\n          this.className = classNames\n        }\n      },\n      remove: (s: any) => {\n        const index = classNames.indexOf(s)\n        if (index >= 0) {\n          classNames.splice(index, 1)\n          this.className = classNames\n        }\n      },\n    }\n  }\n\n  //\n\n  render(h: any = htmlVDOM) {\n    // `html()` and `xml()` take their children through hArgumentParser, which\n    // escapes text, so the already rendered children would be escaped again.\n    // Use the markup variants that insert a children string as it is.\n    if (h.xml === true)\n      h = xmlVDOM\n    else if (h.html === true)\n      h = htmlVDOM\n    // Iterative, so deeply nested elements don't overflow the call stack.\n    // Each frame collects the rendered children of one element.\n    interface Frame { element: VElement, index: number, parts: any[] }\n    const stack: Frame[] = [\n      { element: this, index: 0, parts: [] },\n    ]\n    while (true) {\n      const frame = stack[stack.length - 1]!\n      const children = frame.element._childNodes\n      if (frame.index < children.length) {\n        const child = children[frame.index++]\n        if (child instanceof VElement && child.render === VElement.prototype.render)\n          stack.push({ element: child, index: 0, parts: [] })\n        else\n          frame.parts.push(child.render(h))\n        continue\n      }\n      const { element, parts } = frame\n      const result = h(\n        element._originalTagName || element.tagName,\n        element._attributes,\n        parts.join(''), // children:string is not escaped again\n      )\n      stack.pop()\n      if (!stack.length)\n        return result\n      stack[stack.length - 1]!.parts.push(result)\n    }\n  }\n}\n\nexport class VDocType extends VNode {\n  // todo\n\n  name: any\n  publicId: any\n  systemId: any\n\n  get nodeName(): string {\n    return super.nodeName\n  }\n\n  get nodeValue(): string | null {\n    return super.nodeValue\n  }\n\n  get nodeType(): number {\n    return VDocType.DOCUMENT_TYPE_NODE\n  }\n\n  render() {\n    return '<!DOCTYPE html>' // hack!\n  }\n}\n\nexport class VDocumentFragment extends VNodeQuery {\n  docType?: VDocType\n\n  get nodeType() {\n    return VNode.DOCUMENT_FRAGMENT_NODE\n  }\n\n  get nodeName() {\n    return '#document-fragment'\n  }\n\n  render(h = htmlVDOM) {\n    return this._childNodes.map(c => c.render(h) || []).join('')\n  }\n\n  get innerHTML() {\n    // htmlVDOM, NOT html — see VElement.innerHTML for the double-escape trap.\n    return this._childNodes.map(c => c.render(htmlVDOM)).join('')\n  }\n\n  createElement(name: string, attrs = {}) {\n    return new VElement(name, attrs)\n  }\n\n  createDocumentFragment() {\n    return new VDocumentFragment()\n  }\n\n  createTextNode(text?: string) {\n    return new VTextNode(text)\n  }\n}\n\nexport class VDocument extends VDocumentFragment {\n  get nodeType() {\n    return VNode.DOCUMENT_NODE\n  }\n\n  get nodeName() {\n    return '#document'\n  }\n\n  get documentElement() {\n    return this.firstChild\n  }\n\n  render(h = htmlVDOM) {\n    let content = super.render(h)\n    if (this.docType)\n      content = this.docType.render() + content\n    return content\n  }\n}\n\nexport class VHTMLDocument extends VDocument {\n  constructor(empty = false) {\n    super()\n    this.docType = new VDocType()\n    if (!empty) {\n      const html = new VElement('html')\n      const body = new VElement('body')\n      const head = new VElement('head')\n      const title = new VElement('title')\n      html.appendChild(head)\n      head.appendChild(title)\n      html.appendChild(body)\n      this.appendChild(html)\n    }\n  }\n\n  get body(): VElement {\n    let body = this.querySelector('body')\n    if (!body) {\n      let html = this.querySelector('html')\n      if (!html) {\n        html = new VElement('html')\n        this.appendChild(html)\n      }\n      body = new VElement('body')\n      html.appendChild(body)\n    }\n    return body\n  }\n\n  get title(): string {\n    return this.querySelector('title')?.textContent || ''\n  }\n\n  set title(title: string) {\n    const titleElement = this.querySelector('title')\n    if (titleElement)\n      titleElement.textContent = title\n  }\n\n  get head(): VElement {\n    let head = this.querySelector('head')\n    if (!head) {\n      let html = this.querySelector('html')\n      if (!html) {\n        html = new VElement('html')\n        this.appendChild(html)\n      }\n      head = new VElement('head')\n      html.insertBefore(head, html.firstChild)\n    }\n    return head\n  }\n}\n\nexport function createDocument(): VDocument {\n  return new VDocument()\n}\n\nexport function createHTMLDocument(): VHTMLDocument {\n  return new VHTMLDocument()\n}\n\nexport const document = createDocument()\nexport const h = hFactory({ document })\n\nexport function isVElement(n: VNode): n is VElement {\n  return n.nodeType === VNode.ELEMENT_NODE\n}\n\nexport function isVTextElement(n: VNode): n is VTextNode {\n  return n.nodeType === VNode.TEXT_NODE\n}\n\nexport function isVDocument(n: VNode): n is VDocument {\n  return n.nodeType === VNode.DOCUMENT_NODE\n}\n","import type { VNodeQuery } from './vdom'\nimport { VDocumentFragment } from './vdom'\n\nexport function removeBodyContainer(body: VNodeQuery): VNodeQuery {\n  const ehead = body.querySelector('head')\n  const ebody = body.querySelector('body')\n  if (ebody || ehead) {\n    const body = new VDocumentFragment()\n    if (ehead) {\n      body.appendChild(ehead.childNodes)\n    }\n    if (ebody) {\n      body.appendChild(ebody.children)\n    }\n    return body\n  }\n  return body\n}\n\nconst object = {}\nconst hasOwnProperty = object.hasOwnProperty\n\n/** Fallback for Object.hasOwn */\nexport function hasOwn(object: any, propertyName: string) {\n  return hasOwnProperty.call(object, propertyName)\n}\n","// Special cases:\n// 1. <noop> is an element that is not printed out, can be used to create a list of elements\n// 2. Attribute name '__' gets transformed to ':' for namespace emulation\n// 3. Emulate CDATA by <cdata> element\n\nimport type { VDocumentFragment, VElement } from './vdom'\nimport { escapeHTML } from './encoding'\nimport { hArgumentParser } from './h'\nimport { hasOwn } from './utils'\n\nexport const SELF_CLOSING_TAGS = [\n  'area',\n  'base',\n  'br',\n  'col',\n  'embed',\n  'hr',\n  'img',\n  'input',\n  'keygen',\n  'link',\n  'meta',\n  'param',\n  'source',\n  'track',\n  'wbr',\n  'command',\n]\n\nconst SELF_CLOSING_SET = new Set(SELF_CLOSING_TAGS)\n\n// A tag or attribute name containing one of these would end the tag early\n// and let the rest of the name become attributes or markup, for example\n// `setAttribute('x onload=alert(1)', '')`. Browsers reject such names with an\n// `InvalidCharacterError`. The parser never produces them, it ends names there.\nconst INVALID_TAG_NAME_RE = /[\\s/>]/\n// `=` is allowed at the start, `<a =x>` is parsed to an attribute `=x` like in browsers\nconst INVALID_ATTRIBUTE_NAME_RE = /[\\s>]|.=/\n\n/**\n * Markup that is inserted as it is when used as a child of `html()` or the\n * JSX runtime. Returned by `htmlStrict()`, the strict JSX runtime and `raw()`.\n */\nexport class HTMLString extends String {}\n\nfunction renderChild(child: any, tag: string, strict: boolean): string {\n  if (child instanceof HTMLString)\n    return child.toString()\n  if (tag === 'script' || tag === 'style') {\n    // Strict: `<\\/script>` means the same in JavaScript strings and CSS, but\n    // can't end the element\n    return strict\n      ? String(child).replace(/<\\//g, '<\\\\/')\n      : child\n  }\n  // Not strict: a string looking like markup is taken as markup, because\n  // nested `html()` calls return plain strings. Untrusted text that starts\n  // with `<` and ends with `>` is inserted unescaped, see `htmlStrict()`.\n  if (!strict && typeof child === 'string' && child.startsWith('<') && child.endsWith('>'))\n    return child\n  return escapeHTML(child.toString())\n}\n\nexport const CDATA = (s: string) => `<![CDATA[${s}]]>`\nexport const HTML = (s: string) => s\n\n// export function prependXMLIdentifier(s) {\n//   return '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n' + s\n// }\n\n// https://reactjs.org/docs/jsx-in-depth.html\nexport function markup(\n  xmlMode: boolean,\n  tag: string,\n  attrs: any = {},\n  children?: any[] | string,\n  strict = false,\n) {\n  const hasChildren = !(\n    (typeof children === 'string' && children === '')\n    || (Array.isArray(children)\n      && (children.length === 0\n        || (children.length === 1 && children[0] === '')))\n      || children == null\n  )\n\n  let out = ''\n  if (tag.includes('__'))\n    tag = tag.replace(/__/g, ':')\n  if (INVALID_TAG_NAME_RE.test(tag))\n    throw new Error(`Invalid tag name: ${JSON.stringify(tag)}`)\n\n  // The `html` prop of `html()` / JSX inserts raw markup. An element of the\n  // VDOM renders with its children as one string, there `html` is an ordinary\n  // attribute: it may come from parsed, untrusted HTML like `<div html=\"…\">`.\n  const rawHTML = typeof children === 'string'\n    ? undefined\n    : attrs.html\n\n  // React fragment <>...</> and ours: <noop>...</noop>\n  if (tag !== 'noop' && tag !== '') {\n    if (tag !== 'cdata') {\n      out += `<${tag}`\n    }\n    else {\n      out += '<![CDATA['\n    }\n\n    // Add attributes\n    for (let name in attrs) {\n      if (!name || !hasOwn(attrs, name))\n        continue\n      const v = attrs[name]\n      if (name === 'html' && typeof children !== 'string')\n        continue\n      if (name.length === 9 && name.toLowerCase() === 'classname')\n        name = 'class'\n      if (name.includes('__'))\n        name = name.replace(/__/g, ':')\n      if (INVALID_ATTRIBUTE_NAME_RE.test(name))\n        continue\n      if (v === true) {\n        out += ` ${name}`\n      }\n      else if (name === 'style' && typeof v === 'object' && !(v instanceof HTMLString)) {\n        const styleStr = Object.entries(v)\n          .filter(([, val]) => val != null)\n          .map(([k, val]) => {\n            const vv = typeof val === 'number'\n              ? `${val}px`\n              : val\n            return `${k.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}:${vv}`\n          })\n          .join(';')\n        if (styleStr)\n          out += ` ${name}=\"${escapeHTML(styleStr)}\"`\n      }\n      else if (v !== false && v != null) {\n        out += ` ${name}=\"${escapeHTML(v.toString())}\"`\n      }\n    }\n\n    const isSelfClosing = !xmlMode && SELF_CLOSING_SET.has(tag)\n    if (tag !== 'cdata') {\n      if (xmlMode && !hasChildren) {\n        out += ' />'\n        return out\n      }\n      else {\n        out += '>'\n      }\n    }\n    if (isSelfClosing)\n      return out\n  }\n\n  // Append children\n  if (hasChildren) {\n    if (typeof children === 'string') {\n      out += children\n    }\n    else if (children && children.length > 0) {\n      for (const child of children) {\n        if (child == null || child === false)\n          continue\n        if (Array.isArray(child)) {\n          for (const c of child) {\n            if (c == null || c === false)\n              continue\n            out += renderChild(c, tag, strict)\n          }\n        }\n        else {\n          out += renderChild(child, tag, strict)\n        }\n      }\n    }\n  }\n\n  if (rawHTML)\n    out += rawHTML\n\n  if (tag !== 'noop' && tag !== '') {\n    if (tag !== 'cdata') {\n      out += `</${tag}>`\n    }\n    else {\n      out += ']]>'\n    }\n  }\n  return out\n}\n\nexport function html(\n  tag: string | ((props: any) => VDocumentFragment | VElement),\n  attrs?: Record<string, unknown> | unknown[] | null,\n  ...children: unknown[]\n): string {\n  const parsed = hArgumentParser(tag, attrs, ...children)\n  return markup(false, parsed.tag as string, parsed.attrs, parsed.children)\n}\n\nexport const htmlVDOM = markup.bind(null, false)\nexport const xmlVD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