ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
4 lines (3 loc) • 29 kB
JavaScript
function Pt(r,i){(i==null||i>r.length)&&(i=r.length);for(var s=0,l=Array(i);s<i;s++)l[s]=r[s];return l}function vn(r){if(Array.isArray(r))return r}function Ln(r,i){var s=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(s!=null){var l,f,d,S,ce=[],C=!0,ge=!1;try{if(d=(s=s.call(r)).next,i!==0)for(;!(C=(l=d.call(s)).done)&&(ce.push(l.value),ce.length!==i);C=!0);}catch(J){ge=!0,f=J}finally{try{if(!C&&s.return!=null&&(S=s.return(),Object(S)!==S))return}finally{if(ge)throw f}}return ce}}function wn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cn(r,i){return vn(r)||Ln(r,i)||Mn(r,i)||wn()}function Mn(r,i){if(r){if(typeof r=="string")return Pt(r,i);var s={}.toString.call(r).slice(8,-1);return s==="Object"&&r.constructor&&(s=r.constructor.name),s==="Map"||s==="Set"?Array.from(r):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?Pt(r,i):void 0}}var qt=Object.entries,xt=Object.setPrototypeOf,Pn=Object.isFrozen,xn=Object.getPrototypeOf,kn=Object.getOwnPropertyDescriptor,O=Object.freeze,R=Object.seal,le=Object.create,Kt=typeof Reflect<"u"&&Reflect,ot=Kt.apply,it=Kt.construct;O||(O=function(i){return i});R||(R=function(i){return i});ot||(ot=function(i,s){for(var l=arguments.length,f=new Array(l>2?l-2:0),d=2;d<l;d++)f[d-2]=arguments[d];return i.apply(s,f)});it||(it=function(i){for(var s=arguments.length,l=new Array(s>1?s-1:0),f=1;f<s;f++)l[f-1]=arguments[f];return new i(...l)});var ae=A(Array.prototype.forEach),Un=A(Array.prototype.lastIndexOf),kt=A(Array.prototype.pop),se=A(Array.prototype.push),Fn=A(Array.prototype.splice),j=Array.isArray,_e=A(String.prototype.toLowerCase),Qe=A(String.prototype.toString),Ut=A(String.prototype.match),Te=A(String.prototype.replace),Ft=A(String.prototype.indexOf),zn=A(String.prototype.trim),Hn=A(Number.prototype.toString),Gn=A(Boolean.prototype.toString),zt=typeof BigInt>"u"?null:A(BigInt.prototype.toString),Ht=typeof Symbol>"u"?null:A(Symbol.prototype.toString),b=A(Object.prototype.hasOwnProperty),he=A(Object.prototype.toString),y=A(RegExp.prototype.test),Z=Bn(TypeError);function A(r){return function(i){i instanceof RegExp&&(i.lastIndex=0);for(var s=arguments.length,l=new Array(s>1?s-1:0),f=1;f<s;f++)l[f-1]=arguments[f];return ot(r,i,l)}}function Bn(r){return function(){for(var i=arguments.length,s=new Array(i),l=0;l<i;l++)s[l]=arguments[l];return it(r,s)}}function m(r,i){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_e;if(xt&&xt(r,null),!j(i))return r;let l=i.length;for(;l--;){let f=i[l];if(typeof f=="string"){const d=s(f);d!==f&&(Pn(i)||(i[l]=d),f=d)}r[f]=!0}return r}function Wn(r){for(let i=0;i<r.length;i++)b(r,i)||(r[i]=null);return r}function I(r){const i=le(null);for(const l of qt(r)){var s=Cn(l,2);const f=s[0],d=s[1];b(r,f)&&(j(d)?i[f]=Wn(d):d&&typeof d=="object"&&d.constructor===Object?i[f]=I(d):i[f]=d)}return i}function Yn(r){switch(typeof r){case"string":return r;case"number":return Hn(r);case"boolean":return Gn(r);case"bigint":return zt?zt(r):"0";case"symbol":return Ht?Ht(r):"Symbol()";case"undefined":return he(r);case"function":case"object":{if(r===null)return he(r);const i=r,s=x(i,"toString");if(typeof s=="function"){const l=s(i);return typeof l=="string"?l:he(l)}return he(r)}default:return he(r)}}function x(r,i){for(;r!==null;){const l=kn(r,i);if(l){if(l.get)return A(l.get);if(typeof l.value=="function")return A(l.value)}r=xn(r)}function s(){return null}return s}function jn(r){try{return y(r,""),!0}catch{return!1}}var Gt=O(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),et=O(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),tt=O(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Xn=O(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),nt=O(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$n=O(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bt=O(["#text"]),Wt=O(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),rt=O(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Yt=O(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ce=O(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vn=R(/{{[\w\W]*|^[\w\W]*}}/g),qn=R(/<%[\w\W]*|^[\w\W]*%>/g),Kn=R(/\${[\w\W]*/g),Zn=R(/^data-[\-\w.\u00B7-\uFFFF]+$/),Jn=R(/^aria-[\-\w]+$/),jt=R(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qn=R(/^(?:\w+script|data):/i),er=R(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tr=R(/^html$/i),nr=R(/^[a-z][.\w]*(-[.\w]+)+$/i),Xt=R(/<[/\w!]/g),$t=R(/<[/\w]/g),rr=R(/<\/no(script|embed|frames)/i),or=R(/\/>/i),M={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ir=function(){return typeof window>"u"?null:window},ar=function(i,s){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let l=null;const f="data-tt-policy-suffix";s&&s.hasAttribute(f)&&(l=s.getAttribute(f));const d="dompurify"+(l?"#"+l:"");try{return i.createPolicy(d,{createHTML(S){return S},createScriptURL(S){return S}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},Vt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Y=function(i,s,l,f){return b(i,s)&&j(i[s])?m(f.base?I(f.base):{},i[s],f.transform):l};function Zt(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ir();const i=o=>Zt(o);if(i.version="3.4.13",i.removed=[],!r||!r.document||r.document.nodeType!==M.document||!r.Element)return i.isSupported=!1,i;let s=r.document;const l=s,f=l.currentScript;r.DocumentFragment;const d=r.HTMLTemplateElement,S=r.Node,ce=r.Element,C=r.NodeFilter;r.NamedNodeMap===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const ge=r.DOMParser,J=r.trustedTypes,X=ce.prototype,Jt=x(X,"cloneNode"),Me=x(X,"remove"),Qt=x(X,"nextSibling"),Q=x(X,"childNodes"),$=x(X,"parentNode"),at=x(X,"shadowRoot"),Pe=x(X,"attributes"),N=S&&S.prototype?x(S.prototype,"nodeType"):null,k=S&&S.prototype?x(S.prototype,"nodeName"):null,Ee=S&&S.prototype?x(S.prototype,"ownerDocument"):null;if(typeof d=="function"){const o=s.createElement("template");o.content&&o.content.ownerDocument&&(s=o.content.ownerDocument)}let L,V="",xe,st=!1,ue=0;const lt=function(){if(ue>0)throw Z('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ee=function(e){lt(),ue++;try{return L.createHTML(e)}finally{ue--}},en=function(e){lt(),ue++;try{return L.createScriptURL(e)}finally{ue--}},tn=function(){return st||(xe=ar(J,f),st=!0),xe},Ae=s,ke=Ae.implementation,ct=Ae.createNodeIterator,nn=Ae.createDocumentFragment,rn=Ae.getElementsByTagName,on=l.importNode;let T=Vt();i.isSupported=typeof qt=="function"&&typeof $=="function"&&ke&&ke.createHTMLDocument!==void 0;const an=Vn,sn=qn,ln=Kn,cn=Zn,un=Jn,fn=Qn,ut=er,pn=nr;let ft=jt,h=null;const Ue=m({},[...Gt,...et,...tt,...nt,...Bt]);let _=null;const Fe=m({},[...Wt,...rt,...Yt,...Ce]);let E=Object.seal(le(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),fe=null,pt=null;const H=Object.seal(le(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let mt=!0,ze=!0,dt=!1,Tt=!0,G=!1,B=!0,q=!1,He=!1,Se=null,ye=null,Ge=!1,te=!1,be=!1,Oe=!1,ht=!0,_t=!1;const gt="user-content-";let Be=!0,Re=!1,ne={},U=null;const We=m({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Et=null;const At=m({},["audio","video","img","source","image","track"]);let Ye=null;const St=m({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ie="http://www.w3.org/1998/Math/MathML",Ne="http://www.w3.org/2000/svg",F="http://www.w3.org/1999/xhtml";let re=F,je=!1,Xe=null;const mn=m({},[Ie,Ne,F],Qe),yt=O(["mi","mo","mn","ms","mtext"]);let $e=m({},yt);const bt=O(["annotation-xml"]);let Ve=m({},bt);const dn=m({},["title","style","font","a","script"]);let pe=null;const Tn=["application/xhtml+xml","text/html"],hn="text/html";let g=null,oe=null;const _n=s.createElement("form"),Ot=function(e){return e instanceof RegExp||e instanceof Function},qe=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(oe&&oe===e)return;(!e||typeof e!="object")&&(e={}),e=I(e),pe=Tn.indexOf(e.PARSER_MEDIA_TYPE)===-1?hn:e.PARSER_MEDIA_TYPE,g=pe==="application/xhtml+xml"?Qe:_e,h=Y(e,"ALLOWED_TAGS",Ue,{transform:g}),_=Y(e,"ALLOWED_ATTR",Fe,{transform:g}),Xe=Y(e,"ALLOWED_NAMESPACES",mn,{transform:Qe}),Ye=Y(e,"ADD_URI_SAFE_ATTR",St,{transform:g,base:St}),Et=Y(e,"ADD_DATA_URI_TAGS",At,{transform:g,base:At}),U=Y(e,"FORBID_CONTENTS",We,{transform:g}),fe=Y(e,"FORBID_TAGS",I({}),{transform:g}),pt=Y(e,"FORBID_ATTR",I({}),{transform:g}),ne=b(e,"USE_PROFILES")?e.USE_PROFILES&&typeof e.USE_PROFILES=="object"?I(e.USE_PROFILES):e.USE_PROFILES:!1,mt=e.ALLOW_ARIA_ATTR!==!1,ze=e.ALLOW_DATA_ATTR!==!1,dt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Tt=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,G=e.SAFE_FOR_TEMPLATES||!1,B=e.SAFE_FOR_XML!==!1,q=e.WHOLE_DOCUMENT||!1,te=e.RETURN_DOM||!1,be=e.RETURN_DOM_FRAGMENT||!1,Oe=e.RETURN_TRUSTED_TYPE||!1,Ge=e.FORCE_BODY||!1,ht=e.SANITIZE_DOM!==!1,_t=e.SANITIZE_NAMED_PROPS||!1,Be=e.KEEP_CONTENT!==!1,Re=e.IN_PLACE||!1,ft=jn(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:jt,re=typeof e.NAMESPACE=="string"?e.NAMESPACE:F,$e=b(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS=="object"?I(e.MATHML_TEXT_INTEGRATION_POINTS):m({},yt),Ve=b(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS=="object"?I(e.HTML_INTEGRATION_POINTS):m({},bt);const t=b(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING=="object"?I(e.CUSTOM_ELEMENT_HANDLING):le(null);if(E=le(null),b(t,"tagNameCheck")&&Ot(t.tagNameCheck)&&(E.tagNameCheck=t.tagNameCheck),b(t,"attributeNameCheck")&&Ot(t.attributeNameCheck)&&(E.attributeNameCheck=t.attributeNameCheck),b(t,"allowCustomizedBuiltInElements")&&typeof t.allowCustomizedBuiltInElements=="boolean"&&(E.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),R(E),G&&(ze=!1),be&&(te=!0),ne&&(h=m({},Bt),_=le(null),ne.html===!0&&(m(h,Gt),m(_,Wt)),ne.svg===!0&&(m(h,et),m(_,rt),m(_,Ce)),ne.svgFilters===!0&&(m(h,tt),m(_,rt),m(_,Ce)),ne.mathMl===!0&&(m(h,nt),m(_,Yt),m(_,Ce))),H.tagCheck=null,H.attributeCheck=null,b(e,"ADD_TAGS")&&(typeof e.ADD_TAGS=="function"?H.tagCheck=e.ADD_TAGS:j(e.ADD_TAGS)&&(h===Ue&&(h=I(h)),m(h,e.ADD_TAGS,g))),b(e,"ADD_ATTR")&&(typeof e.ADD_ATTR=="function"?H.attributeCheck=e.ADD_ATTR:j(e.ADD_ATTR)&&(_===Fe&&(_=I(_)),m(_,e.ADD_ATTR,g))),b(e,"ADD_URI_SAFE_ATTR")&&j(e.ADD_URI_SAFE_ATTR)&&m(Ye,e.ADD_URI_SAFE_ATTR,g),b(e,"FORBID_CONTENTS")&&j(e.FORBID_CONTENTS)&&(U===We&&(U=I(U)),m(U,e.FORBID_CONTENTS,g)),b(e,"ADD_FORBID_CONTENTS")&&j(e.ADD_FORBID_CONTENTS)&&(U===We&&(U=I(U)),m(U,e.ADD_FORBID_CONTENTS,g)),Be&&(h["#text"]=!0),q&&m(h,["html","head","body"]),h.table&&(m(h,["tbody"]),delete fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const n=L;L=e.TRUSTED_TYPES_POLICY;try{V=ee("")}catch(a){throw L=n,a}}else e.TRUSTED_TYPES_POLICY===null?(L=void 0,V=""):(L===void 0&&(L=tn()),L&&typeof V=="string"&&(V=ee("")));O&&O(e),oe=e},Rt=m({},[...et,...tt,...Xn]),It=m({},[...nt,...$n]),gn=function(e,t,n){return t.namespaceURI===F?e==="svg":t.namespaceURI===Ie?e==="svg"&&(n==="annotation-xml"||$e[n]):!!Rt[e]},En=function(e,t,n){return t.namespaceURI===F?e==="math":t.namespaceURI===Ne?e==="math"&&Ve[n]:!!It[e]},An=function(e,t,n){return t.namespaceURI===Ne&&!Ve[n]||t.namespaceURI===Ie&&!$e[n]?!1:!It[e]&&(dn[e]||!Rt[e])},Sn=function(e){let t=$(e);(!t||!t.tagName)&&(t={namespaceURI:re,tagName:"template"});const n=_e(e.tagName),a=_e(t.tagName);return Xe[e.namespaceURI]?e.namespaceURI===Ne?gn(n,t,a):e.namespaceURI===Ie?En(n,t,a):e.namespaceURI===F?An(n,t,a):!!(pe==="application/xhtml+xml"&&Xe[e.namespaceURI]):!1},W=function(e){se(i.removed,{element:e});try{$(e).removeChild(e)}catch{if(Me(e),!$(e))throw Z("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},De=function(e){me(e);const t=Q(e);if(t){const a=[];ae(t,c=>{se(a,c)}),ae(a,c=>{try{Me(c)}catch{}})}const n=Pe(e);if(n)for(let a=n.length-1;a>=0;--a){const c=n[a],u=c&&c.name;if(typeof u=="string")try{e.removeAttribute(u)}catch{}}},K=function(e,t){try{se(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch{se(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),e==="is")if(te||be)try{W(t)}catch{}else try{t.setAttribute(e,"")}catch{}},yn=function(e){const t=Pe(e);if(t)for(let n=t.length-1;n>=0;--n){const a=t[n],c=a&&a.name;if(!(typeof c!="string"||_[g(c)]))try{e.removeAttribute(c)}catch{}}},me=function(e){const t=[e];for(;t.length>0;){const n=t.pop();(N?N(n):n.nodeType)===M.element&&yn(n);const a=Q(n);if(a)for(let c=a.length-1;c>=0;--c)t.push(a[c])}},bn=function(e){if(!B)return;const t=[e];for(;t.length>0;){const n=t.pop(),a=N?N(n):n.nodeType;if(a===M.processingInstruction||a===M.comment&&y($t,n.data)){try{Me(n)}catch{}continue}if(a===M.element){const u=n,p=g(k?k(n):n.nodeName);try{u.hasAttribute&&u.hasAttribute("patchsrc")&&u.removeAttribute("patchsrc"),u.hasAttribute&&u.hasAttribute("for")&&p!=="label"&&p!=="output"&&u.removeAttribute("for")}catch{}}const c=Q(n);if(c)for(let u=c.length-1;u>=0;--u)t.push(c[u])}},Nt=function(e){let t=null,n=null;if(Ge)e="<remove></remove>"+e;else{const u=Ut(e,/^[\r\n\t ]+/);n=u&&u[0]}pe==="application/xhtml+xml"&&re===F&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const a=L?ee(e):e;if(re===F)try{t=new ge().parseFromString(a,pe)}catch{}if(!t||!t.documentElement){t=ke.createDocument(re,"template",null);try{t.documentElement.innerHTML=je?V:a}catch{}}const c=t.body||t.documentElement;return e&&n&&c.insertBefore(s.createTextNode(n),c.childNodes[0]||null),re===F?rn.call(t,q?"html":"body")[0]:q?t.documentElement:c},Dt=function(e){const t=Ee?Ee(e):e.ownerDocument;return ct.call(t||e,e,C.SHOW_ELEMENT|C.SHOW_COMMENT|C.SHOW_TEXT|C.SHOW_PROCESSING_INSTRUCTION|C.SHOW_CDATA_SECTION,null)},ve=function(e){return e=Te(e,an," "),e=Te(e,sn," "),e=Te(e,ln," "),e},Ke=function(e){var t;e.normalize();const n=Ee?Ee(e):e.ownerDocument,a=ct.call(n||e,e,C.SHOW_TEXT|C.SHOW_COMMENT|C.SHOW_CDATA_SECTION|C.SHOW_PROCESSING_INSTRUCTION,null);let c=a.nextNode();for(;c;)c.data=ve(c.data),c=a.nextNode();const u=(t=e.querySelectorAll)===null||t===void 0?void 0:t.call(e,"template");u&&ae(u,p=>{ie(p.content)&&Ke(p.content)})},Le=function(e){const t=k?k(e):null;return typeof t!="string"||g(t)!=="form"?!1:typeof e.nodeName!="string"||typeof e.textContent!="string"||typeof e.removeChild!="function"||e.attributes!==Pe(e)||typeof e.removeAttribute!="function"||typeof e.setAttribute!="function"||typeof e.namespaceURI!="string"||typeof e.insertBefore!="function"||typeof e.hasChildNodes!="function"||e.nodeType!==N(e)||e.childNodes!==Q(e)},ie=function(e){if(!N||typeof e!="object"||e===null)return!1;try{return N(e)===M.documentFragment}catch{return!1}},de=function(e){if(!N||typeof e!="object"||e===null)return!1;try{return typeof N(e)=="number"}catch{return!1}};function z(o,e,t){o.length!==0&&ae(o,n=>{n.call(i,e,t,oe)})}const On=function(e,t){return!!(B&&e.hasChildNodes()&&!de(e.firstElementChild)&&y(Xt,e.textContent)&&y(Xt,e.innerHTML)||B&&e.namespaceURI===F&&t==="style"&&de(e.firstElementChild)||e.nodeType===M.processingInstruction||B&&e.nodeType===M.comment&&y($t,e.data))},Rn=function(e,t,n){if(!fe[t]&&Ct(t)&&(E.tagNameCheck instanceof RegExp&&y(E.tagNameCheck,t)||E.tagNameCheck instanceof Function&&E.tagNameCheck(t)))return!1;if(Be&&!U[t]){const a=$(e),c=Q(e);if(c&&a){const u=c.length;for(let p=u-1;p>=0;--p){const D=e===n?Jt(c[p],!0):c[p];a.insertBefore(D,Qt(e))}}}return W(e),!0},vt=function(e,t,n,a){return e.length===0?t:t===n||t===a?I(t):t},Lt=function(e,t){if(z(T.beforeSanitizeElements,e,null),e!==t&&$(e)===null)return Re&&me(e),!0;if(Le(e))return W(e),!0;const n=g(k?k(e):e.nodeName);if(h=vt(T.uponSanitizeElement,h,Ue,Se),z(T.uponSanitizeElement,e,{tagName:n,allowedTags:h}),e!==t&&$(e)===null)return Re&&me(e),!0;if(On(e,n))return W(e),!0;if(fe[n]||!(H.tagCheck instanceof Function&&H.tagCheck(n))&&!h[n]){const a=Rn(e,n,t);return a===!1&&z(T.afterSanitizeElements,e,null),a}if((N?N(e):e.nodeType)===M.element&&!Sn(e)||(n==="noscript"||n==="noembed"||n==="noframes")&&y(rr,e.innerHTML))return W(e),!0;if(G&&e.nodeType===M.text){const a=ve(e.textContent);e.textContent!==a&&(se(i.removed,{element:e.cloneNode()}),e.textContent=a)}return z(T.afterSanitizeElements,e,null),!1},wt=function(e,t,n){if(pt[t]||B&&t==="patchsrc"||B&&t==="for"&&e!=="label"&&e!=="output"||ht&&(t==="id"||t==="name")&&(n in s||n in _n))return!1;const a=_[t]||H.attributeCheck instanceof Function&&H.attributeCheck(t,e);if(!(ze&&y(cn,t))){if(!(mt&&y(un,t))){if(a){if(!Ye[t]){if(!y(ft,Te(n,ut,""))){if(!((t==="src"||t==="xlink:href"||t==="href")&&e!=="script"&&Ft(n,"data:")===0&&Et[e])){if(!(dt&&!y(fn,Te(n,ut,"")))){if(n)return!1}}}}}else if(!(Ct(e)&&(E.tagNameCheck instanceof RegExp&&y(E.tagNameCheck,e)||E.tagNameCheck instanceof Function&&E.tagNameCheck(e))&&(E.attributeNameCheck instanceof RegExp&&y(E.attributeNameCheck,t)||E.attributeNameCheck instanceof Function&&E.attributeNameCheck(t,e))||t==="is"&&E.allowCustomizedBuiltInElements&&(E.tagNameCheck instanceof RegExp&&y(E.tagNameCheck,n)||E.tagNameCheck instanceof Function&&E.tagNameCheck(n))))return!1}}return!0},In=m({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ct=function(e){return!In[_e(e)]&&y(pn,e)},Nn=function(e,t,n,a){if(L&&typeof J=="object"&&typeof J.getAttributeType=="function"&&!n)switch(J.getAttributeType(e,t)){case"TrustedHTML":return ee(a);case"TrustedScriptURL":return en(a)}return a},Dn=function(e,t,n,a){try{n?e.setAttributeNS(n,t,a):e.setAttribute(t,a),Le(e)?W(e):kt(i.removed)}catch{K(t,e)}},Mt=function(e){z(T.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Le(e))return;_=vt(T.uponSanitizeAttribute,_,Fe,ye);const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:_,forceKeepAttr:void 0};let a=t.length;const c=g(e.nodeName);for(;a--;){const u=t[a],p=u.name,D=u.namespaceURI,P=u.value,w=g(p),Je=P;let v=p==="value"?Je:zn(Je);if(n.attrName=w,n.attrValue=v,n.keepAttr=!0,n.forceKeepAttr=void 0,z(T.uponSanitizeAttribute,e,n),v=n.attrValue,_t&&(w==="id"||w==="name")&&Ft(v,gt)!==0&&(K(p,e),v=gt+v),B&&y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,v)){K(p,e);continue}if(w==="attributename"&&Ut(v,"href")){K(p,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){K(p,e);continue}if(!Tt&&y(or,v)){K(p,e);continue}if(G&&(v=ve(v)),!wt(c,w,v)){K(p,e);continue}v=Nn(c,w,D,v),v!==Je&&Dn(e,p,D,v)}}z(T.afterSanitizeAttributes,e,null)},we=function(e){let t=null;const n=Dt(e);for(z(T.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(z(T.uponSanitizeShadowNode,t,null),Lt(t,e),Mt(t),ie(t.content)&&we(t.content),(N?N(t):t.nodeType)===M.element){const a=at(t);ie(a)&&(Ze(a),we(a))}z(T.afterSanitizeShadowDOM,e,null)},Ze=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const n=t.pop();if(n.shadow){we(n.shadow);continue}const a=n.node,c=(N?N(a):a.nodeType)===M.element,u=Q(a);if(u)for(let p=u.length-1;p>=0;--p)t.push({node:u[p],shadow:null});if(c){const p=k?k(a):null;if(typeof p=="string"&&g(p)==="template"){const D=a.content;ie(D)&&t.push({node:D,shadow:null})}}if(c){const p=at(a);ie(p)&&t.push({node:null,shadow:p},{node:p,shadow:null})}}};return i.sanitize=function(o){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=null,n=null,a=null,c=null;if(je=!o,je&&(o="<!-->"),typeof o!="string"&&!de(o)&&(o=Yn(o),typeof o!="string"))throw Z("dirty is not a string, aborting");if(!i.isSupported)return o;He?(h=Se,_=ye):qe(e),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(h=I(h)),T.uponSanitizeAttribute.length>0&&(_=I(_)),i.removed=[];const u=Re&&typeof o!="string"&&de(o);if(u){bn(o);const P=k?k(o):o.nodeName;if(typeof P=="string"){const w=g(P);if(!h[w]||fe[w])throw De(o),Z("root node is forbidden and cannot be sanitized in-place")}if(Le(o))throw De(o),Z("root node is clobbered and cannot be sanitized in-place");try{Ze(o)}catch(w){throw De(o),w}}else if(de(o))t=Nt("<!---->"),n=t.ownerDocument.importNode(o,!0),n.nodeType===M.element&&n.nodeName==="BODY"||n.nodeName==="HTML"?t=n:t.appendChild(n),Ze(n);else{if(!te&&!G&&!q&&o.indexOf("<")===-1)return L&&Oe?ee(o):o;if(t=Nt(o),!t)return te?null:Oe?V:""}t&&Ge&&W(t.firstChild);const p=u?o:t;try{const P=Dt(p);for(;a=P.nextNode();)Lt(a,p),Mt(a),ie(a.content)&&we(a.content)}catch(P){throw u&&(De(o),ae(i.removed,w=>{w.element&&me(w.element)})),P}if(u)return ae(i.removed,P=>{P.element&&me(P.element)}),G&&Ke(o),o;if(te){if(G&&Ke(t),be)for(c=nn.call(t.ownerDocument);t.firstChild;)c.appendChild(t.firstChild);else c=t;return(_.shadowroot||_.shadowrootmode)&&(c=on.call(l,c,!0)),c}let D=q?t.outerHTML:t.innerHTML;return q&&h["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&y(tr,t.ownerDocument.doctype.name)&&(D="<!DOCTYPE "+t.ownerDocument.doctype.name+`>
`+D),G&&(D=ve(D)),L&&Oe?ee(D):D},i.setConfig=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};qe(o),He=!0,Se=h,ye=_},i.clearConfig=function(){oe=null,He=!1,Se=null,ye=null,L=xe,V=""},i.isValidAttribute=function(o,e,t){oe||qe({});const n=g(o),a=g(e);return wt(n,a,t)},i.addHook=function(o,e){typeof e=="function"&&b(T,o)&&se(T[o],e)},i.removeHook=function(o,e){if(b(T,o)){if(e!==void 0){const t=Un(T[o],e);return t===-1?void 0:Fn(T[o],t,1)[0]}return kt(T[o])}},i.removeHooks=function(o){b(T,o)&&(T[o]=[])},i.removeAllHooks=function(){T=Vt()},i}var sr=Zt();Object.defineProperty(exports,"purify",{enumerable:!0,get:function(){return sr}});