var e=Object.defineProperty;import{p as t}from"./purify.es.fbbbfcb0.js";const r=class{constructor(){this.initializeDOMPurify()}static getInstance(){return r.instance||(r.instance=new r),r.instance}initializeDOMPurify(){t.addHook("beforeSanitizeElements",(e=>{if(e.nodeName&&e.nodeName.match(/svg|foreignObject|g|path|circle|rect|line|text/i))return e})),t.addHook("beforeSanitizeAttributes",(e=>{e.hasAttribute("onclick")&&e.removeAttribute("onclick"),e.hasAttribute("onload")&&e.removeAttribute("onload"),e.hasAttribute("onerror")&&e.removeAttribute("onerror")}))}sanitizeHTML(e,r=!0){const i={ALLOWED_TAGS:r?["svg","g","path","circle","rect","line","text","foreignObject","div","span","p","br"]:["div","span","p","br","strong","em"],ALLOWED_ATTR:r?["d","cx","cy","r","x","y","width","height","fill","stroke","stroke-width","class","id","style"]:["class","id","style"],FORBID_ATTR:["onclick","onload","onerror","onmouseover","onmouseout"],FORBID_TAGS:["script","iframe","object","embed","link"],USE_PROFILES:{html:!0,svg:r,svgFilters:!1}};return t.sanitize(e,i)}sanitizeSVG(e){return t.sanitize(e,{ALLOWED_TAGS:["svg","g","path","circle","rect","line","text","tspan","defs","marker","use","symbol","clipPath","mask"],ALLOWED_ATTR:["d","cx","cy","r","x","y","x1","y1","x2","y2","width","height","fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","transform","class","id","viewBox","xmlns","marker-start","marker-end","clip-path","mask"],FORBID_ATTR:["onclick","onload","onerror","style"],FORBID_TAGS:["script","foreignObject","iframe"],USE_PROFILES:{svg:!0,svgFilters:!0}})}validateInput(e,t="text"){if(!e||"string"!=typeof e)return"";let r=e.replace(/[\x00-\x1F\x7F]/g,"");switch(t){case"number":r=r.replace(/[^0-9.-]/g,"");break;case"email":r=r.replace(/[^a-zA-Z0-9@._-]/g,"");break;case"filename":r=r.replace(/[^a-zA-Z0-9._-]/g,"");break;default:r=this.sanitizeHTML(r,!1)}return r.trim()}safeSetInnerHTML(e,t,r=!1){if(!e||"string"!=typeof t)return;const i=this.sanitizeHTML(t,r);e.innerHTML=i}generateSecureId(e="t3"){const t=crypto.getRandomValues(new Uint8Array(8));return`${e}_${Array.from(t,(e=>e.toString(16).padStart(2,"0"))).join("")}`}validateFile(e,t=[],r=10485760){if(!e)return{valid:!1,error:"No file provided"};if(e.size>r)return{valid:!1,error:`File size exceeds ${r/1024/1024}MB limit`};if(t.length>0&&!t.includes(e.type))return{valid:!1,error:`File type ${e.type} not allowed`};const i=e.name.toLowerCase();return[".exe",".bat",".cmd",".scr",".pif",".com",".js",".vbs"].some((e=>i.endsWith(e)))?{valid:!1,error:"Dangerous file extension detected"}:{valid:!0}}};let i=r;var n,a;((t,r,i)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[r]=i})(i,"symbol"!=typeof(n="instance")?n+"":n,a);const s=i.getInstance();export{s as T3Security,i as T3SecurityUtil,s as default};
