import sanitize from 'sanitize-html';
const DEFAULT_ALLOWED_TAGS = [
    'p',
    'br',
    'b',
    'i',
    'em',
    'strong',
    'a',
    'ul',
    'ol',
    'li',
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
    'blockquote',
    'code',
    'pre',
    'img',
    'figure',
    'figcaption',
    'table',
    'thead',
    'tbody',
    'tr',
    'th',
    'td',
    'span',
    'div',
    'hr',
    'sub',
    'sup',
    's',
    'u',
    'mark',
];
const DEFAULT_ALLOWED_ATTRS = {
    a: ['href', 'title', 'target', 'rel'],
    img: ['src', 'alt', 'title', 'width', 'height', 'loading'],
    td: ['colspan', 'rowspan'],
    th: ['colspan', 'rowspan', 'scope'],
};
/** Sanitize HTML content. Strips dangerous tags/attributes while preserving safe content. */
export function sanitizeHtml(html, options) {
    if (options?.stripAll) {
        return sanitize(html, { allowedTags: [], allowedAttributes: {} });
    }
    const tags = options?.allowedTags ?? DEFAULT_ALLOWED_TAGS;
    const attrs = options?.allowedAttributes ?? DEFAULT_ALLOWED_ATTRS;
    return sanitize(html, {
        allowedTags: tags,
        allowedAttributes: attrs,
        disallowedTagsMode: 'discard',
    });
}
/** Strip all HTML tags, returning plain text. */
export function stripHtml(html) {
    return sanitize(html, { allowedTags: [], allowedAttributes: {} }).trim();
}
export { DEFAULT_ALLOWED_TAGS, DEFAULT_ALLOWED_ATTRS };
//# sourceMappingURL=sanitize.js.map