{"version":3,"file":"sanitize-html.cjs","names":[],"sources":["../src/html/sanitize-html.ts"],"sourcesContent":["/**\n * @internal Separate chunk so DOMPurify is tree-shaken away when `sanitizeHtml` is not used.\n * Consumers import from `yummies/html` — this module is not a public entry point.\n */\n\nimport DOMPurify, { type Config as DOMPurifyConfig } from 'dompurify';\nimport type { Maybe } from 'yummies/types';\n\ntype SanitizeHtmlFn = ((\n  html: Maybe<string>,\n  config?: DOMPurifyConfig,\n) => string) & {\n  /**\n   * Default DOMPurify settings\n   */\n  defaults: DOMPurifyConfig;\n};\n/**\n * Sanitizes HTML using the default allowlist merged with custom DOMPurify config.\n *\n * Default DOMPurify settings are exposed on `sanitizeHtml.defaults` and can be\n * overridden per call via `config`.\n *\n * @example\n * ```ts\n * sanitizeHtml('<img src=x onerror=alert(1) />');\n * ```\n */\nexport const sanitizeHtml = ((\n  html: Maybe<string>,\n  config?: DOMPurifyConfig,\n) => {\n  return DOMPurify.sanitize(html || '', {\n    ...sanitizeHtml.defaults,\n    ...config,\n  });\n}) as SanitizeHtmlFn;\n\nsanitizeHtml.defaults = {\n  ALLOWED_TAGS: [\n    'a',\n    'article',\n    'b',\n    'blockquote',\n    'br',\n    'caption',\n    'code',\n    'del',\n    'details',\n    'div',\n    'em',\n    'h1',\n    'h2',\n    'h3',\n    'h4',\n    'h5',\n    'h6',\n    'hr',\n    'i',\n    'img',\n    'ins',\n    'kbd',\n    'li',\n    'main',\n    'ol',\n    'p',\n    'pre',\n    'section',\n    'span',\n    'strong',\n    'sub',\n    'summary',\n    'sup',\n    'table',\n    'tbody',\n    'td',\n    'th',\n    'thead',\n    'tr',\n    'u',\n    'ul',\n  ],\n  ALLOWED_ATTR: ['href', 'target', 'name', 'src', 'class'],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,iBACX,MACA,WACG;CACH,OAAO,UAAA,QAAU,SAAS,QAAQ,IAAI;EACpC,GAAG,aAAa;EAChB,GAAG;CACL,CAAC;AACH;AAEA,aAAa,WAAW;CACtB,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,cAAc;EAAC;EAAQ;EAAU;EAAQ;EAAO;CAAO;AACzD"}