Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
@@ -83,4 +83,4 @@ ${s}</tr>
|
|
83 |
`}strong(s){return`<strong>${s}</strong>`}em(s){return`<em>${s}</em>`}codespan(s){return`<code>${s}</code>`}br(){return"<br>"}del(s){return`<del>${s}</del>`}link(s,o,a){const f=Qc(s);if(f===null)return a;s=f;let h='<a href="'+s+'"';return o&&(h+=' title="'+o+'"'),h+=">"+a+"</a>",h}image(s,o,a){const f=Qc(s);if(f===null)return a;s=f;let h=`<img src="${s}" alt="${a}"`;return o&&(h+=` title="${o}"`),h+=">",h}text(s){return s}}class au{strong(s){return s}em(s){return s}codespan(s){return s}del(s){return s}html(s){return s}text(s){return s}link(s,o,a){return""+a}image(s,o,a){return""+a}br(){return""}}class Zt{constructor(s){xe(this,"options");xe(this,"renderer");xe(this,"textRenderer");this.options=s||pr,this.options.renderer=this.options.renderer||new io,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new au}static parse(s,o){return new Zt(o).parse(s)}static parseInline(s,o){return new Zt(o).parseInline(s)}parse(s,o=!0){let a="";for(let f=0;f<s.length;f++){const h=s[f];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]){const d=h,S=this.options.extensions.renderers[d.type].call({parser:this},d);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(d.type)){a+=S||"";continue}}switch(h.type){case"space":continue;case"hr":{a+=this.renderer.hr();continue}case"heading":{const d=h;a+=this.renderer.heading(this.parseInline(d.tokens),d.depth,Cp(this.parseInline(d.tokens,this.textRenderer)));continue}case"code":{const d=h;a+=this.renderer.code(d.text,d.lang,!!d.escaped);continue}case"table":{const d=h;let S="",E="";for(let P=0;P<d.header.length;P++)E+=this.renderer.tablecell(this.parseInline(d.header[P].tokens),{header:!0,align:d.align[P]});S+=this.renderer.tablerow(E);let j="";for(let P=0;P<d.rows.length;P++){const M=d.rows[P];E="";for(let z=0;z<M.length;z++)E+=this.renderer.tablecell(this.parseInline(M[z].tokens),{header:!1,align:d.align[z]});j+=this.renderer.tablerow(E)}a+=this.renderer.table(S,j);continue}case"blockquote":{const d=h,S=this.parse(d.tokens);a+=this.renderer.blockquote(S);continue}case"list":{const d=h,S=d.ordered,E=d.start,j=d.loose;let P="";for(let M=0;M<d.items.length;M++){const z=d.items[M],G=z.checked,ce=z.task;let Z="";if(z.task){const J=this.renderer.checkbox(!!G);j?z.tokens.length>0&&z.tokens[0].type==="paragraph"?(z.tokens[0].text=J+" "+z.tokens[0].text,z.tokens[0].tokens&&z.tokens[0].tokens.length>0&&z.tokens[0].tokens[0].type==="text"&&(z.tokens[0].tokens[0].text=J+" "+z.tokens[0].tokens[0].text)):z.tokens.unshift({type:"text",text:J+" "}):Z+=J+" "}Z+=this.parse(z.tokens,j),P+=this.renderer.listitem(Z,ce,!!G)}a+=this.renderer.list(P,S,E);continue}case"html":{const d=h;a+=this.renderer.html(d.text,d.block);continue}case"paragraph":{const d=h;a+=this.renderer.paragraph(this.parseInline(d.tokens));continue}case"text":{let d=h,S=d.tokens?this.parseInline(d.tokens):d.text;for(;f+1<s.length&&s[f+1].type==="text";)d=s[++f],S+=`
|
84 |
`+(d.tokens?this.parseInline(d.tokens):d.text);a+=o?this.renderer.paragraph(S):S;continue}default:{const d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return a}parseInline(s,o){o=o||this.renderer;let a="";for(let f=0;f<s.length;f++){const h=s[f];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]){const d=this.options.extensions.renderers[h.type].call({parser:this},h);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(h.type)){a+=d||"";continue}}switch(h.type){case"escape":{const d=h;a+=o.text(d.text);break}case"html":{const d=h;a+=o.html(d.text);break}case"link":{const d=h;a+=o.link(d.href,d.title,this.parseInline(d.tokens,o));break}case"image":{const d=h;a+=o.image(d.href,d.title,d.text);break}case"strong":{const d=h;a+=o.strong(this.parseInline(d.tokens,o));break}case"em":{const d=h;a+=o.em(this.parseInline(d.tokens,o));break}case"codespan":{const d=h;a+=o.codespan(d.text);break}case"br":{a+=o.br();break}case"del":{const d=h;a+=o.del(this.parseInline(d.tokens,o));break}case"text":{const d=h;a+=o.text(d.text);break}default:{const d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return a}}class jl{constructor(s){xe(this,"options");this.options=s||pr}preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}}xe(jl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var dr,bs,yf;class nh{constructor(...s){Mc(this,dr);xe(this,"defaults",ru());xe(this,"options",this.setOptions);xe(this,"parse",Zi(this,dr,bs).call(this,Xt.lex,Zt.parse));xe(this,"parseInline",Zi(this,dr,bs).call(this,Xt.lexInline,Zt.parseInline));xe(this,"Parser",Zt);xe(this,"Renderer",io);xe(this,"TextRenderer",au);xe(this,"Lexer",Xt);xe(this,"Tokenizer",ro);xe(this,"Hooks",jl);this.use(...s)}walkTokens(s,o){var f,h;let a=[];for(const d of s)switch(a=a.concat(o.call(this,d)),d.type){case"table":{const S=d;for(const E of S.header)a=a.concat(this.walkTokens(E.tokens,o));for(const E of S.rows)for(const j of E)a=a.concat(this.walkTokens(j.tokens,o));break}case"list":{const S=d;a=a.concat(this.walkTokens(S.items,o));break}default:{const S=d;(h=(f=this.defaults.extensions)==null?void 0:f.childTokens)!=null&&h[S.type]?this.defaults.extensions.childTokens[S.type].forEach(E=>{const j=S[E].flat(1/0);a=a.concat(this.walkTokens(j,o))}):S.tokens&&(a=a.concat(this.walkTokens(S.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(h=>{if(!h.name)throw new Error("extension name required");if("renderer"in h){const d=o.renderers[h.name];d?o.renderers[h.name]=function(...S){let E=h.renderer.apply(this,S);return E===!1&&(E=d.apply(this,S)),E}:o.renderers[h.name]=h.renderer}if("tokenizer"in h){if(!h.level||h.level!=="block"&&h.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=o[h.level];d?d.unshift(h.tokenizer):o[h.level]=[h.tokenizer],h.start&&(h.level==="block"?o.startBlock?o.startBlock.push(h.start):o.startBlock=[h.start]:h.level==="inline"&&(o.startInline?o.startInline.push(h.start):o.startInline=[h.start]))}"childTokens"in h&&h.childTokens&&(o.childTokens[h.name]=h.childTokens)}),f.extensions=o),a.renderer){const h=this.defaults.renderer||new io(this.defaults);for(const d in a.renderer){if(!(d in h))throw new Error(`renderer '${d}' does not exist`);if(d==="options")continue;const S=d,E=a.renderer[S],j=h[S];h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M||""}}f.renderer=h}if(a.tokenizer){const h=this.defaults.tokenizer||new ro(this.defaults);for(const d in a.tokenizer){if(!(d in h))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const S=d,E=a.tokenizer[S],j=h[S];h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M}}f.tokenizer=h}if(a.hooks){const h=this.defaults.hooks||new jl;for(const d in a.hooks){if(!(d in h))throw new Error(`hook '${d}' does not exist`);if(d==="options")continue;const S=d,E=a.hooks[S],j=h[S];jl.passThroughHooks.has(d)?h[S]=P=>{if(this.defaults.async)return Promise.resolve(E.call(h,P)).then(z=>j.call(h,z));const M=E.call(h,P);return j.call(h,M)}:h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M}}f.hooks=h}if(a.walkTokens){const h=this.defaults.walkTokens,d=a.walkTokens;f.walkTokens=function(S){let E=[];return E.push(d.call(this,S)),h&&(E=E.concat(h.call(this,S))),E}}this.defaults={...this.defaults,...f}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,o){return Xt.lex(s,o??this.defaults)}parser(s,o){return Zt.parse(s,o??this.defaults)}}dr=new WeakSet,bs=function(s,o){return(a,f)=>{const h={...f},d={...this.defaults,...h};this.defaults.async===!0&&h.async===!1&&(d.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),d.async=!0);const S=Zi(this,dr,yf).call(this,!!d.silent,!!d.async);if(typeof a>"u"||a===null)return S(new Error("marked(): input parameter is undefined or null"));if(typeof a!="string")return S(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(a)+", string expected"));if(d.hooks&&(d.hooks.options=d),d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(a):a).then(E=>s(E,d)).then(E=>d.hooks?d.hooks.processAllTokens(E):E).then(E=>d.walkTokens?Promise.all(this.walkTokens(E,d.walkTokens)).then(()=>E):E).then(E=>o(E,d)).then(E=>d.hooks?d.hooks.postprocess(E):E).catch(S);try{d.hooks&&(a=d.hooks.preprocess(a));let E=s(a,d);d.hooks&&(E=d.hooks.processAllTokens(E)),d.walkTokens&&this.walkTokens(E,d.walkTokens);let j=o(E,d);return d.hooks&&(j=d.hooks.postprocess(j)),j}catch(E){return S(E)}}},yf=function(s,o){return a=>{if(a.message+=`
|
85 |
Please report this to https://github.com/markedjs/marked.`,s){const f="<p>An error occurred:</p><pre>"+wt(a.message+"",!0)+"</pre>";return o?Promise.resolve(f):f}if(o)return Promise.reject(a);throw a}};const fr=new nh;function pe(v,s){return fr.parse(v,s)}pe.options=pe.setOptions=function(v){return fr.setOptions(v),pe.defaults=fr.defaults,sf(pe.defaults),pe};pe.getDefaults=ru;pe.defaults=pr;pe.use=function(...v){return fr.use(...v),pe.defaults=fr.defaults,sf(pe.defaults),pe};pe.walkTokens=function(v,s){return fr.walkTokens(v,s)};pe.parseInline=fr.parseInline;pe.Parser=Zt;pe.parser=Zt.parse;pe.Renderer=io;pe.TextRenderer=au;pe.Lexer=Xt;pe.lexer=Xt.lex;pe.Tokenizer=ro;pe.Hooks=jl;pe.parse=pe;pe.options;pe.setOptions;pe.use;pe.walkTokens;pe.parseInline;Zt.parse;Xt.lex;/*! @license DOMPurify 3.2.4 | (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.4/LICENSE */const{entries:vf,setPrototypeOf:Xc,isFrozen:rh,getPrototypeOf:lh,getOwnPropertyDescriptor:ih}=Object;let{freeze:st,seal:At,create:kf}=Object,{apply:eu,construct:tu}=typeof Reflect<"u"&&Reflect;st||(st=function(s){return s});At||(At=function(s){return s});eu||(eu=function(s,o,a){return s.apply(o,a)});tu||(tu=function(s,o){return new s(...o)});const eo=ut(Array.prototype.forEach),oh=ut(Array.prototype.lastIndexOf),Zc=ut(Array.prototype.pop),Pl=ut(Array.prototype.push),sh=ut(Array.prototype.splice),no=ut(String.prototype.toLowerCase),Ys=ut(String.prototype.toString),qc=ut(String.prototype.match),zl=ut(String.prototype.replace),uh=ut(String.prototype.indexOf),ah=ut(String.prototype.trim),$t=ut(Object.prototype.hasOwnProperty),ot=ut(RegExp.prototype.test),Il=ch(TypeError);function ut(v){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 eu(v,s,a)}}function ch(v){return function(){for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return tu(v,o)}}function ie(v,s){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:no;Xc&&Xc(v,null);let a=s.length;for(;a--;){let f=s[a];if(typeof f=="string"){const h=o(f);h!==f&&(rh(s)||(s[a]=h),f=h)}v[f]=!0}return v}function fh(v){for(let s=0;s<v.length;s++)$t(v,s)||(v[s]=null);return v}function cr(v){const s=kf(null);for(const[o,a]of vf(v))$t(v,o)&&(Array.isArray(a)?s[o]=fh(a):a&&typeof a=="object"&&a.constructor===Object?s[o]=cr(a):s[o]=a);return s}function Ml(v,s){for(;v!==null;){const a=ih(v,s);if(a){if(a.get)return ut(a.get);if(typeof a.value=="function")return ut(a.value)}v=lh(v)}function o(){return null}return o}const Jc=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"]),Ks=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"]),Xs=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"]),Zs=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"]),bc=st(["#text"]),ef=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"]),qs=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"]),tf=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"]),to=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hh=At(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mh=At(/<%[\w\W]*|[\w\W]*%>/gm),gh=At(/\$\{[\w\W]*/gm),yh=At(/^data-[\-\w.\u00B7-\uFFFF]+$/),vh=At(/^aria-[\-\w]+$/),wf=At(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kh=At(/^(?:\w+script|data):/i),wh=At(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xf=At(/^html$/i),xh=At(/^[a-z][.\w]*(-[.\w]+)+$/i);var nf=Object.freeze({__proto__:null,ARIA_ATTR:vh,ATTR_WHITESPACE:wh,CUSTOM_ELEMENT:xh,DATA_ATTR:yh,DOCTYPE_NAME:xf,ERB_EXPR:mh,IS_ALLOWED_URI:wf,IS_SCRIPT_OR_DATA:kh,MUSTACHE_EXPR:hh,TMPLIT_EXPR:gh});const Ol={element:1,text:3,progressingInstruction:7,comment:8,document:9},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 h="dompurify"+(a?"#"+a:"");try{return s.createPolicy(h,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+h+" could not be created."),null}},rf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Sf(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Sh();const s=W=>Sf(W);if(s.version="3.2.4",s.removed=[],!v||!v.document||v.document.nodeType!==Ol.document||!v.Element)return s.isSupported=!1,s;let{document:o}=v;const a=o,f=a.currentScript,{DocumentFragment:h,HTMLTemplateElement:d,Node:S,Element:E,NodeFilter:j,NamedNodeMap:P=v.NamedNodeMap||v.MozNamedAttrMap,HTMLFormElement:M,DOMParser:z,trustedTypes:G}=v,ce=E.prototype,Z=Ml(ce,"cloneNode"),J=Ml(ce,"remove"),De=Ml(ce,"nextSibling"),je=Ml(ce,"childNodes"),Re=Ml(ce,"parentNode");if(typeof d=="function"){const W=o.createElement("template");W.content&&W.content.ownerDocument&&(o=W.content.ownerDocument)}let le,ve="";const{implementation:Ae,createNodeIterator:Be,createDocumentFragment:b,getElementsByTagName:Pe}=o,{importNode:Se}=a;let oe=rf();s.isSupported=typeof vf=="function"&&typeof Re=="function"&&Ae&&Ae.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Ne,ERB_EXPR:Fe,TMPLIT_EXPR:Ke,DATA_ATTR:Xe,ARIA_ATTR:Ue,IS_SCRIPT_OR_DATA:Ee,ATTR_WHITESPACE:I,CUSTOM_ELEMENT:X}=nf;let{IS_ALLOWED_URI:D}=nf,y=null;const _=ie({},[...Jc,...Ks,...Xs,...Zs,...bc]);let V=null;const ee=ie({},[...ef,...qs,...tf,...to]);let Q=Object.seal(kf(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}})),ne=null,fe=null,ue=!0,he=!0,Je=!1,Bn=!0,qt=!1,dn=!0,Pt=!1,hr=!1,mr=!1,Ht=!1,Wn=!1,pn=!1,hn=!0,Jt=!1;const Vr="user-content-";let gr=!0,mn=!1,bt={},en=null;const yr=ie({},["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 Vn=null;const Qr=ie({},["audio","video","img","source","image","track"]);let tn=null;const gn=ie({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vr="http://www.w3.org/1998/Math/MathML",Qn="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let yn=xt,Gn=!1,Yn=null;const Gr=ie({},[vr,Qn,xt],Ys);let vn=ie({},["mi","mo","mn","ms","mtext"]),kn=ie({},["annotation-xml"]);const wn=ie({},["title","style","font","a","script"]);let St=null;const $l=["application/xhtml+xml","text/html"],Hl="text/html";let ze=null,nn=null;const Bl=o.createElement("form"),kr=function(m){return m instanceof RegExp||m instanceof Function},wr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(nn&&nn===m)){if((!m||typeof m!="object")&&(m={}),m=cr(m),St=$l.indexOf(m.PARSER_MEDIA_TYPE)===-1?Hl:m.PARSER_MEDIA_TYPE,ze=St==="application/xhtml+xml"?Ys:no,y=$t(m,"ALLOWED_TAGS")?ie({},m.ALLOWED_TAGS,ze):_,V=$t(m,"ALLOWED_ATTR")?ie({},m.ALLOWED_ATTR,ze):ee,Yn=$t(m,"ALLOWED_NAMESPACES")?ie({},m.ALLOWED_NAMESPACES,Ys):Gr,tn=$t(m,"ADD_URI_SAFE_ATTR")?ie(cr(gn),m.ADD_URI_SAFE_ATTR,ze):gn,Vn=$t(m,"ADD_DATA_URI_TAGS")?ie(cr(Qr),m.ADD_DATA_URI_TAGS,ze):Qr,en=$t(m,"FORBID_CONTENTS")?ie({},m.FORBID_CONTENTS,ze):yr,ne=$t(m,"FORBID_TAGS")?ie({},m.FORBID_TAGS,ze):{},fe=$t(m,"FORBID_ATTR")?ie({},m.FORBID_ATTR,ze):{},bt=$t(m,"USE_PROFILES")?m.USE_PROFILES:!1,ue=m.ALLOW_ARIA_ATTR!==!1,he=m.ALLOW_DATA_ATTR!==!1,Je=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Bn=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=m.SAFE_FOR_TEMPLATES||!1,dn=m.SAFE_FOR_XML!==!1,Pt=m.WHOLE_DOCUMENT||!1,Ht=m.RETURN_DOM||!1,Wn=m.RETURN_DOM_FRAGMENT||!1,pn=m.RETURN_TRUSTED_TYPE||!1,mr=m.FORCE_BODY||!1,hn=m.SANITIZE_DOM!==!1,Jt=m.SANITIZE_NAMED_PROPS||!1,gr=m.KEEP_CONTENT!==!1,mn=m.IN_PLACE||!1,D=m.ALLOWED_URI_REGEXP||wf,yn=m.NAMESPACE||xt,vn=m.MATHML_TEXT_INTEGRATION_POINTS||vn,kn=m.HTML_INTEGRATION_POINTS||kn,Q=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&kr(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&kr(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(he=!1),Wn&&(Ht=!0),bt&&(y=ie({},bc),V=[],bt.html===!0&&(ie(y,Jc),ie(V,ef)),bt.svg===!0&&(ie(y,Ks),ie(V,qs),ie(V,to)),bt.svgFilters===!0&&(ie(y,Xs),ie(V,qs),ie(V,to)),bt.mathMl===!0&&(ie(y,Zs),ie(V,tf),ie(V,to))),m.ADD_TAGS&&(y===_&&(y=cr(y)),ie(y,m.ADD_TAGS,ze)),m.ADD_ATTR&&(V===ee&&(V=cr(V)),ie(V,m.ADD_ATTR,ze)),m.ADD_URI_SAFE_ATTR&&ie(tn,m.ADD_URI_SAFE_ATTR,ze),m.FORBID_CONTENTS&&(en===yr&&(en=cr(en)),ie(en,m.FORBID_CONTENTS,ze)),gr&&(y["#text"]=!0),Pt&&ie(y,["html","head","body"]),y.table&&(ie(y,["tbody"]),delete ne.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');le=m.TRUSTED_TYPES_POLICY,ve=le.createHTML("")}else le===void 0&&(le=Eh(G,f)),le!==null&&typeof ve=="string"&&(ve=le.createHTML(""));st&&st(m),nn=m}},xn=ie({},[...Ks,...Xs,...dh]),xr=ie({},[...Zs,...ph]),Kn=function(m){let N=Re(m);(!N||!N.tagName)&&(N={namespaceURI:yn,tagName:"template"});const $=no(m.tagName),ge=no(N.tagName);return Yn[m.namespaceURI]?m.namespaceURI===Qn?N.namespaceURI===xt?$==="svg":N.namespaceURI===vr?$==="svg"&&(ge==="annotation-xml"||vn[ge]):!!xn[$]:m.namespaceURI===vr?N.namespaceURI===xt?$==="math":N.namespaceURI===Qn?$==="math"&&kn[ge]:!!xr[$]:m.namespaceURI===xt?N.namespaceURI===Qn&&!kn[ge]||N.namespaceURI===vr&&!vn[ge]?!1:!xr[$]&&(wn[$]||!xn[$]):!!(St==="application/xhtml+xml"&&Yn[m.namespaceURI]):!1},Et=function(m){Pl(s.removed,{element:m});try{Re(m).removeChild(m)}catch{J(m)}},Bt=function(m,N){try{Pl(s.removed,{attribute:N.getAttributeNode(m),from:N})}catch{Pl(s.removed,{attribute:null,from:N})}if(N.removeAttribute(m),m==="is")if(Ht||Wn)try{Et(N)}catch{}else try{N.setAttribute(m,"")}catch{}},Xn=function(m){let N=null,$=null;if(mr)m="<remove></remove>"+m;else{const te=qc(m,/^[\r\n\t ]+/);$=te&&te[0]}St==="application/xhtml+xml"&&yn===xt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const ge=le?le.createHTML(m):m;if(yn===xt)try{N=new z().parseFromString(ge,St)}catch{}if(!N||!N.documentElement){N=Ae.createDocument(yn,"template",null);try{N.documentElement.innerHTML=Gn?ve:ge}catch{}}const We=N.body||N.documentElement;return m&&$&&We.insertBefore(o.createTextNode($),We.childNodes[0]||null),yn===xt?Pe.call(N,Pt?"html":"body")[0]:Pt?N.documentElement:We},Zn=function(m){return Be.call(m.ownerDocument||m,m,j.SHOW_ELEMENT|j.SHOW_COMMENT|j.SHOW_TEXT|j.SHOW_PROCESSING_INSTRUCTION|j.SHOW_CDATA_SECTION,null)},qn=function(m){return m instanceof M&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof P)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},Wl=function(m){return typeof S=="function"&&m instanceof S};function zt(W,m,N){eo(W,$=>{$.call(s,m,N,nn)})}const Vl=function(m){let N=null;if(zt(oe.beforeSanitizeElements,m,null),qn(m))return Et(m),!0;const $=ze(m.nodeName);if(zt(oe.uponSanitizeElement,m,{tagName:$,allowedTags:y}),m.hasChildNodes()&&!Wl(m.firstElementChild)&&ot(/<[/\w]/g,m.innerHTML)&&ot(/<[/\w]/g,m.textContent)||m.nodeType===Ol.progressingInstruction||dn&&m.nodeType===Ol.comment&&ot(/<[/\w]/g,m.data))return Et(m),!0;if(!y[$]||ne[$]){if(!ne[$]&&Yr($)&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($)))return!1;if(gr&&!en[$]){const ge=Re(m)||m.parentNode,We=je(m)||m.childNodes;if(We&&ge){const te=We.length;for(let be=te-1;be>=0;--be){const at=Z(We[be],!0);at.__removalCount=(m.__removalCount||0)+1,ge.insertBefore(at,De(m))}}}return Et(m),!0}return m instanceof E&&!Kn(m)||($==="noscript"||$==="noembed"||$==="noframes")&&ot(/<\/no(script|embed|frames)/i,m.innerHTML)?(Et(m),!0):(qt&&m.nodeType===Ol.text&&(N=m.textContent,eo([Ne,Fe,Ke],ge=>{N=zl(N,ge," ")}),m.textContent!==N&&(Pl(s.removed,{element:m.cloneNode()}),m.textContent=N)),zt(oe.afterSanitizeElements,m,null),!1)},Wt=function(m,N,$){if(hn&&(N==="id"||N==="name")&&($ in o||$ in Bl))return!1;if(!(he&&!fe[N]&&ot(Xe,N))){if(!(ue&&ot(Ue,N))){if(!V[N]||fe[N]){if(!(Yr(m)&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,m)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(m))&&(Q.attributeNameCheck instanceof RegExp&&ot(Q.attributeNameCheck,N)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(N))||N==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($))))return!1}else if(!tn[N]){if(!ot(D,zl($,I,""))){if(!((N==="src"||N==="xlink:href"||N==="href")&&m!=="script"&&uh($,"data:")===0&&Vn[m])){if(!(Je&&!ot(Ee,zl($,I,"")))){if($)return!1}}}}}}return!0},Yr=function(m){return m!=="annotation-xml"&&qc(m,X)},Kr=function(m){zt(oe.beforeSanitizeAttributes,m,null);const{attributes:N}=m;if(!N||qn(m))return;const $={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let ge=N.length;for(;ge--;){const We=N[ge],{name:te,namespaceURI:be,value:at}=We,Sn=ze(te);let Me=te==="value"?at:ah(at);if($.attrName=Sn,$.attrValue=Me,$.keepAttr=!0,$.forceKeepAttr=void 0,zt(oe.uponSanitizeAttribute,m,$),Me=$.attrValue,Jt&&(Sn==="id"||Sn==="name")&&(Bt(te,m),Me=Vr+Me),dn&&ot(/((--!?|])>)|<\/(style|title)/i,Me)){Bt(te,m);continue}if($.forceKeepAttr||(Bt(te,m),!$.keepAttr))continue;if(!Bn&&ot(/\/>/i,Me)){Bt(te,m);continue}qt&&eo([Ne,Fe,Ke],Xr=>{Me=zl(Me,Xr," ")});const Ql=ze(m.nodeName);if(Wt(Ql,Sn,Me)){if(le&&typeof G=="object"&&typeof G.getAttributeType=="function"&&!be)switch(G.getAttributeType(Ql,Sn)){case"TrustedHTML":{Me=le.createHTML(Me);break}case"TrustedScriptURL":{Me=le.createScriptURL(Me);break}}try{be?m.setAttributeNS(be,te,Me):m.setAttribute(te,Me),qn(m)?Et(m):Zc(s.removed)}catch{}}}zt(oe.afterSanitizeAttributes,m,null)},so=function W(m){let N=null;const $=Zn(m);for(zt(oe.beforeSanitizeShadowDOM,m,null);N=$.nextNode();)zt(oe.uponSanitizeShadowNode,N,null),Vl(N),Kr(N),N.content instanceof h&&W(N.content);zt(oe.afterSanitizeShadowDOM,m,null)};return s.sanitize=function(W){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=null,$=null,ge=null,We=null;if(Gn=!W,Gn&&(W="<!-->"),typeof W!="string"&&!Wl(W))if(typeof W.toString=="function"){if(W=W.toString(),typeof W!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!s.isSupported)return W;if(hr||wr(m),s.removed=[],typeof W=="string"&&(mn=!1),mn){if(W.nodeName){const at=ze(W.nodeName);if(!y[at]||ne[at])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(W instanceof S)N=Xn("<!---->"),$=N.ownerDocument.importNode(W,!0),$.nodeType===Ol.element&&$.nodeName==="BODY"||$.nodeName==="HTML"?N=$:N.appendChild($);else{if(!Ht&&!qt&&!Pt&&W.indexOf("<")===-1)return le&&pn?le.createHTML(W):W;if(N=Xn(W),!N)return Ht?null:pn?ve:""}N&&mr&&Et(N.firstChild);const te=Zn(mn?W:N);for(;ge=te.nextNode();)Vl(ge),Kr(ge),ge.content instanceof h&&so(ge.content);if(mn)return W;if(Ht){if(Wn)for(We=b.call(N.ownerDocument);N.firstChild;)We.appendChild(N.firstChild);else We=N;return(V.shadowroot||V.shadowrootmode)&&(We=Se.call(a,We,!0)),We}let be=Pt?N.outerHTML:N.innerHTML;return Pt&&y["!doctype"]&&N.ownerDocument&&N.ownerDocument.doctype&&N.ownerDocument.doctype.name&&ot(xf,N.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+N.ownerDocument.doctype.name+`>
|
86 |
-
`+be),qt&&eo([Ne,Fe,Ke],at=>{be=zl(be,at," ")}),le&&pn?le.createHTML(be):be},s.setConfig=function(){let W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};wr(W),hr=!0},s.clearConfig=function(){nn=null,hr=!1},s.isValidAttribute=function(W,m,N){nn||wr({});const $=ze(W),ge=ze(m);return Wt($,ge,N)},s.addHook=function(W,m){typeof m=="function"&&Pl(oe[W],m)},s.removeHook=function(W,m){if(m!==void 0){const N=oh(oe[W],m);return N===-1?void 0:sh(oe[W],N,1)[0]}return Zc(oe[W])},s.removeHooks=function(W){oe[W]=[]},s.removeAllHooks=function(){oe=rf()},s}var _h=Sf();function Th(v){return L.jsxs("svg",{...v,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(v){return L.jsxs("svg",{...v,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"})]})}function Rh(v){return _h.sanitize(pe.parse(v))}function Nh({messages:v}){const s=v.length===0;return Ye.useEffect(()=>{window.MathJax.typeset()},[v]),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:s?L.jsx("div",{className:"text-xl",children:"Ready!"}):v.map((o,a)=>L.jsx("div",{className:"flex items-start space-x-4",children:o.role==="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("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:o.content.length>0?L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Rh(o.content)}}):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(Ch,{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:o.content})})]})},`message-${a}`))})}function lf(v){return L.jsxs("svg",{...v,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 Lh(v){return L.jsxs("svg",{...v,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 Ah(v){const s=v==0?0:Math.floor(Math.log(v)/Math.log(1024));return+(v/Math.pow(1024,s)).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}function Ph({text:v,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:[v," (",s.toFixed(2),"%",isNaN(o)?"":` of ${Ah(o)}`,")"]})})}const zh=!!navigator.gpu,Ih=120;function Oh(){const v=Ye.useRef(null),s=Ye.useRef(null),o=Ye.useRef(null),[a,f]=Ye.useState(null),[h,d]=Ye.useState(null),[S,E]=Ye.useState(""),[j,P]=Ye.useState([]),[M,z]=Ye.useState(!1),[G,ce]=Ye.useState(""),[Z,J]=Ye.useState([]),[De,je]=Ye.useState(null),[Re,le]=Ye.useState(null);function ve(b){J(Pe=>[...Pe,{role:"user",content:b}]),je(null),z(!0),ce("")}function Ae(){v.current.postMessage({type:"interrupt"})}Ye.useEffect(()=>{Be()},[G]);function Be(){if(!s.current)return;const b=s.current;b.style.height="auto";const Pe=Math.min(Math.max(b.scrollHeight,24),200);b.style.height=`${Pe}px`}return Ye.useEffect(()=>{v.current||(v.current=new Worker(new URL("worker.js",import.meta.url),{type:"module"}),v.current.postMessage({type:"check"}));const b=Se=>{switch(Se.data.status){case"loading":f("loading"),E(Se.data.data);break;case"initiate":P(oe=>[...oe,Se.data]);break;case"progress":P(oe=>oe.map(Ne=>Ne.file===Se.data.file?{...Ne,...Se.data}:Ne));break;case"done":P(oe=>oe.filter(Ne=>Ne.file!==Se.data.file));break;case"ready":f("ready");break;case"start":J(oe=>[...oe,{role:"assistant",content:""}]);break;case"update":{const{output:oe,tps:Ne,numTokens:Fe}=Se.data;je(Ne),le(Fe),J(Ke=>{const Xe=[...Ke],Ue=Xe.at(-1);return Xe[Xe.length-1]={...Ue,content:Ue.content+oe},Xe})}break;case"complete":z(!1);break;case"error":d(Se.data.data);break}},Pe=Se=>{console.error("Worker error:",Se)};return v.current.addEventListener("message",b),v.current.addEventListener("error",Pe),()=>{v.current.removeEventListener("message",b),v.current.removeEventListener("error",Pe)}},[]),Ye.useEffect(()=>{Z.filter(b=>b.role==="user").length!==0&&Z.at(-1).role!=="assistant"&&(je(null),v.current.postMessage({type:"generate",data:Z}))},[Z,M]),Ye.useEffect(()=>{if(!o.current||!M)return;const b=o.current;b.scrollHeight-b.scrollTop-b.clientHeight<Ih&&(b.scrollTop=b.scrollHeight)},[Z,M]),zh?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&&Z.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-[300px] text-center",children:L.jsx("h1",{className:"text-4xl font-bold mb-1",children:"Prosty Język"})},L.jsxs("div",{className:"flex flex-col items-center px-4",children:[L.jsxs("p",{className:"max-w-[514px] mb-4",children:["Prosty Język to otwartoźródłowy asystent AI (czatbot) oparty na polskim otwartym modelu językowym ",L.jsx("a",{href:"https://huggingface.co/speakleash/Bielik-4.5B-v3.0-Instruct",target:"_blank",rel:"noreferrer",className:"underline",children:"Bielik-4.5B-v3.0-Instruct"}),", który upraszcza skomplikowane teksty zgodnie z ",L.jsx("a",{href:"https://www.gov.pl/web/sluzbacywilna/prosty-jezyk",target:"_blank",rel:"noreferrer",className:"underline",children:"zasadami prostego języka"}),".",L.jsx("br",{}),L.jsx("br",{}),"Po załadowaniu modelu językowego (2,78 GB) aplikacja działa w pełni offline w przeglądarce, z wykorzystaniem ",L.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"Transformers.js"}),", a żadne prywatne dane nie trafiają na serwery."]}),h&&L.jsxs("div",{className:"text-red-500 text-center mb-2",children:[L.jsx("p",{className:"mb-1",children:"Nie można załadować modelu z powodu błędu:"}),L.jsx("p",{className:"text-sm",children:h})]}),L.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 disabled:cursor-not-allowed select-none",onClick:()=>{v.current.postMessage({type:"load"}),f("loading")},disabled:a!==null||h!==null,children:"Załaduj 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:S}),j.map(({file:b,progress:Pe,total:Se},oe)=>L.jsx(Ph,{text:b,percentage:Pe,total:Se},oe))]})}),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(Nh,{messages:Z}),L.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:De&&Z.length>0&&L.jsxs(L.Fragment,{children:[!M&&L.jsxs("span",{children:["Wygenerowano ",Re," tokenów ",(Re/De).toFixed(2)," sek. ("]}),L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:De.toFixed(2)}),L.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokenów/sek."})]}),!M&&L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"mr-1",children:")."}),L.jsx("span",{className:"underline cursor-pointer",onClick:()=>{v.current.postMessage({type:"reset"}),J([])},children:"Reset"})]})]})})]}),L.jsxs("div",{className:"mt-2 border 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-none 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:"Wpisz swoją wiadomość...",type:"text",rows:1,value:G,disabled:a!=="ready",title:a==="ready"?"Model jest gotowy":"Model jeszcze nie załadowany",onKeyDown:b=>{G.length>0&&!M&&b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),ve(G))},onInput:b=>ce(b.target.value)}),M?L.jsx("div",{className:"cursor-pointer",onClick:Ae,children:L.jsx(Lh,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):G.length>0?L.jsx("div",{className:"cursor-pointer",onClick:()=>ve(G),children:L.jsx(lf,{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(lf,{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:"Zastrzeżenie: wygenerowana treść może być niedokładna."})]}):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 nie jest dostępny",L.jsx("br",{}),"w tej przeglądarce."]})}xp.createRoot(document.getElementById("root")).render(L.jsx(hp.StrictMode,{children:L.jsx(Oh,{})}));
|
|
|
83 |
`}strong(s){return`<strong>${s}</strong>`}em(s){return`<em>${s}</em>`}codespan(s){return`<code>${s}</code>`}br(){return"<br>"}del(s){return`<del>${s}</del>`}link(s,o,a){const f=Qc(s);if(f===null)return a;s=f;let h='<a href="'+s+'"';return o&&(h+=' title="'+o+'"'),h+=">"+a+"</a>",h}image(s,o,a){const f=Qc(s);if(f===null)return a;s=f;let h=`<img src="${s}" alt="${a}"`;return o&&(h+=` title="${o}"`),h+=">",h}text(s){return s}}class au{strong(s){return s}em(s){return s}codespan(s){return s}del(s){return s}html(s){return s}text(s){return s}link(s,o,a){return""+a}image(s,o,a){return""+a}br(){return""}}class Zt{constructor(s){xe(this,"options");xe(this,"renderer");xe(this,"textRenderer");this.options=s||pr,this.options.renderer=this.options.renderer||new io,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new au}static parse(s,o){return new Zt(o).parse(s)}static parseInline(s,o){return new Zt(o).parseInline(s)}parse(s,o=!0){let a="";for(let f=0;f<s.length;f++){const h=s[f];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]){const d=h,S=this.options.extensions.renderers[d.type].call({parser:this},d);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(d.type)){a+=S||"";continue}}switch(h.type){case"space":continue;case"hr":{a+=this.renderer.hr();continue}case"heading":{const d=h;a+=this.renderer.heading(this.parseInline(d.tokens),d.depth,Cp(this.parseInline(d.tokens,this.textRenderer)));continue}case"code":{const d=h;a+=this.renderer.code(d.text,d.lang,!!d.escaped);continue}case"table":{const d=h;let S="",E="";for(let P=0;P<d.header.length;P++)E+=this.renderer.tablecell(this.parseInline(d.header[P].tokens),{header:!0,align:d.align[P]});S+=this.renderer.tablerow(E);let j="";for(let P=0;P<d.rows.length;P++){const M=d.rows[P];E="";for(let z=0;z<M.length;z++)E+=this.renderer.tablecell(this.parseInline(M[z].tokens),{header:!1,align:d.align[z]});j+=this.renderer.tablerow(E)}a+=this.renderer.table(S,j);continue}case"blockquote":{const d=h,S=this.parse(d.tokens);a+=this.renderer.blockquote(S);continue}case"list":{const d=h,S=d.ordered,E=d.start,j=d.loose;let P="";for(let M=0;M<d.items.length;M++){const z=d.items[M],G=z.checked,ce=z.task;let Z="";if(z.task){const J=this.renderer.checkbox(!!G);j?z.tokens.length>0&&z.tokens[0].type==="paragraph"?(z.tokens[0].text=J+" "+z.tokens[0].text,z.tokens[0].tokens&&z.tokens[0].tokens.length>0&&z.tokens[0].tokens[0].type==="text"&&(z.tokens[0].tokens[0].text=J+" "+z.tokens[0].tokens[0].text)):z.tokens.unshift({type:"text",text:J+" "}):Z+=J+" "}Z+=this.parse(z.tokens,j),P+=this.renderer.listitem(Z,ce,!!G)}a+=this.renderer.list(P,S,E);continue}case"html":{const d=h;a+=this.renderer.html(d.text,d.block);continue}case"paragraph":{const d=h;a+=this.renderer.paragraph(this.parseInline(d.tokens));continue}case"text":{let d=h,S=d.tokens?this.parseInline(d.tokens):d.text;for(;f+1<s.length&&s[f+1].type==="text";)d=s[++f],S+=`
|
84 |
`+(d.tokens?this.parseInline(d.tokens):d.text);a+=o?this.renderer.paragraph(S):S;continue}default:{const d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return a}parseInline(s,o){o=o||this.renderer;let a="";for(let f=0;f<s.length;f++){const h=s[f];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]){const d=this.options.extensions.renderers[h.type].call({parser:this},h);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(h.type)){a+=d||"";continue}}switch(h.type){case"escape":{const d=h;a+=o.text(d.text);break}case"html":{const d=h;a+=o.html(d.text);break}case"link":{const d=h;a+=o.link(d.href,d.title,this.parseInline(d.tokens,o));break}case"image":{const d=h;a+=o.image(d.href,d.title,d.text);break}case"strong":{const d=h;a+=o.strong(this.parseInline(d.tokens,o));break}case"em":{const d=h;a+=o.em(this.parseInline(d.tokens,o));break}case"codespan":{const d=h;a+=o.codespan(d.text);break}case"br":{a+=o.br();break}case"del":{const d=h;a+=o.del(this.parseInline(d.tokens,o));break}case"text":{const d=h;a+=o.text(d.text);break}default:{const d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return a}}class jl{constructor(s){xe(this,"options");this.options=s||pr}preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}}xe(jl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var dr,bs,yf;class nh{constructor(...s){Mc(this,dr);xe(this,"defaults",ru());xe(this,"options",this.setOptions);xe(this,"parse",Zi(this,dr,bs).call(this,Xt.lex,Zt.parse));xe(this,"parseInline",Zi(this,dr,bs).call(this,Xt.lexInline,Zt.parseInline));xe(this,"Parser",Zt);xe(this,"Renderer",io);xe(this,"TextRenderer",au);xe(this,"Lexer",Xt);xe(this,"Tokenizer",ro);xe(this,"Hooks",jl);this.use(...s)}walkTokens(s,o){var f,h;let a=[];for(const d of s)switch(a=a.concat(o.call(this,d)),d.type){case"table":{const S=d;for(const E of S.header)a=a.concat(this.walkTokens(E.tokens,o));for(const E of S.rows)for(const j of E)a=a.concat(this.walkTokens(j.tokens,o));break}case"list":{const S=d;a=a.concat(this.walkTokens(S.items,o));break}default:{const S=d;(h=(f=this.defaults.extensions)==null?void 0:f.childTokens)!=null&&h[S.type]?this.defaults.extensions.childTokens[S.type].forEach(E=>{const j=S[E].flat(1/0);a=a.concat(this.walkTokens(j,o))}):S.tokens&&(a=a.concat(this.walkTokens(S.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(h=>{if(!h.name)throw new Error("extension name required");if("renderer"in h){const d=o.renderers[h.name];d?o.renderers[h.name]=function(...S){let E=h.renderer.apply(this,S);return E===!1&&(E=d.apply(this,S)),E}:o.renderers[h.name]=h.renderer}if("tokenizer"in h){if(!h.level||h.level!=="block"&&h.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=o[h.level];d?d.unshift(h.tokenizer):o[h.level]=[h.tokenizer],h.start&&(h.level==="block"?o.startBlock?o.startBlock.push(h.start):o.startBlock=[h.start]:h.level==="inline"&&(o.startInline?o.startInline.push(h.start):o.startInline=[h.start]))}"childTokens"in h&&h.childTokens&&(o.childTokens[h.name]=h.childTokens)}),f.extensions=o),a.renderer){const h=this.defaults.renderer||new io(this.defaults);for(const d in a.renderer){if(!(d in h))throw new Error(`renderer '${d}' does not exist`);if(d==="options")continue;const S=d,E=a.renderer[S],j=h[S];h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M||""}}f.renderer=h}if(a.tokenizer){const h=this.defaults.tokenizer||new ro(this.defaults);for(const d in a.tokenizer){if(!(d in h))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const S=d,E=a.tokenizer[S],j=h[S];h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M}}f.tokenizer=h}if(a.hooks){const h=this.defaults.hooks||new jl;for(const d in a.hooks){if(!(d in h))throw new Error(`hook '${d}' does not exist`);if(d==="options")continue;const S=d,E=a.hooks[S],j=h[S];jl.passThroughHooks.has(d)?h[S]=P=>{if(this.defaults.async)return Promise.resolve(E.call(h,P)).then(z=>j.call(h,z));const M=E.call(h,P);return j.call(h,M)}:h[S]=(...P)=>{let M=E.apply(h,P);return M===!1&&(M=j.apply(h,P)),M}}f.hooks=h}if(a.walkTokens){const h=this.defaults.walkTokens,d=a.walkTokens;f.walkTokens=function(S){let E=[];return E.push(d.call(this,S)),h&&(E=E.concat(h.call(this,S))),E}}this.defaults={...this.defaults,...f}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,o){return Xt.lex(s,o??this.defaults)}parser(s,o){return Zt.parse(s,o??this.defaults)}}dr=new WeakSet,bs=function(s,o){return(a,f)=>{const h={...f},d={...this.defaults,...h};this.defaults.async===!0&&h.async===!1&&(d.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),d.async=!0);const S=Zi(this,dr,yf).call(this,!!d.silent,!!d.async);if(typeof a>"u"||a===null)return S(new Error("marked(): input parameter is undefined or null"));if(typeof a!="string")return S(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(a)+", string expected"));if(d.hooks&&(d.hooks.options=d),d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(a):a).then(E=>s(E,d)).then(E=>d.hooks?d.hooks.processAllTokens(E):E).then(E=>d.walkTokens?Promise.all(this.walkTokens(E,d.walkTokens)).then(()=>E):E).then(E=>o(E,d)).then(E=>d.hooks?d.hooks.postprocess(E):E).catch(S);try{d.hooks&&(a=d.hooks.preprocess(a));let E=s(a,d);d.hooks&&(E=d.hooks.processAllTokens(E)),d.walkTokens&&this.walkTokens(E,d.walkTokens);let j=o(E,d);return d.hooks&&(j=d.hooks.postprocess(j)),j}catch(E){return S(E)}}},yf=function(s,o){return a=>{if(a.message+=`
|
85 |
Please report this to https://github.com/markedjs/marked.`,s){const f="<p>An error occurred:</p><pre>"+wt(a.message+"",!0)+"</pre>";return o?Promise.resolve(f):f}if(o)return Promise.reject(a);throw a}};const fr=new nh;function pe(v,s){return fr.parse(v,s)}pe.options=pe.setOptions=function(v){return fr.setOptions(v),pe.defaults=fr.defaults,sf(pe.defaults),pe};pe.getDefaults=ru;pe.defaults=pr;pe.use=function(...v){return fr.use(...v),pe.defaults=fr.defaults,sf(pe.defaults),pe};pe.walkTokens=function(v,s){return fr.walkTokens(v,s)};pe.parseInline=fr.parseInline;pe.Parser=Zt;pe.parser=Zt.parse;pe.Renderer=io;pe.TextRenderer=au;pe.Lexer=Xt;pe.lexer=Xt.lex;pe.Tokenizer=ro;pe.Hooks=jl;pe.parse=pe;pe.options;pe.setOptions;pe.use;pe.walkTokens;pe.parseInline;Zt.parse;Xt.lex;/*! @license DOMPurify 3.2.4 | (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.4/LICENSE */const{entries:vf,setPrototypeOf:Xc,isFrozen:rh,getPrototypeOf:lh,getOwnPropertyDescriptor:ih}=Object;let{freeze:st,seal:At,create:kf}=Object,{apply:eu,construct:tu}=typeof Reflect<"u"&&Reflect;st||(st=function(s){return s});At||(At=function(s){return s});eu||(eu=function(s,o,a){return s.apply(o,a)});tu||(tu=function(s,o){return new s(...o)});const eo=ut(Array.prototype.forEach),oh=ut(Array.prototype.lastIndexOf),Zc=ut(Array.prototype.pop),Pl=ut(Array.prototype.push),sh=ut(Array.prototype.splice),no=ut(String.prototype.toLowerCase),Ys=ut(String.prototype.toString),qc=ut(String.prototype.match),zl=ut(String.prototype.replace),uh=ut(String.prototype.indexOf),ah=ut(String.prototype.trim),$t=ut(Object.prototype.hasOwnProperty),ot=ut(RegExp.prototype.test),Il=ch(TypeError);function ut(v){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 eu(v,s,a)}}function ch(v){return function(){for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return tu(v,o)}}function ie(v,s){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:no;Xc&&Xc(v,null);let a=s.length;for(;a--;){let f=s[a];if(typeof f=="string"){const h=o(f);h!==f&&(rh(s)||(s[a]=h),f=h)}v[f]=!0}return v}function fh(v){for(let s=0;s<v.length;s++)$t(v,s)||(v[s]=null);return v}function cr(v){const s=kf(null);for(const[o,a]of vf(v))$t(v,o)&&(Array.isArray(a)?s[o]=fh(a):a&&typeof a=="object"&&a.constructor===Object?s[o]=cr(a):s[o]=a);return s}function Ml(v,s){for(;v!==null;){const a=ih(v,s);if(a){if(a.get)return ut(a.get);if(typeof a.value=="function")return ut(a.value)}v=lh(v)}function o(){return null}return o}const Jc=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"]),Ks=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"]),Xs=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"]),Zs=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"]),bc=st(["#text"]),ef=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"]),qs=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"]),tf=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"]),to=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),hh=At(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mh=At(/<%[\w\W]*|[\w\W]*%>/gm),gh=At(/\$\{[\w\W]*/gm),yh=At(/^data-[\-\w.\u00B7-\uFFFF]+$/),vh=At(/^aria-[\-\w]+$/),wf=At(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kh=At(/^(?:\w+script|data):/i),wh=At(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xf=At(/^html$/i),xh=At(/^[a-z][.\w]*(-[.\w]+)+$/i);var nf=Object.freeze({__proto__:null,ARIA_ATTR:vh,ATTR_WHITESPACE:wh,CUSTOM_ELEMENT:xh,DATA_ATTR:yh,DOCTYPE_NAME:xf,ERB_EXPR:mh,IS_ALLOWED_URI:wf,IS_SCRIPT_OR_DATA:kh,MUSTACHE_EXPR:hh,TMPLIT_EXPR:gh});const Ol={element:1,text:3,progressingInstruction:7,comment:8,document:9},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 h="dompurify"+(a?"#"+a:"");try{return s.createPolicy(h,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+h+" could not be created."),null}},rf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Sf(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Sh();const s=W=>Sf(W);if(s.version="3.2.4",s.removed=[],!v||!v.document||v.document.nodeType!==Ol.document||!v.Element)return s.isSupported=!1,s;let{document:o}=v;const a=o,f=a.currentScript,{DocumentFragment:h,HTMLTemplateElement:d,Node:S,Element:E,NodeFilter:j,NamedNodeMap:P=v.NamedNodeMap||v.MozNamedAttrMap,HTMLFormElement:M,DOMParser:z,trustedTypes:G}=v,ce=E.prototype,Z=Ml(ce,"cloneNode"),J=Ml(ce,"remove"),De=Ml(ce,"nextSibling"),je=Ml(ce,"childNodes"),Re=Ml(ce,"parentNode");if(typeof d=="function"){const W=o.createElement("template");W.content&&W.content.ownerDocument&&(o=W.content.ownerDocument)}let le,ve="";const{implementation:Ae,createNodeIterator:Be,createDocumentFragment:b,getElementsByTagName:Pe}=o,{importNode:Se}=a;let oe=rf();s.isSupported=typeof vf=="function"&&typeof Re=="function"&&Ae&&Ae.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Ne,ERB_EXPR:Fe,TMPLIT_EXPR:Ke,DATA_ATTR:Xe,ARIA_ATTR:Ue,IS_SCRIPT_OR_DATA:Ee,ATTR_WHITESPACE:I,CUSTOM_ELEMENT:X}=nf;let{IS_ALLOWED_URI:D}=nf,y=null;const _=ie({},[...Jc,...Ks,...Xs,...Zs,...bc]);let V=null;const ee=ie({},[...ef,...qs,...tf,...to]);let Q=Object.seal(kf(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}})),ne=null,fe=null,ue=!0,he=!0,Je=!1,Bn=!0,qt=!1,dn=!0,Pt=!1,hr=!1,mr=!1,Ht=!1,Wn=!1,pn=!1,hn=!0,Jt=!1;const Vr="user-content-";let gr=!0,mn=!1,bt={},en=null;const yr=ie({},["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 Vn=null;const Qr=ie({},["audio","video","img","source","image","track"]);let tn=null;const gn=ie({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vr="http://www.w3.org/1998/Math/MathML",Qn="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let yn=xt,Gn=!1,Yn=null;const Gr=ie({},[vr,Qn,xt],Ys);let vn=ie({},["mi","mo","mn","ms","mtext"]),kn=ie({},["annotation-xml"]);const wn=ie({},["title","style","font","a","script"]);let St=null;const $l=["application/xhtml+xml","text/html"],Hl="text/html";let ze=null,nn=null;const Bl=o.createElement("form"),kr=function(m){return m instanceof RegExp||m instanceof Function},wr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(nn&&nn===m)){if((!m||typeof m!="object")&&(m={}),m=cr(m),St=$l.indexOf(m.PARSER_MEDIA_TYPE)===-1?Hl:m.PARSER_MEDIA_TYPE,ze=St==="application/xhtml+xml"?Ys:no,y=$t(m,"ALLOWED_TAGS")?ie({},m.ALLOWED_TAGS,ze):_,V=$t(m,"ALLOWED_ATTR")?ie({},m.ALLOWED_ATTR,ze):ee,Yn=$t(m,"ALLOWED_NAMESPACES")?ie({},m.ALLOWED_NAMESPACES,Ys):Gr,tn=$t(m,"ADD_URI_SAFE_ATTR")?ie(cr(gn),m.ADD_URI_SAFE_ATTR,ze):gn,Vn=$t(m,"ADD_DATA_URI_TAGS")?ie(cr(Qr),m.ADD_DATA_URI_TAGS,ze):Qr,en=$t(m,"FORBID_CONTENTS")?ie({},m.FORBID_CONTENTS,ze):yr,ne=$t(m,"FORBID_TAGS")?ie({},m.FORBID_TAGS,ze):{},fe=$t(m,"FORBID_ATTR")?ie({},m.FORBID_ATTR,ze):{},bt=$t(m,"USE_PROFILES")?m.USE_PROFILES:!1,ue=m.ALLOW_ARIA_ATTR!==!1,he=m.ALLOW_DATA_ATTR!==!1,Je=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Bn=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qt=m.SAFE_FOR_TEMPLATES||!1,dn=m.SAFE_FOR_XML!==!1,Pt=m.WHOLE_DOCUMENT||!1,Ht=m.RETURN_DOM||!1,Wn=m.RETURN_DOM_FRAGMENT||!1,pn=m.RETURN_TRUSTED_TYPE||!1,mr=m.FORCE_BODY||!1,hn=m.SANITIZE_DOM!==!1,Jt=m.SANITIZE_NAMED_PROPS||!1,gr=m.KEEP_CONTENT!==!1,mn=m.IN_PLACE||!1,D=m.ALLOWED_URI_REGEXP||wf,yn=m.NAMESPACE||xt,vn=m.MATHML_TEXT_INTEGRATION_POINTS||vn,kn=m.HTML_INTEGRATION_POINTS||kn,Q=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&kr(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Q.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&kr(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Q.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Q.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qt&&(he=!1),Wn&&(Ht=!0),bt&&(y=ie({},bc),V=[],bt.html===!0&&(ie(y,Jc),ie(V,ef)),bt.svg===!0&&(ie(y,Ks),ie(V,qs),ie(V,to)),bt.svgFilters===!0&&(ie(y,Xs),ie(V,qs),ie(V,to)),bt.mathMl===!0&&(ie(y,Zs),ie(V,tf),ie(V,to))),m.ADD_TAGS&&(y===_&&(y=cr(y)),ie(y,m.ADD_TAGS,ze)),m.ADD_ATTR&&(V===ee&&(V=cr(V)),ie(V,m.ADD_ATTR,ze)),m.ADD_URI_SAFE_ATTR&&ie(tn,m.ADD_URI_SAFE_ATTR,ze),m.FORBID_CONTENTS&&(en===yr&&(en=cr(en)),ie(en,m.FORBID_CONTENTS,ze)),gr&&(y["#text"]=!0),Pt&&ie(y,["html","head","body"]),y.table&&(ie(y,["tbody"]),delete ne.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');le=m.TRUSTED_TYPES_POLICY,ve=le.createHTML("")}else le===void 0&&(le=Eh(G,f)),le!==null&&typeof ve=="string"&&(ve=le.createHTML(""));st&&st(m),nn=m}},xn=ie({},[...Ks,...Xs,...dh]),xr=ie({},[...Zs,...ph]),Kn=function(m){let N=Re(m);(!N||!N.tagName)&&(N={namespaceURI:yn,tagName:"template"});const $=no(m.tagName),ge=no(N.tagName);return Yn[m.namespaceURI]?m.namespaceURI===Qn?N.namespaceURI===xt?$==="svg":N.namespaceURI===vr?$==="svg"&&(ge==="annotation-xml"||vn[ge]):!!xn[$]:m.namespaceURI===vr?N.namespaceURI===xt?$==="math":N.namespaceURI===Qn?$==="math"&&kn[ge]:!!xr[$]:m.namespaceURI===xt?N.namespaceURI===Qn&&!kn[ge]||N.namespaceURI===vr&&!vn[ge]?!1:!xr[$]&&(wn[$]||!xn[$]):!!(St==="application/xhtml+xml"&&Yn[m.namespaceURI]):!1},Et=function(m){Pl(s.removed,{element:m});try{Re(m).removeChild(m)}catch{J(m)}},Bt=function(m,N){try{Pl(s.removed,{attribute:N.getAttributeNode(m),from:N})}catch{Pl(s.removed,{attribute:null,from:N})}if(N.removeAttribute(m),m==="is")if(Ht||Wn)try{Et(N)}catch{}else try{N.setAttribute(m,"")}catch{}},Xn=function(m){let N=null,$=null;if(mr)m="<remove></remove>"+m;else{const te=qc(m,/^[\r\n\t ]+/);$=te&&te[0]}St==="application/xhtml+xml"&&yn===xt&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const ge=le?le.createHTML(m):m;if(yn===xt)try{N=new z().parseFromString(ge,St)}catch{}if(!N||!N.documentElement){N=Ae.createDocument(yn,"template",null);try{N.documentElement.innerHTML=Gn?ve:ge}catch{}}const We=N.body||N.documentElement;return m&&$&&We.insertBefore(o.createTextNode($),We.childNodes[0]||null),yn===xt?Pe.call(N,Pt?"html":"body")[0]:Pt?N.documentElement:We},Zn=function(m){return Be.call(m.ownerDocument||m,m,j.SHOW_ELEMENT|j.SHOW_COMMENT|j.SHOW_TEXT|j.SHOW_PROCESSING_INSTRUCTION|j.SHOW_CDATA_SECTION,null)},qn=function(m){return m instanceof M&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof P)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},Wl=function(m){return typeof S=="function"&&m instanceof S};function zt(W,m,N){eo(W,$=>{$.call(s,m,N,nn)})}const Vl=function(m){let N=null;if(zt(oe.beforeSanitizeElements,m,null),qn(m))return Et(m),!0;const $=ze(m.nodeName);if(zt(oe.uponSanitizeElement,m,{tagName:$,allowedTags:y}),m.hasChildNodes()&&!Wl(m.firstElementChild)&&ot(/<[/\w]/g,m.innerHTML)&&ot(/<[/\w]/g,m.textContent)||m.nodeType===Ol.progressingInstruction||dn&&m.nodeType===Ol.comment&&ot(/<[/\w]/g,m.data))return Et(m),!0;if(!y[$]||ne[$]){if(!ne[$]&&Yr($)&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($)))return!1;if(gr&&!en[$]){const ge=Re(m)||m.parentNode,We=je(m)||m.childNodes;if(We&&ge){const te=We.length;for(let be=te-1;be>=0;--be){const at=Z(We[be],!0);at.__removalCount=(m.__removalCount||0)+1,ge.insertBefore(at,De(m))}}}return Et(m),!0}return m instanceof E&&!Kn(m)||($==="noscript"||$==="noembed"||$==="noframes")&&ot(/<\/no(script|embed|frames)/i,m.innerHTML)?(Et(m),!0):(qt&&m.nodeType===Ol.text&&(N=m.textContent,eo([Ne,Fe,Ke],ge=>{N=zl(N,ge," ")}),m.textContent!==N&&(Pl(s.removed,{element:m.cloneNode()}),m.textContent=N)),zt(oe.afterSanitizeElements,m,null),!1)},Wt=function(m,N,$){if(hn&&(N==="id"||N==="name")&&($ in o||$ in Bl))return!1;if(!(he&&!fe[N]&&ot(Xe,N))){if(!(ue&&ot(Ue,N))){if(!V[N]||fe[N]){if(!(Yr(m)&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,m)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(m))&&(Q.attributeNameCheck instanceof RegExp&&ot(Q.attributeNameCheck,N)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(N))||N==="is"&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&ot(Q.tagNameCheck,$)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck($))))return!1}else if(!tn[N]){if(!ot(D,zl($,I,""))){if(!((N==="src"||N==="xlink:href"||N==="href")&&m!=="script"&&uh($,"data:")===0&&Vn[m])){if(!(Je&&!ot(Ee,zl($,I,"")))){if($)return!1}}}}}}return!0},Yr=function(m){return m!=="annotation-xml"&&qc(m,X)},Kr=function(m){zt(oe.beforeSanitizeAttributes,m,null);const{attributes:N}=m;if(!N||qn(m))return;const $={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let ge=N.length;for(;ge--;){const We=N[ge],{name:te,namespaceURI:be,value:at}=We,Sn=ze(te);let Me=te==="value"?at:ah(at);if($.attrName=Sn,$.attrValue=Me,$.keepAttr=!0,$.forceKeepAttr=void 0,zt(oe.uponSanitizeAttribute,m,$),Me=$.attrValue,Jt&&(Sn==="id"||Sn==="name")&&(Bt(te,m),Me=Vr+Me),dn&&ot(/((--!?|])>)|<\/(style|title)/i,Me)){Bt(te,m);continue}if($.forceKeepAttr||(Bt(te,m),!$.keepAttr))continue;if(!Bn&&ot(/\/>/i,Me)){Bt(te,m);continue}qt&&eo([Ne,Fe,Ke],Xr=>{Me=zl(Me,Xr," ")});const Ql=ze(m.nodeName);if(Wt(Ql,Sn,Me)){if(le&&typeof G=="object"&&typeof G.getAttributeType=="function"&&!be)switch(G.getAttributeType(Ql,Sn)){case"TrustedHTML":{Me=le.createHTML(Me);break}case"TrustedScriptURL":{Me=le.createScriptURL(Me);break}}try{be?m.setAttributeNS(be,te,Me):m.setAttribute(te,Me),qn(m)?Et(m):Zc(s.removed)}catch{}}}zt(oe.afterSanitizeAttributes,m,null)},so=function W(m){let N=null;const $=Zn(m);for(zt(oe.beforeSanitizeShadowDOM,m,null);N=$.nextNode();)zt(oe.uponSanitizeShadowNode,N,null),Vl(N),Kr(N),N.content instanceof h&&W(N.content);zt(oe.afterSanitizeShadowDOM,m,null)};return s.sanitize=function(W){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=null,$=null,ge=null,We=null;if(Gn=!W,Gn&&(W="<!-->"),typeof W!="string"&&!Wl(W))if(typeof W.toString=="function"){if(W=W.toString(),typeof W!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!s.isSupported)return W;if(hr||wr(m),s.removed=[],typeof W=="string"&&(mn=!1),mn){if(W.nodeName){const at=ze(W.nodeName);if(!y[at]||ne[at])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(W instanceof S)N=Xn("<!---->"),$=N.ownerDocument.importNode(W,!0),$.nodeType===Ol.element&&$.nodeName==="BODY"||$.nodeName==="HTML"?N=$:N.appendChild($);else{if(!Ht&&!qt&&!Pt&&W.indexOf("<")===-1)return le&&pn?le.createHTML(W):W;if(N=Xn(W),!N)return Ht?null:pn?ve:""}N&&mr&&Et(N.firstChild);const te=Zn(mn?W:N);for(;ge=te.nextNode();)Vl(ge),Kr(ge),ge.content instanceof h&&so(ge.content);if(mn)return W;if(Ht){if(Wn)for(We=b.call(N.ownerDocument);N.firstChild;)We.appendChild(N.firstChild);else We=N;return(V.shadowroot||V.shadowrootmode)&&(We=Se.call(a,We,!0)),We}let be=Pt?N.outerHTML:N.innerHTML;return Pt&&y["!doctype"]&&N.ownerDocument&&N.ownerDocument.doctype&&N.ownerDocument.doctype.name&&ot(xf,N.ownerDocument.doctype.name)&&(be="<!DOCTYPE "+N.ownerDocument.doctype.name+`>
|
86 |
+
`+be),qt&&eo([Ne,Fe,Ke],at=>{be=zl(be,at," ")}),le&&pn?le.createHTML(be):be},s.setConfig=function(){let W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};wr(W),hr=!0},s.clearConfig=function(){nn=null,hr=!1},s.isValidAttribute=function(W,m,N){nn||wr({});const $=ze(W),ge=ze(m);return Wt($,ge,N)},s.addHook=function(W,m){typeof m=="function"&&Pl(oe[W],m)},s.removeHook=function(W,m){if(m!==void 0){const N=oh(oe[W],m);return N===-1?void 0:sh(oe[W],N,1)[0]}return Zc(oe[W])},s.removeHooks=function(W){oe[W]=[]},s.removeAllHooks=function(){oe=rf()},s}var _h=Sf();function Th(v){return L.jsxs("svg",{...v,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(v){return L.jsxs("svg",{...v,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"})]})}function Rh(v){return _h.sanitize(pe.parse(v))}function Nh({messages:v}){const s=v.length===0;return Ye.useEffect(()=>{window.MathJax.typeset()},[v]),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:s?L.jsx("div",{className:"text-xl",children:"Ready!"}):v.map((o,a)=>L.jsx("div",{className:"flex items-start space-x-4",children:o.role==="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("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:o.content.length>0?L.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Rh(o.content)}}):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(Ch,{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:o.content})})]})},`message-${a}`))})}function lf(v){return L.jsxs("svg",{...v,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 Lh(v){return L.jsxs("svg",{...v,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 Ah(v){const s=v==0?0:Math.floor(Math.log(v)/Math.log(1024));return+(v/Math.pow(1024,s)).toFixed(2)*1+["B","kB","MB","GB","TB"][s]}function Ph({text:v,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:[v," (",s.toFixed(2),"%",isNaN(o)?"":` of ${Ah(o)}`,")"]})})}const zh=!!navigator.gpu,Ih=120;function Oh(){const v=Ye.useRef(null),s=Ye.useRef(null),o=Ye.useRef(null),[a,f]=Ye.useState(null),[h,d]=Ye.useState(null),[S,E]=Ye.useState(""),[j,P]=Ye.useState([]),[M,z]=Ye.useState(!1),[G,ce]=Ye.useState(""),[Z,J]=Ye.useState([]),[De,je]=Ye.useState(null),[Re,le]=Ye.useState(null);function ve(b){J(Pe=>[...Pe,{role:"user",content:b}]),je(null),z(!0),ce("")}function Ae(){v.current.postMessage({type:"interrupt"})}Ye.useEffect(()=>{Be()},[G]);function Be(){if(!s.current)return;const b=s.current;b.style.height="auto";const Pe=Math.min(Math.max(b.scrollHeight,24),200);b.style.height=`${Pe}px`}return Ye.useEffect(()=>{v.current||(v.current=new Worker(new URL("worker.js",import.meta.url),{type:"module"}),v.current.postMessage({type:"check"}));const b=Se=>{switch(Se.data.status){case"loading":f("loading"),E(Se.data.data);break;case"initiate":P(oe=>[...oe,Se.data]);break;case"progress":P(oe=>oe.map(Ne=>Ne.file===Se.data.file?{...Ne,...Se.data}:Ne));break;case"done":P(oe=>oe.filter(Ne=>Ne.file!==Se.data.file));break;case"ready":f("ready");break;case"start":J(oe=>[...oe,{role:"assistant",content:""}]);break;case"update":{const{output:oe,tps:Ne,numTokens:Fe}=Se.data;je(Ne),le(Fe),J(Ke=>{const Xe=[...Ke],Ue=Xe.at(-1);return Xe[Xe.length-1]={...Ue,content:Ue.content+oe},Xe})}break;case"complete":z(!1);break;case"error":d(Se.data.data);break}},Pe=Se=>{console.error("Worker error:",Se)};return v.current.addEventListener("message",b),v.current.addEventListener("error",Pe),()=>{v.current.removeEventListener("message",b),v.current.removeEventListener("error",Pe)}},[]),Ye.useEffect(()=>{Z.filter(b=>b.role==="user").length!==0&&Z.at(-1).role!=="assistant"&&(je(null),v.current.postMessage({type:"generate",data:Z}))},[Z,M]),Ye.useEffect(()=>{if(!o.current||!M)return;const b=o.current;b.scrollHeight-b.scrollTop-b.clientHeight<Ih&&(b.scrollTop=b.scrollHeight)},[Z,M]),zh?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&&Z.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-[300px] text-center",children:L.jsx("h1",{className:"text-4xl font-bold mb-1",children:"Prosty Język"})}),L.jsxs("div",{className:"flex flex-col items-center px-4",children:[L.jsxs("p",{className:"max-w-[514px] mb-4",children:["Prosty Język to otwartoźródłowy asystent AI (czatbot) oparty na polskim otwartym modelu językowym ",L.jsx("a",{href:"https://huggingface.co/speakleash/Bielik-4.5B-v3.0-Instruct",target:"_blank",rel:"noreferrer",className:"underline",children:"Bielik-4.5B-v3.0-Instruct"}),", który upraszcza skomplikowane teksty zgodnie z ",L.jsx("a",{href:"https://www.gov.pl/web/sluzbacywilna/prosty-jezyk",target:"_blank",rel:"noreferrer",className:"underline",children:"zasadami prostego języka"}),".",L.jsx("br",{}),L.jsx("br",{}),"Po załadowaniu modelu językowego (2,78 GB) aplikacja działa w pełni offline w przeglądarce, z wykorzystaniem ",L.jsx("a",{href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",className:"underline",children:"Transformers.js"}),", a żadne prywatne dane nie trafiają na serwery."]}),h&&L.jsxs("div",{className:"text-red-500 text-center mb-2",children:[L.jsx("p",{className:"mb-1",children:"Nie można załadować modelu z powodu błędu:"}),L.jsx("p",{className:"text-sm",children:h})]}),L.jsx("button",{className:"border px-4 py-2 rounded-lg bg-blue-400 text-white hover:bg-blue-500 disabled:bg-blue-100 disabled:cursor-not-allowed select-none",onClick:()=>{v.current.postMessage({type:"load"}),f("loading")},disabled:a!==null||h!==null,children:"Załaduj 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:S}),j.map(({file:b,progress:Pe,total:Se},oe)=>L.jsx(Ph,{text:b,percentage:Pe,total:Se},oe))]})}),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(Nh,{messages:Z}),L.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:De&&Z.length>0&&L.jsxs(L.Fragment,{children:[!M&&L.jsxs("span",{children:["Wygenerowano ",Re," tokenów ",(Re/De).toFixed(2)," sek. ("]}),L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:De.toFixed(2)}),L.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokenów/sek."})]}),!M&&L.jsxs(L.Fragment,{children:[L.jsx("span",{className:"mr-1",children:")."}),L.jsx("span",{className:"underline cursor-pointer",onClick:()=>{v.current.postMessage({type:"reset"}),J([])},children:"Reset"})]})]})})]}),L.jsxs("div",{className:"mt-2 border 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-none 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:"Wpisz swoją wiadomość...",type:"text",rows:1,value:G,disabled:a!=="ready",title:a==="ready"?"Model jest gotowy":"Model jeszcze nie załadowany",onKeyDown:b=>{G.length>0&&!M&&b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),ve(G))},onInput:b=>ce(b.target.value)}),M?L.jsx("div",{className:"cursor-pointer",onClick:Ae,children:L.jsx(Lh,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):G.length>0?L.jsx("div",{className:"cursor-pointer",onClick:()=>ve(G),children:L.jsx(lf,{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(lf,{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:"Zastrzeżenie: wygenerowana treść może być niedokładna."})]}):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 nie jest dostępny",L.jsx("br",{}),"w tej przeglądarce."]})}xp.createRoot(document.getElementById("root")).render(L.jsx(hp.StrictMode,{children:L.jsx(Oh,{})}));
|