{"version":3,"sources":["../src/jsx-runtime.ts","../src/encoding.ts","../src/h.ts","../src/vcss.ts","../src/vdom.ts","../src/utils.ts","../src/html.ts"],"sourcesContent":["import { h } from './html'\n\n// See\n// https://esbuild.github.io/api/#jsx-import-source\n// https://www.typescriptlang.org/tsconfig/#jsxImportSource\n\nexport {\n  h as jsx,\n  h as jsxs,\n  h as jsxDEV,\n  h,\n}\n","// import { decode } from './encoding-he'\nimport { decodeHTML as decode } from 'entities'\n\nexport function escapeHTML(text: string) {\n  return text\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/'/g, '&apos;')\n    .replace(/\"/g, '&quot;')\n    .replace(/\\xA0/g, '&nbsp;')\n    .replace(/\\xAD/g, '&shy;')\n}\n\n// encode(text, {\n//   useNamedReferences: true,\n// })\n\nexport const unescapeHTML = (html: string) => decode(html)\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 (let [key, value] of Object.entries(attrs)) {\n        key = key.toString()\n        const compareKey = key.toLowerCase()\n        if (compareKey === 'classname') {\n          element.className = value\n        }\n        else if (compareKey === 'on') {\n          Object.entries(value).forEach(([name, value]) => {\n            element.setAttribute(`on${name}`, String(value))\n          })\n          // else if (key.indexOf('on') === 0) {\n          //   if (el.addEventListener) {\n          //     el.addEventListener(key.substring(2), value)\n          //     continue\n          //   }\n        }\n        else if (value !== false && value != null) {\n          if (value === true)\n            element.setAttribute(key, key)\n          else\n            element.setAttribute(key, value.toString())\n        }\n      }\n    }\n    if (children) {\n      for (const childOuter of children) {\n        const cc = Array.isArray(childOuter) ? [...childOuter] : [childOuter]\n        for (const child of cc) {\n          if (child) {\n            if (child !== false && child != null) {\n              if (typeof child !== 'object') {\n                el.appendChild(\n                  context.document.createTextNode(child.toString()),\n                )\n              }\n              else {\n                el.appendChild(child)\n              }\n            }\n          }\n        }\n      }\n    }\n    return el\n  }\n}\n\nexport function hArgumentParser(tag: any, attrs: any, ...children: any[]) {\n  if (typeof tag === 'object') {\n    tag = 'fragment'\n    children = tag.children\n    attrs = tag.attrs\n  }\n  if (Array.isArray(attrs)) {\n    children = [attrs]\n    attrs = {}\n  }\n  else if (attrs) {\n    if (attrs.attrs) {\n      attrs = { ...attrs.attrs, ...attrs }\n      delete attrs.attrs\n    }\n  }\n  else {\n    attrs = {}\n  }\n  return {\n    tag,\n    attrs,\n    children:\n      typeof children[0] === 'string' ? children : 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","import type { VElement } from './vdom'\nimport { parse } from 'css-what'\n\nfunction log(..._args: any) {}\n\n// Alternative could be https://github.com/leaverou/parsel\n\nconst cache: Record<string, any> = {}\n\nexport function parseSelector(selector: string) {\n  let ast = cache[selector]\n  if (ast == null) {\n    ast = parse(selector)\n    cache[selector] = ast\n  }\n  return ast\n}\n\n// Just a very small subset for now: https://github.com/fb55/css-what#api\n\nexport function matchSelector(\n  selector: string,\n  element: VElement,\n  { debug = false } = {},\n) {\n  for (const rules of parseSelector(selector)) {\n    if (debug) {\n      log('Selector:', selector)\n      log('Rules:', rules)\n      log('Element:', element)\n    }\n\n    const handleRules = (element: VElement, rules: any[]) => {\n      // let pos = 0\n      let success = false\n      for (const part of rules) {\n        const { type, name, action, value, _ignoreCase = true, data } = part\n        if (type === 'attribute') {\n          if (action === 'equals') {\n            success = element.getAttribute(name) === value\n            if (debug)\n              log('Attribute equals', success)\n          }\n          else if (action === 'start') {\n            success = !!element.getAttribute(name)?.startsWith(value)\n            if (debug)\n              log('Attribute start', success)\n          }\n          else if (action === 'end') {\n            success = !!element.getAttribute(name)?.endsWith(value)\n            if (debug)\n              log('Attribute start', success)\n          }\n          else if (action === 'element') {\n            if (name === 'class') {\n              success = element.classList.contains(value)\n              if (debug)\n                log('Attribute class', success)\n            }\n            else {\n              success = !!element.getAttribute(name)?.includes(value)\n              if (debug)\n                log('Attribute element', success)\n            }\n          }\n          else if (action === 'exists') {\n            success = element.hasAttribute(name)\n            if (debug)\n              log('Attribute exists', success)\n          }\n          else if (action === 'any') {\n            success = !!element.getAttribute(name)?.includes(value)\n            if (debug)\n              log('Attribute any', success)\n          }\n          else {\n            console.warn('Unknown CSS selector action', action)\n          }\n        }\n        else if (type === 'tag') {\n          success = element.tagName === name.toUpperCase()\n          if (debug)\n            log('Is tag', success)\n        }\n        else if (type === 'universal') {\n          success = true\n          if (debug)\n            log('Is universal', success)\n        }\n        else if (type === 'pseudo') {\n          if (name === 'not') {\n            let ok = true\n            data.forEach((rules: any) => {\n              if (!handleRules(element, rules))\n                ok = false\n            })\n            success = !ok\n          }\n          if (debug)\n            log('Is :not', success)\n          // } else if (type === 'descendant') {\n          //   element = element.\n        }\n        // else if (type === 'descendant') {\n        //   for (const child of element.childNodes)\n        //     handleRules(child, rules.slice(pos))\n        // }\n        else {\n          console.warn('Unknown CSS selector type', type, selector, rules)\n        }\n        // log(success, selector, part, element)\n        if (!success)\n          break\n\n        // pos += 1\n      }\n      return success\n    }\n\n    if (handleRules(element, rules))\n      return true\n  }\n  return false\n}\n","import { escapeHTML } from './encoding'\nimport { hFactory } from './h'\nimport { html, htmlVDOM } from './html'\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\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    // @ts-expect-error xxx\n    const node = new this.constructor()\n    if (deep) {\n      node._childNodes = this._childNodes.map(c => c.cloneNode(true))\n      node._fixChildNodesParent()\n    }\n    return node\n  }\n\n  _fixChildNodesParent() {\n    this._childNodes.forEach(node => (node._parentNode = this))\n  }\n\n  insertBefore(newNode: VNode, node?: VNode) {\n    if (newNode !== node) {\n      let index = node ? this._childNodes.indexOf(node) : 0\n      if (index < 0)\n        index = 0\n      this._childNodes.splice(index, 0, newNode)\n      this._fixChildNodesParent()\n    }\n  }\n\n  appendChild(node: VNode | VNode[] | string | string[] | null | undefined) {\n    if (node == null)\n      return\n    if (node === this) {\n      console.warn('Cannot appendChild to self')\n      return\n    }\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      this._childNodes.push(node)\n    }\n    else {\n      // Fallback for unknown data\n      try {\n        const text\n          = typeof node === 'string' ? node : JSON.stringify(node, null, 2)\n        this._childNodes.push(new VTextNode(text))\n      }\n      catch (err) {\n        console.error(`The data ${node} to be added to ${this.render()} is problematic: ${err}`)\n      }\n    }\n    this._fixChildNodesParent()\n  }\n\n  append = this.appendChild\n\n  removeChild(node: { _parentNode: null }) {\n    const i = this._childNodes.indexOf(node)\n    if (i >= 0) {\n      node._parentNode = null\n      this._childNodes.splice(i, 1)\n      this._fixChildNodesParent()\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    this._childNodes = nodes.map(n =>\n      typeof n === 'string' ? new VTextNode(n) : n.remove(),\n    )\n    this._fixChildNodesParent()\n  }\n\n  /** Replace node itself with nodes */\n  replaceWith(...nodes: any[]) {\n    const p = this._parentNode\n    if (p) {\n      const index = this._indexInParent()\n      if (index >= 0) {\n        nodes = nodes.map(n =>\n          typeof n === 'string' ? new VTextNode(n) : n.remove(),\n        )\n        p._childNodes.splice(index, 1, ...nodes)\n        this._parentNode = null\n        p._fixChildNodesParent()\n      }\n    }\n  }\n\n  _indexInParent() {\n    if (this._parentNode)\n      return this._parentNode.childNodes.indexOf(this)\n    return -1\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 || []\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 != null)\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  flatten(): VElement[] {\n    const elements: VElement[] = []\n    if (this instanceof VElement)\n      elements.push(this)\n    for (const child of this._childNodes)\n      elements.push(...child.flatten())\n    return elements\n  }\n\n  flattenNodes(): VNode[] {\n    const nodes: VNode[] = []\n    nodes.push(this)\n    for (const child of this._childNodes)\n      nodes.push(...child.flattenNodes())\n    return nodes\n  }\n\n  render() {\n    return ''\n  }\n\n  get textContent(): string | null {\n    return this._childNodes.map(c => c.textContent).join('')\n  }\n\n  set textContent(text) {\n    this._childNodes = []\n    if (text)\n      this.appendChild(new VTextNode(text.toString()))\n  }\n\n  contains(otherNode: this) {\n    if (otherNode === this)\n      return true\n    // if (this._childNodes.includes(otherNode)) return true\n    return this._childNodes.some(n => n.contains(otherNode))\n  }\n\n  get ownerDocument() {\n    if (this.nodeType === VNode.DOCUMENT_NODE || this.nodeType === VNode.DOCUMENT_FRAGMENT_NODE)\n      return this\n\n    return this?._parentNode?.ownerDocument\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\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  get textContent(): string | null {\n    return this.nodeValue\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  getElementById(name: string) {\n    return this.flatten().find(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    return this.flatten().find(e => e.matches(selector))\n  }\n\n  //\n\n  parent(selector: string) {\n    if (this.matches(selector))\n      return this\n\n    if (this.parentNode == null)\n      return null\n\n    return this.parentNode?.parent(selector)\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}\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: string) {\n    this.removeAttribute(name)\n    this._attributes[name] = value\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[name]\n  }\n\n  hasAttribute(name: any) {\n    const originalName = this._findAttributeName(name)\n    return originalName ? this._attributes[originalName] != null : 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        let m: string[] | null\n\n        // Thanks to https://github.com/holtwick/zeed-dom/issues/12#issuecomment-2148998665\n        const re = /\\s*([\\w-]+)\\s*:\\s*((url\\(.*?\\)[^;]*|[^;]+))/gi\n\n        // eslint-disable-next-line no-cond-assign\n        while ((m = re.exec(styleString))) {\n          ++count\n          const name = m[1]\n          const value = m[2].trim()\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    }\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._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  get innerHTML() {\n    return this._childNodes.map(c => c.render(html)).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) || []\n    // log('classList', classNames)\n    return {\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 = htmlVDOM) {\n    return h(\n      this._originalTagName || this.tagName,\n      this._attributes,\n      this._childNodes.map(c => c.render(h)).join(''), // children:string is not escaped again\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    // for debug\n    return this._childNodes.map(c => c.render(html)).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(html)\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(html)\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 { 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\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) {\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  const parts: string[] = []\n  tag = tag.replace(/__/g, ':')\n\n  // React fragment <>...</> and ours: <noop>...</noop>\n  if (tag !== 'noop' && tag !== '') {\n    if (tag !== 'cdata')\n      parts.push(`<${tag}`)\n    else\n      parts.push('<![CDATA[')\n\n    // Add attributes\n    for (let name in attrs) {\n      if (name && hasOwn(attrs, name)) {\n        const v = attrs[name]\n        if (name === 'html')\n          continue\n\n        if (name.toLowerCase() === 'classname')\n          name = 'class'\n\n        name = name.replace(/__/g, ':')\n        if (v === true) {\n          // s.push( ` ${name}=\"${name}\"`)\n          parts.push(` ${name}`)\n        }\n        else if (name === 'style' && typeof v === 'object') {\n          parts.push(\n            ` ${name}=\"${Object.keys(v)\n              .filter(k => v[k] != null)\n              .map((k) => {\n                let vv = v[k]\n                vv = typeof vv === 'number' ? `${vv}px` : vv\n                return `${k\n                  .replace(/([a-z])([A-Z])/g, '$1-$2')\n                  .toLowerCase()}:${vv}`\n              })\n              .join(';')}\"`,\n          )\n        }\n        else if (v !== false && v != null) {\n          parts.push(` ${name}=\"${escapeHTML(v.toString())}\"`)\n        }\n      }\n    }\n\n    if (tag !== 'cdata') {\n      if (xmlMode && !hasChildren) {\n        parts.push(' />')\n        return parts.join('')\n      }\n      else {\n        parts.push('>')\n      }\n    }\n\n    if (!xmlMode && SELF_CLOSING_TAGS.includes(tag))\n      return parts.join('')\n  }\n\n  // Append children\n  if (hasChildren) {\n    if (typeof children === 'string') {\n      parts.push(children)\n    }\n    else if (children && children.length > 0) {\n      for (let child of children) {\n        if (child != null && child !== false) {\n          if (!Array.isArray(child))\n            child = [child]\n\n          for (const c of child) {\n            // todo: this fails if textContent starts with `<` and ends with `>`\n            if (\n              (c.startsWith('<') && c.endsWith('>'))\n              || tag === 'script'\n              || tag === 'style'\n            ) {\n              parts.push(c)\n            }\n            else {\n              parts.push(escapeHTML(c.toString()))\n            }\n          }\n        }\n      }\n    }\n  }\n\n  if (attrs.html)\n    parts.push(attrs.html)\n\n  if (tag !== 'noop' && tag !== '') {\n    if (tag !== 'cdata')\n      parts.push(`</${tag}>`)\n    else\n      parts.push(']]>')\n  }\n  return parts.join('')\n}\n\nexport function html(itag: string, iattrs?: object, ...ichildren: any[]) {\n  const { tag, attrs, children } = hArgumentParser(itag, iattrs, ichildren)\n  return markup(false, tag, attrs, children)\n}\n\nexport const htmlVDOM = markup.bind(null, false)\n\nhtml.firstLine = '<!DOCTYPE html>'\nhtml.html = true\n\nexport const h = html\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,WAAAA;AAAA,EAAA,WAAAA;AAAA,EAAA,cAAAA;AAAA,EAAA,YAAAA;AAAA;AAAA;;;ACCA,sBAAqC;AAE9B,SAAS,WAAW,MAAc;AACvC,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,SAAS,QAAQ,EACzB,QAAQ,SAAS,OAAO;A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