Spaces:
Running
Running
sab
commited on
Commit
·
e1a5dbb
1
Parent(s):
f9e5e48
- assets/index-dKoIuxf-.js +1 -1
assets/index-dKoIuxf-.js
CHANGED
@@ -93,4 +93,4 @@ ${s}</tr>
|
|
93 |
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${bt(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:o,tokens:a}){const f=this.parser.parseInline(a),p=Kc(s);if(p===null)return f;s=p;let y='<a href="'+s+'"';return o&&(y+=' title="'+bt(o)+'"'),y+=">"+f+"</a>",y}image({href:s,title:o,text:a}){const f=Kc(s);if(f===null)return bt(a);s=f;let p=`<img src="${s}" alt="${a}"`;return o&&(p+=` title="${bt(o)}"`),p+=">",p}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:bt(s.text)}}class hu{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}}class At{constructor(s){Se(this,"options");Se(this,"renderer");Se(this,"textRenderer");this.options=s||hr,this.options.renderer=this.options.renderer||new so,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hu}static parse(s,o){return new At(o).parse(s)}static parseInline(s,o){return new At(o).parseInline(s)}parse(s,o=!0){var f,p;let a="";for(let y=0;y<s.length;y++){const k=s[y];if((p=(f=this.options.extensions)==null?void 0:f.renderers)!=null&&p[k.type]){const T=k,S=this.options.extensions.renderers[T.type].call({parser:this},T);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(T.type)){a+=S||"";continue}}const _=k;switch(_.type){case"space":{a+=this.renderer.space(_);continue}case"hr":{a+=this.renderer.hr(_);continue}case"heading":{a+=this.renderer.heading(_);continue}case"code":{a+=this.renderer.code(_);continue}case"table":{a+=this.renderer.table(_);continue}case"blockquote":{a+=this.renderer.blockquote(_);continue}case"list":{a+=this.renderer.list(_);continue}case"html":{a+=this.renderer.html(_);continue}case"paragraph":{a+=this.renderer.paragraph(_);continue}case"text":{let T=_,S=this.renderer.text(T);for(;y+1<s.length&&s[y+1].type==="text";)T=s[++y],S+=`
|
94 |
`+this.renderer.text(T);o?a+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):a+=S;continue}default:{const T='Token with "'+_.type+'" type was not found.';if(this.options.silent)return console.error(T),"";throw new Error(T)}}}return a}parseInline(s,o=this.renderer){var f,p;let a="";for(let y=0;y<s.length;y++){const k=s[y];if((p=(f=this.options.extensions)==null?void 0:f.renderers)!=null&&p[k.type]){const T=this.options.extensions.renderers[k.type].call({parser:this},k);if(T!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(k.type)){a+=T||"";continue}}const _=k;switch(_.type){case"escape":{a+=o.text(_);break}case"html":{a+=o.html(_);break}case"link":{a+=o.link(_);break}case"image":{a+=o.image(_);break}case"strong":{a+=o.strong(_);break}case"em":{a+=o.em(_);break}case"codespan":{a+=o.codespan(_);break}case"br":{a+=o.br(_);break}case"del":{a+=o.del(_);break}case"text":{a+=o.text(_);break}default:{const T='Token with "'+_.type+'" type was not found.';if(this.options.silent)return console.error(T),"";throw new Error(T)}}}return a}}class Hl{constructor(s){Se(this,"options");Se(this,"block");this.options=s||hr}preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}provideLexer(){return this.block?Pt.lex:Pt.lexInline}provideParser(){return this.block?At.parse:At.parseInline}}Se(Hl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class lh{constructor(...s){Se(this,"defaults",su());Se(this,"options",this.setOptions);Se(this,"parse",this.parseMarkdown(!0));Se(this,"parseInline",this.parseMarkdown(!1));Se(this,"Parser",At);Se(this,"Renderer",so);Se(this,"TextRenderer",hu);Se(this,"Lexer",Pt);Se(this,"Tokenizer",oo);Se(this,"Hooks",Hl);this.use(...s)}walkTokens(s,o){var f,p;let a=[];for(const y of s)switch(a=a.concat(o.call(this,y)),y.type){case"table":{const k=y;for(const _ of k.header)a=a.concat(this.walkTokens(_.tokens,o));for(const _ of k.rows)for(const T of _)a=a.concat(this.walkTokens(T.tokens,o));break}case"list":{const k=y;a=a.concat(this.walkTokens(k.items,o));break}default:{const k=y;(p=(f=this.defaults.extensions)==null?void 0:f.childTokens)!=null&&p[k.type]?this.defaults.extensions.childTokens[k.type].forEach(_=>{const T=k[_].flat(1/0);a=a.concat(this.walkTokens(T,o))}):k.tokens&&(a=a.concat(this.walkTokens(k.tokens,o)))}}return a}use(...s){const o=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(a=>{const f={...a};if(f.async=this.defaults.async||f.async||!1,a.extensions&&(a.extensions.forEach(p=>{if(!p.name)throw new Error("extension name required");if("renderer"in p){const y=o.renderers[p.name];y?o.renderers[p.name]=function(...k){let _=p.renderer.apply(this,k);return _===!1&&(_=y.apply(this,k)),_}:o.renderers[p.name]=p.renderer}if("tokenizer"in p){if(!p.level||p.level!=="block"&&p.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const y=o[p.level];y?y.unshift(p.tokenizer):o[p.level]=[p.tokenizer],p.start&&(p.level==="block"?o.startBlock?o.startBlock.push(p.start):o.startBlock=[p.start]:p.level==="inline"&&(o.startInline?o.startInline.push(p.start):o.startInline=[p.start]))}"childTokens"in p&&p.childTokens&&(o.childTokens[p.name]=p.childTokens)}),f.extensions=o),a.renderer){const p=this.defaults.renderer||new so(this.defaults);for(const y in a.renderer){if(!(y in p))throw new Error(`renderer '${y}' does not exist`);if(["options","parser"].includes(y))continue;const k=y,_=a.renderer[k],T=p[k];p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O||""}}f.renderer=p}if(a.tokenizer){const p=this.defaults.tokenizer||new oo(this.defaults);for(const y in a.tokenizer){if(!(y in p))throw new Error(`tokenizer '${y}' does not exist`);if(["options","rules","lexer"].includes(y))continue;const k=y,_=a.tokenizer[k],T=p[k];p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O}}f.tokenizer=p}if(a.hooks){const p=this.defaults.hooks||new Hl;for(const y in a.hooks){if(!(y in p))throw new Error(`hook '${y}' does not exist`);if(["options","block"].includes(y))continue;const k=y,_=a.hooks[k],T=p[k];Hl.passThroughHooks.has(y)?p[k]=S=>{if(this.defaults.async)return Promise.resolve(_.call(p,S)).then(A=>T.call(p,A));const O=_.call(p,S);return T.call(p,O)}:p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O}}f.hooks=p}if(a.walkTokens){const p=this.defaults.walkTokens,y=a.walkTokens;f.walkTokens=function(k){let _=[];return _.push(y.call(this,k)),p&&(_=_.concat(p.call(this,k))),_}}this.defaults={...this.defaults,...f}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,o){return Pt.lex(s,o??this.defaults)}parser(s,o){return At.parse(s,o??this.defaults)}parseMarkdown(s){return(a,f)=>{const p={...f},y={...this.defaults,...p},k=this.onError(!!y.silent,!!y.async);if(this.defaults.async===!0&&p.async===!1)return k(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof a>"u"||a===null)return k(new Error("marked(): input parameter is undefined or null"));if(typeof a!="string")return k(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(a)+", string expected"));y.hooks&&(y.hooks.options=y,y.hooks.block=s);const _=y.hooks?y.hooks.provideLexer():s?Pt.lex:Pt.lexInline,T=y.hooks?y.hooks.provideParser():s?At.parse:At.parseInline;if(y.async)return Promise.resolve(y.hooks?y.hooks.preprocess(a):a).then(S=>_(S,y)).then(S=>y.hooks?y.hooks.processAllTokens(S):S).then(S=>y.walkTokens?Promise.all(this.walkTokens(S,y.walkTokens)).then(()=>S):S).then(S=>T(S,y)).then(S=>y.hooks?y.hooks.postprocess(S):S).catch(k);try{y.hooks&&(a=y.hooks.preprocess(a));let S=_(a,y);y.hooks&&(S=y.hooks.processAllTokens(S)),y.walkTokens&&this.walkTokens(S,y.walkTokens);let O=T(S,y);return y.hooks&&(O=y.hooks.postprocess(O)),O}catch(S){return k(S)}}}onError(s,o){return a=>{if(a.message+=`
|
95 |
Please report this to https://github.com/markedjs/marked.`,s){const f="<p>An error occurred:</p><pre>"+bt(a.message+"",!0)+"</pre>";return o?Promise.resolve(f):f}if(o)return Promise.reject(a);throw a}}}const pr=new lh;function ve(d,s){return pr.parse(d,s)}ve.options=ve.setOptions=function(d){return pr.setOptions(d),ve.defaults=pr.defaults,hf(ve.defaults),ve};ve.getDefaults=su;ve.defaults=hr;ve.use=function(...d){return pr.use(...d),ve.defaults=pr.defaults,hf(ve.defaults),ve};ve.walkTokens=function(d,s){return pr.walkTokens(d,s)};ve.parseInline=pr.parseInline;ve.Parser=At;ve.parser=At.parse;ve.Renderer=so;ve.TextRenderer=hu;ve.Lexer=Pt;ve.lexer=Pt.lex;ve.Tokenizer=oo;ve.Hooks=Hl;ve.parse=ve;ve.options;ve.setOptions;ve.use;ve.walkTokens;ve.parseInline;At.parse;Pt.lex;/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:Ef,setPrototypeOf:qc,isFrozen:ih,getPrototypeOf:oh,getOwnPropertyDescriptor:sh}=Object;let{freeze:st,seal:Mt,create:_f}=Object,{apply:nu,construct:ru}=typeof Reflect<"u"&&Reflect;st||(st=function(s){return s});Mt||(Mt=function(s){return s});nu||(nu=function(s,o,a){return s.apply(o,a)});ru||(ru=function(s,o){return new s(...o)});const no=wt(Array.prototype.forEach),Jc=wt(Array.prototype.pop),zl=wt(Array.prototype.push),lo=wt(String.prototype.toLowerCase),Zs=wt(String.prototype.toString),ef=wt(String.prototype.match),Ol=wt(String.prototype.replace),uh=wt(String.prototype.indexOf),ah=wt(String.prototype.trim),Ht=wt(Object.prototype.hasOwnProperty),it=wt(RegExp.prototype.test),Il=ch(TypeError);function wt(d){return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),f=1;f<o;f++)a[f-1]=arguments[f];return nu(d,s,a)}}function ch(d){return function(){for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return ru(d,o)}}function se(d,s){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lo;qc&&qc(d,null);let a=s.length;for(;a--;){let f=s[a];if(typeof f=="string"){const p=o(f);p!==f&&(ih(s)||(s[a]=p),f=p)}d[f]=!0}return d}function fh(d){for(let s=0;s<d.length;s++)Ht(d,s)||(d[s]=null);return d}function dr(d){const s=_f(null);for(const[o,a]of Ef(d))Ht(d,o)&&(Array.isArray(a)?s[o]=fh(a):a&&typeof a=="object"&&a.constructor===Object?s[o]=dr(a):s[o]=a);return s}function Dl(d,s){for(;d!==null;){const a=sh(d,s);if(a){if(a.get)return wt(a.get);if(typeof a.value=="function")return wt(a.value)}d=oh(d)}function o(){return null}return o}const tf=st(["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","section","select","shadow","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"]),bs=st(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qs=st(["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"]),dh=st(["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"]),Js=st(["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"]),ph=st(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),nf=st(["#text"]),rf=st(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),eu=st(["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","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","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-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"]),lf=st(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","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"]),ro=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hh=Mt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mh=Mt(/<%[\w\W]*|[\w\W]*%>/gm),gh=Mt(/\$\{[\w\W]*}/gm),yh=Mt(/^data-[\-\w.\u00B7-\uFFFF]+$/),vh=Mt(/^aria-[\-\w]+$/),Tf=Mt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kh=Mt(/^(?:\w+script|data):/i),wh=Mt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cf=Mt(/^html$/i),xh=Mt(/^[a-z][.\w]*(-[.\w]+)+$/i);var of=Object.freeze({__proto__:null,ARIA_ATTR:vh,ATTR_WHITESPACE:wh,CUSTOM_ELEMENT:xh,DATA_ATTR:yh,DOCTYPE_NAME:Cf,ERB_EXPR:mh,IS_ALLOWED_URI:Tf,IS_SCRIPT_OR_DATA:kh,MUSTACHE_EXPR:hh,TMPLIT_EXPR:gh});const jl={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Sh=function(){return typeof window>"u"?null:window},Eh=function(s,o){if(typeof s!="object"||typeof s.createPolicy!="function")return null;let a=null;const f="data-tt-policy-suffix";o&&o.hasAttribute(f)&&(a=o.getAttribute(f));const p="dompurify"+(a?"#"+a:"");try{return s.createPolicy(p,{createHTML(y){return y},createScriptURL(y){return y}})}catch{return console.warn("TrustedTypes policy "+p+" could not be created."),null}},sf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rf(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Sh();const s=X=>Rf(X);if(s.version="3.2.3",s.removed=[],!d||!d.document||d.document.nodeType!==jl.document)return s.isSupported=!1,s;let{document:o}=d;const a=o,f=a.currentScript,{DocumentFragment:p,HTMLTemplateElement:y,Node:k,Element:_,NodeFilter:T,NamedNodeMap:S=d.NamedNodeMap||d.MozNamedAttrMap,HTMLFormElement:O,DOMParser:A,trustedTypes:I}=d,G=_.prototype,j=Dl(G,"cloneNode"),K=Dl(G,"remove"),ce=Dl(G,"nextSibling"),ge=Dl(G,"childNodes"),Ee=Dl(G,"parentNode");if(typeof y=="function"){const X=o.createElement("template");X.content&&X.content.ownerDocument&&(o=X.content.ownerDocument)}let te,fe="";const{implementation:ne,createNodeIterator:_e,createDocumentFragment:Q,getElementsByTagName:Ie}=o,{importNode:Le}=a;let ue=sf();s.isSupported=typeof Ef=="function"&&typeof Ee=="function"&&ne&&ne.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ze,ERB_EXPR:Be,TMPLIT_EXPR:Xe,DATA_ATTR:ut,ARIA_ATTR:De,IS_SCRIPT_OR_DATA:ke,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:J}=of;let{IS_ALLOWED_URI:U}=of,v=null;const C=se({},[...tf,...bs,...qs,...Js,...nf]);let Y=null;const re=se({},[...rf,...eu,...lf,...ro]);let Z=Object.seal(_f(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}})),ie=null,he=null,de=!0,we=!0,be=!1,Vn=!0,qt=!1,pn=!0,zt=!1,mr=!1,gr=!1,Wt=!1,Qn=!1,hn=!1,mn=!0,Jt=!1;const Qr="user-content-";let yr=!0,gn=!1,en={},tn=null;const vr=se({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Gn=null;const Gr=se({},["audio","video","img","source","image","track"]);let nn=null;const yn=se({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kr="http://www.w3.org/1998/Math/MathML",Yn="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let vn=xt,Xn=!1,Kn=null;const Yr=se({},[kr,Yn,xt],Zs);let kn=se({},["mi","mo","mn","ms","mtext"]),wn=se({},["annotation-xml"]);const xn=se({},["title","style","font","a","script"]);let St=null;const Vl=["application/xhtml+xml","text/html"],Ql="text/html";let je=null,rn=null;const Gl=o.createElement("form"),wr=function(g){return g instanceof RegExp||g instanceof Function},xr=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rn&&rn===g)){if((!g||typeof g!="object")&&(g={}),g=dr(g),St=Vl.indexOf(g.PARSER_MEDIA_TYPE)===-1?Ql:g.PARSER_MEDIA_TYPE,je=St==="application/xhtml+xml"?Zs:lo,v=Ht(g,"ALLOWED_TAGS")?se({},g.ALLOWED_TAGS,je):C,Y=Ht(g,"ALLOWED_ATTR")?se({},g.ALLOWED_ATTR,je):re,Kn=Ht(g,"ALLOWED_NAMESPACES")?se({},g.ALLOWED_NAMESPACES,Zs):Yr,nn=Ht(g,"ADD_URI_SAFE_ATTR")?se(dr(yn),g.ADD_URI_SAFE_ATTR,je):yn,Gn=Ht(g,"ADD_DATA_URI_TAGS")?se(dr(Gr),g.ADD_DATA_URI_TAGS,je):Gr,tn=Ht(g,"FORBID_CONTENTS")?se({},g.FORBID_CONTENTS,je):vr,ie=Ht(g,"FORBID_TAGS")?se({},g.FORBID_TAGS,je):{},he=Ht(g,"FORBID_ATTR")?se({},g.FORBID_ATTR,je):{},en=Ht(g,"USE_PROFILES")?g.USE_PROFILES:!1,de=g.ALLOW_ARIA_ATTR!==!1,we=g.ALLOW_DATA_ATTR!==!1,be=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Vn=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=g.SAFE_FOR_TEMPLATES||!1,pn=g.SAFE_FOR_XML!==!1,zt=g.WHOLE_DOCUMENT||!1,Wt=g.RETURN_DOM||!1,Qn=g.RETURN_DOM_FRAGMENT||!1,hn=g.RETURN_TRUSTED_TYPE||!1,gr=g.FORCE_BODY||!1,mn=g.SANITIZE_DOM!==!1,Jt=g.SANITIZE_NAMED_PROPS||!1,yr=g.KEEP_CONTENT!==!1,gn=g.IN_PLACE||!1,U=g.ALLOWED_URI_REGEXP||Tf,vn=g.NAMESPACE||xt,kn=g.MATHML_TEXT_INTEGRATION_POINTS||kn,wn=g.HTML_INTEGRATION_POINTS||wn,Z=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&wr(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Z.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&wr(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Z.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(we=!1),Qn&&(Wt=!0),en&&(v=se({},nf),Y=[],en.html===!0&&(se(v,tf),se(Y,rf)),en.svg===!0&&(se(v,bs),se(Y,eu),se(Y,ro)),en.svgFilters===!0&&(se(v,qs),se(Y,eu),se(Y,ro)),en.mathMl===!0&&(se(v,Js),se(Y,lf),se(Y,ro))),g.ADD_TAGS&&(v===C&&(v=dr(v)),se(v,g.ADD_TAGS,je)),g.ADD_ATTR&&(Y===re&&(Y=dr(Y)),se(Y,g.ADD_ATTR,je)),g.ADD_URI_SAFE_ATTR&&se(nn,g.ADD_URI_SAFE_ATTR,je),g.FORBID_CONTENTS&&(tn===vr&&(tn=dr(tn)),se(tn,g.FORBID_CONTENTS,je)),yr&&(v["#text"]=!0),zt&&se(v,["html","head","body"]),v.table&&(se(v,["tbody"]),delete ie.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=g.TRUSTED_TYPES_POLICY,fe=te.createHTML("")}else te===void 0&&(te=Eh(I,f)),te!==null&&typeof fe=="string"&&(fe=te.createHTML(""));st&&st(g),rn=g}},Sn=se({},[...bs,...qs,...dh]),Sr=se({},[...Js,...ph]),Zn=function(g){let M=Ee(g);(!M||!M.tagName)&&(M={namespaceURI:vn,tagName:"template"});const H=lo(g.tagName),Te=lo(M.tagName);return Kn[g.namespaceURI]?g.namespaceURI===Yn?M.namespaceURI===xt?H==="svg":M.namespaceURI===kr?H==="svg"&&(Te==="annotation-xml"||kn[Te]):!!Sn[H]:g.namespaceURI===kr?M.namespaceURI===xt?H==="math":M.namespaceURI===Yn?H==="math"&&wn[Te]:!!Sr[H]:g.namespaceURI===xt?M.namespaceURI===Yn&&!wn[Te]||M.namespaceURI===kr&&!kn[Te]?!1:!Sr[H]&&(xn[H]||!Sn[H]):!!(St==="application/xhtml+xml"&&Kn[g.namespaceURI]):!1},Et=function(g){zl(s.removed,{element:g});try{Ee(g).removeChild(g)}catch{K(g)}},Vt=function(g,M){try{zl(s.removed,{attribute:M.getAttributeNode(g),from:M})}catch{zl(s.removed,{attribute:null,from:M})}if(M.removeAttribute(g),g==="is")if(Wt||Qn)try{Et(M)}catch{}else try{M.setAttribute(g,"")}catch{}},bn=function(g){let M=null,H=null;if(gr)g="<remove></remove>"+g;else{const le=ef(g,/^[\r\n\t ]+/);H=le&&le[0]}St==="application/xhtml+xml"&&vn===xt&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const Te=te?te.createHTML(g):g;if(vn===xt)try{M=new A().parseFromString(Te,St)}catch{}if(!M||!M.documentElement){M=ne.createDocument(vn,"template",null);try{M.documentElement.innerHTML=Xn?fe:Te}catch{}}const Ve=M.body||M.documentElement;return g&&H&&Ve.insertBefore(o.createTextNode(H),Ve.childNodes[0]||null),vn===xt?Ie.call(M,zt?"html":"body")[0]:zt?M.documentElement:Ve},qn=function(g){return _e.call(g.ownerDocument||g,g,T.SHOW_ELEMENT|T.SHOW_COMMENT|T.SHOW_TEXT|T.SHOW_PROCESSING_INSTRUCTION|T.SHOW_CDATA_SECTION,null)},Jn=function(g){return g instanceof O&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof S)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},Yl=function(g){return typeof k=="function"&&g instanceof k};function Ot(X,g,M){no(X,H=>{H.call(s,g,M,rn)})}const Xl=function(g){let M=null;if(Ot(ue.beforeSanitizeElements,g,null),Jn(g))return Et(g),!0;const H=je(g.nodeName);if(Ot(ue.uponSanitizeElement,g,{tagName:H,allowedTags:v}),g.hasChildNodes()&&!Yl(g.firstElementChild)&&it(/<[/\w]/g,g.innerHTML)&&it(/<[/\w]/g,g.textContent)||g.nodeType===jl.progressingInstruction||pn&&g.nodeType===jl.comment&&it(/<[/\w]/g,g.data))return Et(g),!0;if(!v[H]||ie[H]){if(!ie[H]&&Xr(H)&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,H)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(H)))return!1;if(yr&&!tn[H]){const Te=Ee(g)||g.parentNode,Ve=ge(g)||g.childNodes;if(Ve&&Te){const le=Ve.length;for(let qe=le-1;qe>=0;--qe){const at=j(Ve[qe],!0);at.__removalCount=(g.__removalCount||0)+1,Te.insertBefore(at,ce(g))}}}return Et(g),!0}return g instanceof _&&!Zn(g)||(H==="noscript"||H==="noembed"||H==="noframes")&&it(/<\/no(script|embed|frames)/i,g.innerHTML)?(Et(g),!0):(qt&&g.nodeType===jl.text&&(M=g.textContent,no([ze,Be,Xe],Te=>{M=Ol(M,Te," ")}),g.textContent!==M&&(zl(s.removed,{element:g.cloneNode()}),g.textContent=M)),Ot(ue.afterSanitizeElements,g,null),!1)},Qt=function(g,M,H){if(mn&&(M==="id"||M==="name")&&(H in o||H in Gl))return!1;if(!(we&&!he[M]&&it(ut,M))){if(!(de&&it(De,M))){if(!Y[M]||he[M]){if(!(Xr(g)&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,g)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(g))&&(Z.attributeNameCheck instanceof RegExp&&it(Z.attributeNameCheck,M)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(M))||M==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,H)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(H))))return!1}else if(!nn[M]){if(!it(U,Ol(H,D,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&g!=="script"&&uh(H,"data:")===0&&Gn[g])){if(!(be&&!it(ke,Ol(H,D,"")))){if(H)return!1}}}}}}return!0},Xr=function(g){return g!=="annotation-xml"&&ef(g,J)},Kr=function(g){Ot(ue.beforeSanitizeAttributes,g,null);const{attributes:M}=g;if(!M||Jn(g))return;const H={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let Te=M.length;for(;Te--;){const Ve=M[Te],{name:le,namespaceURI:qe,value:at}=Ve,En=je(le);let Ue=le==="value"?at:ah(at);if(H.attrName=En,H.attrValue=Ue,H.keepAttr=!0,H.forceKeepAttr=void 0,Ot(ue.uponSanitizeAttribute,g,H),Ue=H.attrValue,Jt&&(En==="id"||En==="name")&&(Vt(le,g),Ue=Qr+Ue),pn&&it(/((--!?|])>)|<\/(style|title)/i,Ue)){Vt(le,g);continue}if(H.forceKeepAttr||(Vt(le,g),!H.keepAttr))continue;if(!Vn&&it(/\/>/i,Ue)){Vt(le,g);continue}qt&&no([ze,Be,Xe],Zr=>{Ue=Ol(Ue,Zr," ")});const Kl=je(g.nodeName);if(Qt(Kl,En,Ue)){if(te&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!qe)switch(I.getAttributeType(Kl,En)){case"TrustedHTML":{Ue=te.createHTML(Ue);break}case"TrustedScriptURL":{Ue=te.createScriptURL(Ue);break}}try{qe?g.setAttributeNS(qe,le,Ue):g.setAttribute(le,Ue),Jn(g)?Et(g):Jc(s.removed)}catch{}}}Ot(ue.afterSanitizeAttributes,g,null)},co=function X(g){let M=null;const H=qn(g);for(Ot(ue.beforeSanitizeShadowDOM,g,null);M=H.nextNode();)Ot(ue.uponSanitizeShadowNode,M,null),Xl(M),Kr(M),M.content instanceof p&&X(M.content);Ot(ue.afterSanitizeShadowDOM,g,null)};return s.sanitize=function(X){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,H=null,Te=null,Ve=null;if(Xn=!X,Xn&&(X="<!-->"),typeof X!="string"&&!Yl(X))if(typeof X.toString=="function"){if(X=X.toString(),typeof X!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!s.isSupported)return X;if(mr||xr(g),s.removed=[],typeof X=="string"&&(gn=!1),gn){if(X.nodeName){const at=je(X.nodeName);if(!v[at]||ie[at])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(X instanceof k)M=bn("<!---->"),H=M.ownerDocument.importNode(X,!0),H.nodeType===jl.element&&H.nodeName==="BODY"||H.nodeName==="HTML"?M=H:M.appendChild(H);else{if(!Wt&&!qt&&!zt&&X.indexOf("<")===-1)return te&&hn?te.createHTML(X):X;if(M=bn(X),!M)return Wt?null:hn?fe:""}M&&gr&&Et(M.firstChild);const le=qn(gn?X:M);for(;Te=le.nextNode();)Xl(Te),Kr(Te),Te.content instanceof p&&co(Te.content);if(gn)return X;if(Wt){if(Qn)for(Ve=Q.call(M.ownerDocument);M.firstChild;)Ve.appendChild(M.firstChild);else Ve=M;return(Y.shadowroot||Y.shadowrootmode)&&(Ve=Le.call(a,Ve,!0)),Ve}let qe=zt?M.outerHTML:M.innerHTML;return zt&&v["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&it(Cf,M.ownerDocument.doctype.name)&&(qe="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
|
96 |
-
`+qe),qt&&no([ze,Be,Xe],at=>{qe=Ol(qe,at," ")}),te&&hn?te.createHTML(qe):qe},s.setConfig=function(){let X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xr(X),mr=!0},s.clearConfig=function(){rn=null,mr=!1},s.isValidAttribute=function(X,g,M){rn||xr({});const H=je(X),Te=je(g);return Qt(H,Te,M)},s.addHook=function(X,g){typeof g=="function"&&zl(ue[X],g)},s.removeHook=function(X){return Jc(ue[X])},s.removeHooks=function(X){ue[X]=[]},s.removeAllHooks=function(){ue=sf()},s}var _h=Rf();function Th(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M12 8V4H8"}),L.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),L.jsx("path",{d:"M2 14h2"}),L.jsx("path",{d:"M20 14h2"}),L.jsx("path",{d:"M15 13v2"}),L.jsx("path",{d:"M9 13v2"})]})}function Ch(d){return L.jsx("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 32 32",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:L.jsx("path",{className:"stroke-gray-600 dark:stroke-gray-400",d:"M16 6v3.33M16 6c0-2.65 3.25-4.3 5.4-2.62 1.2.95 1.6 2.65.95 4.04a3.63 3.63 0 0 1 4.61.16 3.45 3.45 0 0 1 .46 4.37 5.32 5.32 0 0 1 1.87 4.75c-.22 1.66-1.39 3.6-3.07 4.14M16 6c0-2.65-3.25-4.3-5.4-2.62a3.37 3.37 0 0 0-.95 4.04 3.65 3.65 0 0 0-4.6.16 3.37 3.37 0 0 0-.49 4.27 5.57 5.57 0 0 0-1.85 4.85 5.3 5.3 0 0 0 3.07 4.15M16 9.33v17.34m0-17.34c0 2.18 1.82 4 4 4m6.22 7.5c.67 1.3.56 2.91-.27 4.11a4.05 4.05 0 0 1-4.62 1.5c0 1.53-1.05 2.9-2.66 2.9A2.7 2.7 0 0 1 16 26.66m10.22-5.83a4.05 4.05 0 0 0-3.55-2.17m-16.9 2.18a4.05 4.05 0 0 0 .28 4.1c1 1.44 2.92 2.09 4.59 1.5 0 1.52 1.12 2.88 2.7 2.88A2.7 2.7 0 0 0 16 26.67M5.78 20.85a4.04 4.04 0 0 1 3.55-2.18"})})}function Rh(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),L.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}var lu=function(){return(lu=Object.assign||function(d){for(var s,o=1,a=arguments.length;o<a;o++)for(var f in s=arguments[o])Object.prototype.hasOwnProperty.call(s,f)&&(d[f]=s[f]);return d}).apply(this,arguments)},Fl,Ul,iu=me.createContext(void 0),uf="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_CHTML",af="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js",Nh=function(S){var s=S.config,o=S.version,o=o===void 0?3:o,a=S.src,a=a===void 0?o===2?uf:af:a,f=S.onStartup,p=S.onLoad,y=S.onError,k=S.typesettingOptions,_=S.renderMode,_=_===void 0?"post":_,T=S.hideUntilTypeset,S=S.children,A=me.useContext(iu);if((A==null?void 0:A.version)!==void 0&&(A==null?void 0:A.version)!==o)throw Error("Cannot nest MathJaxContexts with different versions. MathJaxContexts should not be nested at all but if they are, they cannot have different versions. Stick with one version of MathJax in your app and avoid using more than one MathJaxContext.");if(o===2&&Ul!==void 0||o===3&&Fl!==void 0)throw Error("Cannot use MathJax versions 2 and 3 simultaneously in the same app due to how MathJax is set up in the browser; either you have multiple MathJaxContexts with different versions or you have mounted and unmounted MathJaxContexts with different versions. Please stick with one version of MathJax in your app. File an issue in the project Github page if you need this feature.");var O=me.useRef(A),A=me.useRef((A==null?void 0:A.version)||null);if(A.current===null)A.current=o;else if(A.current!==o)throw Error("Cannot change version of MathJax in a MathJaxContext after it has mounted. Reload the page with a new version when this must happen.");var I=a||(o===2?uf:af);function G(j,K){s&&(window.MathJax=s);var ce=document.createElement("script");ce.type="text/javascript",ce.src=I,ce.async=!1,ce.addEventListener("load",function(){var ge=window.MathJax;f&&f(ge),j(ge),p&&p()}),ce.addEventListener("error",function(ge){return K(ge)}),document.getElementsByTagName("head")[0].appendChild(ce)}return O.current===void 0&&(A={typesettingOptions:k,renderMode:_,hideUntilTypeset:T},o===2?Fl===void 0&&(typeof window<"u"?(Fl=new Promise(G)).catch(function(j){if(!y)throw Error("Failed to download MathJax version 2 from '".concat(I,"' due to: ").concat(j));y(j)}):(Fl=Promise.reject()).catch(function(j){})):Ul===void 0&&(typeof window<"u"?(Ul=new Promise(G)).catch(function(j){if(!y)throw Error("Failed to download MathJax version 3 from '".concat(I,"' due to: ").concat(j));y(j)}):(Ul=Promise.reject()).catch(function(j){})),O.current=lu(lu({},A),o===2?{version:2,promise:Fl}:{version:3,promise:Ul})),pf.createElement(iu.Provider,{value:O.current},S)},Wn=function(){return(Wn=Object.assign||function(d){for(var s,o=1,a=arguments.length;o<a;o++)for(var f in s=arguments[o])Object.prototype.hasOwnProperty.call(s,f)&&(d[f]=s[f]);return d}).apply(this,arguments)},Lh=function(d,s){var o={};for(f in d)Object.prototype.hasOwnProperty.call(d,f)&&s.indexOf(f)<0&&(o[f]=d[f]);if(d!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,f=Object.getOwnPropertySymbols(d);a<f.length;a++)s.indexOf(f[a])<0&&Object.prototype.propertyIsEnumerable.call(d,f[a])&&(o[f[a]]=d[f[a]]);return o},$l=function(d){return"Typesetting failed: ".concat(d.message!==void 0?d.message:d.toString())},cf=function(d){function s(){var fe;j==="every"&&ge&&K==="post"&&I.current!==null&&(I.current.style.visibility=(fe=(fe=O.style)==null?void 0:fe.visibility)!=null?fe:"visible"),Ee.current||(j==="first"&&I.current!==null&&(I.current.style.visibility="visible"),f&&f(),Ee.current=!0),p&&p(),te.current=!1}var a=d.inline,o=a!==void 0&&a,a=d.hideUntilTypeset,f=d.onInitTypeset,p=d.onTypeset,y=d.text,k=d.dynamic,_=d.typesettingOptions,T=d.renderMode,S=d.children,O=Lh(d,["inline","hideUntilTypeset","onInitTypeset","onTypeset","text","dynamic","typesettingOptions","renderMode","children"]),A=me.useRef(""),I=me.useRef(null),G=me.useContext(iu),j=a??(G==null?void 0:G.hideUntilTypeset),K=T??(G==null?void 0:G.renderMode),ce=_??(G==null?void 0:G.typesettingOptions),ge=k!==!1&&(k||!1),Ee=me.useRef(!1),te=me.useRef(!1);return!te.current&&I.current!==null&&ge&&j==="every"&&K==="post"&&(I.current.style.visibility="hidden"),(typeof window<"u"?me.useLayoutEffect:me.useEffect)(function(){if((ge||!Ee.current)&&I.current!==null){if(!G)throw Error("MathJax was not loaded, did you use the MathJax component outside of a MathJaxContext?");if(K==="pre"){if(!(typeof(fe=y)=="string"&&0<fe.length))throw Error(`Render mode 'pre' requires text prop to be set and non-empty, which was currently "`.concat(y,'"'));if(!_||!_.fn)throw Error("Render mode 'pre' requires 'typesettingOptions' prop with 'fn' property to be set on MathJax element or in the MathJaxContext");if(G.version===2)throw Error("Render mode 'pre' only available with MathJax 3, and version 2 is currently in use")}K!=="post"&&y===A.current||te.current||(te.current=!0,G.version===3?G.promise.then(function(ne){var _e;K==="pre"?(_e=function(Q){A.current=y,ne.startup.document.clear(),ne.startup.document.updateDocument(),I.current!==null&&(I.current.innerHTML=Q.outerHTML),s()},_.fn.endsWith("Promise")?ne.startup.promise.then(function(){return ne[ce.fn](y,Wn(Wn({},(ce==null?void 0:ce.options)||{}),{display:!o}))}).then(_e).catch(function(Q){throw s(),Error($l(Q))}):ne.startup.promise.then(function(){var Q=ne[ce.fn](y,Wn(Wn({},(ce==null?void 0:ce.options)||{}),{display:!o}));_e(Q)}).catch(function(Q){throw s(),Error($l(Q))})):ne.startup.promise.then(function(){return ne.typesetClear([I.current]),ne.typesetPromise([I.current])}).then(s).catch(function(Q){throw s(),Error($l(Q))})}).catch(function(ne){throw s(),Error($l(ne))}):G.promise.then(function(ne){ne.Hub.Queue(["Typeset",ne.Hub,I.current]),ne.Hub.Queue(s)}).catch(function(ne){throw s(),Error($l(ne))}))}var fe}),pf.createElement("span",Wn({},O,{style:Wn(Wn({display:o?"inline":"block"},O.style),{visibility:j?"hidden":(d=O.style)==null?void 0:d.visibility}),ref:I}),S)};function ff(d){return d=d.replace(/\\([\[\]\(\)])/g,"\\\\$1"),_h.sanitize(ve.parse(d,{async:!1,breaks:!0}))}function Ph({role:d,content:s,answerIndex:o}){const a=o?s.slice(0,o):s,f=o?s.slice(o):"",[p,y]=me.useState(!1),k=f.length>0;return L.jsx("div",{className:"flex items-start space-x-4",children:d==="assistant"?L.jsxs(L.Fragment,{children:[L.jsx(Th,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),L.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:L.jsx("div",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:a.length>0?L.jsxs(L.Fragment,{children:[L.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg flex flex-col",children:[L.jsxs("button",{className:"flex items-center gap-2 cursor-pointer p-4 hover:bg-gray-50 dark:hover:bg-gray-900 rounded-lg ",onClick:()=>y(_=>!_),style:{width:p?"100%":"auto"},children:[L.jsx(Ch,{className:k?"":"animate-pulse"}),L.jsx("span",{children:k?"View reasoning.":"Thinking..."}),L.jsx("span",{className:"ml-auto text-gray-700",children:p?"▲":"▼"})]}),p&&L.jsx(cf,{className:"border-t border-gray-200 dark:border-gray-700 px-4 py-2",dynamic:!0,children:L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:ff(a)}})})]}),k&&L.jsx(cf,{className:"mt-2",dynamic:!0,children:L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:ff(f)}})})]}):L.jsxs("span",{className:"h-6 flex items-center gap-1",children:[L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):L.jsxs(L.Fragment,{children:[L.jsx(Rh,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),L.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:L.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:s})})]})})}function Ah({messages:d}){const s=d.length===0;return L.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${s?"flex flex-col items-center justify-end":"space-y-4"}`,children:L.jsx(Nh,{children:s?L.jsx("div",{className:"text-xl",children:"Ready!"}):d.map((o,a)=>L.jsx(Ph,{...o},`message-${a}`))})})}function df(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M5 12h14"}),L.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Mh(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),L.jsx("path",{fill:"currentColor",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})]})}function zh(d){const s=d==0?0:Math.floor(Math.log(d)/Math.log(1024));return+(d/Math.pow(1024,s)).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}function Oh({text:d,percentage:s,total:o}){return s??(s=0),L.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:L.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${s}%`},children:[d," (",s.toFixed(2),"%",isNaN(o)?"":` of ${zh(o)}`,")"]})})}const Ih=!!navigator.gpu,Dh=120,jh=["Solve the equation x^2 - 3x + 2 = 0","Lily is three times older than her son. In 15 years, she will be twice as old as him. How old is she now?","Write python code to compute the nth fibonacci number."];function Fh(){const d=me.useRef(null),s=me.useRef(null),o=me.useRef(null),[a,f]=me.useState(null),[p,y]=me.useState(null),[k,_]=me.useState(""),[T,S]=me.useState([]),[O,A]=me.useState(!1),[I,G]=me.useState(""),[j,K]=me.useState([]),[ce,ge]=me.useState(null),[Ee,te]=me.useState(null);function fe(Q){K(Ie=>[...Ie,{role:"user",content:Q}]),ge(null),A(!0),G("")}function ne(){d.current.postMessage({type:"interrupt"})}me.useEffect(()=>{_e()},[I]);function _e(){if(!s.current)return;const Q=s.current;Q.style.height="auto";const Ie=Math.min(Math.max(Q.scrollHeight,24),200);Q.style.height=`${Ie}px`}return me.useEffect(()=>{d.current||(d.current=new Worker(new URL("/assets/worker-DzyjP8xi.js",import.meta.url),{type:"module"}),d.current.postMessage({type:"check"}));const Q=Le=>{switch(Le.data.status){case"loading":f("loading"),_(Le.data.data);break;case"initiate":S(ue=>[...ue,Le.data]);break;case"progress":S(ue=>ue.map(ze=>ze.file===Le.data.file?{...ze,...Le.data}:ze));break;case"done":S(ue=>ue.filter(ze=>ze.file!==Le.data.file));break;case"ready":f("ready");break;case"start":K(ue=>[...ue,{role:"assistant",content:""}]);break;case"update":{const{output:ue,tps:ze,numTokens:Be,state:Xe}=Le.data;ge(ze),te(Be),K(ut=>{const De=[...ut],ke=De.at(-1),D={...ke,content:ke.content+ue};return D.answerIndex===void 0&&Xe==="answering"&&(D.answerIndex=ke.content.length),De[De.length-1]=D,De})}break;case"complete":A(!1);break;case"error":y(Le.data.data);break}},Ie=Le=>{console.error("Worker error:",Le)};return d.current.addEventListener("message",Q),d.current.addEventListener("error",Ie),()=>{d.current.removeEventListener("message",Q),d.current.removeEventListener("error",Ie)}},[]),me.useEffect(()=>{j.filter(Q=>Q.role==="user").length!==0&&j.at(-1).role!=="assistant"&&(ge(null),d.current.postMessage({type:"generate",data:j}))},[j,O]),me.useEffect(()=>{if(!o.current||!O)return;const Q=o.current;Q.scrollHeight-Q.scrollTop-Q.clientHeight<Dh&&(Q.scrollTop=Q.scrollHeight)},[j,O]),Ih?L.jsxs("div",{className:"flex flex-col h-screen mx-auto items justify-end text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:[a===null&&j.length===0&&L.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[L.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[400px] text-center",children:[L.jsx("img",{src:"logo_2.png",width:"80%",height:"auto",className:"block drop-shadow-lg bg-transparent"}),L.jsx("h1",{className:"text-4xl font-bold mb-1",children:"DeepSeek-R1 WebGPU"}),L.jsx("h2",{className:"font-semibold",children:"A next-generation reasoning model that runs locally in your browser with WebGPU acceleration."})]}),L.jsxs("div",{className:"flex flex-col items-center px-4",children:[L.jsxs("p",{className:"max-w-[510px] mb-4",children:[L.jsx("br",{}),"You are about to load"," ",L.jsx("a",{href:"https://huggingface.co/onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"DeepSeek-R1-Distill-Qwen-1.5B"}),", a 1.5B parameter reasoning LLM optimized for in-browser inference. Everything runs entirely in your browser with"," ",L.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"🤗 Transformers.js"})," ","and ONNX Runtime Web, meaning no data is sent to a server. Once loaded, it can even be used offline. The source code for the demo is available on"," ",L.jsx("a",{href:"https://github.com/huggingface/transformers.js-examples/tree/main/deepseek-r1-webgpu",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"GitHub"}),"."]}),p&&L.jsxs("div",{className:"text-red-500 text-center mb-2",children:[L.jsx("p",{className:"mb-1",children:"Unable to load model due to the following error:"}),L.jsx("p",{className:"text-sm",children:p})]}),L.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 cursor-pointer disabled:cursor-not-allowed select-none",onClick:()=>{d.current.postMessage({type:"load"}),f("loading")},disabled:a!==null||p!==null,children:"Load model"})]})]}),a==="loading"&&L.jsx(L.Fragment,{children:L.jsxs("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:[L.jsx("p",{className:"text-center mb-1",children:k}),T.map(({file:Q,progress:Ie,total:Le},ue)=>L.jsx(Oh,{text:Q,percentage:Ie,total:Le},ue))]})}),a==="ready"&&L.jsxs("div",{ref:o,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[L.jsx(Ah,{messages:j}),j.length===0&&L.jsx("div",{children:jh.map((Q,Ie)=>L.jsx("div",{className:"m-1 border border-gray-300 dark:border-gray-600 rounded-md p-2 bg-gray-100 dark:bg-gray-700 cursor-pointer",onClick:()=>fe(Q),children:Q},Ie))}),L.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:ce&&j.length>0&&L.jsxs(L.Fragment,{children:[!O&&L.jsxs("span",{children:["Generated ",Ee," tokens in"," ",(Ee/ce).toFixed(2)," seconds ("]}),L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:ce.toFixed(2)}),L.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!O&&L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"mr-1",children:")."}),L.jsx("span",{className:"underline cursor-pointer",onClick:()=>{d.current.postMessage({type:"reset"}),K([])},children:"Reset"})]})]})})]}),L.jsxs("div",{className:"mt-2 border border-gray-300 dark:bg-gray-700 rounded-lg w-[600px] max-w-[80%] max-h-[200px] mx-auto relative mb-3 flex",children:[L.jsx("textarea",{ref:s,className:"scrollbar-thin w-[550px] dark:bg-gray-700 px-3 py-4 rounded-lg bg-transparent border-none outline-hidden text-gray-800 disabled:text-gray-400 dark:text-gray-200 placeholder-gray-500 dark:placeholder-gray-400 disabled:placeholder-gray-200 resize-none disabled:cursor-not-allowed",placeholder:"Type your message...",type:"text",rows:1,value:I,disabled:a!=="ready",title:a==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:Q=>{I.length>0&&!O&&Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),fe(I))},onInput:Q=>G(Q.target.value)}),O?L.jsx("div",{className:"cursor-pointer",onClick:ne,children:L.jsx(Mh,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):I.length>0?L.jsx("div",{className:"cursor-pointer",onClick:()=>fe(I),children:L.jsx(df,{className:"h-8 w-8 p-1 bg-gray-800 dark:bg-gray-100 text-white dark:text-black rounded-md absolute right-3 bottom-3"})}):L.jsx("div",{children:L.jsx(df,{className:"h-8 w-8 p-1 bg-gray-200 dark:bg-gray-600 text-gray-50 dark:text-gray-800 rounded-md absolute right-3 bottom-3"})})]}),L.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):L.jsxs("div",{className:"fixed w-screen h-screen bg-black z-10 bg-opacity-[92%] text-white text-2xl font-semibold flex justify-center items-center text-center",children:["WebGPU is not supported",L.jsx("br",{}),"by this browser :("]})}Ep.createRoot(document.getElementById("root")).render(L.jsx(me.StrictMode,{children:L.jsx(Fh,{})}));
|
|
|
93 |
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${bt(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:o,tokens:a}){const f=this.parser.parseInline(a),p=Kc(s);if(p===null)return f;s=p;let y='<a href="'+s+'"';return o&&(y+=' title="'+bt(o)+'"'),y+=">"+f+"</a>",y}image({href:s,title:o,text:a}){const f=Kc(s);if(f===null)return bt(a);s=f;let p=`<img src="${s}" alt="${a}"`;return o&&(p+=` title="${bt(o)}"`),p+=">",p}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:bt(s.text)}}class hu{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}}class At{constructor(s){Se(this,"options");Se(this,"renderer");Se(this,"textRenderer");this.options=s||hr,this.options.renderer=this.options.renderer||new so,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hu}static parse(s,o){return new At(o).parse(s)}static parseInline(s,o){return new At(o).parseInline(s)}parse(s,o=!0){var f,p;let a="";for(let y=0;y<s.length;y++){const k=s[y];if((p=(f=this.options.extensions)==null?void 0:f.renderers)!=null&&p[k.type]){const T=k,S=this.options.extensions.renderers[T.type].call({parser:this},T);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(T.type)){a+=S||"";continue}}const _=k;switch(_.type){case"space":{a+=this.renderer.space(_);continue}case"hr":{a+=this.renderer.hr(_);continue}case"heading":{a+=this.renderer.heading(_);continue}case"code":{a+=this.renderer.code(_);continue}case"table":{a+=this.renderer.table(_);continue}case"blockquote":{a+=this.renderer.blockquote(_);continue}case"list":{a+=this.renderer.list(_);continue}case"html":{a+=this.renderer.html(_);continue}case"paragraph":{a+=this.renderer.paragraph(_);continue}case"text":{let T=_,S=this.renderer.text(T);for(;y+1<s.length&&s[y+1].type==="text";)T=s[++y],S+=`
|
94 |
`+this.renderer.text(T);o?a+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):a+=S;continue}default:{const T='Token with "'+_.type+'" type was not found.';if(this.options.silent)return console.error(T),"";throw new Error(T)}}}return a}parseInline(s,o=this.renderer){var f,p;let a="";for(let y=0;y<s.length;y++){const k=s[y];if((p=(f=this.options.extensions)==null?void 0:f.renderers)!=null&&p[k.type]){const T=this.options.extensions.renderers[k.type].call({parser:this},k);if(T!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(k.type)){a+=T||"";continue}}const _=k;switch(_.type){case"escape":{a+=o.text(_);break}case"html":{a+=o.html(_);break}case"link":{a+=o.link(_);break}case"image":{a+=o.image(_);break}case"strong":{a+=o.strong(_);break}case"em":{a+=o.em(_);break}case"codespan":{a+=o.codespan(_);break}case"br":{a+=o.br(_);break}case"del":{a+=o.del(_);break}case"text":{a+=o.text(_);break}default:{const T='Token with "'+_.type+'" type was not found.';if(this.options.silent)return console.error(T),"";throw new Error(T)}}}return a}}class Hl{constructor(s){Se(this,"options");Se(this,"block");this.options=s||hr}preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}provideLexer(){return this.block?Pt.lex:Pt.lexInline}provideParser(){return this.block?At.parse:At.parseInline}}Se(Hl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class lh{constructor(...s){Se(this,"defaults",su());Se(this,"options",this.setOptions);Se(this,"parse",this.parseMarkdown(!0));Se(this,"parseInline",this.parseMarkdown(!1));Se(this,"Parser",At);Se(this,"Renderer",so);Se(this,"TextRenderer",hu);Se(this,"Lexer",Pt);Se(this,"Tokenizer",oo);Se(this,"Hooks",Hl);this.use(...s)}walkTokens(s,o){var f,p;let a=[];for(const y of s)switch(a=a.concat(o.call(this,y)),y.type){case"table":{const k=y;for(const _ of k.header)a=a.concat(this.walkTokens(_.tokens,o));for(const _ of k.rows)for(const T of _)a=a.concat(this.walkTokens(T.tokens,o));break}case"list":{const k=y;a=a.concat(this.walkTokens(k.items,o));break}default:{const k=y;(p=(f=this.defaults.extensions)==null?void 0:f.childTokens)!=null&&p[k.type]?this.defaults.extensions.childTokens[k.type].forEach(_=>{const T=k[_].flat(1/0);a=a.concat(this.walkTokens(T,o))}):k.tokens&&(a=a.concat(this.walkTokens(k.tokens,o)))}}return a}use(...s){const o=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(a=>{const f={...a};if(f.async=this.defaults.async||f.async||!1,a.extensions&&(a.extensions.forEach(p=>{if(!p.name)throw new Error("extension name required");if("renderer"in p){const y=o.renderers[p.name];y?o.renderers[p.name]=function(...k){let _=p.renderer.apply(this,k);return _===!1&&(_=y.apply(this,k)),_}:o.renderers[p.name]=p.renderer}if("tokenizer"in p){if(!p.level||p.level!=="block"&&p.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const y=o[p.level];y?y.unshift(p.tokenizer):o[p.level]=[p.tokenizer],p.start&&(p.level==="block"?o.startBlock?o.startBlock.push(p.start):o.startBlock=[p.start]:p.level==="inline"&&(o.startInline?o.startInline.push(p.start):o.startInline=[p.start]))}"childTokens"in p&&p.childTokens&&(o.childTokens[p.name]=p.childTokens)}),f.extensions=o),a.renderer){const p=this.defaults.renderer||new so(this.defaults);for(const y in a.renderer){if(!(y in p))throw new Error(`renderer '${y}' does not exist`);if(["options","parser"].includes(y))continue;const k=y,_=a.renderer[k],T=p[k];p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O||""}}f.renderer=p}if(a.tokenizer){const p=this.defaults.tokenizer||new oo(this.defaults);for(const y in a.tokenizer){if(!(y in p))throw new Error(`tokenizer '${y}' does not exist`);if(["options","rules","lexer"].includes(y))continue;const k=y,_=a.tokenizer[k],T=p[k];p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O}}f.tokenizer=p}if(a.hooks){const p=this.defaults.hooks||new Hl;for(const y in a.hooks){if(!(y in p))throw new Error(`hook '${y}' does not exist`);if(["options","block"].includes(y))continue;const k=y,_=a.hooks[k],T=p[k];Hl.passThroughHooks.has(y)?p[k]=S=>{if(this.defaults.async)return Promise.resolve(_.call(p,S)).then(A=>T.call(p,A));const O=_.call(p,S);return T.call(p,O)}:p[k]=(...S)=>{let O=_.apply(p,S);return O===!1&&(O=T.apply(p,S)),O}}f.hooks=p}if(a.walkTokens){const p=this.defaults.walkTokens,y=a.walkTokens;f.walkTokens=function(k){let _=[];return _.push(y.call(this,k)),p&&(_=_.concat(p.call(this,k))),_}}this.defaults={...this.defaults,...f}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,o){return Pt.lex(s,o??this.defaults)}parser(s,o){return At.parse(s,o??this.defaults)}parseMarkdown(s){return(a,f)=>{const p={...f},y={...this.defaults,...p},k=this.onError(!!y.silent,!!y.async);if(this.defaults.async===!0&&p.async===!1)return k(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof a>"u"||a===null)return k(new Error("marked(): input parameter is undefined or null"));if(typeof a!="string")return k(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(a)+", string expected"));y.hooks&&(y.hooks.options=y,y.hooks.block=s);const _=y.hooks?y.hooks.provideLexer():s?Pt.lex:Pt.lexInline,T=y.hooks?y.hooks.provideParser():s?At.parse:At.parseInline;if(y.async)return Promise.resolve(y.hooks?y.hooks.preprocess(a):a).then(S=>_(S,y)).then(S=>y.hooks?y.hooks.processAllTokens(S):S).then(S=>y.walkTokens?Promise.all(this.walkTokens(S,y.walkTokens)).then(()=>S):S).then(S=>T(S,y)).then(S=>y.hooks?y.hooks.postprocess(S):S).catch(k);try{y.hooks&&(a=y.hooks.preprocess(a));let S=_(a,y);y.hooks&&(S=y.hooks.processAllTokens(S)),y.walkTokens&&this.walkTokens(S,y.walkTokens);let O=T(S,y);return y.hooks&&(O=y.hooks.postprocess(O)),O}catch(S){return k(S)}}}onError(s,o){return a=>{if(a.message+=`
|
95 |
Please report this to https://github.com/markedjs/marked.`,s){const f="<p>An error occurred:</p><pre>"+bt(a.message+"",!0)+"</pre>";return o?Promise.resolve(f):f}if(o)return Promise.reject(a);throw a}}}const pr=new lh;function ve(d,s){return pr.parse(d,s)}ve.options=ve.setOptions=function(d){return pr.setOptions(d),ve.defaults=pr.defaults,hf(ve.defaults),ve};ve.getDefaults=su;ve.defaults=hr;ve.use=function(...d){return pr.use(...d),ve.defaults=pr.defaults,hf(ve.defaults),ve};ve.walkTokens=function(d,s){return pr.walkTokens(d,s)};ve.parseInline=pr.parseInline;ve.Parser=At;ve.parser=At.parse;ve.Renderer=so;ve.TextRenderer=hu;ve.Lexer=Pt;ve.lexer=Pt.lex;ve.Tokenizer=oo;ve.Hooks=Hl;ve.parse=ve;ve.options;ve.setOptions;ve.use;ve.walkTokens;ve.parseInline;At.parse;Pt.lex;/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:Ef,setPrototypeOf:qc,isFrozen:ih,getPrototypeOf:oh,getOwnPropertyDescriptor:sh}=Object;let{freeze:st,seal:Mt,create:_f}=Object,{apply:nu,construct:ru}=typeof Reflect<"u"&&Reflect;st||(st=function(s){return s});Mt||(Mt=function(s){return s});nu||(nu=function(s,o,a){return s.apply(o,a)});ru||(ru=function(s,o){return new s(...o)});const no=wt(Array.prototype.forEach),Jc=wt(Array.prototype.pop),zl=wt(Array.prototype.push),lo=wt(String.prototype.toLowerCase),Zs=wt(String.prototype.toString),ef=wt(String.prototype.match),Ol=wt(String.prototype.replace),uh=wt(String.prototype.indexOf),ah=wt(String.prototype.trim),Ht=wt(Object.prototype.hasOwnProperty),it=wt(RegExp.prototype.test),Il=ch(TypeError);function wt(d){return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),f=1;f<o;f++)a[f-1]=arguments[f];return nu(d,s,a)}}function ch(d){return function(){for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return ru(d,o)}}function se(d,s){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lo;qc&&qc(d,null);let a=s.length;for(;a--;){let f=s[a];if(typeof f=="string"){const p=o(f);p!==f&&(ih(s)||(s[a]=p),f=p)}d[f]=!0}return d}function fh(d){for(let s=0;s<d.length;s++)Ht(d,s)||(d[s]=null);return d}function dr(d){const s=_f(null);for(const[o,a]of Ef(d))Ht(d,o)&&(Array.isArray(a)?s[o]=fh(a):a&&typeof a=="object"&&a.constructor===Object?s[o]=dr(a):s[o]=a);return s}function Dl(d,s){for(;d!==null;){const a=sh(d,s);if(a){if(a.get)return wt(a.get);if(typeof a.value=="function")return wt(a.value)}d=oh(d)}function o(){return null}return o}const tf=st(["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","section","select","shadow","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"]),bs=st(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qs=st(["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"]),dh=st(["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"]),Js=st(["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"]),ph=st(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),nf=st(["#text"]),rf=st(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),eu=st(["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","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","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-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"]),lf=st(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","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"]),ro=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hh=Mt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mh=Mt(/<%[\w\W]*|[\w\W]*%>/gm),gh=Mt(/\$\{[\w\W]*}/gm),yh=Mt(/^data-[\-\w.\u00B7-\uFFFF]+$/),vh=Mt(/^aria-[\-\w]+$/),Tf=Mt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kh=Mt(/^(?:\w+script|data):/i),wh=Mt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cf=Mt(/^html$/i),xh=Mt(/^[a-z][.\w]*(-[.\w]+)+$/i);var of=Object.freeze({__proto__:null,ARIA_ATTR:vh,ATTR_WHITESPACE:wh,CUSTOM_ELEMENT:xh,DATA_ATTR:yh,DOCTYPE_NAME:Cf,ERB_EXPR:mh,IS_ALLOWED_URI:Tf,IS_SCRIPT_OR_DATA:kh,MUSTACHE_EXPR:hh,TMPLIT_EXPR:gh});const jl={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Sh=function(){return typeof window>"u"?null:window},Eh=function(s,o){if(typeof s!="object"||typeof s.createPolicy!="function")return null;let a=null;const f="data-tt-policy-suffix";o&&o.hasAttribute(f)&&(a=o.getAttribute(f));const p="dompurify"+(a?"#"+a:"");try{return s.createPolicy(p,{createHTML(y){return y},createScriptURL(y){return y}})}catch{return console.warn("TrustedTypes policy "+p+" could not be created."),null}},sf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rf(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Sh();const s=X=>Rf(X);if(s.version="3.2.3",s.removed=[],!d||!d.document||d.document.nodeType!==jl.document)return s.isSupported=!1,s;let{document:o}=d;const a=o,f=a.currentScript,{DocumentFragment:p,HTMLTemplateElement:y,Node:k,Element:_,NodeFilter:T,NamedNodeMap:S=d.NamedNodeMap||d.MozNamedAttrMap,HTMLFormElement:O,DOMParser:A,trustedTypes:I}=d,G=_.prototype,j=Dl(G,"cloneNode"),K=Dl(G,"remove"),ce=Dl(G,"nextSibling"),ge=Dl(G,"childNodes"),Ee=Dl(G,"parentNode");if(typeof y=="function"){const X=o.createElement("template");X.content&&X.content.ownerDocument&&(o=X.content.ownerDocument)}let te,fe="";const{implementation:ne,createNodeIterator:_e,createDocumentFragment:Q,getElementsByTagName:Ie}=o,{importNode:Le}=a;let ue=sf();s.isSupported=typeof Ef=="function"&&typeof Ee=="function"&&ne&&ne.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ze,ERB_EXPR:Be,TMPLIT_EXPR:Xe,DATA_ATTR:ut,ARIA_ATTR:De,IS_SCRIPT_OR_DATA:ke,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:J}=of;let{IS_ALLOWED_URI:U}=of,v=null;const C=se({},[...tf,...bs,...qs,...Js,...nf]);let Y=null;const re=se({},[...rf,...eu,...lf,...ro]);let Z=Object.seal(_f(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}})),ie=null,he=null,de=!0,we=!0,be=!1,Vn=!0,qt=!1,pn=!0,zt=!1,mr=!1,gr=!1,Wt=!1,Qn=!1,hn=!1,mn=!0,Jt=!1;const Qr="user-content-";let yr=!0,gn=!1,en={},tn=null;const vr=se({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Gn=null;const Gr=se({},["audio","video","img","source","image","track"]);let nn=null;const yn=se({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kr="http://www.w3.org/1998/Math/MathML",Yn="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let vn=xt,Xn=!1,Kn=null;const Yr=se({},[kr,Yn,xt],Zs);let kn=se({},["mi","mo","mn","ms","mtext"]),wn=se({},["annotation-xml"]);const xn=se({},["title","style","font","a","script"]);let St=null;const Vl=["application/xhtml+xml","text/html"],Ql="text/html";let je=null,rn=null;const Gl=o.createElement("form"),wr=function(g){return g instanceof RegExp||g instanceof Function},xr=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rn&&rn===g)){if((!g||typeof g!="object")&&(g={}),g=dr(g),St=Vl.indexOf(g.PARSER_MEDIA_TYPE)===-1?Ql:g.PARSER_MEDIA_TYPE,je=St==="application/xhtml+xml"?Zs:lo,v=Ht(g,"ALLOWED_TAGS")?se({},g.ALLOWED_TAGS,je):C,Y=Ht(g,"ALLOWED_ATTR")?se({},g.ALLOWED_ATTR,je):re,Kn=Ht(g,"ALLOWED_NAMESPACES")?se({},g.ALLOWED_NAMESPACES,Zs):Yr,nn=Ht(g,"ADD_URI_SAFE_ATTR")?se(dr(yn),g.ADD_URI_SAFE_ATTR,je):yn,Gn=Ht(g,"ADD_DATA_URI_TAGS")?se(dr(Gr),g.ADD_DATA_URI_TAGS,je):Gr,tn=Ht(g,"FORBID_CONTENTS")?se({},g.FORBID_CONTENTS,je):vr,ie=Ht(g,"FORBID_TAGS")?se({},g.FORBID_TAGS,je):{},he=Ht(g,"FORBID_ATTR")?se({},g.FORBID_ATTR,je):{},en=Ht(g,"USE_PROFILES")?g.USE_PROFILES:!1,de=g.ALLOW_ARIA_ATTR!==!1,we=g.ALLOW_DATA_ATTR!==!1,be=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Vn=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=g.SAFE_FOR_TEMPLATES||!1,pn=g.SAFE_FOR_XML!==!1,zt=g.WHOLE_DOCUMENT||!1,Wt=g.RETURN_DOM||!1,Qn=g.RETURN_DOM_FRAGMENT||!1,hn=g.RETURN_TRUSTED_TYPE||!1,gr=g.FORCE_BODY||!1,mn=g.SANITIZE_DOM!==!1,Jt=g.SANITIZE_NAMED_PROPS||!1,yr=g.KEEP_CONTENT!==!1,gn=g.IN_PLACE||!1,U=g.ALLOWED_URI_REGEXP||Tf,vn=g.NAMESPACE||xt,kn=g.MATHML_TEXT_INTEGRATION_POINTS||kn,wn=g.HTML_INTEGRATION_POINTS||wn,Z=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&wr(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Z.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&wr(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Z.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(we=!1),Qn&&(Wt=!0),en&&(v=se({},nf),Y=[],en.html===!0&&(se(v,tf),se(Y,rf)),en.svg===!0&&(se(v,bs),se(Y,eu),se(Y,ro)),en.svgFilters===!0&&(se(v,qs),se(Y,eu),se(Y,ro)),en.mathMl===!0&&(se(v,Js),se(Y,lf),se(Y,ro))),g.ADD_TAGS&&(v===C&&(v=dr(v)),se(v,g.ADD_TAGS,je)),g.ADD_ATTR&&(Y===re&&(Y=dr(Y)),se(Y,g.ADD_ATTR,je)),g.ADD_URI_SAFE_ATTR&&se(nn,g.ADD_URI_SAFE_ATTR,je),g.FORBID_CONTENTS&&(tn===vr&&(tn=dr(tn)),se(tn,g.FORBID_CONTENTS,je)),yr&&(v["#text"]=!0),zt&&se(v,["html","head","body"]),v.table&&(se(v,["tbody"]),delete ie.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=g.TRUSTED_TYPES_POLICY,fe=te.createHTML("")}else te===void 0&&(te=Eh(I,f)),te!==null&&typeof fe=="string"&&(fe=te.createHTML(""));st&&st(g),rn=g}},Sn=se({},[...bs,...qs,...dh]),Sr=se({},[...Js,...ph]),Zn=function(g){let M=Ee(g);(!M||!M.tagName)&&(M={namespaceURI:vn,tagName:"template"});const H=lo(g.tagName),Te=lo(M.tagName);return Kn[g.namespaceURI]?g.namespaceURI===Yn?M.namespaceURI===xt?H==="svg":M.namespaceURI===kr?H==="svg"&&(Te==="annotation-xml"||kn[Te]):!!Sn[H]:g.namespaceURI===kr?M.namespaceURI===xt?H==="math":M.namespaceURI===Yn?H==="math"&&wn[Te]:!!Sr[H]:g.namespaceURI===xt?M.namespaceURI===Yn&&!wn[Te]||M.namespaceURI===kr&&!kn[Te]?!1:!Sr[H]&&(xn[H]||!Sn[H]):!!(St==="application/xhtml+xml"&&Kn[g.namespaceURI]):!1},Et=function(g){zl(s.removed,{element:g});try{Ee(g).removeChild(g)}catch{K(g)}},Vt=function(g,M){try{zl(s.removed,{attribute:M.getAttributeNode(g),from:M})}catch{zl(s.removed,{attribute:null,from:M})}if(M.removeAttribute(g),g==="is")if(Wt||Qn)try{Et(M)}catch{}else try{M.setAttribute(g,"")}catch{}},bn=function(g){let M=null,H=null;if(gr)g="<remove></remove>"+g;else{const le=ef(g,/^[\r\n\t ]+/);H=le&&le[0]}St==="application/xhtml+xml"&&vn===xt&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const Te=te?te.createHTML(g):g;if(vn===xt)try{M=new A().parseFromString(Te,St)}catch{}if(!M||!M.documentElement){M=ne.createDocument(vn,"template",null);try{M.documentElement.innerHTML=Xn?fe:Te}catch{}}const Ve=M.body||M.documentElement;return g&&H&&Ve.insertBefore(o.createTextNode(H),Ve.childNodes[0]||null),vn===xt?Ie.call(M,zt?"html":"body")[0]:zt?M.documentElement:Ve},qn=function(g){return _e.call(g.ownerDocument||g,g,T.SHOW_ELEMENT|T.SHOW_COMMENT|T.SHOW_TEXT|T.SHOW_PROCESSING_INSTRUCTION|T.SHOW_CDATA_SECTION,null)},Jn=function(g){return g instanceof O&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof S)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},Yl=function(g){return typeof k=="function"&&g instanceof k};function Ot(X,g,M){no(X,H=>{H.call(s,g,M,rn)})}const Xl=function(g){let M=null;if(Ot(ue.beforeSanitizeElements,g,null),Jn(g))return Et(g),!0;const H=je(g.nodeName);if(Ot(ue.uponSanitizeElement,g,{tagName:H,allowedTags:v}),g.hasChildNodes()&&!Yl(g.firstElementChild)&&it(/<[/\w]/g,g.innerHTML)&&it(/<[/\w]/g,g.textContent)||g.nodeType===jl.progressingInstruction||pn&&g.nodeType===jl.comment&&it(/<[/\w]/g,g.data))return Et(g),!0;if(!v[H]||ie[H]){if(!ie[H]&&Xr(H)&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,H)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(H)))return!1;if(yr&&!tn[H]){const Te=Ee(g)||g.parentNode,Ve=ge(g)||g.childNodes;if(Ve&&Te){const le=Ve.length;for(let qe=le-1;qe>=0;--qe){const at=j(Ve[qe],!0);at.__removalCount=(g.__removalCount||0)+1,Te.insertBefore(at,ce(g))}}}return Et(g),!0}return g instanceof _&&!Zn(g)||(H==="noscript"||H==="noembed"||H==="noframes")&&it(/<\/no(script|embed|frames)/i,g.innerHTML)?(Et(g),!0):(qt&&g.nodeType===jl.text&&(M=g.textContent,no([ze,Be,Xe],Te=>{M=Ol(M,Te," ")}),g.textContent!==M&&(zl(s.removed,{element:g.cloneNode()}),g.textContent=M)),Ot(ue.afterSanitizeElements,g,null),!1)},Qt=function(g,M,H){if(mn&&(M==="id"||M==="name")&&(H in o||H in Gl))return!1;if(!(we&&!he[M]&&it(ut,M))){if(!(de&&it(De,M))){if(!Y[M]||he[M]){if(!(Xr(g)&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,g)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(g))&&(Z.attributeNameCheck instanceof RegExp&&it(Z.attributeNameCheck,M)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(M))||M==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&it(Z.tagNameCheck,H)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(H))))return!1}else if(!nn[M]){if(!it(U,Ol(H,D,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&g!=="script"&&uh(H,"data:")===0&&Gn[g])){if(!(be&&!it(ke,Ol(H,D,"")))){if(H)return!1}}}}}}return!0},Xr=function(g){return g!=="annotation-xml"&&ef(g,J)},Kr=function(g){Ot(ue.beforeSanitizeAttributes,g,null);const{attributes:M}=g;if(!M||Jn(g))return;const H={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let Te=M.length;for(;Te--;){const Ve=M[Te],{name:le,namespaceURI:qe,value:at}=Ve,En=je(le);let Ue=le==="value"?at:ah(at);if(H.attrName=En,H.attrValue=Ue,H.keepAttr=!0,H.forceKeepAttr=void 0,Ot(ue.uponSanitizeAttribute,g,H),Ue=H.attrValue,Jt&&(En==="id"||En==="name")&&(Vt(le,g),Ue=Qr+Ue),pn&&it(/((--!?|])>)|<\/(style|title)/i,Ue)){Vt(le,g);continue}if(H.forceKeepAttr||(Vt(le,g),!H.keepAttr))continue;if(!Vn&&it(/\/>/i,Ue)){Vt(le,g);continue}qt&&no([ze,Be,Xe],Zr=>{Ue=Ol(Ue,Zr," ")});const Kl=je(g.nodeName);if(Qt(Kl,En,Ue)){if(te&&typeof I=="object"&&typeof I.getAttributeType=="function"&&!qe)switch(I.getAttributeType(Kl,En)){case"TrustedHTML":{Ue=te.createHTML(Ue);break}case"TrustedScriptURL":{Ue=te.createScriptURL(Ue);break}}try{qe?g.setAttributeNS(qe,le,Ue):g.setAttribute(le,Ue),Jn(g)?Et(g):Jc(s.removed)}catch{}}}Ot(ue.afterSanitizeAttributes,g,null)},co=function X(g){let M=null;const H=qn(g);for(Ot(ue.beforeSanitizeShadowDOM,g,null);M=H.nextNode();)Ot(ue.uponSanitizeShadowNode,M,null),Xl(M),Kr(M),M.content instanceof p&&X(M.content);Ot(ue.afterSanitizeShadowDOM,g,null)};return s.sanitize=function(X){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,H=null,Te=null,Ve=null;if(Xn=!X,Xn&&(X="<!-->"),typeof X!="string"&&!Yl(X))if(typeof X.toString=="function"){if(X=X.toString(),typeof X!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!s.isSupported)return X;if(mr||xr(g),s.removed=[],typeof X=="string"&&(gn=!1),gn){if(X.nodeName){const at=je(X.nodeName);if(!v[at]||ie[at])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(X instanceof k)M=bn("<!---->"),H=M.ownerDocument.importNode(X,!0),H.nodeType===jl.element&&H.nodeName==="BODY"||H.nodeName==="HTML"?M=H:M.appendChild(H);else{if(!Wt&&!qt&&!zt&&X.indexOf("<")===-1)return te&&hn?te.createHTML(X):X;if(M=bn(X),!M)return Wt?null:hn?fe:""}M&&gr&&Et(M.firstChild);const le=qn(gn?X:M);for(;Te=le.nextNode();)Xl(Te),Kr(Te),Te.content instanceof p&&co(Te.content);if(gn)return X;if(Wt){if(Qn)for(Ve=Q.call(M.ownerDocument);M.firstChild;)Ve.appendChild(M.firstChild);else Ve=M;return(Y.shadowroot||Y.shadowrootmode)&&(Ve=Le.call(a,Ve,!0)),Ve}let qe=zt?M.outerHTML:M.innerHTML;return zt&&v["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&it(Cf,M.ownerDocument.doctype.name)&&(qe="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
|
96 |
+
`+qe),qt&&no([ze,Be,Xe],at=>{qe=Ol(qe,at," ")}),te&&hn?te.createHTML(qe):qe},s.setConfig=function(){let X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xr(X),mr=!0},s.clearConfig=function(){rn=null,mr=!1},s.isValidAttribute=function(X,g,M){rn||xr({});const H=je(X),Te=je(g);return Qt(H,Te,M)},s.addHook=function(X,g){typeof g=="function"&&zl(ue[X],g)},s.removeHook=function(X){return Jc(ue[X])},s.removeHooks=function(X){ue[X]=[]},s.removeAllHooks=function(){ue=sf()},s}var _h=Rf();function Th(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M12 8V4H8"}),L.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),L.jsx("path",{d:"M2 14h2"}),L.jsx("path",{d:"M20 14h2"}),L.jsx("path",{d:"M15 13v2"}),L.jsx("path",{d:"M9 13v2"})]})}function Ch(d){return L.jsx("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 32 32",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:L.jsx("path",{className:"stroke-gray-600 dark:stroke-gray-400",d:"M16 6v3.33M16 6c0-2.65 3.25-4.3 5.4-2.62 1.2.95 1.6 2.65.95 4.04a3.63 3.63 0 0 1 4.61.16 3.45 3.45 0 0 1 .46 4.37 5.32 5.32 0 0 1 1.87 4.75c-.22 1.66-1.39 3.6-3.07 4.14M16 6c0-2.65-3.25-4.3-5.4-2.62a3.37 3.37 0 0 0-.95 4.04 3.65 3.65 0 0 0-4.6.16 3.37 3.37 0 0 0-.49 4.27 5.57 5.57 0 0 0-1.85 4.85 5.3 5.3 0 0 0 3.07 4.15M16 9.33v17.34m0-17.34c0 2.18 1.82 4 4 4m6.22 7.5c.67 1.3.56 2.91-.27 4.11a4.05 4.05 0 0 1-4.62 1.5c0 1.53-1.05 2.9-2.66 2.9A2.7 2.7 0 0 1 16 26.66m10.22-5.83a4.05 4.05 0 0 0-3.55-2.17m-16.9 2.18a4.05 4.05 0 0 0 .28 4.1c1 1.44 2.92 2.09 4.59 1.5 0 1.52 1.12 2.88 2.7 2.88A2.7 2.7 0 0 0 16 26.67M5.78 20.85a4.04 4.04 0 0 1 3.55-2.18"})})}function Rh(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),L.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}var lu=function(){return(lu=Object.assign||function(d){for(var s,o=1,a=arguments.length;o<a;o++)for(var f in s=arguments[o])Object.prototype.hasOwnProperty.call(s,f)&&(d[f]=s[f]);return d}).apply(this,arguments)},Fl,Ul,iu=me.createContext(void 0),uf="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_CHTML",af="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js",Nh=function(S){var s=S.config,o=S.version,o=o===void 0?3:o,a=S.src,a=a===void 0?o===2?uf:af:a,f=S.onStartup,p=S.onLoad,y=S.onError,k=S.typesettingOptions,_=S.renderMode,_=_===void 0?"post":_,T=S.hideUntilTypeset,S=S.children,A=me.useContext(iu);if((A==null?void 0:A.version)!==void 0&&(A==null?void 0:A.version)!==o)throw Error("Cannot nest MathJaxContexts with different versions. MathJaxContexts should not be nested at all but if they are, they cannot have different versions. Stick with one version of MathJax in your app and avoid using more than one MathJaxContext.");if(o===2&&Ul!==void 0||o===3&&Fl!==void 0)throw Error("Cannot use MathJax versions 2 and 3 simultaneously in the same app due to how MathJax is set up in the browser; either you have multiple MathJaxContexts with different versions or you have mounted and unmounted MathJaxContexts with different versions. Please stick with one version of MathJax in your app. File an issue in the project Github page if you need this feature.");var O=me.useRef(A),A=me.useRef((A==null?void 0:A.version)||null);if(A.current===null)A.current=o;else if(A.current!==o)throw Error("Cannot change version of MathJax in a MathJaxContext after it has mounted. Reload the page with a new version when this must happen.");var I=a||(o===2?uf:af);function G(j,K){s&&(window.MathJax=s);var ce=document.createElement("script");ce.type="text/javascript",ce.src=I,ce.async=!1,ce.addEventListener("load",function(){var ge=window.MathJax;f&&f(ge),j(ge),p&&p()}),ce.addEventListener("error",function(ge){return K(ge)}),document.getElementsByTagName("head")[0].appendChild(ce)}return O.current===void 0&&(A={typesettingOptions:k,renderMode:_,hideUntilTypeset:T},o===2?Fl===void 0&&(typeof window<"u"?(Fl=new Promise(G)).catch(function(j){if(!y)throw Error("Failed to download MathJax version 2 from '".concat(I,"' due to: ").concat(j));y(j)}):(Fl=Promise.reject()).catch(function(j){})):Ul===void 0&&(typeof window<"u"?(Ul=new Promise(G)).catch(function(j){if(!y)throw Error("Failed to download MathJax version 3 from '".concat(I,"' due to: ").concat(j));y(j)}):(Ul=Promise.reject()).catch(function(j){})),O.current=lu(lu({},A),o===2?{version:2,promise:Fl}:{version:3,promise:Ul})),pf.createElement(iu.Provider,{value:O.current},S)},Wn=function(){return(Wn=Object.assign||function(d){for(var s,o=1,a=arguments.length;o<a;o++)for(var f in s=arguments[o])Object.prototype.hasOwnProperty.call(s,f)&&(d[f]=s[f]);return d}).apply(this,arguments)},Lh=function(d,s){var o={};for(f in d)Object.prototype.hasOwnProperty.call(d,f)&&s.indexOf(f)<0&&(o[f]=d[f]);if(d!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,f=Object.getOwnPropertySymbols(d);a<f.length;a++)s.indexOf(f[a])<0&&Object.prototype.propertyIsEnumerable.call(d,f[a])&&(o[f[a]]=d[f[a]]);return o},$l=function(d){return"Typesetting failed: ".concat(d.message!==void 0?d.message:d.toString())},cf=function(d){function s(){var fe;j==="every"&&ge&&K==="post"&&I.current!==null&&(I.current.style.visibility=(fe=(fe=O.style)==null?void 0:fe.visibility)!=null?fe:"visible"),Ee.current||(j==="first"&&I.current!==null&&(I.current.style.visibility="visible"),f&&f(),Ee.current=!0),p&&p(),te.current=!1}var a=d.inline,o=a!==void 0&&a,a=d.hideUntilTypeset,f=d.onInitTypeset,p=d.onTypeset,y=d.text,k=d.dynamic,_=d.typesettingOptions,T=d.renderMode,S=d.children,O=Lh(d,["inline","hideUntilTypeset","onInitTypeset","onTypeset","text","dynamic","typesettingOptions","renderMode","children"]),A=me.useRef(""),I=me.useRef(null),G=me.useContext(iu),j=a??(G==null?void 0:G.hideUntilTypeset),K=T??(G==null?void 0:G.renderMode),ce=_??(G==null?void 0:G.typesettingOptions),ge=k!==!1&&(k||!1),Ee=me.useRef(!1),te=me.useRef(!1);return!te.current&&I.current!==null&&ge&&j==="every"&&K==="post"&&(I.current.style.visibility="hidden"),(typeof window<"u"?me.useLayoutEffect:me.useEffect)(function(){if((ge||!Ee.current)&&I.current!==null){if(!G)throw Error("MathJax was not loaded, did you use the MathJax component outside of a MathJaxContext?");if(K==="pre"){if(!(typeof(fe=y)=="string"&&0<fe.length))throw Error(`Render mode 'pre' requires text prop to be set and non-empty, which was currently "`.concat(y,'"'));if(!_||!_.fn)throw Error("Render mode 'pre' requires 'typesettingOptions' prop with 'fn' property to be set on MathJax element or in the MathJaxContext");if(G.version===2)throw Error("Render mode 'pre' only available with MathJax 3, and version 2 is currently in use")}K!=="post"&&y===A.current||te.current||(te.current=!0,G.version===3?G.promise.then(function(ne){var _e;K==="pre"?(_e=function(Q){A.current=y,ne.startup.document.clear(),ne.startup.document.updateDocument(),I.current!==null&&(I.current.innerHTML=Q.outerHTML),s()},_.fn.endsWith("Promise")?ne.startup.promise.then(function(){return ne[ce.fn](y,Wn(Wn({},(ce==null?void 0:ce.options)||{}),{display:!o}))}).then(_e).catch(function(Q){throw s(),Error($l(Q))}):ne.startup.promise.then(function(){var Q=ne[ce.fn](y,Wn(Wn({},(ce==null?void 0:ce.options)||{}),{display:!o}));_e(Q)}).catch(function(Q){throw s(),Error($l(Q))})):ne.startup.promise.then(function(){return ne.typesetClear([I.current]),ne.typesetPromise([I.current])}).then(s).catch(function(Q){throw s(),Error($l(Q))})}).catch(function(ne){throw s(),Error($l(ne))}):G.promise.then(function(ne){ne.Hub.Queue(["Typeset",ne.Hub,I.current]),ne.Hub.Queue(s)}).catch(function(ne){throw s(),Error($l(ne))}))}var fe}),pf.createElement("span",Wn({},O,{style:Wn(Wn({display:o?"inline":"block"},O.style),{visibility:j?"hidden":(d=O.style)==null?void 0:d.visibility}),ref:I}),S)};function ff(d){return d=d.replace(/\\([\[\]\(\)])/g,"\\\\$1"),_h.sanitize(ve.parse(d,{async:!1,breaks:!0}))}function Ph({role:d,content:s,answerIndex:o}){const a=o?s.slice(0,o):s,f=o?s.slice(o):"",[p,y]=me.useState(!1),k=f.length>0;return L.jsx("div",{className:"flex items-start space-x-4",children:d==="assistant"?L.jsxs(L.Fragment,{children:[L.jsx(Th,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),L.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:L.jsx("div",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:a.length>0?L.jsxs(L.Fragment,{children:[L.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg flex flex-col",children:[L.jsxs("button",{className:"flex items-center gap-2 cursor-pointer p-4 hover:bg-gray-50 dark:hover:bg-gray-900 rounded-lg ",onClick:()=>y(_=>!_),style:{width:p?"100%":"auto"},children:[L.jsx(Ch,{className:k?"":"animate-pulse"}),L.jsx("span",{children:k?"View reasoning.":"Thinking..."}),L.jsx("span",{className:"ml-auto text-gray-700",children:p?"▲":"▼"})]}),p&&L.jsx(cf,{className:"border-t border-gray-200 dark:border-gray-700 px-4 py-2",dynamic:!0,children:L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:ff(a)}})})]}),k&&L.jsx(cf,{className:"mt-2",dynamic:!0,children:L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:ff(f)}})})]}):L.jsxs("span",{className:"h-6 flex items-center gap-1",children:[L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),L.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):L.jsxs(L.Fragment,{children:[L.jsx(Rh,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),L.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:L.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:s})})]})})}function Ah({messages:d}){const s=d.length===0;return L.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${s?"flex flex-col items-center justify-end":"space-y-4"}`,children:L.jsx(Nh,{children:s?L.jsx("div",{className:"text-xl",children:"Ready!"}):d.map((o,a)=>L.jsx(Ph,{...o},`message-${a}`))})})}function df(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M5 12h14"}),L.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Mh(d){return L.jsxs("svg",{...d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[L.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),L.jsx("path",{fill:"currentColor",d:"M9 9.563C9 9.252 9.252 9 9.563 9h4.874c.311 0 .563.252.563.563v4.874c0 .311-.252.563-.563.563H9.564A.562.562 0 0 1 9 14.437V9.564Z"})]})}function zh(d){const s=d==0?0:Math.floor(Math.log(d)/Math.log(1024));return+(d/Math.pow(1024,s)).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}function Oh({text:d,percentage:s,total:o}){return s??(s=0),L.jsx("div",{className:"w-full bg-gray-100 dark:bg-gray-700 text-left rounded-lg overflow-hidden mb-0.5",children:L.jsxs("div",{className:"bg-blue-400 whitespace-nowrap px-1 text-sm",style:{width:`${s}%`},children:[d," (",s.toFixed(2),"%",isNaN(o)?"":` of ${zh(o)}`,")"]})})}const Ih=!!navigator.gpu,Dh=120,jh=["Solve the equation x^2 - 3x + 2 = 0","Lily is three times older than her son. In 15 years, she will be twice as old as him. How old is she now?","Write python code to compute the nth fibonacci number."];function Fh(){const d=me.useRef(null),s=me.useRef(null),o=me.useRef(null),[a,f]=me.useState(null),[p,y]=me.useState(null),[k,_]=me.useState(""),[T,S]=me.useState([]),[O,A]=me.useState(!1),[I,G]=me.useState(""),[j,K]=me.useState([]),[ce,ge]=me.useState(null),[Ee,te]=me.useState(null);function fe(Q){K(Ie=>[...Ie,{role:"user",content:Q}]),ge(null),A(!0),G("")}function ne(){d.current.postMessage({type:"interrupt"})}me.useEffect(()=>{_e()},[I]);function _e(){if(!s.current)return;const Q=s.current;Q.style.height="auto";const Ie=Math.min(Math.max(Q.scrollHeight,24),200);Q.style.height=`${Ie}px`}return me.useEffect(()=>{d.current||(d.current=new Worker(new URL("/assets/worker-DzyjP8xi.js",import.meta.url),{type:"module"}),d.current.postMessage({type:"check"}));const Q=Le=>{switch(Le.data.status){case"loading":f("loading"),_(Le.data.data);break;case"initiate":S(ue=>[...ue,Le.data]);break;case"progress":S(ue=>ue.map(ze=>ze.file===Le.data.file?{...ze,...Le.data}:ze));break;case"done":S(ue=>ue.filter(ze=>ze.file!==Le.data.file));break;case"ready":f("ready");break;case"start":K(ue=>[...ue,{role:"assistant",content:""}]);break;case"update":{const{output:ue,tps:ze,numTokens:Be,state:Xe}=Le.data;ge(ze),te(Be),K(ut=>{const De=[...ut],ke=De.at(-1),D={...ke,content:ke.content+ue};return D.answerIndex===void 0&&Xe==="answering"&&(D.answerIndex=ke.content.length),De[De.length-1]=D,De})}break;case"complete":A(!1);break;case"error":y(Le.data.data);break}},Ie=Le=>{console.error("Worker error:",Le)};return d.current.addEventListener("message",Q),d.current.addEventListener("error",Ie),()=>{d.current.removeEventListener("message",Q),d.current.removeEventListener("error",Ie)}},[]),me.useEffect(()=>{j.filter(Q=>Q.role==="user").length!==0&&j.at(-1).role!=="assistant"&&(ge(null),d.current.postMessage({type:"generate",data:j}))},[j,O]),me.useEffect(()=>{if(!o.current||!O)return;const Q=o.current;Q.scrollHeight-Q.scrollTop-Q.clientHeight<Dh&&(Q.scrollTop=Q.scrollHeight)},[j,O]),Ih?L.jsxs("div",{className:"flex flex-col h-screen mx-auto items justify-end text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900",children:[a===null&&j.length===0&&L.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[L.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[400px] text-center",children:[L.jsx("img",{src:"no_bg_image_80053472567b4e26b0ca561b6fdcf01b.png",width:"80%",height:"auto",className:"block drop-shadow-lg bg-transparent"}),L.jsx("h1",{className:"text-4xl font-bold mb-1",children:"DeepSeek-R1 WebGPU"}),L.jsx("h2",{className:"font-semibold",children:"A next-generation reasoning model that runs locally in your browser with WebGPU acceleration."})]}),L.jsxs("div",{className:"flex flex-col items-center px-4",children:[L.jsxs("p",{className:"max-w-[510px] mb-4",children:[L.jsx("br",{}),"You are about to load"," ",L.jsx("a",{href:"https://huggingface.co/onnx-community/DeepSeek-R1-Distill-Qwen-1.5B-ONNX",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"DeepSeek-R1-Distill-Qwen-1.5B"}),", a 1.5B parameter reasoning LLM optimized for in-browser inference. Everything runs entirely in your browser with"," ",L.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"🤗 Transformers.js"})," ","and ONNX Runtime Web, meaning no data is sent to a server. Once loaded, it can even be used offline. The source code for the demo is available on"," ",L.jsx("a",{href:"https://github.com/huggingface/transformers.js-examples/tree/main/deepseek-r1-webgpu",target:"_blank",rel:"noreferrer",className:"font-medium underline",children:"GitHub"}),"."]}),p&&L.jsxs("div",{className:"text-red-500 text-center mb-2",children:[L.jsx("p",{className:"mb-1",children:"Unable to load model due to the following error:"}),L.jsx("p",{className:"text-sm",children:p})]}),L.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 cursor-pointer disabled:cursor-not-allowed select-none",onClick:()=>{d.current.postMessage({type:"load"}),f("loading")},disabled:a!==null||p!==null,children:"Load model"})]})]}),a==="loading"&&L.jsx(L.Fragment,{children:L.jsxs("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:[L.jsx("p",{className:"text-center mb-1",children:k}),T.map(({file:Q,progress:Ie,total:Le},ue)=>L.jsx(Oh,{text:Q,percentage:Ie,total:Le},ue))]})}),a==="ready"&&L.jsxs("div",{ref:o,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[L.jsx(Ah,{messages:j}),j.length===0&&L.jsx("div",{children:jh.map((Q,Ie)=>L.jsx("div",{className:"m-1 border border-gray-300 dark:border-gray-600 rounded-md p-2 bg-gray-100 dark:bg-gray-700 cursor-pointer",onClick:()=>fe(Q),children:Q},Ie))}),L.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:ce&&j.length>0&&L.jsxs(L.Fragment,{children:[!O&&L.jsxs("span",{children:["Generated ",Ee," tokens in"," ",(Ee/ce).toFixed(2)," seconds ("]}),L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:ce.toFixed(2)}),L.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!O&&L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"mr-1",children:")."}),L.jsx("span",{className:"underline cursor-pointer",onClick:()=>{d.current.postMessage({type:"reset"}),K([])},children:"Reset"})]})]})})]}),L.jsxs("div",{className:"mt-2 border border-gray-300 dark:bg-gray-700 rounded-lg w-[600px] max-w-[80%] max-h-[200px] mx-auto relative mb-3 flex",children:[L.jsx("textarea",{ref:s,className:"scrollbar-thin w-[550px] dark:bg-gray-700 px-3 py-4 rounded-lg bg-transparent border-none outline-hidden text-gray-800 disabled:text-gray-400 dark:text-gray-200 placeholder-gray-500 dark:placeholder-gray-400 disabled:placeholder-gray-200 resize-none disabled:cursor-not-allowed",placeholder:"Type your message...",type:"text",rows:1,value:I,disabled:a!=="ready",title:a==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:Q=>{I.length>0&&!O&&Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),fe(I))},onInput:Q=>G(Q.target.value)}),O?L.jsx("div",{className:"cursor-pointer",onClick:ne,children:L.jsx(Mh,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):I.length>0?L.jsx("div",{className:"cursor-pointer",onClick:()=>fe(I),children:L.jsx(df,{className:"h-8 w-8 p-1 bg-gray-800 dark:bg-gray-100 text-white dark:text-black rounded-md absolute right-3 bottom-3"})}):L.jsx("div",{children:L.jsx(df,{className:"h-8 w-8 p-1 bg-gray-200 dark:bg-gray-600 text-gray-50 dark:text-gray-800 rounded-md absolute right-3 bottom-3"})})]}),L.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):L.jsxs("div",{className:"fixed w-screen h-screen bg-black z-10 bg-opacity-[92%] text-white text-2xl font-semibold flex justify-center items-center text-center",children:["WebGPU is not supported",L.jsx("br",{}),"by this browser :("]})}Ep.createRoot(document.getElementById("root")).render(L.jsx(me.StrictMode,{children:L.jsx(Fh,{})}));
|