mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-11-01 10:34:07 +00:00
4 lines
30 KiB
JavaScript
4 lines
30 KiB
JavaScript
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function on(i,s){(s==null||s>i.length)&&(s=i.length);for(var a=0,c=Array(s);a<s;a++)c[a]=i[a];return c}function io(i){if(Array.isArray(i))return i}function so(i,s){var a=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(a!=null){var c,f,h,y,mt=[],C=!0,Rt=!1;try{if(h=(a=a.call(i)).next,s!==0)for(;!(C=(c=h.call(a)).done)&&(mt.push(c.value),mt.length!==s);C=!0);}catch(tt){Rt=!0,f=tt}finally{try{if(!C&&a.return!=null&&(y=a.return(),Object(y)!==y))return}finally{if(Rt)throw f}}return mt}}function ao(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function lo(i,s){return io(i)||so(i,s)||co(i,s)||ao()}function co(i,s){if(i){if(typeof i=="string")return on(i,s);var a={}.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?on(i,s):void 0}}const An=Object.entries,rn=Object.setPrototypeOf,uo=Object.isFrozen,En=Object.getPrototypeOf,Sn=Object.getOwnPropertyDescriptor;let b=Object.freeze,R=Object.seal,ft=Object.create,yn=typeof Reflect<"u"&&Reflect,Se=yn.apply,ye=yn.construct;b||(b=function(s){return s});R||(R=function(s){return s});Se||(Se=function(s,a){for(var c=arguments.length,f=new Array(c>2?c-2:0),h=2;h<c;h++)f[h-2]=arguments[h];return s.apply(a,f)});ye||(ye=function(s){for(var a=arguments.length,c=new Array(a>1?a-1:0),f=1;f<a;f++)c[f-1]=arguments[f];return new s(...c)});const G=g(Array.prototype.forEach),fo=g(Array.prototype.lastIndexOf),sn=g(Array.prototype.pop),St=g(Array.prototype.push),po=g(Array.prototype.slice),mo=g(Array.prototype.splice),pt=Array.isArray,pe=bn(Set),me=g(Set.prototype.add),yt=g(Set.prototype.has),Q=g(String.prototype.toLowerCase),de=g(String.prototype.toString),an=g(String.prototype.match),bt=g(String.prototype.replace),ln=g(String.prototype.indexOf),ho=g(String.prototype.trim),_o=g(Number.prototype.toString),To=g(Boolean.prototype.toString),cn=typeof BigInt>"u"?null:g(BigInt.prototype.toString),un=typeof Symbol>"u"?null:g(Symbol.prototype.toString),N=g(Object.prototype.hasOwnProperty),Ot=g(Object.prototype.toString),O=g(RegExp.prototype.test),W=bn(TypeError);function g(i){return function(s){s instanceof RegExp&&(s.lastIndex=0);for(var a=arguments.length,c=new Array(a>1?a-1:0),f=1;f<a;f++)c[f-1]=arguments[f];return Se(i,s,c)}}function bn(i){return function(){for(var s=arguments.length,a=new Array(s),c=0;c<s;c++)a[c]=arguments[c];return ye(i,a)}}function m(i,s){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q;if(rn&&rn(i,null),!pt(s))return i;let c=s.length;for(;c--;){let f=s[c];if(typeof f=="string"){const h=a(f);h!==f&&(uo(s)||(s[c]=h),f=h)}i[f]=!0}return i}function go(i){for(let s=0;s<i.length;s++)N(i,s)||(i[s]=null);return i}function M(i){const s=ft(null);for(const c of An(i)){var a=lo(c,2);const f=a[0],h=a[1];N(i,f)&&(pt(h)?s[f]=go(h):h&&typeof h=="object"&&h.constructor===Object?s[f]=M(h):s[f]=h)}return s}function Ao(i){switch(typeof i){case"string":return i;case"number":return _o(i);case"boolean":return To(i);case"bigint":return cn?cn(i):"0";case"symbol":return un?un(i):"Symbol()";case"undefined":return Ot(i);case"function":case"object":{if(i===null)return Ot(i);const s=i,a=v(s,"toString");if(typeof a=="function"){const c=a(s);return typeof c=="string"?c:Ot(c)}return Ot(i)}default:return Ot(i)}}function v(i,s){for(;i!==null;){const c=Sn(i,s);if(c){if(c.get)return g(c.get);if(typeof c.value=="function")return g(c.value)}i=En(i)}function a(){return null}return a}function Eo(i,s){for(;i!==null;){const a=Sn(i,s);if(a)return a.get?g(a.get):null;i=En(i)}return null}function So(i){try{return O(i,""),!0}catch{return!1}}const fn=b(["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"]),he=b(["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"]),_e=b(["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"]),yo=b(["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"]),Te=b(["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"]),bo=b(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),pn=b(["#text"]),mn=b(["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"]),ge=b(["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","pointer-events","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","vector-effect","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"]),dn=b(["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"]),Ut=b(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Oo=R(/{{[\w\W]*|^[\w\W]*}}/g),Ro=R(/<%[\w\W]*|^[\w\W]*%>/g),Do=R(/\${[\w\W]*/g),wo=R(/^data-[\-\w.\u00B7-\uFFFF]+$/),Lo=R(/^aria-[\-\w]+$/),hn=R(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Io=R(/^(?:\w+script|data):/i),No=R(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Co=R(/^html$/i),Mo=R(/^[a-z][.\w]*(-[.\w]+)+$/i),Ae=R(/<[/\w!]/g),_n=R(/<[/\w]/g),Po=R(/<\/no(script|embed|frames)/i),Tn=R(/\/>/i),E={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vo=b(m({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),xo=function(){return typeof window>"u"?null:window},ko=function(s,a){if(typeof s!="object"||typeof s.createPolicy!="function")return null;let c=null;const f="data-tt-policy-suffix";a&&a.hasAttribute(f)&&(c=a.getAttribute(f));const h="dompurify"+(c?"#"+c:"");try{return s.createPolicy(h,{createHTML(y){return y},createScriptURL(y){return y}})}catch{return console.warn("TrustedTypes policy "+h+" could not be created."),null}},gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},V=function(s,a,c,f){return N(s,a)&&pt(s[a])?m(f.base?M(f.base):{},s[a],f.transform):c},Ee=function(s,a,c){const f=N(s,a)?s[a]:void 0;return f&&typeof f=="object"?M(f):c()};function On(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xo();const s=r=>On(r);if(s.version="3.4.17",s.removed=[],!i||!i.document||i.document.nodeType!==E.document||!i.Element)return s.isSupported=!1,s;let a=i.document;const c=a,f=c.currentScript;i.DocumentFragment;const h=i.HTMLTemplateElement,y=i.Node,mt=i.Element,C=i.NodeFilter;i.NamedNodeMap===void 0&&(i.NamedNodeMap||i.MozNamedAttrMap),i.HTMLFormElement;const Rt=i.DOMParser,tt=i.trustedTypes,F=mt.prototype,Rn=v(F,"cloneNode"),zt=v(F,"remove"),be=v(F,"removeAttributeNode"),Dn=v(F,"nextSibling"),dt=v(F,"childNodes"),et=v(F,"parentNode"),Ft=v(F,"shadowRoot"),Ht=v(F,"attributes"),$=y&&y.prototype?v(y.prototype,"nodeType"):null,nt=y&&y.prototype?v(y.prototype,"nodeName"):null,Dt=y&&y.prototype?v(y.prototype,"ownerDocument"):null,P=function(t){return $?$(t):t.nodeType},ht=function(t){return nt?nt(t):t.nodeName},Oe=Eo(F,"namespaceURI"),Gt=function(t){return Oe?Oe(t):t.namespaceURI};if(typeof h=="function"){const r=a.createElement("template");r.content&&r.content.ownerDocument&&(a=r.content.ownerDocument)}let w,X="",Wt,Re=!1,_t=0;const De=function(){if(_t>0)throw W('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.')},ot=function(t){De(),_t++;try{return w.createHTML(t)}finally{_t--}},wn=function(t){De(),_t++;try{return w.createScriptURL(t)}finally{_t--}},Ln=function(){return Re||(Wt=ko(tt,f),Re=!0),Wt},wt=a,Bt=wt.implementation,we=wt.createNodeIterator,In=wt.createDocumentFragment,Nn=wt.getElementsByTagName,Cn=c.importNode;let d=gn();s.isSupported=typeof An=="function"&&typeof et=="function"&&Bt&&Bt.createHTMLDocument!==void 0;const Mn=Oo,Pn=Ro,vn=Do,xn=wo,kn=Lo,Un=Io,Le=No,zn=Mo;let Ie=hn,_=null;const Yt=m({},[...fn,...he,..._e,...Te,...pn]);let T=null;const jt=m({},[...mn,...ge,...dn,...Ut]);let k=Object.seal(ft(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}})),Tt=null,Ne=null;const B=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ce=!0,Vt=!0,Me=!1,$t=!0,H=!1,q=!0,K=!1,Xt=!1,Lt=null,It=null,qt=!1,rt=!1,Nt=!1,Ct=!1,Pe=!0,ve=!1;const xe="user-content-";let Kt=!0,Zt=!1,Z=null,it={},J=null;const ke=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 Ue=null;const ze=m({},["audio","video","img","source","image","track"]);let Fe=null;const He=m({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",U="http://www.w3.org/1999/xhtml";let st=U,Jt=!1,Qt=null;const Fn=m({},[Mt,Pt,U],de),Ge=b(["mi","mo","mn","ms","mtext"]);let te=m({},Ge);const We=b(["annotation-xml"]);let ee=m({},We);const Hn=m({},["title","style","font","a","script"]);let gt=null;const Gn=["application/xhtml+xml","text/html"],Wn="text/html";let A=null,at=null;const Bn=a.createElement("form"),Be=function(t){return t instanceof RegExp||t instanceof Function},ne=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(at&&at===t)return;(!t||typeof t!="object")&&(t={}),t=M(t),gt=Gn.indexOf(t.PARSER_MEDIA_TYPE)===-1?Wn:t.PARSER_MEDIA_TYPE,A=gt==="application/xhtml+xml"?de:Q,_=V(t,"ALLOWED_TAGS",Yt,{transform:A}),T=V(t,"ALLOWED_ATTR",jt,{transform:A}),Qt=V(t,"ALLOWED_NAMESPACES",Fn,{transform:de}),Fe=V(t,"ADD_URI_SAFE_ATTR",He,{transform:A,base:He}),Ue=V(t,"ADD_DATA_URI_TAGS",ze,{transform:A,base:ze}),J=V(t,"FORBID_CONTENTS",ke,{transform:A}),Tt=V(t,"FORBID_TAGS",M({}),{transform:A}),Ne=V(t,"FORBID_ATTR",M({}),{transform:A}),it=N(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?M(t.USE_PROFILES):t.USE_PROFILES:!1,Ce=t.ALLOW_ARIA_ATTR!==!1,Vt=t.ALLOW_DATA_ATTR!==!1,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,$t=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=t.SAFE_FOR_TEMPLATES||!1,q=t.SAFE_FOR_XML!==!1,K=t.WHOLE_DOCUMENT||!1,rt=t.RETURN_DOM||!1,Nt=t.RETURN_DOM_FRAGMENT||!1,Ct=t.RETURN_TRUSTED_TYPE||!1,qt=t.FORCE_BODY||!1,Pe=t.SANITIZE_DOM!==!1,ve=t.SANITIZE_NAMED_PROPS||!1,Kt=t.KEEP_CONTENT!==!1,Zt=t.IN_PLACE||!1,Ie=So(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:hn,st=typeof t.NAMESPACE=="string"?t.NAMESPACE:U,te=Ee(t,"MATHML_TEXT_INTEGRATION_POINTS",()=>m({},Ge)),ee=Ee(t,"HTML_INTEGRATION_POINTS",()=>m({},We));const e=Ee(t,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(k=ft(null),N(e,"tagNameCheck")&&Be(e.tagNameCheck)&&(k.tagNameCheck=e.tagNameCheck),N(e,"attributeNameCheck")&&Be(e.attributeNameCheck)&&(k.attributeNameCheck=e.attributeNameCheck),N(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(k.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),R(k),H&&(Vt=!1),Nt&&(rt=!0),it&&(_=m({},pn),T=ft(null),it.html===!0&&(m(_,fn),m(T,mn)),it.svg===!0&&(m(_,he),m(T,ge),m(T,Ut)),it.svgFilters===!0&&(m(_,_e),m(T,ge),m(T,Ut)),it.mathMl===!0&&(m(_,Te),m(T,dn),m(T,Ut))),B.tagCheck=null,B.attributeCheck=null,N(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?B.tagCheck=t.ADD_TAGS:pt(t.ADD_TAGS)&&(_===Yt&&(_=M(_)),m(_,t.ADD_TAGS,A))),N(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?B.attributeCheck=t.ADD_ATTR:pt(t.ADD_ATTR)&&(T===jt&&(T=M(T)),m(T,t.ADD_ATTR,A))),N(t,"ADD_FORBID_CONTENTS")&&pt(t.ADD_FORBID_CONTENTS)&&(J===ke&&(J=M(J)),m(J,t.ADD_FORBID_CONTENTS,A)),Kt&&(_["#text"]=!0),K&&m(_,["html","head","body"]),_.table&&(m(_,["tbody"]),delete Tt.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw W('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw W('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const n=w;w=t.TRUSTED_TYPES_POLICY;try{X=ot("")}catch(o){throw w=n,o}}else t.TRUSTED_TYPES_POLICY===null?(w=void 0,X=""):(w===void 0&&(w=Ln()),w&&typeof X=="string"&&(X=ot("")));b&&b(t),at=t},Ye=m({},[...he,..._e,...yo]),je=m({},[...Te,...bo]),Yn=function(t,e,n){return e.namespaceURI===U?t==="svg":e.namespaceURI===Mt?t==="svg"&&(n==="annotation-xml"||te[n]):!!Ye[t]},jn=function(t,e,n){return e.namespaceURI===U?t==="math":e.namespaceURI===Pt?t==="math"&&ee[n]:!!je[t]},Vn=function(t,e,n){return e.namespaceURI===Pt&&!ee[n]||e.namespaceURI===Mt&&!te[n]?!1:!je[t]&&(Hn[t]||!Ye[t])},$n=function(t){const e=Gt(t),n=Q(ht(t)),o=et(t);let l,u;return o&&P(o)===E.element?(l={namespaceURI:Gt(o)},u=Q(ht(o))):(l={namespaceURI:st},u="template"),Qt[e]?e===Pt?Yn(n,l,u):e===Mt?jn(n,l,u):e===U?Vn(n,l,u):!!(gt==="application/xhtml+xml"&&Qt[e]):!1},Y=function(t){St(s.removed,{element:t});try{et(t).removeChild(t)}catch{if(zt(t),!et(t))throw W("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ve=function(t,e,n){try{be(t,e)}catch{try{t.removeAttribute(n)}catch{}}},oe=function(t){ie(t);const e=dt(t);e&&G(po(e),o=>{try{zt(o)}catch{}});const n=P(t)===E.element?Ht(t):null;if(n)for(let o=n.length-1;o>=0;--o){const l=n[o],u=l&&l.name;typeof u=="string"&&Ve(t,l,u)}},lt=function(t,e,n){if(!n)try{n=e.getAttributeNode(t)}catch{n=null}St(s.removed,{attribute:n||null,from:e});try{n?be(e,n):e.removeAttribute(t)}catch{try{e.removeAttribute(t)}catch{}}if(t==="is")if(rt||Nt)try{Y(e)}catch{}else try{e.setAttribute(t,"")}catch{}},$e=function(t){const e=Ht(t);if(e)for(let n=e.length-1;n>=0;--n){const o=e[n],l=o&&o.name;typeof l!="string"||T[A(l)]||Ve(t,o,l)}},re=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const o=[t];for(;o.length>0;){const l=o.pop();if(e(l)===!1)continue;if(n&&P(l)===E.element){const p=Ft(l);j(p)&&o.push(p)}const u=dt(l);if(u)for(let p=u.length-1;p>=0;--p)o.push(u[p])}},ie=function(t){re(t,e=>{P(e)===E.element&&$e(e)})},se=function(t){const e=[];return re(t,n=>{e.push(n)},!0),e},Xn=function(t,e){const n=pe();G(se(t),o=>{P(o)===E.element&&me(n,o)}),G(e,o=>{P(o)===E.element&&!yt(n,o)&&$e(o)})},Xe=function(t,e){let n=!1;return G(s.removed,o=>{o.element&&(n=n||o.element===t,ie(o.element))}),Xn(t,e),n},qn=8,Kn=function(t,e){const n=Z;let o=null;const l=()=>(o||(o=pe(),G(e,u=>{me(o,u)})),o);for(let u=0;;u++){const p=se(t),S=[t];let z=!1;if(G(p,D=>{P(D)===E.documentFragment?St(S,D):!z&&!yt(n,D)&&(z=yt(l(),D))}),!z)return;if(u>=qn)throw W("the tree kept changing during in-place sanitization; refusing to return it");G(S,(D,L)=>{Zn(D,L>0,t,l())})}},Zn=function(t,e,n,o){const l=ae(t);let u;for(;u=l.nextNode();)!yt(o,u)||yt(Z,u)||(e&&x(d.uponSanitizeShadowNode,u,null),ce(u,n),ue(u,n),j(u.content)&&Et(u.content))},Jn=function(t){Z&&me(Z,t)},qe=function(t,e){return q?t==="patchsrc"?!0:t==="for"&&e!=="label"&&e!=="output":!1},Qn=function(t){q&&re(t,e=>{const n=P(e);if(n===E.processingInstruction||n===E.comment&&O(_n,e.data)){try{zt(e)}catch{}return!1}if(n===E.element){const o=e,l=A(ht(e));try{o.hasAttribute&&o.hasAttribute("patchsrc")&&o.removeAttribute("patchsrc"),o.hasAttribute&&o.hasAttribute("for")&&qe("for",l)&&o.removeAttribute("for")}catch{}}return!0})},Ke=function(t){let e=null,n=null;if(qt)t="<remove></remove>"+t;else{const u=an(t,/^[\r\n\t ]+/);n=u&&u[0]}gt==="application/xhtml+xml"&&st===U&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const o=w?ot(t):t;if(st===U)try{e=new Rt().parseFromString(o,gt)}catch{}if(!e||!e.documentElement){e=Bt.createDocument(st,"template",null);try{e.documentElement.innerHTML=Jt?X:o}catch{}}const l=e.body||e.documentElement;return t&&n&&l.insertBefore(a.createTextNode(n),l.childNodes[0]||null),st===U?Nn.call(e,K?"html":"body")[0]:K?e.documentElement:l},ae=function(t){const e=Dt?Dt(t):t.ownerDocument;return we.call(e||t,t,C.SHOW_ELEMENT|C.SHOW_COMMENT|C.SHOW_TEXT|C.SHOW_PROCESSING_INSTRUCTION|C.SHOW_CDATA_SECTION,null)},vt=function(t){return t=bt(t,Mn," "),t=bt(t,Pn," "),t=bt(t,vn," "),t},le=function(t){var e;Ze(t);const n=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");n&&G(n,o=>{j(o.content)&&le(o.content)})},Ze=function(t){t.normalize();const e=Dt?Dt(t):t.ownerDocument,n=we.call(e||t,t,C.SHOW_TEXT|C.SHOW_COMMENT|C.SHOW_CDATA_SECTION|C.SHOW_PROCESSING_INSTRUCTION,null);let o=n.nextNode();for(;o;)o.data=vt(o.data),o=n.nextNode()},xt=function(t){const e=nt?nt(t):null;return typeof e!="string"||A(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==Ht(t)||typeof t.removeAttribute!="function"||typeof t.removeAttributeNode!="function"||typeof t.getAttributeNode!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==$(t)||t.childNodes!==dt(t)},j=function(t){if(!$||typeof t!="object"||t===null)return!1;try{return $(t)===E.documentFragment}catch{return!1}},At=function(t){if(!$||typeof t!="object"||t===null)return!1;try{return typeof $(t)=="number"}catch{return!1}};function x(r,t,e){r.length!==0&&G(r,n=>{n.call(s,t,e,at)})}const to=function(t,e){return!!(q&&t.hasChildNodes()&&!At(t.firstElementChild)&&O(Ae,t.textContent)&&O(Ae,t.innerHTML)||q&&vo[e]&&P(t)===E.element&&Gt(t)===U&&(At(t.firstElementChild)||typeof t.textContent=="string"&&O(Ae,t.textContent))||t.nodeType===E.processingInstruction||q&&t.nodeType===E.comment&&O(_n,t.data))},kt=function(t,e){if(t instanceof RegExp)return O(t,e);if(t instanceof Function){for(var n=arguments.length,o=new Array(n>2?n-2:0),l=2;l<n;l++)o[l-2]=arguments[l];return!!t(e,...o)}return!1},eo=function(t,e,n){if(!Tt[e]&&tn(e)&&kt(k.tagNameCheck,e))return!1;if(Kt&&!J[e]&&!J[Q(e)]){const o=et(t),l=dt(t);if(l&&o){const u=l.length;for(let p=u-1;p>=0;--p){const S=t===n?Rn(l[p],!0):l[p];o.insertBefore(S,Dn(t))}}}return Y(t),!0},Je=function(t,e,n,o){return t.length===0?e:e===n||e===o?M(e):e},ct=function(t,e){return t===e||et(t)!==null?!1:(Zt&&ie(t),!0)},ce=function(t,e){if(Jn(t),x(d.beforeSanitizeElements,t,null),ct(t,e))return!0;if(xt(t))return Y(t),!0;const n=A(ht(t));if(_=Je(d.uponSanitizeElement,_,Yt,Lt),x(d.uponSanitizeElement,t,{tagName:n,allowedTags:_}),ct(t,e))return!0;if(to(t,n))return Y(t),!0;if(Tt[n]||!(B.tagCheck instanceof Function&&B.tagCheck(n))&&!_[n]){const o=eo(t,n,e);return o===!1&&(x(d.afterSanitizeElements,t,null),ct(t,e))?!0:o}if(P(t)===E.element&&!$n(t)||(n==="noscript"||n==="noembed"||n==="noframes")&&O(Po,t.innerHTML))return Y(t),!0;if(H&&t.nodeType===E.text){const o=vt(t.textContent);t.textContent!==o&&(St(s.removed,{element:t.cloneNode()}),t.textContent=o)}return x(d.afterSanitizeElements,t,null),ct(t,e)},Qe=function(t,e,n){if(Ne[e]||qe(e,t)||Pe&&(e==="id"||e==="name")&&(n in a||n in Bn))return!1;const o=T[e]||B.attributeCheck instanceof Function&&B.attributeCheck(e,t);return Vt&&O(xn,e)||Ce&&O(kn,e)?!0:o?Fe[e]||O(Ie,bt(n,Le,""))||(e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&ln(n,"data:")===0&&Ue[t]||Me&&!O(Un,bt(n,Le,""))?!0:!n:tn(t)&&kt(k.tagNameCheck,t)&&kt(k.attributeNameCheck,e,t)||e==="is"&&k.allowCustomizedBuiltInElements&&kt(k.tagNameCheck,n)},no=m({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),tn=function(t){return!no[Q(t)]&&O(zn,t)},oo=function(t,e,n,o){if(w&&typeof tt=="object"&&typeof tt.getAttributeType=="function"&&!n)switch(tt.getAttributeType(t,e)){case"TrustedHTML":return ot(o);case"TrustedScriptURL":return wn(o)}return o},ro=function(t,e,n,o){try{return n?t.setAttributeNS(n,e,o):t.setAttribute(e,o),xt(t)?(Y(t),!1):!0}catch{return lt(e,t),!1}},en=function(t,e){return q&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,e)?!0:Q(t)==="attributename"&&an(e,"href")!==null},ue=function(t,e){if(x(d.beforeSanitizeAttributes,t,null),ct(t,e))return;const n=t.attributes;if(!n||xt(t))return;T=Je(d.uponSanitizeAttribute,T,jt,It);const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0};let l=n.length;const u=A(t.nodeName);for(;l--;){const p=n[l],S=p.name,z=p.namespaceURI,D=p.value,L=A(S),ut=D;let I=S==="value"?ut:ho(ut),nn=!1;if(o.attrName=L,o.attrValue=I,o.keepAttr=!0,o.forceKeepAttr=void 0,x(d.uponSanitizeAttribute,t,o),I=o.attrValue,ve&&(L==="id"||L==="name")&&ln(I,xe)!==0&&(lt(S,t,p),I=xe+I,nn=!0),en(S,I)){lt(S,t,p);continue}if(!o.forceKeepAttr){if(!o.keepAttr){lt(S,t,p);continue}if(!$t&&O(Tn,I)){lt(S,t,p);continue}if(H&&(I=vt(I)),!Qe(u,L,I)){lt(S,t,p);continue}I=oo(u,L,z,I),I!==ut&&ro(t,S,z,I)&&nn&&sn(s.removed)}}x(d.afterSanitizeAttributes,t,null),ct(t,e)},Et=function(t){let e=null;const n=ae(t);for(x(d.beforeSanitizeShadowDOM,t,null);e=n.nextNode();)if(x(d.uponSanitizeShadowNode,e,null),ce(e,t),ue(e,t),j(e.content)&&Et(e.content),P(e)===E.element){const o=Ft(e);j(o)&&(fe(o),Et(o))}H&&Ze(t),x(d.afterSanitizeShadowDOM,t,null)},fe=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const n=e.pop();if(n.shadow){Et(n.shadow);continue}const o=n.node,l=P(o)===E.element,u=dt(o);if(u)for(let p=u.length-1;p>=0;--p)e.push({node:u[p],shadow:null});if(l){const p=nt?nt(o):null;if(typeof p=="string"&&A(p)==="template"){const S=o.content;j(S)&&e.push({node:S,shadow:null})}}if(l){const p=Ft(o);j(p)&&e.push({node:null,shadow:p},{node:p,shadow:null})}}};return s.sanitize=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,n=null,o=null,l=null;if(Jt=!r,Jt&&(r="<!-->"),typeof r!="string"&&!At(r)&&(r=Ao(r),typeof r!="string"))throw W("dirty is not a string, aborting");if(!s.isSupported)return r;Xt?(_=Lt,T=It):ne(t),(d.uponSanitizeElement.length>0||d.uponSanitizeAttribute.length>0)&&(_=M(_)),d.uponSanitizeAttribute.length>0&&(T=M(T)),s.removed=[];const u=Zt&&typeof r!="string"&&At(r);let p=[];const S=Z;if(u){Qn(r);const L=ht(r);if(typeof L=="string"){const ut=A(L);if(!_[ut]||Tt[ut])throw oe(r),W("root node is forbidden and cannot be sanitized in-place")}if(xt(r))throw oe(r),W("root node is clobbered and cannot be sanitized in-place");p=se(r),Z=pe()}else if(At(r))e=Ke("<!---->"),n=e.ownerDocument.importNode(r,!0),n.nodeType===E.element&&n.nodeName==="BODY"||n.nodeName==="HTML"?e=n:e.appendChild(n),fe(e);else{if(!rt&&!H&&!K&&r.indexOf("<")===-1)return w&&Ct?ot(r):r;if(e=Ke(r),!e)return rt?null:Ct?X:""}e&&qt&&Y(e.firstChild);const z=u?r:e;try{u&&fe(r);const L=ae(z);for(;o=L.nextNode();)ce(o,z),ue(o,z),j(o.content)&&Et(o.content);u&&Kn(r,p)}catch(L){throw u&&(oe(r),Xe(r,p)),L}finally{Z=S}if(u){if(Xe(r,p))throw W("a node selected for removal could not be safely returned; refusing to sanitize in place");return H&&le(r),r}if(rt){if(H&&le(e),Nt)for(l=In.call(e.ownerDocument);e.firstChild;)l.appendChild(e.firstChild);else l=e;return(T.shadowroot||T.shadowrootmode)&&(l=Cn.call(c,l,!0)),l}let D=K?e.outerHTML:e.innerHTML;return K&&_["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&O(Co,e.ownerDocument.doctype.name)&&(D="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
|
|
`+D),H&&(D=vt(D)),w&&Ct?ot(D):D},s.setConfig=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ne(r),Xt=!0,Lt=_,It=T},s.clearConfig=function(){at=null,Xt=!1,Lt=null,It=null,w=Wt,X=""},s.isValidAttribute=function(r,t,e){at||ne({});const n=A(r),o=A(t);return typeof e=="string"&&(en(t,e)||!$t&&O(Tn,e))?!1:Qe(n,o,e)},s.addHook=function(r,t){typeof t=="function"&&N(d,r)&&St(d[r],t)},s.removeHook=function(r,t){if(N(d,r)){if(t!==void 0){const e=fo(d[r],t);return e===-1?void 0:mo(d[r],e,1)[0]}return sn(d[r])}},s.removeHooks=function(r){N(d,r)&&(d[r]=[])},s.removeAllHooks=function(){d=gn()},s}var Uo=On();export{Uo as default};
|