import DOMPurify from "dompurify";
/**
 * Sanitize SVG markup from CMS/backend sources.
 * Allows SVG elements and presentation attributes but strips scripts and event handlers.
 */
export function sanitizeSvg(dirty) {
    return DOMPurify.sanitize(dirty, {
        USE_PROFILES: { svg: true, svgFilters: true },
        ADD_TAGS: ["use"],
        ADD_ATTR: ["xmlns", "xmlns:xlink", "viewBox", "fill", "stroke", "stroke-width", "stroke-linecap", "stroke-linejoin", "d", "cx", "cy", "r", "rx", "ry", "x", "y", "x1", "y1", "x2", "y2", "width", "height", "transform", "opacity", "clip-path", "clip-rule", "fill-rule", "fill-opacity", "stroke-opacity", "stroke-dasharray", "stroke-dashoffset"],
    });
}
/**
 * Sanitize rich text HTML from CMS fields, AI responses, and user-generated content.
 * Allows standard formatting tags but strips scripts, iframes, and event handlers.
 */
export function sanitizeHtml(dirty) {
    return DOMPurify.sanitize(dirty, {
        USE_PROFILES: { html: true },
        ALLOWED_TAGS: [
            "h1", "h2", "h3", "h4", "h5", "h6",
            "p", "br", "hr",
            "ul", "ol", "li",
            "strong", "b", "em", "i", "u", "s", "del", "ins", "sub", "sup",
            "a", "span", "div",
            "table", "thead", "tbody", "tfoot", "tr", "th", "td",
            "blockquote", "pre", "code",
            "img",
        ],
        ALLOWED_ATTR: [
            "href", "target", "rel", "title", "alt", "src",
            "class", "style",
            "colspan", "rowspan", "scope",
            "width", "height",
        ],
        ADD_ATTR: ["target"],
        ALLOW_DATA_ATTR: false,
    });
}
//# sourceMappingURL=sanitize.js.map