{"version":3,"file":"html-to-dom.mjs","names":[],"sources":["../../src/client/html-to-dom.ts"],"sourcesContent":["import type { HTMLDOMParserOptions } from '../types';\nimport domparser from './domparser';\nimport { formatDOM } from './utilities';\n\nconst DIRECTIVE_REGEX = /<(![a-zA-Z\\s]+)>/; // e.g., <!doctype html>\n\n/**\n * Parses HTML string to DOM nodes in browser.\n *\n * @param html - HTML markup.\n * @param options - Parser options.\n * @returns - DOM elements.\n */\nexport default function HTMLDOMParser(\n  html: string,\n  options?: HTMLDOMParserOptions,\n) {\n  if (typeof html !== 'string') {\n    throw new TypeError('First argument must be a string');\n  }\n\n  if (!html) {\n    return [];\n  }\n\n  // match directive\n  const match = DIRECTIVE_REGEX.exec(html);\n  const directive = match ? match[1] : undefined;\n\n  return formatDOM(\n    domparser(html, options?.trustedTypePolicy),\n    null,\n    directive,\n  );\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB;;;;;;;;AASxB,SAAwB,cACtB,MACA,SACA;CACA,IAAI,OAAO,SAAS,UAClB,MAAM,IAAI,UAAU,iCAAiC;CAGvD,IAAI,CAAC,MACH,OAAO,CAAC;CAIV,MAAM,QAAQ,gBAAgB,KAAK,IAAI;CACvC,MAAM,YAAY,QAAQ,MAAM,KAAK,KAAA;CAErC,OAAO,UACL,UAAU,MAAM,SAAS,iBAAiB,GAC1C,MACA,SACF;AACF"}