import{t}from"./p-b75ee3ba.js";class s{constructor(){this.preserveTextContent=!0}execute(t,s){var e;switch(t.nodeType){case Node.TEXT_NODE:return this.preserveTextContent?s.createTextNode(null!==(e=t.textContent)&&void 0!==e?e:""):null;case Node.ELEMENT_NODE:return this.sanitizeElement(t,s);default:return null}}sanitizeElement(t,s){var e;const n=t.tagName;if(!this.allowedTags.has(n)){const e=s.createDocumentFragment();return t.childNodes.forEach((t=>{const n=this.execute(t,s);n&&e.appendChild(n)})),e}const r=s.createElement(n.toLowerCase()),c=null===(e=this.allowedAttributes)||void 0===e?void 0:e.get(n);return c&&Array.from(t.attributes).forEach((t=>{c.has(t.name)&&r.setAttribute(t.name,t.value)})),t.childNodes.forEach((t=>{const e=this.execute(t,s);e&&r.appendChild(e)})),r}}const e=new Set(["B","I","STRONG","EM"]),n=new class{sanitize(s,e){if(!s||""===s.trim())return"";const n=t();if(!n)return"";const r=(new DOMParser).parseFromString(s,"text/html"),c=n.createDocumentFragment();return r.body.childNodes.forEach((t=>{const s=e.execute(t,n);s&&c.appendChild(s)})),function(t,s){var e;const n=s.createElement("div");return n.appendChild(t),0===n.children.length?null!==(e=n.textContent)&&void 0!==e?e:"":n.innerHTML}(c,n)}},r=new class extends s{constructor(){super(...arguments),this.allowedTags=e}},c=new class extends s{constructor(){super(...arguments),this.allowedTags=new Set,this.preserveTextContent=!0}execute(t,s){var e;switch(t.nodeType){case Node.TEXT_NODE:{const n=null!==(e=t.textContent)&&void 0!==e?e:"";return this.isSafeCss(n)?s.createTextNode(n):null}case Node.ELEMENT_NODE:{const e=s.createDocumentFragment();return t.childNodes.forEach((t=>{const n=this.execute(t,s);n&&e.appendChild(n)})),e}default:return null}}isSafeCss(t){return!/expression\s*\(|javascript:|url\s*\(/i.test(t)}},u=new class extends s{constructor(){super(...arguments),this.allowedTags=new Set,this.preserveTextContent=!1}execute(){return null}};export{u as e,n as h,r as l,c as s}